Module Idas.Adjoint.Quadrature

module Quadrature: sig .. end

Support for backward quadrature equations that may or may not depend on forward sensitivities.


Initialization

type 'd bquadrhsfn_args = {
   t : float; (*

The value of the independent variable.

*)
   y : 'd; (*

The vector of dependent-variable values $y(t)$.

*)
   y' : 'd; (*

The vector of dependent-variable derivatives $\dot{y}(t)$ .

*)
   yb : 'd; (*

The vector of backward dependent-variable values $y_B(t)$.

*)
   yb' : 'd; (*

The vector of backward dependent-variable derivatives $\dot{y}_B(t)$ .

*)
}

Arguments common to Idas.Adjoint.Quadrature.bquadrhsfn_no_sens and Idas.Adjoint.Quadrature.bquadrhsfn_with_sens.

type 'd bquadrhsfn_no_sens = 'd bquadrhsfn_args -> 'd -> unit 

Functions defining backward quadrature variables without forward sensitivities. They are passed the arguments:

Within the function, raising a Sundials.RecoverableFailure exception indicates a recoverable error. Any other exception is treated as an unrecoverable error.

Vectors held in this function's arguments should not be accessed after the function returns.

type 'd bquadrhsfn_with_sens = 'd bquadrhsfn_args ->
'd array -> 'd array -> 'd -> unit

Functions defining backward quadrature variables that depend on forward sensitivities. They are passed the arguments:

Within the function, raising a Sundials.RecoverableFailure exception indicates a recoverable error. Any other exception is treated as an unrecoverable error.

Vectors held in this function's arguments should not be accessed after the function returns.

type 'd bquadrhsfn = 
| NoSens of 'd bquadrhsfn_no_sens (*

Does not depend on forward sensitivities.

*)
| WithSens of 'd bquadrhsfn_with_sens (*

Depends on forward sensitivities.

*)

These functions compute the quadrature equation right-hand side for the backward problem.

val init : ('d, 'k) Idas.Adjoint.bsession ->
'd bquadrhsfn -> ('d, 'k) Nvector.t -> unit

This function activates the integration of quadrature equations. The arguments are the function that computes the right-hand side of the backward quadrature equations, and a vector giving the values of the quadrature variables at tB0.

val reinit : ('d, 'k) Idas.Adjoint.bsession -> ('d, 'k) Nvector.t -> unit

This function reinitializes the integration of quadrature equations during the backward phase.

Tolerances

type ('d, 'k) tolerance = 
| NoStepSizeControl (*

Quadrature variables are not used for step-size control (the default).

*)
| SStolerances of float * float (*

(rel, abs) : scalar relative and absolute tolerances.

*)
| SVtolerances of float * ('d, 'k) Nvector.t (*

(rel, abs) : scalar relative and vector absolute tolerances.

*)

Tolerances for calculating backward quadrature variables.

val set_tolerances : ('d, 'k) Idas.Adjoint.bsession ->
('d, 'k) tolerance -> unit

Specify how to use quadrature variables in step size control.

Output functions

val get : ('d, 'k) Idas.Adjoint.bsession -> ('d, 'k) Nvector.t -> float

Returns the backward quadrature solutions and time reached after a successful solver step. The given vectors are filled with values calculated during either Idas.Adjoint.backward_normal or Idas.Adjoint.backward_one_step and the value of the independent variable is returned.

Querying the solver (optional output functions)

val get_num_rhs_evals : ('d, 'k) Idas.Adjoint.bsession -> int

Returns the number of calls to the backward quadrature right-hand side function.

val get_num_err_test_fails : ('d, 'k) Idas.Adjoint.bsession -> int

Returns the number of local error test failures due to quadrature variables.

val get_err_weights : ('d, 'k) Idas.Adjoint.bsession -> ('d, 'k) Nvector.t -> unit

Returns the quadrature error weights at the current time.

val get_stats : ('d, 'k) Idas.Adjoint.bsession -> int * int

Returns quadrature-related statistics. These are the number of calls to the quadrature function (nfqevals) and the number of error test failures due to quadrature variables (nqetfails).