6

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

solver1.integrate(t_end)

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

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

然后我绘制y,整合的结果,我的问题来了。我有出现在定位区域的不稳定性:

y 启用求解器的 step 选项

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

while solver1.successful() and solver1.t < t0+dt:
    solver1.integrate(t_end)

和惊喜......我有正确的结果:

y 禁用求解器的 step 选项

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

编辑 :

要设置求解器,我这样做:

solver1 = ode(y_dot,jac).set_integrator('vode',with_jacobian=True)
solver1.set_initial_value(x0,t0)

我使用存储结果.append()

4

1 回答 1

2

当你设置时,step=True你间接地给vode._integrator.runner(一个 Fortran 子例程)一个使用指令itask=2,默认是itask=1. 您可以获得有关此操作的更多详细信息runner

r._integrator.runner?

在 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).
于 2013-05-17T16:01:04.647 回答