我需要从对 odeint 的调用传递内部计算。我通常在完成积分后再次重新计算这些值,但我更愿意在 odeint 的调用函数中进行所有计算。我的问题在计算上并不繁重,因此在 ode 求解器内部进行计算时会增加一些额外的性能损失是可以接受的。from scipy.integrate import odeintimport numpy as npdef eom(y, t): internal_calc = y/(t+1) xdot = y return xdot, internal_calcif __name__ == '__main__': t = np.linspace(0, 5, 100) y0 = 1.0 # the initial condition output, internal_calc = odeint(eom, y0, t)这段代码没有运行,但希望能显示我所追求的。我想在每次通过积分器时从 eom 函数中获取“internal_calc”值。我四处寻找选项,但我认识的最好的 Python 程序员之一告诉我编写自己的集成器,这样我就可以做我想做的事。在我这样做之前,我想我会问其他人是否有从 odeint 求解器中获取值的方法。
添加回答
举报
0/150
提交
取消