|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
想利用odeint()函数解微分方程,做出四个图但是一直出现问题,快奔溃了,新手一枚,希望大神能指点一下,有点急。最后做出来的应该做出四个关于时间的函数图(一年内)
- from scipy.integrate import odeint
- import numpy as np
- def CTANI(Y,t):
- a = 0.269
- b = 4.228
- c = 4.226
- d = 0.060
- e = 0.250
- f = 1.860
- return a*(b-c*exp(-t))+d*W-e*Y-f*Y/(Y+Q)
- def CNOXI(Q,t):
- g = 0.200
- h = 0.050
- f = 1.860
- return g*Y-h*Q-f*Y/(Y+Q)
- def CCHLI(Z,t):
- f = 1.860
- return f*Y/(Y+Q)
- def MNSEDI(W,t):
- i = 10.400
- d = 0.060
- return i*Z-d*W
- time = linspace(0,365,1000)
- Yinit = array([0.0,2.0])
- Qinit = array([0.0,2.0])
- Zinit = array([0.0,2.0])
- Winit = array([0.0,2.0])
- Y = odeint(CTANI,Yinit,time)
- Q = odeint(CNOXI,Qinit,time)
- Z = odeint(CCHLI,Zinit,time)
- W = odeint(MNSEDI,Winit,time)
- figure()
- plot(time,Y[:,0],label='Y')
- plot(time,Q[:,0],label='Q')
- plot(time,Z[:,0],label='Z')
- plot(time,W[:,0],label='W')
- Ylabel('Y')
- Qlabel('Q')
- Zlabel('Z')
- Wlabel('W')
- legend()
- show()
复制代码 |
|