sEE_minimum.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import numpy as np
  2. from charged_shells import expansion, interactions, mapping
  3. from charged_shells.parameters import ModelParams
  4. from functools import partial
  5. Expansion = expansion.Expansion
  6. def sEE_minimum(ex: Expansion, params: ModelParams, accuracy=1e-3, dist=2., match_expansion_axis_to_params=None):
  7. ex2 = ex.clone()
  8. zero_to_pi_half = np.linspace(0, np.pi / 2, int(1 / accuracy), endpoint=True)
  9. ex.rotate_euler(alpha=0, beta=zero_to_pi_half, gamma=0)
  10. ex2.rotate_euler(alpha=0, beta=zero_to_pi_half, gamma=0)
  11. energy_fn = mapping.parameter_map_two_expansions(partial(interactions.charged_shell_energy, dist=dist),
  12. match_expansion_axis_to_params)
  13. energy = energy_fn(ex, ex2, params)
  14. min_idx = np.argmin(energy, axis=0)
  15. min_energy = np.min(energy, axis=0)
  16. return min_energy, zero_to_pi_half[min_idx]
  17. def main():
  18. kappaR = np.array([1, 3, 10])
  19. params = ModelParams(R=150, kappaR=kappaR)
  20. ex = expansion.MappedExpansionQuad(0.4, kappaR, 0.001)
  21. min_energy, min_angle = sEE_minimum(ex, params, match_expansion_axis_to_params=1)
  22. print(min_energy, min_angle + np.pi/2)
  23. if __name__ == '__main__':
  24. main()