Module Cvode.Alternate

module Alternate: sig .. end

Alternate Linear Solvers.

type conv_fail = AlternateTypes.conv_fail = 
| NoFailures (*

Either the first call for a step or the local error test failed on the previous attempt at this setup but the Newton iteration converged.

| FailBadJ (*

The setup routine indicates that its Jacobian related data is not current and either the previous Newton corrector iteration did not converge, or, during the previous Newton corrector iteration, the linear solver's lsolve routine failed in a recoverable manner.

| FailOther (*

The previous Newton iteration failed to converge even though the linear solver was using current Jacobian-related data.


Indicates problems during the solution of nonlinear equations at a step. Helps decide whether to update the Jacobian data kept by a linear solver.

type ('data, 'kind) linit = ('data, 'kind) Cvode.session -> unit 

Functions that initialize linear solver data, like counters and statistics.

Raising any exception in this function (including Sundials.RecoverableFailure) is treated as an unrecoverable error.

type ('data, 'kind) lsetup = ('data, 'kind) Cvode.session -> 'data lsetup_args -> bool 

Functions that prepare the linear solver for subsequent calls to lsolve. This function must return true only if the Jacobian-related data is current after the call.

This function may raise a Sundials.RecoverableFailure exception to indicate that a recoverable error has occurred. Any other exception is treated as an unrecoverable error.

The vectors ypred, fpred, and those in tmp should not be accessed after the function returns.

type 'data lsetup_args = 'data alternate_lsetup_args = {
   lsetup_conv_fail : conv_fail; (*

Indicates that a problem occurred during the solution of the nonlinear equation at the current time step.

   lsetup_y : 'data; (*

The predicted $y$ vector for the current internal step.

   lsetup_rhs : 'data; (*

The value of the right-hand side at the predicted $y$ vector.

   lsetup_tmp : 'data Cvode.triple; (*

Temporary variables for use by the routine.


Arguments to Cvode.Alternate.lsetup.

type ('data, 'kind) lsolve = ('data, 'kind) Cvode.session ->
'data lsolve_args -> 'data -> unit

Functions that solve the linear equation $Mx = b$. $M$ is a preconditioning matrix chosen by the user, and $b$ is the right-hand side vector calculated within the function. $M$ should approximate $I - \gamma J$ where $J = (\frac{\partial f}{\partial y})(t_n, y_{\text{cur}})$, and $\gamma$ is available through Cvode.Alternate.get_gammas. The call lsolve s args b has as arguments:

Raising Sundials.RecoverableFailure indicates a recoverable error. Any other exception is treated as an unrecoverable error.

The vectors in Cvode.Alternate.lsolve_args should not be accessed after the function returns.

type 'data lsolve_args = 'data alternate_lsolve_args = {
   lsolve_ewt : 'data; (*

The error weights.

   lsolve_y : 'data; (*

The solver's current approximation to $y(t_n)$.

   lsolve_rhs : 'data; (*

A vector containing $f(t_n, y_{\text{cur}})$.


Arguments to Cvode.Alternate.lsolve.

type ('data, 'kind) callbacks = ('data, 'kind) alternate_linsolv = {
   linit : ('data, 'kind) linit option;
   lsetup : ('data, 'kind) lsetup option;
   lsolve : ('data, 'kind) lsolve;

The callbacks needed to implement an alternate linear solver.

val solver : (('data, 'kind) Cvode.session ->
('data, 'kind) Nvector.t -> ('data, 'kind) callbacks) ->
('data, 'kind) Cvode.session_linear_solver

Creates a linear solver from a function returning a set of callbacks. The creation function is passed a session and a vector. The latter indicates the problem size and can, for example, be cloned.

Solver internals

type gammas = {
   gamma : float; (*

The current $\gamma$ value.

   gammap : float; (*

The value of $\gamma$ at the last setup call.


Internal values used in Newton iteration.

val get_gammas : ('data, 'kind) Cvode.session -> gammas

Returns the current and previous gamma values.