如何找到 scipy.integrate.ode 的默认 atol 和 rtol?
How to find the default atol and rtol for scipy.integrate.ode?
如何在 scipy.integrate.ode
中找到默认参数?具体来说,积分器 dopri5
中的 atol
和 rtol
?可以使用 set_integrator
方法设置参数,但如果我不设置它们,我看不到任何查询它的方法以了解它一直在使用什么。
据我所知,找出答案的唯一方法是调查 the source。在那里,从第 966 行开始(截至目前),您会发现:
class dopri5(IntegratorBase):
[…]
def __init__(self,
rtol=1e-6, atol=1e-12,
nsteps=500,
max_step=0.0,
[…]
):
因此,dopri
的默认绝对容差为 10⁻¹²,其默认相对容差为 10⁻⁶。 (是的,这应该记录在案。)
查看 ode() 的源代码,您实例化的 ode 的集成器似乎可以通过执行以下操作来检查,例如:
r = ode(f)
print('atol:', r._integrator.atol)
print('rtol:', r._integrator.rtol)
如何在 scipy.integrate.ode
中找到默认参数?具体来说,积分器 dopri5
中的 atol
和 rtol
?可以使用 set_integrator
方法设置参数,但如果我不设置它们,我看不到任何查询它的方法以了解它一直在使用什么。
据我所知,找出答案的唯一方法是调查 the source。在那里,从第 966 行开始(截至目前),您会发现:
class dopri5(IntegratorBase):
[…]
def __init__(self,
rtol=1e-6, atol=1e-12,
nsteps=500,
max_step=0.0,
[…]
):
因此,dopri
的默认绝对容差为 10⁻¹²,其默认相对容差为 10⁻⁶。 (是的,这应该记录在案。)
查看 ode() 的源代码,您实例化的 ode 的集成器似乎可以通过执行以下操作来检查,例如:
r = ode(f)
print('atol:', r._integrator.atol)
print('rtol:', r._integrator.rtol)