Skip to content

Commit

Permalink
Fix old rate equations
Browse files Browse the repository at this point in the history
  • Loading branch information
vatai committed Aug 16, 2024
1 parent c2c7333 commit 7b8ff58
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
20 changes: 10 additions & 10 deletions examples/kinetics_cryptochrome.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import matplotlib.pyplot as plt
import numpy as np

from radicalpy.classical import RateEquations
from radicalpy.classical import Rate, RateEquations


def main():
Expand Down Expand Up @@ -106,10 +106,10 @@ def main():
"S": 1,
}
time = np.linspace(0, 100e-6, 500)

result_off = RateEquations({**base, **off}, time, initial_states)
result_on = RateEquations({**base, **on}, time, initial_states)

re_off = RateEquations({**base, **off})
re_on = RateEquations({**base, **on})
result_off = re_off.time_evolution(time, initial_states)
result_on = re_on.time_evolution(time, initial_states)
fluor_field_off = result_off["A-D"]
fluor_field_on = result_on["A-D"]
fluor_delta_A = fluor_field_on - fluor_field_off
Expand All @@ -128,9 +128,9 @@ def main():
axs[1].plot(time * scale, rp_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 @@ -148,9 +148,9 @@ def main():
axs[1].plot(time * scale, fluor_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[1].set_xlabel(r"Time ($\mu s$)", 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
6 changes: 4 additions & 2 deletions examples/kinetics_fad.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,10 @@ def main():
}
time = np.linspace(0, 6e-6, 200)

result_off = RateEquations({**base, **off}, time, initial_states)
result_on = RateEquations({**base, **on}, time, initial_states)
re_off = RateEquations({**base, **off})
re_on = RateEquations({**base, **on})
result_off = re_off.time_evolution(time, initial_states)
result_on = re_on.time_evolution(time, initial_states)
fac = 0.07

keys = ["S", "T+/-", "T0", "Quencher"] + 2 * ["T*+/-", "T*0"]
Expand Down
12 changes: 7 additions & 5 deletions examples/kinetics_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ def main():
initial_states = {Tp: 1 / 3, T0: 1 / 3, Tm: 1 / 3}
time = np.linspace(0, 1e-6, 10000)

result_off = RateEquations(off, time, initial_states)
result_on = RateEquations(on, time, initial_states)
re_off = RateEquations(off)
re_on = RateEquations(on)
result_off = re_off.time_evolution(time, initial_states)
result_on = re_on.time_evolution(time, initial_states)

keys = [S, Tp, T0, Tm]
rp_field_off = result_off[keys]
Expand All @@ -65,9 +67,9 @@ def main():
axs[1].plot(time * scale, rp_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 Down
2 changes: 1 addition & 1 deletion radicalpy/classical.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def check_initial_states(self, initial_states: dict):

def _construct_matrix(self):
tmp = [
(v.value, self.indices[i], self.indices[j])
(v.value if isinstance(v, Rate) else v, self.indices[i], self.indices[j])
for i, d in self.rate_equations.items()
for j, v in d.items()
]
Expand Down

0 comments on commit 7b8ff58

Please sign in to comment.