qiskit_dynamics.solvers.solve_ode#
- solve_ode(rhs, t_span, y0, method='DOP853', t_eval=None, **kwargs)[source]#
General interface for solving Ordinary Differential Equations (ODEs).
ODEs are differential equations of the form
\[\dot{y}(t) = f(t, y(t)),\]where \(f\) is a callable function and the state \(y(t)\) is an arbitrarily-shaped complex array.
The
method
argument exposes a variety of underlying ODE solvers. Optional arguments for any of the solver routines can be passed viakwargs
. Available methods are:scipy.integrate.solve_ivp
- supports methods['RK45', 'RK23', 'BDF', 'DOP853', 'Radau', 'LSODA']
or by passing a validscipy
OdeSolver
instance.'RK4'
: A fixed-step 4th order Runge-Kutta solver. Requires additional kwargmax_dt
, indicating the maximum step size to take. This solver will break integration periods into even sub-intervals no larger thanmax_dt
, and step over each sub-interval using the standard 4th order Runge-Kutta integration rule.'jax_RK4'
: JAX backend implementation of'RK4'
method.'jax_odeint'
: Callsjax.experimental.ode.odeint
variable step solver.diffrax.diffeqsolve
- a JAX solver function, called by passingmethod
as a validdiffrax.AbstractSolver
instance. Requires thediffrax
library.
Results are returned as a
OdeResult
object.- Parameters:
rhs (
Union
[Callable
,BaseGeneratorModel
]) – RHS function \(f(t, y)\).t_span (
Union
[ndarray
,number
,int
,float
,complex
,Tracer
,Array
,Array
,spmatrix
,BCOO
,list
]) –Tuple
orlist
of initial and final time.y0 (
Union
[ndarray
,number
,int
,float
,complex
,Tracer
,Array
,Array
,spmatrix
,BCOO
,list
]) – State at initial time.method (
Union
[str
,OdeSolver
,TypeVar
(AbstractSolver
),None
]) – Solving method to use.t_eval (
Union
[ndarray
,number
,int
,float
,complex
,Tracer
,Array
,Array
,spmatrix
,BCOO
,list
,None
]) – Times at which to return the solution. Must lie withint_span
. If unspecified, the solution will be returned at the points int_span
.**kwargs – Additional arguments to pass to the solver.
- Returns:
Results object.
- Return type:
OdeResult
- Raises:
QiskitError – If specified method does not exist.