bundles / scipy latest / scipy / integrate / _ivp / lsoda / LSODA
class
scipy.integrate._ivp.lsoda:LSODA
Signature
class LSODA ( fun , t0 , y0 , t_bound , first_step = None , min_step = 0.0 , max_step = inf , rtol = 0.001 , atol = 1e-06 , jac = None , lband = None , uband = None , vectorized = False , ** extraneous ) Members
Summary
Adams/BDF method with automatic stiffness detection and switching.
Extended Summary
This is a wrapper to the Fortran solver from ODEPACK [1]. It switches automatically between the nonstiff Adams method and the stiff BDF method. The method was originally detailed in [2].
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.
first_step: float or None, optionalInitial step size. Default is
Nonewhich means that the algorithm should choose.min_step: float, optionalMinimum allowed step size. Default is 0.0, i.e., the step size is not bounded and determined solely by the solver.
max_step: float, optionalMaximum allowed step size. Default is np.inf, i.e., the step size is not bounded and determined solely by the solver.
rtol, atol: float and array_like, optionalRelative and absolute tolerances. The solver keeps the local error estimates less than
atol + rtol * abs(y). Herertolcontrols a relative accuracy (number of correct digits), whileatolcontrols absolute accuracy (number of correct decimal places). To achieve the desiredrtol, setatolto be smaller than the smallest value that can be expected fromrtol * abs(y)so thatrtoldominates the allowable error. Ifatolis larger thanrtol * abs(y)the number of correct digits is not guaranteed. Conversely, to achieve the desiredatolsetrtolsuch thatrtol * abs(y)is always smaller thanatol. If components of y have different scales, it might be beneficial to set differentatolvalues for different components by passing array_like with shape (n,) foratol. Default values are 1e-3 forrtoland 1e-6 foratol.jac: None or callable, optionalJacobian matrix of the right-hand side of the system with respect to
y. The Jacobian matrix has shape (n, n) and its element (i, j) is equal tod f_i / d y_j. The function will be called asjac(t, y). If None (default), the Jacobian will be approximated by finite differences. It is generally recommended to provide the Jacobian rather than relying on a finite-difference approximation.lband, uband: int or NoneParameters defining the bandwidth of the Jacobian, i.e.,
jac[i, j] != 0 only for i - lband <= j <= i + uband. Setting these requires your jac routine to return the Jacobian in the packed format: the returned array must havencolumns anduband + lband + 1rows in which Jacobian diagonals are written. Specificallyjac_packed[uband + i - j , j] = jac[i, j]. The same format is used in scipy.linalg.solve_banded (check for an illustration). These parameters can be also used withjac=Noneto reduce the number of Jacobian elements estimated by finite differences.vectorized: bool, optionalWhether
funmay be called in a vectorized fashion. False (default) is recommended for this solver.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 this solver.
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.
nfev: intNumber of evaluations of the right-hand side.
njev: intNumber of evaluations of the Jacobian.
Aliases
-
scipy.integrate.LSODA