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([
-2*v_0(y[0], y[1]),
+1*v_0(y[0], y[1]),
])
# 2*A <-> C
def v_0(A, C):
return k0 * A**2 - k0r * C**1
return odeint(dydt, y0, t)
# Reaction rates:
# 2*A <-> C
评论列表
文章目录