Scipy:过度的odeint工作 [英] Scipy: excessive odeint work

查看:58
本文介绍了Scipy:过度的odeint工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个一阶 ODE 系统:f(x) = x_i ** 2 - x_i 对于所有 i(我现在正在研究 3 个维度).

I have a first order ODE system: f(x) = x_i ** 2 - x_i for all i (I'm working on 3 dimensions for now).

我是这样定义的:

lower, upper = -10, 10

def xdot(__xs, t):
    return [__xs[i] ** 2 - __xs[i] for i in range(len(__xs))]

x0 = [1.2, 1.2, 1.2]
t = np.linspace(lower, upper, upper - lower)
res = integrate.odeint(xdot, x0, t)

这是使用 odeint 的正确方法吗?我得到:ODEintWarning:在此调用上完成了过多的工作

Is this the correct way of using odeint? I get: ODEintWarning: Excess work done on this call

推荐答案

您对 ODE 求解器的使用是正确的.

Your use of the ODE solver is correct.

x' = x^2-x=x*(x-1)的解是

(1/x)'=-x'/x^2 = -1+1/x
1/x = C*e^t + 1  ==> C = (1/x0 - 1)*e^(-t0)
x(t) = x0 / ( (1-x0)*e^(t-t0) + x0)

并且在 x0 >1 分母的根在 t = t0 + ln(x0) - ln(x0-1).

and in the case that x0 > 1 the denominator has a root at t = t0 + ln(x0) - ln(x0-1).

对于x0 = 1.2,这发生在t=t0+1.7917594,而您的积分区间长度为20.接近这一点时,函数值和导数会变得非常大,从而驱动内部步长减小以进行补偿.小步长的大量积分步骤会导致错误消息完成过多工作".如果您通过增加 mxstep 参数来删除它,则会出现步长太小而无法通过浮点加法来提前时间的错误.

For x0 = 1.2 this happens at t=t0+1.7917594, while your integration interval has length 20. Close to this point function value and derivative grow very large, thus driving the internal step size down to compensate. The high number of integration steps with small step size leads to the error message "Excess work done". If you remove that by increasing the mxstep parameter you will then get the error that the step size is too small to advance the time by floating point addition.

这篇关于Scipy:过度的odeint工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆