Python - Scipy:ode模块:启用求解器的步骤选项的问题

kui*_*der 6 python scipy numerical-methods ode

当我调用它时,我想存储求解器本身采用的不同集成步骤:

solver1.integrate(t_end)
Run Code Online (Sandbox Code Playgroud)

所以我做了一个while循环并启用了step选项,将其值设置为True:

while solver1.successful() and solver1.t < t0+dt:
    solver1.integrate(t_end,step=True)
    time.append(solver1.t)
Run Code Online (Sandbox Code Playgroud)

然后我绘制y,积分的结果,这是我的问题.我有不稳定性出现在一个位置区域:

y启用求解器的步骤选项

我认为这是因为循环或类似的东西,所以我检查结果删除step:

while solver1.successful() and solver1.t < t0+dt:
    solver1.integrate(t_end)
Run Code Online (Sandbox Code Playgroud)

并且惊讶......我有正确的结果:

y禁用解算器的步骤选项

这是一个非常奇怪的情况......如果你们中的某个人可以帮我解决这个问题,我将不胜感激.

编辑:

要设置求解器我做:

solver1 = ode(y_dot,jac).set_integrator('vode',with_jacobian=True)
solver1.set_initial_value(x0,t0)
Run Code Online (Sandbox Code Playgroud)

我使用存储结果 .append()

Sau*_*tro 2

当您设置时,step=True您间接地向vode._integrator.runner(Fortran 子例程)发出使用 的指令itask=2,默认值为itask=1。您可以获得有关此runner操作的更多详细信息:

r._integrator.runner?
Run Code Online (Sandbox Code Playgroud)

在 SciPy 0.12.0 文档中,您找不到有关不同itask=1or发生情况的解释itask=2但您可以在这里找到它

ITASK  = An index specifying the task to be performed.
!          Input only. ITASK has the following values and meanings.
!          1  means normal computation of output values of y(t) at
!             t = TOUT(by overshooting and interpolating).
!          2  means take one step only and return.
!          3  means stop at the first internal mesh point at or
!             beyond t = TOUT and return.
!          4  means normal computation of output values of y(t) at
!             t = TOUT but without overshooting t = TCRIT.
!             TCRIT must be input as RUSER(1). TCRIT may be equal to
!             or beyond TOUT, but not behind it in the direction of
!             integration. This option is useful if the problem
!             has a singularity at or beyond t = TCRIT.
!          5  means take one step, without passing TCRIT, and return.
!             TCRIT must be input as RUSER(1).
Run Code Online (Sandbox Code Playgroud)