cpp/main.py
2024-11-30 16:15:38 +01:00

69 lines
2.2 KiB
Python

import matplotlib.pyplot as plt
from python.ste import *
from python.helpers import *
# Simulation parameter
motion = 'IsotropicAngle'
distribution = 'Delta'
# parameter = {}
parameter = {
"angle": [10],
}
parameter = prepare_rw_parameter(parameter)
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')
for variation in parameter:
print(f"\nRun RW for {motion}/{distribution} with arguments {variation}\n")
# run_sims(motion, distribution, ste=True, spectrum=False, **variation)
conf_file = find_config_file(motion, distribution, variation)
vary_string, tau_cc, beta_cc, finfty_cc = fit_ste(conf_file, f'coscos', plot_decays=False, verbose=False)
_, tau_ss, beta_ss, finfty_ss = fit_ste(conf_file, f'sinsin', plot_decays=False, verbose=False)
_, tau_2, beta_2, finfty_2 = fit_ste(conf_file, f'f2', plot_decays=True, 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)
np.savetxt(
f'ste_fit_{vary_string}.dat',
np.c_[
tau_cc, beta_cc[:, 1], finfty_cc[:, 1],
tau_ss[:, 1], beta_ss[:, 1], finfty_ss[:, 1],
],
header=f'Fit STE {vary_string}\n'
f'F2: tau={tau_2[0, 1]} beta={beta_2[0, 1]} finfty={finfty_2[0, 1]}\n'
f'tevo\ttaucc\tbetacc\tfinftycc\ttauss\tbetass\tfinftyss',
)
for ax in [ax_tau_cc, ax_beta_cc, ax_finfty_cc, ax_tau_ss, ax_beta_ss, ax_finfty_ss]:
ax.legend()
plt.show()