【发布时间】:2018-07-22 18:14:28
【问题描述】:
我正在使用 scipy.integrate 中的 odeint 包求解一组耦合微分方程。
对于我的整合时间:
t=numpy.linspace(0,8e+9,5e+06)
其中 5e+06 是时间步长。
然后我绘制出这样的方程式:
plt.xscale('symlog') #x axis logarithmic scale
plt.yscale('log',basey=2) #Y axis logarithmic scale
plt.gca().set_ylim(8, 100000) #Changing y axis ticks
ax = plt.gca()
ax.yaxis.set_major_formatter(matplotlib.ticker.ScalarFormatter())
ax.xaxis.set_major_formatter(matplotlib.ticker.ScalarFormatter())
plt.title("Example graph")
plt.xlabel("time (yr)")
plt.ylabel("quantity a")
plt.plot(t,a,"r-", label = 'Example graph')
plt.legend(loc='best')
其中 a 是时间相关变量。 (这只是众多图表中的一张。)
但是,图表看起来有点锯齿状,而不是振荡,我收到此错误:
OverflowError: Exceeded cell block limit (set 'agg.path.chunksize' rcparam)
我不太确定这个错误意味着什么,我查看了其他答案,但不知道如何实现“agg.path.chunksize”。
此外,集成 + 绘图大约需要 7 个小时,而且还有一些 CPU 处理技巧,所以我真的不想实现任何会增加时间的东西。
我该如何克服这个错误?
我试图减少时间步长,但是我得到了这个错误:
Excess work done on this call (perhaps wrong Dfun type).
Run with full_output = 1 to get quantitative information.
【问题讨论】:
-
那个溢出错误看起来像是来自matplotlib的agg后端,所以它可能与odeint无关。你能通过绘制与 odeint 的输出大小相同的随机数据来重现错误吗?
-
好的,所以我使用了大约 12 个微分方程,其中 6 个是非常振荡的。如果我注释掉高度振荡的方程并保持时间步长和积分时间相同,我不会得到错误。
标签: python numpy matplotlib physics differential-equations