quad_path_plot.py 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. import numpy as np
  2. from matplotlib import gridspec
  3. from matplotlib.lines import Line2D
  4. from charged_shells.rotational_path import PairRotationalPath, PathEnergyPlot
  5. from charged_shells import expansion
  6. from charged_shells.parameters import ModelParams
  7. from pathlib import Path
  8. import json
  9. import quadrupole_model_mappings
  10. from plot_settings import *
  11. Array = np.ndarray
  12. zero_to_pi_half = np.linspace(0, np.pi/2, 100, endpoint=True)
  13. pi_half_to_pi = np.linspace(np.pi/2, np.pi, 100, endpoint=True)
  14. QuadPath = PairRotationalPath()
  15. QuadPath.set_default_x_axis(zero_to_pi_half)
  16. QuadPath.add_euler(beta1=np.pi/2, beta2=zero_to_pi_half, start_name="EP", end_name="EE")
  17. QuadPath.add_euler(beta1=zero_to_pi_half[::-1], beta2=zero_to_pi_half[::-1], end_name="PP")
  18. QuadPath.add_euler(beta1=zero_to_pi_half, end_name="EP")
  19. QuadPath.add_euler(beta1=pi_half_to_pi, beta2=zero_to_pi_half, end_name="EP")
  20. QuadPath.add_euler(beta1=np.pi/2, beta2=zero_to_pi_half, alpha2=np.pi/2, end_name="tEE")
  21. QuadPath.add_euler(beta1=np.pi/2, beta2=np.pi/2, alpha1=zero_to_pi_half[::-1], end_name="EE")
  22. def model_comparison(config_data: dict, save_as=None, save_data=False):
  23. kappaR = 3
  24. params = ModelParams(R=150, kappaR=kappaR)
  25. a_bar = 0.5
  26. sigma_tilde = 0.001
  27. ex1 = expansion.MappedExpansionQuad(a_bar, params.kappaR, sigma_tilde, l_max=30)
  28. ex2 = ex1.clone()
  29. # matching other models to the mapped CSp model based on equal patch size in potential
  30. # ex_gauss = quadrupole_model_mappings.ic_to_gauss(sigma_tilde, a_bar, params, l_max=30, sigma0=0)
  31. # ex_gauss2 = ex_gauss.clone()
  32. # ex_cap = quadrupole_model_mappings.ic_to_cap(sigma_tilde, a_bar, params, l_max=30, sigma0=0)
  33. # ex_cap2 = ex_cap.clone()
  34. # path plots for all models
  35. path_plot = PathEnergyPlot(ex1, ex2, QuadPath, dist=2., params=params)
  36. energy = path_plot.evaluate_path()
  37. x_axis = path_plot.rot_path.stack_x_axes()
  38. # path_plot_gauss = PathEnergyPlot(ex_gauss, ex_gauss2, QuadPath, dist=2., params=params)
  39. # energy_gauss = path_plot_gauss.evaluate_path()
  40. #
  41. # path_plot_cap = PathEnergyPlot(ex_cap, ex_cap2, QuadPath, dist=2., params=params)
  42. # energy_cap = path_plot_cap.evaluate_path()
  43. # peak_energy_sanity_check
  44. # ex1new = expansion.MappedExpansionQuad(abar, params.kappaR, sigma_tilde, l_max=30)
  45. # ex2new = ex1new.clone()
  46. # pp_energy = interactions.charged_shell_energy(ex1new, ex2new, params)
  47. # print(f'PP energy: {pp_energy}')
  48. # Emanuele data
  49. em_data = np.load(Path(config_data["emanuele_data"]).joinpath("FIG_3C").joinpath("pathway.npz"))['arr_0']
  50. # em_data = np.load(Path(config_data["emanuele_data"]).joinpath("FIG_7").joinpath("pathway.npz"))['arr_0']
  51. # em_data_path = (Path(config_data["emanuele_data"]).joinpath("FIG_8").joinpath("FIXEDCHARGE")
  52. # .joinpath("FIX_A").joinpath("ECC_0.25"))
  53. # em_data = np.load(em_data_path.joinpath(f"EMME_{kappaR}.").joinpath("pathway.npz"))['arr_0']
  54. if save_data:
  55. np.savez(Path(config_data["figure_data"]).joinpath(f"fig_7_kR{kappaR}.npz"),
  56. ICi=em_data,
  57. CSp=np.stack((x_axis, np.squeeze(energy))).T,
  58. # CSp_gauss=np.stack((x_axis, np.squeeze(energy_gauss))).T,
  59. # CSp_cap=np.stack((x_axis, np.squeeze(energy_cap))).T
  60. )
  61. fig, ax = plt.subplots(figsize=(8.25, 3))
  62. ax.plot(em_data[:, 0], em_data[:, 1], label='ICi', c=COLOR_LIST[1])
  63. ax.plot(x_axis, np.squeeze(energy), label='CSp', c=COLOR_LIST[1], ls='--')
  64. # ax.plot(x_axis, np.squeeze(energy_gauss), label='CSp - Gauss')
  65. # ax.plot(x_axis, np.squeeze(energy_cap), label='CSp - cap')
  66. # ax.plot(x_axis, em_data[:, 1] / np.squeeze(energy), label='CSp')
  67. path_plot.plot_style(fig, ax, size=(8.25, 3.5))
  68. if save_as is not None:
  69. plt.savefig(save_as, dpi=300)
  70. plt.show()
  71. def kappaR_dependence(kappaR: Array, abar: float, sigma_tilde=0.001, save_as=None):
  72. params = ModelParams(R=150, kappaR=kappaR)
  73. ex1 = expansion.MappedExpansionQuad(abar, params.kappaR, sigma_tilde, l_max=30)
  74. ex2 = ex1.clone()
  75. path_plot = PathEnergyPlot(ex1, ex2, QuadPath, dist=2., params=params, match_expansion_axis_to_params=0)
  76. path_plot.plot(labels=[rf'$\kappa R$={kR}' for kR in kappaR],
  77. # norm_euler_angles={'beta2': np.pi},
  78. save_as=save_as)
  79. def abar_dependence(abar: Array, kappaR: float, sigma_tilde=0.001, save_as=None):
  80. params = ModelParams(R=150, kappaR=kappaR)
  81. ex1 = expansion.MappedExpansionQuad(abar, params.kappaR, sigma_tilde, l_max=30)
  82. ex2 = ex1.clone()
  83. path_plot = PathEnergyPlot(ex1, ex2, QuadPath, dist=2., params=params, match_expansion_axis_to_params=None)
  84. path_plot.plot(labels=[rf'$\bar a$={a}' for a in abar],
  85. # norm_euler_angles={'beta2': np.pi},
  86. save_as=save_as)
  87. def sigma0_dependence(sigma0: Array, kappaR: float, abar: float, sigma_tilde=0.001, save_as=None):
  88. params = ModelParams(R=150, kappaR=kappaR)
  89. ex1 = expansion.MappedExpansionQuad(abar, params.kappaR, sigma_tilde, l_max=30, sigma0=sigma0)
  90. ex2 = ex1.clone()
  91. path_plot = PathEnergyPlot(ex1, ex2, QuadPath, dist=2., params=params, match_expansion_axis_to_params=None)
  92. path_plot.plot(labels=[rf'$\eta={s0 / sigma_tilde}$' for s0 in sigma0],
  93. # norm_euler_angles={'beta2': np.pi},
  94. save_as=save_as)
  95. def distance_dependence(dist: Array, kappaR: float, abar: float, sigma_tilde=0.001, save_as=None):
  96. params = ModelParams(R=150, kappaR=kappaR)
  97. ex1 = expansion.MappedExpansionQuad(abar, params.kappaR, sigma_tilde, l_max=30)
  98. ex2 = ex1.clone()
  99. plots = []
  100. for d in dist:
  101. path_plot = PathEnergyPlot(ex1, ex2, QuadPath, dist=d, params=params)
  102. x = d * kappaR
  103. plots.append(path_plot.evaluate_path() * np.exp(x) * x)
  104. x_axis = path_plot.rot_path.stack_x_axes()
  105. labels = [rf'$\rho/R ={d}$' for d in dist]
  106. fig, ax = plt.subplots(figsize=plt.figaspect(0.5))
  107. for pl, lbl in zip(plots, labels):
  108. ax.plot(x_axis, pl, label=lbl)
  109. QuadPath.plot_style(fig, ax)
  110. ax.set_ylabel(r'$U \kappa\rho e^{\kappa\rho}$', fontsize=15)
  111. if save_as is not None:
  112. plt.savefig(save_as, dpi=300)
  113. plt.show()
  114. def IC_kappaR_dependence(config_data: dict, save_as=None):
  115. # em_data_path = (Path(config_data["emanuele_data"]).joinpath("FIG_8").joinpath("FIXEDCHARGE")
  116. # .joinpath("FIX_A").joinpath("ECC_0.25"))
  117. em_data_path = (Path(config_data["emanuele_data"]).joinpath("FIG_4_Panels_ACE").joinpath("FIXEDCHARGE")
  118. .joinpath("FIX_A").joinpath("ECC_0.25"))
  119. kR1 = np.load(em_data_path.joinpath("EMME_1.").joinpath("pathway.npz"))['arr_0']
  120. kR3 = np.load(em_data_path.joinpath("EMME_3.").joinpath("pathway.npz"))['arr_0']
  121. kR10 = np.load(em_data_path.joinpath("EMME_10.").joinpath("pathway.npz"))['arr_0']
  122. labels = [rf'$\kappa R$={kR}' for kR in [1, 3, 10]]
  123. fig, ax = plt.subplots()
  124. ax.plot(kR1[:, 0], kR1[:, 1], label=labels[0])
  125. ax.plot(kR3[:, 0], kR3[:, 1], label=labels[1])
  126. ax.plot(kR10[:, 0], kR10[:, 1], label=labels[2])
  127. QuadPath.plot_style(fig, ax)
  128. if save_as is not None:
  129. plt.savefig(save_as, dpi=300)
  130. plt.show()
  131. def IC_abar_dependence(config_data: dict, save_as=None):
  132. # em_data_path = (Path(config_data["emanuele_data"]).joinpath("FIG_8").joinpath("FIXEDCHARGE").joinpath("FIX_M"))
  133. em_data_path = (Path(config_data["emanuele_data"]).joinpath("FIG_4_Panels_ACE").joinpath("FIXEDCHARGE").joinpath("FIX_M"))
  134. a03 = np.load(em_data_path.joinpath("ECC_0.15").joinpath("EMME_3.").joinpath("pathway.npz"))['arr_0']
  135. a04 = np.load(em_data_path.joinpath("ECC_0.2").joinpath("EMME_3.").joinpath("pathway.npz"))['arr_0']
  136. a05 = np.load(em_data_path.joinpath("ECC_0.25").joinpath("EMME_3.").joinpath("pathway.npz"))['arr_0']
  137. labels =[rf'$\bar a$={a}' for a in [0.3, 0.4, 0.5]]
  138. fig, ax = plt.subplots()
  139. ax.plot(a03[:, 0], a03[:, 1], label=labels[0])
  140. ax.plot(a04[:, 0], a04[:, 1], label=labels[1])
  141. ax.plot(a05[:, 0], a05[:, 1], label=labels[2])
  142. QuadPath.plot_style(fig, ax)
  143. if save_as is not None:
  144. plt.savefig(save_as, dpi=300)
  145. plt.show()
  146. def IC_sigma0_dependence(config_data: dict, save_as=None):
  147. # em_data_path = (Path(config_data["emanuele_data"]).joinpath("FIG_8").joinpath("CHARGE_ZC"))
  148. em_data_path = (Path(config_data["emanuele_data"]).joinpath("FIG_4_Panels_ACE").joinpath("CHARGE_ZC"))
  149. undercharged = np.load(em_data_path.joinpath("ZC_-277.27").joinpath("pathway.npz"))['arr_0']
  150. neutral = np.load(em_data_path.joinpath("ZC_-560").joinpath("pathway.npz"))['arr_0']
  151. overchargerd = np.load(em_data_path.joinpath("ZC_-842.74").joinpath("pathway.npz"))['arr_0']
  152. labels = [rf'$\eta={eta}$' for eta in [-0.1, 0, 0.1]]
  153. fig, ax = plt.subplots()
  154. ax.plot(overchargerd[:, 0], overchargerd[:, 1], label=labels[0])
  155. ax.plot(neutral[:, 0], neutral[:, 1], label=labels[1])
  156. ax.plot(undercharged[:, 0], undercharged[:, 1], label=labels[2])
  157. QuadPath.plot_style(fig, ax)
  158. if save_as is not None:
  159. plt.savefig(save_as, dpi=300)
  160. plt.show()
  161. def combined_distance_dependence(config_data: dict, dist: Array = 2 * np.array([1., 1.15, 1.3, 1.45]),
  162. kappaR: float = 3,
  163. abar: float = 0.5,
  164. sigma_tilde=0.00099,
  165. save_as=None):
  166. # em_data_path = Path(config_data["emanuele_data"]).joinpath("FIG_12")
  167. em_data_path = Path(config_data["emanuele_data"]).joinpath("FIG_3D_LONG_DIST")
  168. em_data = np.load(em_data_path.joinpath("pathway_fig12A.npz"))
  169. em_data_d2 = np.load(Path(config_data["emanuele_data"]).joinpath("FIG_3C").joinpath("pathway.npz"))['arr_0']
  170. ic_data = [em_data_d2]
  171. for key, d in em_data.items():
  172. ic_data.append(d)
  173. params = ModelParams(R=150, kappaR=kappaR)
  174. ex1 = expansion.MappedExpansionQuad(abar, params.kappaR, sigma_tilde, l_max=30)
  175. ex2 = ex1.clone()
  176. plots = []
  177. for d in dist:
  178. path_plot = PathEnergyPlot(ex1, ex2, QuadPath, dist=d, params=params)
  179. plots.append(path_plot.evaluate_path())
  180. x_axis = path_plot.rot_path.stack_x_axes()
  181. labels = [rf'$\rho/R ={d}$' for d in dist]
  182. # additional legend
  183. line1 = Line2D([0], [0], color='black', linewidth=1.2, label='ICi')
  184. line2 = Line2D([0], [0], color='black', linestyle='--', linewidth=1.2, label='CSp')
  185. # np.savetxt("/home/andraz/Downloads/calibrate_CSp.dat", np.stack((x_axis, plots[0])).T)
  186. # np.savetxt("/home/andraz/Downloads/calibrate_ICi.dat", ic_data[0])
  187. fig, ax = plt.subplots()
  188. for i, (d, en, label, c) in enumerate(zip(ic_data, plots, labels, COLORS)):
  189. if i < 3:
  190. ax.plot(d[:, 0], d[:, 1], label=label, c=c)
  191. ax.plot(x_axis, en, ls='--', c=c)
  192. QuadPath.plot_style(fig, ax)
  193. main_legend = ax.get_legend()
  194. extra_legend = ax.legend(handles=[line1, line2], loc='upper left', fontsize=11, frameon=False)
  195. ax.add_artist(main_legend)
  196. ax.add_artist(extra_legend)
  197. if save_as is not None:
  198. plt.savefig(save_as, dpi=300)
  199. plt.show()
  200. def combined_rescaled_distance_dependence(config_data: dict,
  201. dist: Array = 2 * np.array([1, 1.5, 2, 3, 5, 10]),
  202. kappaR: float = 3,
  203. abar: float = 0.5,
  204. sigma_tilde=0.001,
  205. save_as=None):
  206. # em_data_path = Path(config_data["emanuele_data"]).joinpath("FIG_12")
  207. em_data_path = Path(config_data["emanuele_data"]).joinpath("FIG_3D_LONG_DIST")
  208. em_data = np.load(em_data_path.joinpath("pathway_fig12B.npz"))
  209. ic_data = []
  210. for key, d in em_data.items():
  211. # if key == 'kr10':
  212. # continue
  213. print(key, np.max(d[:, 1]))
  214. ic_data.append(d)
  215. params = ModelParams(R=150, kappaR=kappaR)
  216. ex1 = expansion.MappedExpansionQuad(abar, params.kappaR, sigma_tilde, l_max=30)
  217. ex2 = ex1.clone()
  218. plots = []
  219. for d in dist:
  220. path_plot = PathEnergyPlot(ex1, ex2, QuadPath, dist=d, params=params)
  221. x = d * kappaR
  222. plots.append(path_plot.evaluate_path() * np.exp(x) * x)
  223. # plots.append(path_plot.evaluate_path())
  224. x_axis = path_plot.rot_path.stack_x_axes()
  225. labels = [rf'$\rho/R ={d}$' for d in dist]
  226. fig, ax = plt.subplots()
  227. for d, en, label, c in zip(ic_data, plots, labels, COLORS):
  228. ax.plot(d[:, 0], d[:, 1], label=label, c=c)
  229. ax.plot(x_axis, en, ls='--', c=c)
  230. QuadPath.plot_style(fig, ax)
  231. ax.set_ylabel(r'$U \kappa\rho e^{\kappa\rho}$', fontsize=15)
  232. if save_as is not None:
  233. plt.savefig(save_as, dpi=300)
  234. plt.show()
  235. def combined_kappaR_dependence(config_data: dict, kappaR: list[int], abar: float, sigma_tilde=0.001, save_as=None):
  236. # em_data_path = (Path(config_data["emanuele_data"]).joinpath("FIG_8").joinpath("FIXEDCHARGE")
  237. # .joinpath("FIX_A").joinpath(f"ECC_{np.round(abar/2, 4)}"))
  238. em_data_path = (Path(config_data["emanuele_data"]).joinpath("FIG_4_Panels_ACE").joinpath("FIXEDCHARGE")
  239. .joinpath("FIX_A").joinpath(f"ECC_{np.round(abar/2, 4)}"))
  240. ic_data = []
  241. for kR in kappaR:
  242. ic_data.append(np.load(em_data_path.joinpath(f"EMME_{kR}.").joinpath("pathway.npz"))['arr_0'])
  243. params = ModelParams(R=150, kappaR=np.asarray(kappaR))
  244. ex1 = expansion.MappedExpansionQuad(abar, params.kappaR, sigma_tilde, l_max=30)
  245. ex2 = ex1.clone()
  246. path_plot = PathEnergyPlot(ex1, ex2, QuadPath, dist=2., params=params, match_expansion_axis_to_params=0)
  247. energy = path_plot.evaluate_path()
  248. x_axis = path_plot.rot_path.stack_x_axes()
  249. labels = [rf'$\kappa R={kR}$' for kR in [1, 3, 10]]
  250. fig, ax = plt.subplots()
  251. for d, en, label, c in zip(ic_data, energy.T, labels, COLORS):
  252. ax.plot(d[:, 0], d[:, 1], label=label, c=c)
  253. ax.plot(x_axis, en, ls='--', c=c)
  254. QuadPath.plot_style(fig, ax)
  255. if save_as is not None:
  256. plt.savefig(save_as, dpi=300)
  257. plt.show()
  258. def combined_abar_dependence(config_data: dict, kappaR: int, abar: list[float], sigma_tilde=0.001, save_as=None):
  259. # em_data_path = (Path(config_data["emanuele_data"]).joinpath("FIG_8").joinpath("FIXEDCHARGE").joinpath("FIX_M"))
  260. em_data_path = (Path(config_data["emanuele_data"]).joinpath("FIG_4_Panels_ACE").joinpath("FIXEDCHARGE").joinpath("FIX_M"))
  261. ic_data = []
  262. for ab in abar:
  263. ic_data.append(np.load(em_data_path.joinpath(f"ECC_{np.round(ab/2, 4)}").
  264. joinpath(f"EMME_{kappaR}.").joinpath("pathway.npz"))['arr_0'])
  265. params = ModelParams(R=150, kappaR=kappaR)
  266. ex1 = expansion.MappedExpansionQuad(np.asarray(abar), params.kappaR, sigma_tilde, l_max=30)
  267. ex2 = ex1.clone()
  268. path_plot = PathEnergyPlot(ex1, ex2, QuadPath, dist=2., params=params, match_expansion_axis_to_params=None)
  269. energy = path_plot.evaluate_path()
  270. x_axis = path_plot.rot_path.stack_x_axes()
  271. labels = [rf'$\bar a={a}$' for a in [0.3, 0.4, 0.5]]
  272. fig, ax = plt.subplots()
  273. for d, en, label, c in zip(ic_data, energy.T, labels, COLORS):
  274. ax.plot(d[:, 0], d[:, 1], label=label, c=c)
  275. ax.plot(x_axis, en, ls='--', c=c)
  276. QuadPath.plot_style(fig, ax)
  277. if save_as is not None:
  278. plt.savefig(save_as, dpi=300)
  279. plt.show()
  280. def combined_sigma0_dependence(config_data: dict, kappaR=3., abar=0.5, sigma0=(0.0002, 0.00, -0.0002), sigma_tilde=0.001, save_as=None):
  281. # em_data_path = (Path(config_data["emanuele_data"]).joinpath("FIG_8").joinpath("CHARGE_ZC"))
  282. em_data_path = (Path(config_data["emanuele_data"]).joinpath("FIG_4_Panels_ACE").joinpath("CHARGE_ZC"))
  283. undercharged = np.load(em_data_path.joinpath("ZC_-503").joinpath("pathway.npz"))['arr_0']
  284. neutral = np.load(em_data_path.joinpath("ZC_-560").joinpath("pathway.npz"))['arr_0']
  285. overchargerd = np.load(em_data_path.joinpath("ZC_-617").joinpath("pathway.npz"))['arr_0']
  286. ic_data = [undercharged, neutral, overchargerd]
  287. params = ModelParams(R=150, kappaR=kappaR)
  288. ex1 = expansion.MappedExpansionQuad(abar, params.kappaR, sigma_tilde, l_max=30, sigma0=np.asarray(sigma0))
  289. ex2 = ex1.clone()
  290. path_plot = PathEnergyPlot(ex1, ex2, QuadPath, dist=2., params=params, match_expansion_axis_to_params=None)
  291. energy = path_plot.evaluate_path()
  292. x_axis = path_plot.rot_path.stack_x_axes()
  293. labels = [rf'$\eta={s0/sigma_tilde}$' for s0 in sigma0]
  294. fig, ax = plt.subplots()
  295. for d, en, label, c in zip(ic_data, energy.T, labels, COLORS):
  296. ax.plot(d[:, 0], d[:, 1], label=label, c=c)
  297. ax.plot(x_axis, en, ls='--', c=c)
  298. QuadPath.plot_style(fig, ax)
  299. if save_as is not None:
  300. plt.savefig(save_as, dpi=300)
  301. plt.show()
  302. def combined_all(config_data: dict, save_as=None):
  303. sigma_tilde = 0.00099
  304. kappaR_list = [1, 3, 10]
  305. abar_list = [0.5, 0.4, 0.3]
  306. sigma0_list = [0.000198, 0.00, -0.000198]
  307. kappaR = 3
  308. abar = 0.5
  309. em_data_kappaR = (Path(config_data["emanuele_data"]).joinpath("FIG_4_Panels_ACE").joinpath("FIXEDCHARGE")
  310. .joinpath("FIX_A").joinpath(f"ECC_{np.round(abar/2, 4)}"))
  311. ic_data_kappaR = []
  312. for kR in kappaR_list:
  313. ic_data_kappaR.append(np.load(em_data_kappaR.joinpath(f"EMME_{kR}.").joinpath("pathway.npz"))['arr_0'])
  314. params = ModelParams(R=150, kappaR=np.asarray(kappaR_list))
  315. ex1 = expansion.MappedExpansionQuad(abar, params.kappaR, sigma_tilde, l_max=30)
  316. ex2 = ex1.clone()
  317. path_plot = PathEnergyPlot(ex1, ex2, QuadPath, dist=2., params=params, match_expansion_axis_to_params=0)
  318. energy_kappaR = path_plot.evaluate_path()
  319. x_axis_kappaR = path_plot.rot_path.stack_x_axes()
  320. labels_kappaR = [rf'$\kappa R={kR}$' for kR in [1, 3, 10]]
  321. em_data_abar = (Path(config_data["emanuele_data"]).joinpath("FIG_4_Panels_ACE").joinpath("FIXEDCHARGE").joinpath("FIX_M"))
  322. ic_data_abar = []
  323. for ab in abar_list:
  324. ic_data_abar.append(np.load(em_data_abar.joinpath(f"ECC_{np.round(ab/2, 4)}").
  325. joinpath(f"EMME_{kappaR}.").joinpath("pathway.npz"))['arr_0'])
  326. params = ModelParams(R=150, kappaR=kappaR)
  327. ex1 = expansion.MappedExpansionQuad(np.asarray(abar_list), params.kappaR, sigma_tilde, l_max=30)
  328. ex2 = ex1.clone()
  329. path_plot = PathEnergyPlot(ex1, ex2, QuadPath, dist=2., params=params, match_expansion_axis_to_params=None)
  330. energy_abar = path_plot.evaluate_path()
  331. x_axis_abar = path_plot.rot_path.stack_x_axes()
  332. labels_abar = [rf'$\bar a={a}$' for a in abar_list]
  333. em_data_charge = (Path(config_data["emanuele_data"]).joinpath("FIG_4_Panels_ACE").joinpath("CHARGE_ZC"))
  334. undercharged = np.load(em_data_charge.joinpath("ZC_-503").joinpath("pathway.npz"))['arr_0']
  335. neutral = np.load(em_data_charge.joinpath("ZC_-560").joinpath("pathway.npz"))['arr_0']
  336. overchargerd = np.load(em_data_charge.joinpath("ZC_-617").joinpath("pathway.npz"))['arr_0']
  337. ic_data_sigma0 = [undercharged, neutral, overchargerd]
  338. params = ModelParams(R=150, kappaR=kappaR)
  339. ex1 = expansion.MappedExpansionQuad(abar, params.kappaR, sigma_tilde, l_max=30, sigma0=np.asarray(sigma0_list))
  340. ex2 = ex1.clone()
  341. path_plot = PathEnergyPlot(ex1, ex2, QuadPath, dist=2., params=params, match_expansion_axis_to_params=None)
  342. energy_sigma0 = path_plot.evaluate_path()
  343. x_axis_sigma0 = path_plot.rot_path.stack_x_axes()
  344. labels_sigma0 = [rf'$\eta={s0/sigma_tilde:.1f}$' for s0 in sigma0_list]
  345. line1 = Line2D([0], [0], color='black', linewidth=1.2, label='ICi')
  346. line2 = Line2D([0], [0], color='black', linestyle='--', linewidth=1.2, label='CSp')
  347. # fig, axs = plt.subplots(3, 1, figsize=(6, 7.8))
  348. fig = plt.figure(figsize=(4, 5.4))
  349. gs = gridspec.GridSpec(3, 1, figure=fig)
  350. gs.update(left=0.12, right=0.975, top=0.96, bottom=0.04, hspace=0.3)
  351. axs = [fig.add_subplot(gs[0, 0]), fig.add_subplot(gs[1, 0]), fig.add_subplot(gs[2, 0])]
  352. for d, en, label, c in zip(ic_data_kappaR, energy_kappaR.T, labels_kappaR, COLOR_LIST):
  353. axs[0].set_title('Screening', fontsize=11, y=0.98)
  354. axs[0].plot(d[:, 0], d[:, 1], label=label, c=c)
  355. axs[0].plot(x_axis_kappaR, en, ls='--', c=c)
  356. extra_legend = axs[0].legend(handles=[line1, line2], loc='upper left', fontsize=11, frameon=False)
  357. axs[0].add_artist(extra_legend)
  358. QuadPath.plot_style(fig, axs[0], size=None)
  359. for d, en, label, c in zip(ic_data_abar, energy_abar.T, labels_abar, COLOR_LIST):
  360. axs[1].set_title('Eccentricity', fontsize=11, y=0.98)
  361. axs[1].plot(d[:, 0], d[:, 1], label=label, c=c)
  362. axs[1].plot(x_axis_abar, en, ls='--', c=c)
  363. QuadPath.plot_style(fig, axs[1], size=None)
  364. for d, en, label, c in zip(ic_data_sigma0, energy_sigma0.T, labels_sigma0, COLOR_LIST):
  365. axs[2].set_title('Net charge', fontsize=11, y=0.98)
  366. axs[2].plot(d[:, 0], d[:, 1], label=label, c=c)
  367. axs[2].plot(x_axis_sigma0, en, ls='--', c=c)
  368. for ax in axs:
  369. ax.yaxis.set_label_coords(-0.08, 0.5)
  370. # axs[-1].set_xlabel('rotational path', fontsize=15)
  371. QuadPath.plot_style(fig, axs[2], size=None)
  372. for ax in axs:
  373. ax.get_legend().set_bbox_to_anchor((0.6, 1))
  374. if save_as is not None:
  375. plt.savefig(save_as, dpi=300)
  376. plt.show()
  377. def main():
  378. with open(Path("/home/andraz/ChargedShells/charged-shells/config.json")) as config_file:
  379. config_data = json.load(config_file)
  380. # model_comparison(config_data, save_data=False,
  381. # save_as=Path(config_data["figures"]).joinpath("final_figures").joinpath('quad_og_comparison.png')
  382. # )
  383. # kappaR_dependence(np.array([1, 3, 10]), 0.5,
  384. # # save_as=Path("/home/andraz/ChargedShells/Figures/quadrupole_kappaR_dep.png")
  385. # )
  386. #
  387. # abar_dependence(np.array([0.3, 0.4, 0.5]), 3,
  388. # save_as=Path("/home/andraz/ChargedShells/Figures/quadrupole_abar_dep.png")
  389. # )
  390. # sigma0_dependence(np.array([-0.0002, 0.00, 0.0002]), 3, 0.5,
  391. # save_as=Path("/home/andraz/ChargedShells/Figures/quadrupole_charge_dep_abar05_kappaR3.png")
  392. # )
  393. # distance_dependence(dist=np.array([2, 3, 4, 6, 10, 20]), kappaR=3, abar=0.5,
  394. # # save_as=Path(config_data["figures"]).joinpath('quadrupole_distance_dep.png')
  395. # )
  396. # IC_kappaR_dependence(config_data,
  397. # save_as=Path(config_data["figures"]).joinpath("Emanuele_data").joinpath('IC_quadrupole_kappaR_dep.png')
  398. # )
  399. #
  400. # IC_abar_dependence(config_data, save_as=Path(config_data["figures"]).joinpath("Emanuele_data").
  401. # joinpath('IC_quadrupole_abar_dep.png'))
  402. #
  403. # IC_sigma0_dependence(config_data, save_as=Path(config_data["figures"]).joinpath("Emanuele_data").
  404. # joinpath('IC_quadrupole_charge_dep_abar05_kappaR3.png'))
  405. # combined_kappaR_dependence(config_data, kappaR=[1, 3, 10], abar=0.5,
  406. # save_as=Path(config_data["figures"]).joinpath("final_figures").joinpath('quad_kappaR_dep.png')
  407. # )
  408. # combined_sigma0_dependence(config_data,
  409. # save_as=Path(config_data["figures"]).joinpath("final_figures").joinpath('quad_charge_dep.png')
  410. # )
  411. # combined_abar_dependence(config_data, kappaR=3, abar=[0.3, 0.4, 0.5],
  412. # save_as=Path(config_data["figures"]).joinpath("final_figures").joinpath('quad_abar_dep.png')
  413. # )
  414. # combined_rescaled_distance_dependence(config_data)
  415. # combined_distance_dependence(config_data,
  416. # save_as=Path(config_data["figures"]).joinpath("final_figures").joinpath('quad_dist_dep.png')
  417. # )
  418. combined_all(config_data,
  419. save_as=Path(config_data["figures"]).joinpath("final_figures").joinpath('quad_combined_dep.png')
  420. )
  421. if __name__ == '__main__':
  422. main()