<< CVODE sci_sundials IDA >>

sci_sundials >> sci_sundials > CVODE user functions

CVODE user functions

The different ways of coding user functions used by CVODE

Introduction

To solve a problem with CVODE different functions have to be provided. For example the right hand side of the ode has to be computed by the user and is the only mandatory function. Providing the Jacobian always help the solver when the BDF method is used, for example when the ode is stiff. Two other optional functions allow to handle events and intermediate callbacks (at each user prescribed or internal solver step). The usual way is to write functions in the Scilab language but if speed is a concern, entrypoints of dynamically linked shared libraries (DLL, built from C,C++ of Fortran) should be used instead, as at least one order of magnitude in speed is typically achieved that way (examples below use C). In that case all arguments are given via their address (Fortran convention).

Passing extra parameters

Extra parameters can be passed to user Scilab functions or entrypoints by replacing the corresponding argument or option by a list, where the first element is the usual argument (a function identifier or a string with the entrypoint name) and the subsequent elements are the parameters to be passed after the mandatory arguments. Note that DLL entrypoints accept only one extra parameter as a double array.

Right hand side

In the call cvode(f,tspan,y0) the first argument f can be:

Jacobian

When the BDF method is chosen, Newton iterations are used and the Jacobian of the equation system is by default approximated by finite differences. Iterations can be accelerated and precision can be improved by giving the true Jacobian of the right hand side with respect to y with the jacobian option. In the call cvode(f,tspan,y0,jacobian=df), df can be:

Events

In the call cvode(f,tspan,y0,events=g), g can be:

Callback

CVODE can call a Scilab function or DLL entryoint after every successfull internal or user prescribed step. In the call cvode(f,tspan,y0, intcb=callback), callback can be:

See also


Report an issue
<< CVODE sci_sundials IDA >>