为了使用SciPy解决简单的ODE,我曾经使用odeint函数,其形式为:
scipy.integrate.odeint(func, y0, t, args=(), Dfun=None, col_deriv=0, full_output=0, ml=None, mu=None, rtol=None, atol=None, tcrit=None, h0=0.0, hmax=0.0, hmin=0.0, ixpr=0, mxstep=0, mxhnil=0, mxordn=12, mxords=5, printmessg=0)[source]
要集成的简单函数可以包含表单的其他参数:
def dy_dt(t, y, arg1, arg2):
# processing code here
在SciPy 1.0中,似乎ode和odeint函数已被更新的solve_ivp方法所取代 .
scipy.integrate.solve_ivp(fun, t_span, y0, method='RK45', t_eval=None, dense_output=False, events=None, vectorized=False, **options)
但是,这似乎没有提供args参数,也没有提供文档中关于实现args传递的任何指示 .
因此,我想知道是否可以使用新API进行arg传递,或者这是一个尚未添加的功能? (如果故意删除这些功能,对我来说似乎是一种疏忽?)
参考:https://docs.scipy.org/doc/scipy/reference/integrate.html
2 回答
看起来新函数似乎没有
args
参数 . 作为一种解决方法,您可以创建一个包装器并通过它 .
最近在scipy's github上出现了类似的问题 . 他们的解决方案是使用
lambda
:而且他们认为已经有足够的开销来解决这个问题 .