<< IDA user functions sci_sundials

sci_sundials >> sci_sundials > CVODE, ARKODE and IDA options

CVODE, ARKODE and IDA options

Options allowing to change the default behavior of solvers

Syntax

... = cvode( ... , options)
... = ida( ... , options)
... = arkode( ... , options)

Common options

When calling cvode, arkode or ida the default behavior of the solver can be changed by specifying a sequence of named parameter values. These parameters are the following:

method

The solver method. CVODE accepts "adams" or "bdf", IDA accepts only "bdf".

rtol

The scalar relative tolerance to control the local error estimator

atol

The absolute tolerance controlling the local error. Can be a scalar or an array of the same dimension as the differential equation state.

maxorder

Allows to bound the maximum order of the method. The default maximum order of the method is 5 for the BDF method and 12 for the Adams method and any lower value can be chosen. Cannot be changed when using ARKODE.

h0

Proposed initial step. By default the solver computes the initial step by estimating second derivatives.

hmin

Minimum value of solver time steps. Can make convergence fail if taken too large.

hmax

Maximum value of solver time steps. Use it with care and only if the solver misses an event (for example a discontinuity) because of a large step. If you need a finer discretization of time span don't use an interval as time span but a vector like t0:h:tf or use the refine options.

refine

The number of complimentary time points (plus one) added between two successive solver time points. This option is active when using an interval [t0, tf] as time span. Example:

function acc=bounce(t, y, g)
    acc = [y(2); -g]
endfunction
function [out, term, dir]=bounce_ev(t, y)
    out = y(1);
    term = 1;
    dir = -1;
endfunction
[t,y] = cvode(list(bounce,9.81), [0 10], [1;0], events=bounce_ev);
[tr,yr] = cvode(list(bounce,9.81), [0 10], [1;0], events=bounce_ev,refine=8);
plot(tr,yr(1,:),'-o',t,y(1,:),'or')
legend("refined","original")

Jacobian, Events and Callback

These options are accepted by all solvers but the prototype of expected functions may vary and is discussed in the relevant pages:

jacobian

See the Jacobian section of the user functions page of CVODE, IDA and ARKODE.

events

See the Events section of the user functions page of CVODE, IDA and ARKODE.

intcb

See the Callback section of the user functions page of CVODE, IDA and ARKODE.

IDA options

IDA accepts options that only make sense for differential-algebric implicit equations:

calcIC

A string specifying the type of initial condition to compute if y0,yp0 vectors in the ida do not verify the equation. This string can be "yp0y0", in this case y'(0) and the algebric (non-differential) states of y0 are computed, knowing the differential states of y0. The algebric states are specified with the yIsAlgebric option. It can also be "y0" and in that case y(0) is computed knowing y'(0). The provided y0,yp0 vectors in the ida call are used as inital guesses.

yIsAlgebric

A vector of integer indices of non-differential states.

function res=weissinger(t, y, yp)
    res=t*y^2 * yp^3 - y^3 * yp^2 + t*(t^2 + 1)*yp - t^2 * y;
end
t0=1;
y0=sqrt(3/2);
yp0=0;
[t,y,yp]=ida(weissinger,[1 10],y0,yp0,calcIc="y0yp0");

See also


Report an issue
<< IDA user functions sci_sundials