cpp/main.py

79 lines
2.6 KiB
Python
Raw Normal View History

2024-11-28 13:50:26 +00:00
import matplotlib.pyplot as plt
2024-11-28 10:07:44 +00:00
from python.ste import *
from python.helpers import *
# Simulation parameter
motion = 'IsotropicAngle'
distribution = 'Delta'
2024-11-28 13:50:26 +00:00
# parameter = {}
2024-11-28 10:07:44 +00:00
parameter = {
2024-11-28 18:40:07 +00:00
"angle": np.linspace(3, 150, num=148),
# "sigma": 0.1,
# "tau": np.logspace(-1, 1, num=3)
2024-11-28 10:07:44 +00:00
}
parameter = prepare_rw_parameter(parameter)
2024-11-28 18:40:07 +00:00
# fig_tau_cc, ax_tau_cc = plt.subplots()
# ax_tau_cc.set_title('tau_cc')
#
# fig_beta_cc, ax_beta_cc = plt.subplots()
# ax_beta_cc.set_title('beta_cc')
#
# fig_finfty_cc, ax_finfty_cc = plt.subplots()
# ax_finfty_cc.set_title('f_infty_cc')
#
# fig_tau_ss, ax_tau_ss = plt.subplots()
# ax_tau_ss.set_title('tau_ss')
#
# fig_beta_ss, ax_beta_ss = plt.subplots()
# ax_beta_ss.set_title('beta_ss')
#
# fig_finfty_ss, ax_finfty_ss = plt.subplots()
# ax_finfty_ss.set_title('f_infty_ss')
2024-11-28 10:07:44 +00:00
2024-11-28 18:40:07 +00:00
tau_ss_angles = []
tau_cc_angles = []
tau_2_angles = []
angles = []
2024-11-28 10:07:44 +00:00
for variation in parameter:
print(f"\nRun RW for {motion}/{distribution} with arguments {variation}\n")
2024-11-28 13:50:26 +00:00
run_sims(motion, distribution, ste=True, spectrum=False, **variation)
2024-11-28 10:07:44 +00:00
2024-11-28 13:50:26 +00:00
conf_file = find_config_file(motion, distribution, variation)
2024-11-28 10:07:44 +00:00
2024-11-28 13:50:26 +00:00
vary_string, tau_cc, beta_cc, finfty_cc = fit_and_save_ste(conf_file, 'coscos', plot_decays=False, verbose=False)
_, tau_ss, beta_ss, finfty_ss = fit_and_save_ste(conf_file, 'sinsin', plot_decays=False, verbose=False)
2024-11-28 18:40:07 +00:00
_, tau_2, beta_2, finfty_2 = fit_and_save_ste(conf_file, 'f2', plot_decays=False, verbose=True)
# ax_tau_cc.semilogy(tau_cc[:, 0], tau_cc[:, 1], label=vary_string)
# ax_tau_cc.axhline(tau_2[:, 1], color='k', linestyle='--')
# ax_beta_cc.plot(*beta_cc.T, label=vary_string)
# ax_finfty_cc.plot(*finfty_cc.T, label=vary_string)
# ax_tau_ss.semilogy(tau_ss[:, 0], tau_ss[:, 1], label=vary_string)
# ax_tau_ss.axhline(tau_2[:, 1], color='k', linestyle='--')
# ax_beta_ss.plot(*beta_ss.T, label=vary_string)
# ax_finfty_ss.plot(*finfty_ss.T, label=vary_string)
angles.append(variation['angle'])
tau_ss_angles.append(tau_ss[0, 1])
tau_cc_angles.append(tau_cc[0, 1])
tau_2_angles.append(tau_2[0, 1])
fig, ax = plt.subplots()
ax.semilogy(angles, tau_ss_angles, 'o', label='SS (4.9mus)')
ax.plot(angles, tau_cc_angles, 'o', label='CC (4.9mus)')
ax.plot(angles, tau_2_angles, 'o', label='F2')
ax.legend()
np.savetxt('angle.dat', np.c_[angles, tau_cc_angles, tau_ss_angles, tau_2_angles], header='#x\tcc\tss\tf2')
fig2, ax2 = plt.subplots()
ax2.plot(angles, np.array(tau_cc_angles)/np.array(tau_2_angles), 'o')
# for ax in [ax_tau_cc, ax_beta_cc, ax_finfty_cc, ax_tau_ss, ax_beta_ss, ax_finfty_ss]:
# ax.legend()
2024-11-28 10:07:44 +00:00
plt.show()