0
我有以下的Python MWE(代碼如下解釋)integrate.odeint給出了兩個非常不同的答案時,它不應該
#!/usr/bin/python
from scipy import integrate
from math import *
import numpy
import matplotlib.pyplot as plt
def base_equations(y,t,center):
return [5*exp(-(t-center)**2/3),-5*exp(-(t-center)**2/3)]
def eqexec1(y,t):
return base_equations(y,t,30)
def eqexec2(y,t):
return base_equations(y,t,60)
inits=[0.5, 0.5]
trange=numpy.arange(0,100,0.1)
print trange
y1=integrate.odeint(eqexec1,inits, trange, full_output=0, printmessg=1)
y2=integrate.odeint(eqexec2,inits, trange, full_output=0, printmessg=1)
plt.plot(trange,y1,trange,y2)
plt.legend(["y1a","y1b","y2a","y2b"])
plt.xlabel("Time")
plt.show()
正如你所看到的,我集成一組方程(base_equations
)實質上是高斯脈衝。我使用odeint
來數值求解脈衝(30和60)的兩個中心點的這些方程。對於第一個中心點(t = 30),方程y1產生預期的行爲:脈衝是可見的。對於第二個中心點(t = 60),等式y2產生意外的行爲:根本沒有脈衝可見!
工作之間的轉換和不工作時47和48
之間的圖形輸出如下所示。預期的結果是y2a和y2b線將在60左右顯示出巨大的變化,但它們不會。
任何想法,以什麼可能是怎麼回事?
拍攝!當你這麼說的時候似乎很明顯...... – Richard