second_order.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:kinpy 作者: dudektria 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号