本文整理汇总了Python中chemreac.ReactionDiffusion.k方法的典型用法代码示例。如果您正苦于以下问题:Python ReactionDiffusion.k方法的具体用法?Python ReactionDiffusion.k怎么用?Python ReactionDiffusion.k使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类chemreac.ReactionDiffusion
的用法示例。
在下文中一共展示了ReactionDiffusion.k方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from chemreac import ReactionDiffusion [as 别名]
# 或者: from chemreac.ReactionDiffusion import k [as 别名]
def main(tdelay=1.0, B0=0.6, noiselvl=3e-4, nt=200, eps_l=4200.0, plot=False):
"""
Solution:
1. non-linear fit to:
A) if approx equal conc A+A -> C
B) else: A+B -> C
2. Use as guess for guess and shoot. A + B <-> C
"""
Keq = 10.0
k_fw_true = 1.3
ktrue = [1.3, k_fw_true/Keq]
c0 = [1.0, B0, 0.0]
ttrue = np.linspace(0, 10, nt)
rd_eq = ReactionDiffusion(3, [[0, 1], [2]], [[2], [0, 1]], k=ktrue)
tinp, yinp = simulate_stopped_flow(
rd_eq, ttrue, c0, ktrue, noiselvl, eps_l, tdelay)
k_fw_opt, d_opt, eps_l_opt = fit_binary_eq_from_temporal_abs_data(
tinp, yinp, c0, Keq, True)
rd_eq.k = [k_fw_opt, k_fw_opt/Keq]
integr = run(rd_eq, c0, ttrue)
yopt = integr.Cout[:, 0, 2]*eps_l_opt
if plot:
import matplotlib.pyplot as plt
# Plot
plt.subplot(2, 1, 1)
plt.plot(tinp, yinp, label='Input data')
plt.plot(ttrue-tdelay, yopt,
label='Shooting Opt (k={})'.format(k_fw_opt))
plt.legend(loc='best')
plt.subplot(2, 1, 2)
plt.plot(tinp, yinp, label='Input data')
# TODO: this needs to be improved...
yquad = (B0-1/(1/B0+k_fw_opt*ttrue))*eps_l_opt
plt.plot(ttrue-tdelay, yquad, label='Equal initial conc treatment')
plt.legend(loc='best')
plt.show()