gpt4 book ai didi

Python-Scipy : ode module : issue enabling the step option of the solver

转载 作者:太空狗 更新时间:2023-10-30 00:15:03 25 4
gpt4 key购买 nike

我想在调用求解器时存储求解器本身采取的不同积分步骤:

solver1.integrate(t_end)

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

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

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

y enabling the step option of the solver

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

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

令人惊讶的是......我得到了正确的结果:

y disabling the step option of the solver

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

编辑:

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

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

然后我使用 .append() 存储结果

最佳答案

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

r._integrator.runner?

在 SciPy 0.12.0 文档中,您不会找到关于不同 itask=1 的解释。或 itask=2 , but you can find it here :

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).

关于Python-Scipy : ode module : issue enabling the step option of the solver,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15524392/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com