Module Cvode.Spils

module Spils: sig .. end
Scaled Preconditioned Iterative Linear Solvers.
See sundials: Iterative linear solvers optional input functions.
See sundials: Iterative linear solvers optional output functions.
See sundials: CVSpilsPrecSolveFn
See sundials: CVSpilsPrecSetupFn


Preconditioners


type 'd prec_solve_arg = {
   rhs : 'd; (*
Right-hand side vector of the linear system.
*)
   gamma : float; (*
Scalar $\gamma$ in the Newton matrix given by $M = I - \gamma J$.
*)
   delta : float; (*
Input tolerance for iterative methods.
*)
   left : bool; (*
true for left preconditioning and false for right preconditioning.
*)
}
Arguments passed to the preconditioner solver function.
See sundials: CVSpilsPrecSolveFn
type 'd prec_solve_fn = ('d, 'd) Cvode.jacobian_arg -> 'd prec_solve_arg -> 'd -> unit 
Callback functions that solve a linear system involving a preconditioner matrix. In the call prec_solve_fn jac arg z, jac is a Cvode.jacobian_arg with one work vector, arg is a Cvode.Spils.prec_solve_arg that specifies the linear system, and z is computed to solve $P\mathtt{z} = \mathtt{arg.rhs}$. $P$ is a preconditioner matrix, which approximates, however crudely, the Newton matrix $M = I - \gamma J$ where $J = \frac{\partial f}{\partial y}$.

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

The elements of jac, arg, and z should not be accessed after the function has returned.

See sundials: CVSpilsPrecSolveFn
type 'd prec_setup_fn = ('d Cvode.triple, 'd) Cvode.jacobian_arg -> bool -> float -> bool 
Callback functions that preprocess or evaluate Jacobian-related data needed by Cvode.Spils.prec_solve_fn. In the call prec_setup_fn jac jok gamma, jac is a Cvode.jacobian_arg with three work vectors, jok indicates whether any saved Jacobian-related data can be reused with the current value of gamma, and gamma is the scalar $\gamma$ in the Newton matrix $M = I - \gamma J$ where $J$ is the Jacobian matrix. A function should return true if Jacobian-related data was updated and false if saved data was reused.

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

The elements of jac should not be accessed after the function has returned.

See sundials: CVSpilsSetPreconditioner
See sundials: CVSpilsPrecSetupFn
type 'd jac_times_vec_fn = ('d, 'd) Cvode.jacobian_arg -> 'd -> 'd -> unit 
Callback functions that compute the Jacobian times a vector. In the call jac_times_vec_fn arg v jv, arg is a Cvode.jacobian_arg with one work vector, v is the vector multiplying the Jacobian, and jv is the vector in which to store the result—$\mathtt{jv} = J\mathtt{v}$.

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

Neither the elements of arg nor v or jv should be accessed after the function has returned.

See sundials: CVSpilsSetJacTimesVecFn
See sundials: CVSpilsJacTimesVecFn
type ('d, 'k) preconditioner = ('d, 'k) SpilsTypes.preconditioner 
Specifies a preconditioner, including the type of preconditioning (none, left, right, or both) and callback functions. The following functions and those in Cvode.Spils.Banded and Cvode_bbd construct preconditioners.

The Cvode.Spils.prec_solve_fn is mandatory. The Cvode.Spils.prec_setup_fn can be omitted if not needed.

See sundials: CVSpilsSetPreconditioner
See sundials: CVSpilsPrecSetupFn
See sundials: CVSpilsPrecSolveFn
val prec_none : ('d, 'k) preconditioner
No preconditioning.
val prec_left : ?setup:'d prec_setup_fn ->
'd prec_solve_fn -> ('d, 'k) preconditioner
Left preconditioning. $(P^{-1}A)x = P^{-1}b$ .
val prec_right : ?setup:'d prec_setup_fn ->
'd prec_solve_fn -> ('d, 'k) preconditioner
Right preconditioning. $(AP^{-1})Px = b$ .
val prec_both : ?setup:'d prec_setup_fn ->
'd prec_solve_fn -> ('d, 'k) preconditioner
Left and right preconditioning. $(P_L^{-1}AP_R^{-1})P_Rx = P_L^{-1}b$
module Banded: sig .. end
Banded preconditioners.

Solvers


val spgmr : ?maxl:int ->
?jac_times_vec:'d jac_times_vec_fn ->
('d, 'k) preconditioner -> ('d, 'k) Cvode.linear_solver
Krylov iterative solver using the scaled preconditioned generalized minimum residual (GMRES) method. In the call spgmr ~maxl:maxl ~jac_times_vec:jtv prec, If the Cvode.Spils.jac_times_vec_fn is omitted, a default implementation based on difference quotients is used.
See sundials: CVSpgmr
See sundials: CVSpilsSetPreconditioner
See sundials: CVSpilsSetMaxl
See sundials: CVSpilsSetJacTimesVecFn
See sundials: CVSpilsJacTimesVecFn
val spbcg : ?maxl:int ->
?jac_times_vec:'d jac_times_vec_fn ->
('d, 'k) preconditioner -> ('d, 'k) Cvode.linear_solver
Krylov iterative solver using the scaled preconditioned biconjugate stabilized (Bi-CGStab) method. In the call spbcg ~maxl:maxl ~jac_times_vec:jtv prec, If the Cvode.Spils.jac_times_vec_fn is omitted, a default implementation based on difference quotients is used.
See sundials: CVSpbcg
See sundials: CVSpilsSetPreconditioner
See sundials: CVSpilsSetMaxl
See sundials: CVSpilsSetJacTimesVecFn
See sundials: CVSpilsJacTimesVecFn
val sptfqmr : ?maxl:int ->
?jac_times_vec:'d jac_times_vec_fn ->
('d, 'k) preconditioner -> ('d, 'k) Cvode.linear_solver
Krylov iterative with the scaled preconditioned transpose-free quasi-minimal residual (SPTFQMR) method. In the call sptfqmr ~maxl:maxl ~jac_times_vec:jtv prec, If the Cvode.Spils.jac_times_vec_fn is omitted, a default implementation based on difference quotients is used.
See sundials: CVSptfqmr
See sundials: CVSpilsSetPreconditioner
See sundials: CVSpilsSetMaxl
See sundials: CVSpilsSetJacTimesVecFn
See sundials: CVSpilsJacTimesVecFn

Solver parameters


val set_gs_type : ('d, 'k) Cvode.session -> Spils.gramschmidt_type -> unit
Sets the Gram-Schmidt orthogonalization to be used with the Spgmr Cvode.linear_solver.
See sundials: CVSpilsSetGSType
val set_eps_lin : ('d, 'k) Cvode.session -> float -> unit
Sets the factor by which the Krylov linear solver's convergence test constant is reduced from the Newton iteration test constant. This factor must be >= 0; passing 0 specifies the default (0.05).
See sundials: CVSpilsSetEpsLin
val set_maxl : ('d, 'k) Cvode.session -> int -> unit
Resets the maximum Krylov subspace dimension for the Bi-CGStab and TFQMR methods. A value <= 0 specifies the default (5.0).
See sundials: CVSpilsSetMaxl

Solver statistics


val get_work_space : ('d, 'k) Cvode.session -> int * int
Returns the sizes of the real and integer workspaces used by the spils linear solver.
Returns (real_size, integer_size)
See sundials: CVSpilsGetWorkSpace
val get_num_lin_iters : ('d, 'k) Cvode.session -> int
Returns the cumulative number of linear iterations.
See sundials: CVSpilsGetNumLinIters
val get_num_conv_fails : ('d, 'k) Cvode.session -> int
Returns the cumulative number of linear convergence failures.
See sundials: CVSpilsGetNumConvFails
val get_num_prec_evals : ('d, 'k) Cvode.session -> int
Returns the cumulative number of calls to the setup function with jok=false.
See sundials: CVSpilsGetNumPrecEvals
val get_num_prec_solves : ('d, 'k) Cvode.session -> int
Returns the cumulative number of calls to the preconditioner solve function.
See sundials: CVSpilsGetNumPrecSolves
val get_num_jtimes_evals : ('d, 'k) Cvode.session -> int
Returns the cumulative number of calls to the Jacobian-vector function.
See sundials: CVSpilsGetNumJtimesEvals
val get_num_rhs_evals : ('d, 'k) Cvode.session -> int
Returns the number of calls to the right-hand side callback for finite difference Jacobian-vector product approximation. This counter is only updated if the default difference quotient function is used.
See sundials: CVSpilsGetNumRhsEvals

Low-level solver manipulation

The Cvode.init and Cvode.reinit functions are the preferred way to set or change preconditioner functions. These low-level functions are provided for experts who want to avoid resetting internal counters and other associated side-effects.

val set_preconditioner : ('d, 'k) Cvode.session ->
?setup:'d prec_setup_fn -> 'd prec_solve_fn -> unit
Change the preconditioner functions.
See sundials: CVSpilsSetPreconditioner
See sundials: CVSpilsPrecSolveFn
See sundials: CVSpilsPrecSetupFn
val set_jac_times_vec_fn : ('d, 'k) Cvode.session -> 'd jac_times_vec_fn -> unit
Change the Jacobian-times-vector function.
See sundials: CVSpilsSetJacTimesVecFn
See sundials: CVSpilsJacTimesVecFn
val clear_jac_times_vec_fn : ('d, 'k) Cvode.session -> unit
Remove a Jacobian-times-vector function and use the default implementation.
See sundials: CVSpilsSetJacTimesVecFn
See sundials: CVSpilsJacTimesVecFn
val set_prec_type : ('d, 'k) Cvode.session -> Spils.preconditioning_type -> unit
Change the preconditioning direction without modifying callback functions. If the preconditioning type is changed from Spils.PrecNone then Cvode.Spils.set_preconditioner must be called to install the necessary callbacks.
See sundials: CVSpilsSetPrecType