123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- import expansion
- import patch_size
- import potentials
- import numpy as np
- from parameters import ModelParams
- import functions as fn
- import matplotlib.pyplot as plt
- import scipy.special as sps
- from pathlib import Path
- import rotational_path
- import path_plot
- def point_to_gauss_map(sigma_m, a_bar, lbd, params: ModelParams):
- return (sigma_m * fn.coefficient_Cim(2, params.kappaR) / fn.coefficient_Cpm(2, params.kappaR)
- * np.sinh(lbd) / (lbd * fn.sph_bessel_i(2, lbd)) * a_bar ** 2)
- def point_to_cap_map(sigma_m, a_bar, theta0, params: ModelParams):
- return (sigma_m * 10 * fn.coefficient_Cim(2, params.kappaR) / fn.coefficient_Cpm(2, params.kappaR) *
- a_bar ** 2 / (sps.eval_legendre(1, np.cos(theta0)) - sps.eval_legendre(3, np.cos(theta0))))
- if __name__ == '__main__':
- target_patch_size = 0.9
- params = ModelParams(R=150, kappaR=1)
- sigma_m = 0.001
- def fn1(x):
- return expansion.MappedExpansionQuad(a_bar=x, kappaR=params.kappaR, sigma_m=sigma_m, l_max=30)
- def fn2(x):
- return expansion.GaussianCharges(lambda_k=x, omega_k=np.array([[0, 0], [np.pi, 0]]), sigma1=0.001, l_max=30)
- def fn3(x):
- return expansion.SphericalCap(theta0_k=x, sigma1=0.001, l_max=50, omega_k=np.array([[0, 0], [np.pi, 0]]))
- a_bar = patch_size.inverse_potential_patch_size(target_patch_size, fn1, 0.5, params)
- lbd = patch_size.inverse_potential_patch_size(target_patch_size, fn2, 5, params)
- theta0 = patch_size.inverse_potential_patch_size(target_patch_size, fn3, 0.5, params)
- ex_point = expansion.MappedExpansionQuad(a_bar=a_bar, kappaR=params.kappaR, sigma_m=sigma_m, l_max=30)
- gauss_sigma = point_to_gauss_map(sigma_m, a_bar, lbd, params)
- ex_gauss = expansion.GaussianCharges(lambda_k=lbd, omega_k=np.array([[0, 0], [np.pi, 0]]), sigma1=gauss_sigma, l_max=30)
- cap_sigma = point_to_cap_map(sigma_m, a_bar, theta0, params)
- ex_cap = expansion.SphericalCap(theta0_k=theta0, sigma1=cap_sigma, omega_k=np.array([[0, 0], [np.pi, 0]]), l_max=30)
- theta = np.linspace(0, np.pi, 1000)
- phi = 0.
- dist = 1
- potential1 = potentials.charged_shell_potential(theta, phi, dist, ex_point, params)
- potential2 = potentials.charged_shell_potential(theta, phi, dist, ex_gauss, params)
- potential3 = potentials.charged_shell_potential(theta, phi, dist, ex_cap, params)
- # print(potential.shape)
- # print(potential)
- # expansion.plot_theta_profile_multiple([ex_point, ex_gauss, ex_cap], ['IC', 'Gauss', 'cap'], num=1000)
- # fig, ax = plt.subplots()
- # ax.plot(theta, potential1.T, label='IC')
- # ax.plot(theta, potential2.T, label='Gauss')
- # ax.plot(theta, potential3.T, label='cap')
- # ax.tick_params(which='both', direction='in', top=True, right=True, labelsize=12)
- # ax.set_xlabel(r'$\theta$', fontsize=13)
- # ax.set_ylabel(r'$\phi$', fontsize=13)
- # plt.legend(fontsize=12)
- # plt.tight_layout()
- # plt.savefig(Path("/home/andraz/ChargedShells/Figures/potential_shape_comparison.png"), dpi=600)
- # plt.show()
- path_comparison = rotational_path.PathExpansionComparison([ex_point, ex_gauss, ex_cap],
- path_plot.QuadPath,
- dist=2,
- params=params)
- path_comparison.plot(['IC', 'Gauss', 'cap'],
- save_as=Path("/home/andraz/ChargedShells/Figures/energy_shape_comparison_kR1.png"))
|