bundles / scipy 1.17.1 / scipy / integrate / _ode / ode
class
scipy.integrate._ode:ode
source: /scipy/integrate/_ode.py :100
Signature
class ode ( f , jac = None ) Members
-
__init__ -
get_return_code -
integrate -
set_f_params -
set_initial_value -
set_integrator -
set_jac_params -
set_solout -
successful
Summary
A generic interface class to numeric integrators.
Extended Summary
Solve an equation system with (optional) jac = df/dy.
Note: The first two arguments of f(t, y, ...) are in the opposite order of the arguments in the system definition function used by scipy.integrate.odeint.
Parameters
f: callable ``f(t, y, *f_args)``Right-hand side of the differential equation. t is a scalar,
y.shape == (n,).f_argsis set by callingset_f_params(*args).fshould return a scalar, array or list (not a tuple).jac: callable ``jac(t, y, *jac_args)``, optionalJacobian of the right-hand side,
jac[i,j] = d f[i] / d y[j].jac_argsis set by callingset_jac_params(*args).
Attributes
t: floatCurrent time.
y: ndarrayCurrent variable values.
Notes
Available integrators are listed below. They can be selected using the set_integrator method.
"vode"
Real-valued Variable-coefficient Ordinary Differential Equation solver, with fixed-leading-coefficient implementation. It provides implicit Adams method (for non-stiff problems) and a method based on backward differentiation formulas (BDF) (for stiff problems).
Source: http://www.netlib.org/ode/vode.f
This integrator accepts the following parameters in
set_integratormethod of the ode class:
atolfloat or sequence absolute tolerance for solution
rtolfloat or sequence relative tolerance for solution
lbandNone or int
ubandNone or int Jacobian band width, jac[i,j] != 0 for i-lband <= j <= i+uband. Setting these requires your jac routine to return the jacobian in packed format, jac_packed[i-j+uband, j] = jac[i,j]. The dimension of the matrix must be (lband+uband+1, len(y)).
method: 'adams' or 'bdf' Which solver to use, Adams (non-stiff) or BDF (stiff)
with_jacobianbool This option is only considered when the user has not supplied a Jacobian function and has not indicated (by setting either band) that the Jacobian is banded. In this case,
with_jacobianspecifies whether the iteration method of the ODE solver's correction step is chord iteration with an internally generated full Jacobian or functional iteration with no Jacobian.nstepsint Maximum number of (internally defined) steps allowed during one call to the solver.
first_stepfloat
min_stepfloat
max_stepfloat Limits for the step sizes used by the integrator.
orderint Maximum order used by the integrator, order <= 12 for Adams, <= 5 for BDF.
"zvode"
Complex-valued Variable-coefficient Ordinary Differential Equation solver, with fixed-leading-coefficient implementation. It provides implicit Adams method (for non-stiff problems) and a method based on backward differentiation formulas (BDF) (for stiff problems).
Source: http://www.netlib.org/ode/zvode.f
This integrator accepts the same parameters in
set_integratoras the "vode" solver.
"lsoda"
Real-valued Variable-coefficient Ordinary Differential Equation solver, with fixed-leading-coefficient implementation. It provides automatic method switching between implicit Adams method (for non-stiff problems) and a method based on backward differentiation formulas (BDF) (for stiff problems).
This integrator uses the C translation of the original Fortran 77 ODEPACK library, which can be found at http://www.netlib.org/odepack
This integrator accepts the following parameters in
set_integratormethod of the ode class:
atolfloat or sequence absolute tolerance for solution
rtolfloat or sequence relative tolerance for solution
lbandNone or int
ubandNone or int Jacobian band width, jac[i,j] != 0 for i-lband <= j <= i+uband. Setting these requires your jac routine to return the jacobian in packed format, jac_packed[i-j+uband, j] = jac[i,j].
with_jacobianbool Not used.
nstepsint Maximum number of (internally defined) steps allowed during one call to the solver.
first_stepfloat
min_stepfloat
max_stepfloat Limits for the step sizes used by the integrator.
max_order_nsint Maximum order used in the nonstiff case (default 12).
max_order_sint Maximum order used in the stiff case (default 5).
max_hnilint Maximum number of messages reporting too small step size (t + h = t) (default 0)
ixprint Whether to generate extra printing at method switches (default False).
"dopri5"
This is an explicit runge-kutta method of order (4)5 due to Dormand & Prince (with stepsize control and dense output).
Authors:
Hairer and G. Wanner
Universite de Geneve, Dept. de Mathematiques CH-1211 Geneve 24, Switzerland e-mail: ernst.hairer@math.unige.ch, gerhard.wanner@math.unige.ch
This code is described in [HNW93].
This integrator accepts the following parameters in set_integrator() method of the ode class:
atolfloat or sequence absolute tolerance for solution
rtolfloat or sequence relative tolerance for solution
nstepsint Maximum number of (internally defined) steps allowed during one call to the solver.
first_stepfloat
max_stepfloat
safetyfloat Safety factor on new step selection (default 0.9)
ifactorfloat
dfactorfloat Maximum factor to increase/decrease step size by in one step
betafloat Beta parameter for stabilised step size control.
verbosityint Switch for printing messages (< 0 for no messages).
"dop853"
This is an explicit runge-kutta method of order 8(5,3) due to Dormand & Prince (with stepsize control and dense output).
Options and references the same as "dopri5".
Examples
A problem to integrate and the corresponding jacobian:from scipy.integrate import ode y0, t0 = [1.0j, 2.0], 0 def f(t, y, arg1): return [1j*arg1*y[0] + y[1], -arg1*y[1]**2] def jac(t, y, arg1): return [[1j*arg1, 1], [0, -arg1*2*y[1]]]✓
r = ode(f, jac).set_integrator('zvode', method='bdf')
✓r.set_initial_value(y0, t0).set_f_params(2.0).set_jac_params(2.0)
✗t1 = 10 dt = 1✓
while r.successful() and r.t < t1: print(r.t+dt, r.integrate(r.t+dt))✗
See also
- odeint
an integrator with a simpler interface based on lsoda from ODEPACK
- quad
for finding the area under a curve
Aliases
-
scipy.integrate.ode