||Assert that max_Step is valid and return it.|
||Display a warning for extraneous keyword arguments.|
||Validate tolerance values.|
||Compute RMS norm.|
||Empirically select a good initial step.|
||Finite differences Jacobian approximation tailored for ODE solvers.|
Assert that max_Step is valid and return it.
Display a warning for extraneous keyword arguments.
The initializer of each solver class is expected to collect keyword arguments that it doesn’t understand and warn about them. This function prints a warning for each key in the supplied dictionary.
- extraneous : dict
- Extraneous keyword arguments
validate_tol(rtol, atol, n)¶
Validate tolerance values.
Compute RMS norm.
select_initial_step(fun, t0, y0, f0, direction, order, rtol, atol)¶
Empirically select a good initial step.
The algorithm is described in .
- fun : callable
- Right-hand side of the system.
- t0 : float
- Initial value of the independent variable.
- y0 : ndarray, shape (n,)
- Initial value of the dependent variable.
- f0 : ndarray, shape (n,)
- Initial value of the derivative, i. e.
- direction : float
- Integration direction.
- order : float
- Method order.
- rtol : float
- Desired relative tolerance.
- atol : float
- Desired absolute tolerance.
- h_abs : float
- Absolute value of the suggested initial step.
 E. Hairer, S. P. Norsett G. Wanner, “Solving Ordinary Differential Equations I: Nonstiff Problems”, Sec. II.4.
Continuous ODE solution.
It is organized as a collection of DenseOutput objects which represent local interpolants. It provides an algorithm to select a right interpolant for each given point.
The interpolants cover the range between t_min and t_max (see Attributes below). Evaluation outside this interval is not forbidden, but the accuracy is not guaranteed.
When evaluating at a breakpoint (one of the values in ts) a segment with the lower index is selected.
- ts : array_like, shape (n_segments + 1,)
- Time instants between which local interpolants are defined. Must be strictly increasing or decreasing (zero segment with two points is also allowed).
- interpolants : list of DenseOutput with n_segments elements
- Local interpolants. An i-th interpolant is assumed to be defined
ts[i + 1].
- t_min, t_max : float
- Time range of the interpolation.
Evaluate the solution.
- t : float or array_like with shape (n_points,)
- Points to evaluate at.
- y : ndarray, shape (n_states,) or (n_states, n_points)
- Computed values. Shape depends on whether t is a scalar or a 1-d array.
num_jac(fun, t, y, f, threshold, factor, sparsity=None)¶
Finite differences Jacobian approximation tailored for ODE solvers.
This function computes finite difference approximation to the Jacobian matrix of fun with respect to y using forward differences. The Jacobian matrix has shape (n, n) and its element (i, j) is equal to
d f_i / d y_j.
A special feature of this function is the ability to correct the step size from iteration to iteration. The main idea is to keep the finite difference significantly separated from its round-off error which approximately equals
EPS * np.abs(f). It reduces a possibility of a huge error and assures that the estimated derivative are reasonably close to the true values (i.e. the finite difference approximation is at least qualitatively reflects the structure of the true Jacobian).
- fun : callable
- Right-hand side of the system implemented in a vectorized fashion.
- t : float
- Current time.
- y : ndarray, shape (n,)
- Current state.
- f : ndarray, shape (n,)
- Value of the right hand side at (t, y).
- threshold : float
- Threshold for y value used for computing the step size as
factor * np.maximum(np.abs(y), threshold). Typically the value of absolute tolerance (atol) for a solver should be passed as threshold.
- factor : ndarray with shape (n,) or None
- Factor to use for computing the step size. Pass None for the very evaluation, then use the value returned from this function.
- sparsity : tuple (structure, groups) or None
- Sparsity structure of the Jacobian, structure must be csc_matrix.
- J : ndarray or csc_matrix, shape (n, n)
- Jacobian matrix.
- factor : ndarray, shape (n,)
- Suggested factor for the next evaluation.
_dense_num_jac(fun, t, y, f, h, factor, y_scale)¶
_sparse_num_jac(fun, t, y, f, h, factor, y_scale, structure, groups)¶