Skip to content

Commit

Permalink
Fix some failing examples
Browse files Browse the repository at this point in the history
  • Loading branch information
vatai committed Aug 16, 2024
1 parent 7d8c319 commit 91fe934
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 32 deletions.
12 changes: 6 additions & 6 deletions examples/kinetics_fad.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ def main():
axs[1].plot(time * scale, delta_delta_A, color="orange", linewidth=2)
plt.xscale("linear")
axs[0].legend([r"$F (B_0 = 0)$", r"$F (B_0 \neq 0)$"])
axs[1].set_xlabel("Time ($\mu s$)", size=14)
axs[0].set_ylabel("$\Delta A$", size=14)
axs[1].set_ylabel("$\Delta \Delta A$", size=14)
axs[1].set_xlabel(r"Time ($\mu s$)", size=14)
axs[0].set_ylabel(r"$\Delta A$", size=14)
axs[1].set_ylabel(r"$\Delta \Delta A$", size=14)
axs[0].tick_params(labelsize=14)
axs[1].tick_params(labelsize=14)
fig.set_size_inches(10, 5)
Expand All @@ -153,9 +153,9 @@ def main():
axs[1].plot(time * scale, fluor_del_A, color="orange", linewidth=2)
plt.xscale("linear")
axs[0].legend([r"$F (B_0 = 0)$", r"$F (B_0 \neq 0)$"])
axs[1].set_xlabel("Time ($\mu s$)", size=14)
axs[0].set_ylabel("$F$", size=14)
axs[1].set_ylabel("$\Delta F$", size=14)
axs[1].set_xlabel(r"Time ($\mu s$)", size=14)
axs[0].set_ylabel(r"$F$", size=14)
axs[1].set_ylabel(r"$\Delta F$", size=14)
axs[0].tick_params(labelsize=14)
axs[1].tick_params(labelsize=14)
fig.set_size_inches(10, 5)
Expand Down
33 changes: 18 additions & 15 deletions examples/kinetics_fad_semiclassical.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
from radicalpy.plot import plot_3d_results, plot_bhalf_time
from radicalpy.relaxation import RandomFields
from radicalpy.simulation import Molecule, SemiclassicalSimulation
from radicalpy.utils import Bhalf_fit
from radicalpy.utils import Bhalf_fit, is_fast_run


def main():
def main(Bmax=30, dB=0.5, tmax=20e-6, dt=10e-9):

# Parameters
time = np.arange(0, 20e-6, 10e-9)
Bs = np.arange(0, 30, 0.5)
time = np.arange(0, tmax, dt)
Bs = np.arange(0, Bmax, dB)
num_samples = 400
scale_factor = 10
kr = 0 # 1.7e6 # radical pair relaxation rate
Expand Down Expand Up @@ -231,9 +231,9 @@ def main():
rstride=1,
cstride=1,
)
ax.set_xlabel("$B_0$ / mT", size=18)
ax.set_ylabel("Time / $\mu s$", size=18)
ax.set_zlabel("$\Delta \Delta A$", size=18)
ax.set_xlabel(r"$B_0$ / mT", size=18)
ax.set_ylabel(r"Time / $\mu s$", size=18)
ax.set_zlabel(r"$\Delta \Delta A$", size=18)
plt.tick_params(labelsize=14)
fig.set_size_inches(10, 5)
# plt.show()
Expand Down Expand Up @@ -271,8 +271,8 @@ def main():
color="k",
linewidth=2,
)
plt.xlabel("Time / $\mu s$", size=18)
plt.ylabel("$B_{1/2}$ / mT", size=18)
plt.xlabel(r"Time / $\mu s$", size=18)
plt.ylabel(r"$B_{1/2}$ / mT", size=18)
plt.tick_params(labelsize=14)
plt.gcf().set_size_inches(10, 5)
path = __file__[:-3] + f"_{1}.png"
Expand All @@ -293,9 +293,9 @@ def main():
rstride=1,
cstride=1,
)
ax.set_xlabel("$B_0$ / mT", size=18)
ax.set_ylabel("Time / $\mu s$", size=18)
ax.set_zlabel("$\Delta \Delta A$", size=18)
ax.set_xlabel(r"$B_0$ / mT", size=18)
ax.set_ylabel(r"Time / $\mu s$", size=18)
ax.set_zlabel(r"$\Delta \Delta A$", size=18)
plt.tick_params(labelsize=14)
fig.set_size_inches(10, 5)
# plt.show()
Expand Down Expand Up @@ -327,13 +327,16 @@ def main():
color="k",
linewidth=2,
)
plt.xlabel("Time / $\mu s$", size=18)
plt.ylabel("$B_{1/2}$ / mT", size=18)
plt.xlabel(r"Time / $\mu s$", size=18)
plt.ylabel(r"$B_{1/2}$ / mT", size=18)
plt.tick_params(labelsize=14)
plt.gcf().set_size_inches(10, 5)
path = __file__[:-3] + f"_{3}.png"
plt.savefig(path, dpi=300)


if __name__ == "__main__":
main()
if is_fast_run():
main(Bmax=10, dB=2, tmax=10e-6, dt=1e-6)
else:
main()
19 changes: 11 additions & 8 deletions examples/kinetics_fad_semiclassical_wavelength.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
from radicalpy.plot import plot_3d_results, plot_bhalf_time, plot_general
from radicalpy.relaxation import RandomFields, SingletTripletDephasing
from radicalpy.simulation import Basis, Molecule, SemiclassicalSimulation
from radicalpy.utils import Bhalf_fit
from radicalpy.utils import Bhalf_fit, is_fast_run


def main():
def main(Bmax=30, dB=0.5, tmax=10e-6, dt=10e-9):

# Parameters
time = np.arange(0, 10e-6, 10e-9)
Bs = np.arange(0, 30, 0.5)
time = np.arange(0, tmax, dt)
Bs = np.arange(0, Bmax, dB)
num_samples = 200
scale_factor = 1 # 4e-1
kr = 7e7 # 1.7e6 # radical pair relaxation rate
Expand Down Expand Up @@ -700,7 +700,7 @@ def main():
plot_3d_results(
groundstate_wavelength,
results["Bs"],
mary_groundstate[250, :, :],
mary_groundstate[len(mary_groundstate) // 4, :, :],
xlabel,
ylabel,
zlabel,
Expand Down Expand Up @@ -731,7 +731,7 @@ def main():
plot_3d_results(
emission_wavelength,
results["Bs"],
mary_emission[250, :, :],
mary_emission[len(mary_emission) // 4, :, :],
xlabel,
ylabel,
zlabel,
Expand Down Expand Up @@ -762,7 +762,7 @@ def main():
plot_3d_results(
wavelength,
results["Bs"],
mary[250, :, :],
mary[len(mary) // 4, :, :],
xlabel,
ylabel,
zlabel,
Expand All @@ -774,4 +774,7 @@ def main():


if __name__ == "__main__":
main()
if is_fast_run():
main(Bmax=10, dB=2, tmax=10e-6, dt=1e-6)
else:
main()
6 changes: 3 additions & 3 deletions examples/kinetics_flavin_quencher.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ def main():
plt.xscale("linear")
axs[0].legend([r"$F (B_0 = 0)$", r"$F (B_0 \neq 0)$"])
axs[1].set_xlabel("Time ($ns$)", size=14)
axs[0].set_ylabel("$\Delta A$", size=14)
axs[1].set_ylabel("$\Delta \Delta A$", size=14)
axs[0].set_ylabel(r"$\Delta A$", size=14)
axs[1].set_ylabel(r"$\Delta \Delta A$", size=14)
axs[0].tick_params(labelsize=14)
axs[1].tick_params(labelsize=14)
fig.set_size_inches(10, 5)
Expand All @@ -182,7 +182,7 @@ def main():
axs[0].legend([r"$F (B_0 = 0)$", r"$F (B_0 \neq 0)$"])
axs[1].set_xlabel("Time ($ms$)", size=14)
axs[0].set_ylabel("$F$", size=14)
axs[1].set_ylabel("$\Delta F$", size=14)
axs[1].set_ylabel(r"$\Delta F$", size=14)
axs[0].tick_params(labelsize=14)
axs[1].tick_params(labelsize=14)
fig.set_size_inches(10, 5)
Expand Down

0 comments on commit 91fe934

Please sign in to comment.