patch_size_dependence.py 5.8 KB

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