patch_size_dependence.py 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. from matplotlib import pyplot as plt
  2. from pathlib import Path
  3. import numpy as np
  4. from charged_shells import expansion, patch_size
  5. from charged_shells.parameters import ModelParams
  6. import time
  7. def plot_abar_dependence(*, save=False):
  8. a_bar = np.linspace(0.2, 0.8, 101)
  9. kappaR = np.array([0.1, 1, 3, 10, 30])
  10. params = ModelParams(R=150, kappaR=kappaR)
  11. ex = expansion.MappedExpansionQuad(a_bar=a_bar[:, None], sigma_tilde=0.001, l_max=30, kappaR=kappaR[None, :])
  12. ps = patch_size.potential_patch_size(ex, params, match_expansion_axis_to_params=1)
  13. markers = ['o', 's', '^', 'D', 'v', '<', '>', 'p', '*', 'H', '+', 'x']
  14. # fig, ax = plt.subplots(figsize=plt.figaspect(0.5)/1.5)
  15. fig, ax = plt.subplots()
  16. for patch, kR, marker in zip(ps.T, kappaR, markers):
  17. ax.plot(a_bar, patch, label=rf'$\kappa R$ = {kR}', marker=marker, markerfacecolor='none', markevery=5)
  18. ax.tick_params(which='both', direction='in', top=True, right=True, labelsize=12)
  19. ax.set_xlabel(r'$\bar a$', fontsize=15)
  20. ax.set_ylabel(r'$\theta_0$', fontsize=15)
  21. plt.legend(fontsize=14)
  22. plt.tight_layout()
  23. if save:
  24. plt.savefig(Path("/home/andraz/ChargedShells/Figures/patch_size_potential_new.pdf"), dpi=300)
  25. plt.show()
  26. def plot_abar_charge_dependence(*, save=False):
  27. a_bar = np.linspace(0.2, 0.8, 101)
  28. kappaR = np.array([0.1, 1, 3, 10, 30])
  29. ex = expansion.MappedExpansionQuad(a_bar=a_bar[:, None], sigma_tilde=0.001, l_max=30, kappaR=kappaR[None, :])
  30. ps = patch_size.charge_patch_size(ex)
  31. markers = ['o', 's', '^', 'D', 'v', '<', '>', 'p', '*', 'H', '+', 'x']
  32. fig, ax = plt.subplots(figsize=plt.figaspect(0.5)/1.5)
  33. for patch, kR, marker in zip(ps.T, kappaR, markers):
  34. ax.plot(a_bar, patch, label=rf'$\kappa R$ = {kR}', marker=marker, markerfacecolor='none', markevery=5)
  35. ax.tick_params(which='both', direction='in', top=True, right=True, labelsize=12)
  36. ax.set_xlabel(r'$\bar a$', fontsize=15)
  37. ax.set_ylabel(r'$\theta_0$', fontsize=15)
  38. plt.legend(fontsize=14)
  39. plt.tight_layout()
  40. if save:
  41. plt.savefig(Path("/home/andraz/ChargedShells/Figures/patch_size_charge.pdf"), dpi=300)
  42. plt.show()
  43. def plot_kappaR_charge_dependence(*, normalized=False, save=False):
  44. a_bar = np.array([0.2, 0.4, 0.6, 0.8])
  45. kappaR = np.linspace(0.01, 30, 100)
  46. ex = expansion.MappedExpansionQuad(a_bar=a_bar[None, :], sigma_tilde=0.001, l_max=30, kappaR=kappaR[:, None])
  47. ps = patch_size.charge_patch_size(ex)
  48. if normalized:
  49. ps = ps / ps[0][None, :]
  50. markers = ['o', 's', '^', 'D', 'v', '<', '>', 'p', '*', 'H', '+', 'x']
  51. fig, ax = plt.subplots(figsize=plt.figaspect(0.5)/1.5)
  52. for patch, abar, marker in zip(ps.T, a_bar, markers):
  53. ax.plot(kappaR, patch, label=rf'$\bar a$ = {abar}', marker=marker, markerfacecolor='none', markevery=5)
  54. ax.tick_params(which='both', direction='in', top=True, right=True, labelsize=12)
  55. ax.set_xlabel(r'$\kappa R$', fontsize=15)
  56. ax.set_ylabel(r'$\theta_0$', fontsize=15)
  57. plt.legend(fontsize=14)
  58. plt.tight_layout()
  59. if save:
  60. plt.savefig(Path("/home/andraz/ChargedShells/Figures/patch_size_charge_nonmonotonicity.pdf"), dpi=300)
  61. plt.show()
  62. def plot_sigma0_dependence(*, save=False):
  63. # kappaR = np.array([0.1, 1, 3, 10, 30])
  64. kappaR = np.linspace(0.1, 15, 201)
  65. # sigma0 = np.linspace(-0.001, 0.0015, 6)
  66. sigma0 = np.array([-0.0002, 0, 0.0002])
  67. params = ModelParams(R=150, kappaR=kappaR)
  68. ex = expansion.MappedExpansionQuad(a_bar=0.3, sigma_tilde=0.001, l_max=30, kappaR=kappaR, sigma0=sigma0)
  69. t0 = time.perf_counter()
  70. ps = patch_size.potential_patch_size(ex, params, match_expansion_axis_to_params=0, skip_nozero_cases=True)
  71. t1 = time.perf_counter()
  72. print(f'Time: {t1 - t0}')
  73. markers = ['o', 's', '^', 'D', 'p', 'v', '<', '>', 'x', '*', 'H', '+']
  74. fig, ax = plt.subplots(figsize=plt.figaspect(0.5)/1.5)
  75. for patch, sgm, marker in zip(ps.T, sigma0, markers):
  76. nonzero_ps = np.nonzero(patch)
  77. ax.plot(kappaR[nonzero_ps], patch[nonzero_ps], label=rf'$\tilde \sigma_0$ = {sgm}', marker=marker, markerfacecolor='none', markevery=10)
  78. ax.tick_params(which='both', direction='in', top=True, right=True, labelsize=12)
  79. ax.set_xlabel(r'$\kappa R$', fontsize=15)
  80. ax.set_ylabel(r'$\theta_0$', fontsize=15)
  81. plt.legend(fontsize=14, loc='upper right')
  82. plt.tight_layout()
  83. if save:
  84. plt.savefig(Path("/home/andraz/ChargedShells/Figures/patch_size_potential_charge_abar03.pdf"), dpi=300)
  85. plt.show()
  86. def plot_sigma0_dependence_relative(*, save=False):
  87. # kappaR = np.array([0.1, 1, 3, 10, 30])
  88. kappaR = np.linspace(0.1, 15, 201)
  89. # sigma0 = np.linspace(-0.001, 0.0015, 6)
  90. sigma0 = np.array([-0.0002, 0, 0.0002])
  91. params = ModelParams(R=150, kappaR=kappaR)
  92. ex = expansion.MappedExpansionQuad(a_bar=0.8, sigma_tilde=0.001, l_max=30, kappaR=kappaR, sigma0=sigma0)
  93. ex_neutral = expansion.MappedExpansionQuad(a_bar=0.3, sigma_tilde=0.001, l_max=30, kappaR=kappaR, sigma0=0)
  94. ps = patch_size.potential_patch_size(ex, params, match_expansion_axis_to_params=0, skip_nozero_cases=True)
  95. ps_neutral = patch_size.potential_patch_size(ex_neutral, params, match_expansion_axis_to_params=0)
  96. markers = ['o', 's', '^', 'D', 'p', 'v', '<', '>', 'x', '*', 'H', '+']
  97. fig, ax = plt.subplots(figsize=plt.figaspect(0.5)/1.5)
  98. for patch, sgm, marker in zip(ps.T, sigma0, markers):
  99. nonzero_ps = np.nonzero(patch)
  100. ax.plot(kappaR[nonzero_ps], patch[nonzero_ps] / ps_neutral[nonzero_ps],
  101. label=rf'$\tilde \sigma_0$ = {sgm}', marker=marker, markerfacecolor='none', markevery=10)
  102. ax.tick_params(which='both', direction='in', top=True, right=True, labelsize=12)
  103. ax.set_xlabel(r'$\kappa R$', fontsize=15)
  104. ax.set_ylabel(r'$\theta_0$', fontsize=15)
  105. plt.legend(fontsize=14)
  106. plt.tight_layout()
  107. if save:
  108. plt.savefig(Path("/home/andraz/ChargedShells/Figures/patch_size_potential_charge_abar03_relative.pdf"), dpi=300)
  109. plt.show()
  110. def main():
  111. plot_abar_dependence(save=True)
  112. # plot_sigma0_dependence(save=True)
  113. # plot_sigma0_dependence_relative(save=True)
  114. # plot_abar_charge_dependence(save=True)
  115. # plot_kappaR_charge_dependence(normalized=True, save=True)
  116. if __name__ == '__main__':
  117. main()