set options for ode solvers
odeoptions()
This function interactively displays a command which should be
executed to set various options of ode solvers. The context variable
%ODEOPTIONS
sets the options.
![]() | The ode function checks if this variable
exists and in this case it uses it. For using default values you should
clear this variable. To create it you must execute the instruction
%ODEOPTIONS=odeoptions() . |
The variable %ODEOPTIONS
is a vector with the
following elements:
[itask, tcrit, h0, hmax, hmin, jactyp, mxstep, maxordn, maxords, ixpr, ml, mu]
.
The default value is: [1,0,0,%inf,0,2,500,12,5,0,-1,-1].
The meaning of the elements is described below.
itask
sets the integration mode:
ode
)tcrit
tcrit
, and returntcrit
critical time used only if itask
equals 4
or 5 as described aboveh0
first step triedhmax
max step sizehmin
min step sizejactype
set jacobian properties:
"adams"
or "stiff"
only)"adams"
or "stiff"
only)ml
and mu
below)ml
and mu
below)maxordn
maximum non-stiff order
allowed, at most 12maxords
maximum stiff order allowed,
at most 5ixpr
print level, 0 or 1ml
,mu
If
jactype
equals 4 or 5, ml
and mu
are the lower and upper
half-bandwidths of the banded jacobian: the band is the i,j
's
with i-ml
<= j
<= ny-1
.
If jactype
equals 4 the jacobian
function must return a matrix J
which is ml+mu+1 x ny
(where ny=dim
of y
in ydot=f(t,y))
such that column 1 of J
is made of mu
zeros followed
by df1/dy1
, df2/dy1
, df3/dy1
, ...
(1+ml
possibly non-zero entries), column 2 is made of
mu-1
zeros followed by df1/dx2
,
df2/dx2
, etc.
In the following example, we solve the Ordinary Differential Equation
dy/dt=y^2-y sin(t)+cos(t)
with the initial
condition y(0)=0
claiming the solution be stored at each mesh value.
function ydot=f(t, y) ydot=y^2-y*sin(t)+cos(t) endfunction %ODEOPTIONS=[2,0,0,%inf,0,2,500,12,5,0,-1,-1]; y=ode(0,0,%pi,f); plot(y(1,:),y(2,:)) clear %ODEOPTIONS | ![]() | ![]() |