Library

Module

Module type

Parameter

Class

Class type

Legend:

Library

Module

Module type

Parameter

Class

Class type

Library

Module

Module type

Parameter

Class

Class type

Binding to ODEPACK. This is a collection of solvers for the initial value problem for ordinary differential equation systems. See the ODEPACK page and Netlib.

An `example_of_use`

of this library is presented at the end.

```
type vec =
(float, Bigarray.float64_elt, Bigarray.fortran_layout) Bigarray.Array1.t
```

Representation of vectors (parametrized by their layout).

```
type mat =
(float, Bigarray.float64_elt, Bigarray.fortran_layout) Bigarray.Array2.t
```

Representation of matrices (parametrized by their layout).

`type jacobian = `

`| Auto_full`

(*Internally generated (difference quotient) full Jacobian

*)`| Auto_band of int * int`

(*Internally generated (difference quotient) band Jacobian. It takes

*)`(l,u)`

where`l`

(resp.`u`

) is the number of lines below (resp. above) the diagonal (excluded).`| Full of float -> vec -> mat -> unit`

(*

*)`Full df`

means that a function`df`

is provided to compute the full Jacobian matrix (∂f_i/∂y_j) of the vector field f(t,y).`df t y jac`

must store ∂f_i/∂y_j(`t`

,`y`

) into`jac.{i,j}`

.`| Band of int * int * float -> vec -> int -> mat -> unit`

(*

*)`Band(l, u, df)`

means that a function`df`

is provided to compute the banded Jacobian matrix with`l`

(resp.`u`

) diagonals below (resp. above) the main one (not counted).`df t y d jac`

must store ∂f_i/∂y_j(`t`

,`y`

) into`jac.{i-j+d, j}`

.`d`

is the row of`jac`

corresponding to the main diagonal of the Jacobian matrix.

Types of Jacobian matrices.

```
val lsoda :
?rtol:float ->
?rtol_vec:vec ->
?atol:float ->
?atol_vec:vec ->
?jac:jacobian ->
?mxstep:int ->
?copy_y0:bool ->
?debug:bool ->
?debug_switches:bool ->
(float -> vec -> vec -> unit) ->
vec ->
float ->
float ->
t
```

`lsoda f y0 t0 t`

solves the ODE dy/dt = F(t,y) with initial condition y(`t0`

) = `y0`

. The execution of `f t y y'`

must compute the value of the F(`t`

, `y`

) and store it in `y'`

. It uses a dense or banded Jacobian when the problem is stiff, but it automatically selects between nonstiff (Adams) and stiff (BDF) methods. It uses the nonstiff method initially, and dynamically monitors data in order to decide which method to use.

```
val lsodar :
?rtol:float ->
?rtol_vec:vec ->
?atol:float ->
?atol_vec:vec ->
?jac:jacobian ->
?mxstep:int ->
?copy_y0:bool ->
?debug:bool ->
?debug_switches:bool ->
g:(float -> vec -> vec -> unit) ->
ng:int ->
(float -> vec -> vec -> unit) ->
vec ->
float ->
float ->
t
```

`lsodar f y0 t0 t ~g ~ng`

is like `lsoda`

but has root searching capabilities. The algorithm will stop before reacing time `t`

if a root of one of the `ng`

constraints is found. You can determine whether the `lsodar`

stopped at a root using `has_root`

. It only finds those roots for which some component of `g`

, as a function of t, changes sign in the interval of integration. The function `g`

is evaluated like `f`

, that is: `g t y gout`

must write to `gout.{1},..., gout.{ng}`

the value of the `ng`

constraints.

`val time : t -> float`

`t ode`

returns the current time at which the solution vector was computed.

`val advance : ?time:float -> t -> unit`

`advance ode ~time:t`

modifies `ode`

so that an approximation of the value of the solution at times `t`

is computed. Note that, if the solver has root searching capabilities and a time is provided, the solver may stop before that time if a root is found. The time is recorded for future calls to `advance ode`

. If the solver has no root finding capabilities and no time is provided, this function does nothing.

`val has_root : t -> bool`

`has_root ode`

says wheter the solver stopped (i.e. the current state of `ode`

is) because a root was found. If the solver has no root searching capabilities, this returns `false`

.

`val root : t -> int -> bool`

`root t i`

returns true iff the `i`

th constraint in `lsodar`

has a root. It raises `Invalid_argument`

if `i`

is not between 1 and `ng`

, the number of constraints (included). This only makes sense if `has_root t`

holds.

`val roots : t -> bool array`

`roots t`

returns an array `r`

such that `r.(i)`

holds if and only if the `i`

th constraint has a root.

sectionYPositions = computeSectionYPositions($el), 10)" x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)">