<< IDA sci_sundials CVODE, ARKODE and IDA options >>

sci_sundials >> sci_sundials > IDA user functions

IDA user functions

The different ways of coding user functions used by IDA

Introduction

To solve a problem with IDA different functions have to be provided. For example the residual function of the dae has to be computed by the user and is the only mandatory function. Providing the Jacobian always help the solver, 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.

Residual function

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

Jacobian

In IDA Newton iterations the Jacobian of the residual system is by default approximated by finite differences. Iterations can be accelerated and precision can be improved by giving the true Jacobian of the residual with respect to y and yp with the jacobian option. In the call ida(f,tspan,y0,yp0,jacobian=jacyyp), jacyyp can be:

Events

In the call ida(f,tspan,y0,yp0,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 ida(f,tspan,y0,yp0,intcb=callback), callback can be:

See also


Report an issue
<< IDA sci_sundials CVODE, ARKODE and IDA options >>