【发布时间】:2012-09-28 01:10:41
【问题描述】:
我有以下python MWE(代码解释如下)
#!/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 左右显示出巨大的变化,但事实并非如此。
对可能发生的事情有什么想法吗?
【问题讨论】: