You are looking at historical revision 25083 of this page. It may differ significantly from its current revision.

## sundials

### Description

The Chicken `sundials` library provides bindings to the solvers from the SUNDIALS library. SUNDIALS (SUite of Nonlinear and DIfferential/ALgebraic equation Solvers) is a collection of solvers for systems of ordinary differential equations and differential-algebraic equations.

The Chicken `sundials` library provides interfaces to the CVODE and IDA solvers and has been tested with SUNDIALS version 2.4.0.

### Library procedures

#### IDA solver interface

<procedure>(ida-create-solver TSTART TSTOP VARIABLES DERIVATIVES RESIDUAL-MAIN

[RESIDUAL-INIT] [RESIDUAL-EVENT] [EVENTS] [ALG-OR-DIFF] [SUPPRESS] [IC] [USER-DATA] [RELTOL] [ABSTOL])</procedure>

Creates and initializes an object representing a problem to be solved with the IDA solver.

Arguments `TSTART` and `TSTOP` must be real numbers that represent the beginning and end of the independent variable range.

Arguments `VARIABLES` and `DERIVATIVES` must be SRFI-4 `f64vector` objects that hold respectively the initial values and derivatives of the system variables.

Argument `RESIDUAL-MAIN` is used to compute the residual function `F` and must be a procedure of the following form:

(LAMBDA T YY YP DATA)

or

(LAMBDA T YY YP)

depending on whether the `USER-DATA` optional argument is set, where

`T`- real-valued independent variable
`YY`- SRFI-4
`f64vector`with current variable values `YP`- SRFI-4
`f64vector`with current variable derivatives `DATA`- is a user data object (if set)

This procedure must return a SRFI-4 `f64vector` containing the residual vector.

Optional keyword argument `RESIDUAL-EVENT` must be a procedure of the same form as `RESIDUAL-MAIN`, which computes a rootfinding problem to be solved during the integration of the system. It is set only if argument `EVENTS` is given.

Optional keyword argument `EVENTS` is an SRFI-4 `s32vector` that is used for storage of root finding solutions. It must be given if `RESIDUAL-EVENT` is given.

Optional keyword argument `ALG-OR-DIFF` must be an SRFI-4 `s32vector` which indicates the algebraic and differential variables in the system. A value of 1 indiciates differential variable, and a value of 0 indicates an algebraic one. This is required if the `SUPPRESS` argument is given and true.

Optional keyword argument `SUPPRESS` is a boolean flag that indicates whether algebraic variables must be suppressed in the local error test. If it is true (suppress), then the argument `ALG-OR-DIFF` must be given.

Optional keyword argument `IC` is a boolean flag that indicates whether the solver must calculate consistent initial conditions, or whether it must use the initial conditions given by `VARIABLES`.

Optional keyword argument `USER-DATA` is an object that will be passed as an additional argument to the residual functions.

Optional keyword arguments `RELTOL` and `ABSTOL` specify relative and absolute error tolerance, respectively. These both default to 1e-4.

*[procedure]*

`(ida-destroy-solver)`

*[procedure]*

`(ida-solve)`

*[procedure]*

`(ida-yy)`

*[procedure]*

`(ida-yp)`

*[procedure]*

`(ida-get-last-order)`

*[procedure]*

`(ida-get-num-steps)`

*[procedure]*

`(ida-get-last-step)`

### Example

(with-server-connection h "localhost" 11211 (let ((foo 4)) (let ((success (set h "foo" foo))) (let ((foo1 (get h "foo"))) (equal? foo foo1)))))

### Version History

- 1.0 Initial release

### License

Copyright 2011 Ivan Raikov. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.