我认为问题可能出在“功能”中,但我找不到。我得到的图表只是 0 处的一条红线。我正在尝试获取 Belousov-Zhabotinsky 反应的 z 和 y 浓度随时间变化的图。
# -*- coding: utf-8 -*-
from __future__ import division
from numpy import linspace
from matplotlib import pyplot as plot
from scipy.integrate import odeint
k0 = 1.0*60.0
kR2 = (10.0**6.0)*60.0
kR3 = 2.0*60.0
kR4 = 2000.0*60.0
kR5 = 10.0*60.0
CH = 0.8 #[0]
CA = 0.04 #[1]
CB = 0.05 #[2]
CX = 0.0 #[3]
CY = 0.0 #[4]
CZ = 3.0*(10.0**4.0) #[5]
CP = 0.0
def func(c,t):
([(-(kR3*(CH**2)*c[0]*c[3])-(kR5*CH*c[0]*c[2])+(0.5*kR4*(c[2]**2))),
(-k0*c[2]*c[4]),
((kR3*(CH**2)-(kR2*CH*c[2]*c[3])+(kR5*CH*c[0]*c[2])-(kR4*(c[2]**2)))),
(-(kR3*(CH**2)-(kR2*CH*c[2]*c[3])+((1/3)*k0*c[1]*c[4]))),
((2*kR5*CH*c[0]*c[2])-(k0*c[1]*c[4])),
((kR3*(CH**2)+(2*kR2*CH*c[2]*c[3])+(0.5*kR4*(c[2]**2))))])
ti = linspace(0,20,1000)
Ci = odeint(func,[CA,CB,CX,CY,CZ,CP],ti)
plot.plot(ti,Ci[:,3],'r',ti,Ci[:,4],'b')