bundles / scipy 1.17.1 / scipy / integrate / _ivp / base / OdeSolver
class
scipy.integrate._ivp.base:OdeSolver
Signature
class OdeSolver ( fun , t0 , y0 , t_bound , vectorized , support_complex = False ) Members
Summary
Base class for ODE solvers.
Extended Summary
In order to implement a new solver you need to follow the guidelines:
A constructor must accept parameters presented in the base class (listed below) along with any other parameters specific to a solver.
A constructor must accept arbitrary extraneous arguments
**extraneous, but warn that these arguments are irrelevant using common.warn_extraneous function. Do not pass these arguments to the base class.A solver must implement a private method
_step_impl(self)which propagates a solver one step further. It must return tuple(success, message), wheresuccessis a boolean indicating whether a step was successful, andmessageis a string containing description of a failure if a step failed or None otherwise.A solver must implement a private method
_dense_output_impl(self), which returns a DenseOutput object covering the last successful step.A solver must have attributes listed below in Attributes section. Note that
t_oldandstep_sizeare updated automatically.Use
fun(self, t, y)method for the system rhs evaluation, this way the number of function evaluations (nfev) will be tracked automatically.For convenience, a base class provides
fun_single(self, t, y)andfun_vectorized(self, t, y)for evaluating the rhs in non-vectorized and vectorized fashions respectively (regardless of howfunfrom the constructor is implemented). These calls don't increment nfev.If a solver uses a Jacobian matrix and LU decompositions, it should track the number of Jacobian evaluations (njev) and the number of LU decompositions (nlu).
By convention, the function evaluations used to compute a finite difference approximation of the Jacobian should not be counted in nfev, thus use
fun_single(self, t, y)orfun_vectorized(self, t, y)when computing a finite difference approximation of the Jacobian.
Parameters
fun: callableRight-hand side of the system: the time derivative of the state
yat timet. The calling signature isfun(t, y), wheretis a scalar andyis an ndarray withlen(y) = len(y0).funmust return an array of the same shape asy. Seevectorizedfor more information.t0: floatInitial time.
y0: array_like, shape (n,)Initial state.
t_bound: floatBoundary time --- the integration won't continue beyond it. It also determines the direction of the integration.
vectorized: boolWhether
funcan be called in a vectorized fashion. Default is False.If
vectorizedis False,funwill always be called withyof shape(n,), wheren = len(y0).If
vectorizedis True,funmay be called withyof shape(n, k), wherekis an integer. In this case,funmust behave such thatfun(t, y)[:, i] == fun(t, y[:, i])(i.e. each column of the returned array is the time derivative of the state corresponding with a column ofy).Setting
vectorized=Trueallows for faster finite difference approximation of the Jacobian by methods 'Radau' and 'BDF', but will result in slower execution for other methods. It can also result in slower overall execution for 'Radau' and 'BDF' in some circumstances (e.g. smalllen(y0)).support_complex: bool, optionalWhether integration in a complex domain should be supported. Generally determined by a derived solver class capabilities. Default is False.
Attributes
n: intNumber of equations.
status: stringCurrent status of the solver: 'running', 'finished' or 'failed'.
t_bound: floatBoundary time.
direction: floatIntegration direction: +1 or -1.
t: floatCurrent time.
y: ndarrayCurrent state.
t_old: floatPrevious time. None if no steps were made yet.
step_size: floatSize of the last successful step. None if no steps were made yet.
nfev: intNumber of the system's rhs evaluations.
njev: intNumber of the Jacobian evaluations.
nlu: intNumber of LU decompositions.
Aliases
-
scipy.integrate.OdeSolver