peak_heigth.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import matplotlib.pyplot as plt
  2. import expansion
  3. import interactions
  4. from parameters import ModelParams
  5. import numpy as np
  6. from typing import Literal
  7. from pathlib import Path
  8. Array = np.ndarray
  9. Expansion = expansion.Expansion
  10. RotConfig = Literal['ep', 'pp']
  11. def peak_energy_plot(kappaR: Array,
  12. a_bar: Array,
  13. which: Literal['ep', 'pp'],
  14. R: float = 150,
  15. dist: float = 2.,
  16. l_max=20,
  17. save_as: Path = None):
  18. params = ModelParams(R=R, kappaR=kappaR)
  19. energy = []
  20. for params in params.unravel():
  21. ex1 = expansion.MappedExpansionQuad(a_bar, params.kappaR, 0.001, l_max=l_max)
  22. ex2 = ex1.clone()
  23. if which == 'ep':
  24. ex1.rotate_euler(alpha=0, beta=np.pi / 2, gamma=0)
  25. energy.append(interactions.charged_shell_energy(ex1, ex2, dist, params))
  26. energy = np.array(energy)
  27. fig, ax = plt.subplots()
  28. for en, ab in zip(energy.T, a_bar):
  29. ax.plot(kappaR, en / en[0], label=rf'$\bar a = {ab:.1f}$')
  30. ax.legend(fontsize=12)
  31. ax.tick_params(which='both', direction='in', top=True, right=True, labelsize=12)
  32. ax.set_xlabel(r'$\kappa R$', fontsize=13)
  33. ax.set_ylabel(rf'$\bar V$', fontsize=13)
  34. plt.tight_layout()
  35. if save_as is not None:
  36. plt.savefig(save_as, dpi=600)
  37. plt.show()
  38. if __name__ == '__main__':
  39. kappaR = np.arange(1, 10, 0.1)
  40. a_bar = np.arange(0.2, 0.8, 0.2)
  41. peak_energy_plot(kappaR, a_bar, which='pp',
  42. save_as=Path('/home/andraz/ChargedShells/Figures/nonmonotonicity_check_pp.pdf')
  43. )