def reaction(y0, t, k0, k0r):
"""
Wrapper for the reaction.
It receives an `np.array` `y0` with the initial concentrations and an
`np.array` `t` with timestamps (it should also include `0`).
This function solves the corresponding ODE system and returns an `np.array`
`Y` in which each column represents a chemical species and each line a
timestamp.
"""
def dydt(y, t):
return np.array([
-1*v_0(y[1], y[0], y[2]),
+2*v_0(y[1], y[0], y[2]),
+2*v_0(y[1], y[0], y[2]),
])
# S <-> 2*A + 2*C
def v_0(A, S, C):
return k0 * S**1 - k0r * A**2 * C**2
return odeint(dydt, y0, t)
# Reaction rates:
# S <-> 2*A + 2*C
评论列表
文章目录