Navigation

Operators and Keywords

Function List:

C++ API

: [x, xdot, t_out, istat, msg] = dasrt (fcn, [], x_0, xdot_0, t)
: … = dasrt (fcn, g, x_0, xdot_0, t)
: … = dasrt (fcn, [], x_0, xdot_0, t, t_crit)
: … = dasrt (fcn, g, x_0, xdot_0, t, t_crit)

Solve the set of differential-algebraic equations

0 = f (x, xdot, t)

with

x(t_0) = x_0, xdot(t_0) = xdot_0

with functional stopping criteria (root solving).

The solution is returned in the matrices x and xdot, with each row in the result matrices corresponding to one of the elements in the vector t_out. The first element of t should be t_0 and correspond to the initial state of the system x_0 and its derivative xdot_0, so that the first row of the output x is x_0 and the first row of the output xdot is xdot_0.

The vector t provides an upper limit on the length of the integration. If the stopping condition is met, the vector t_out will be shorter than t, and the final element of t_out will be the point at which the stopping condition was met, and may not correspond to any element of the vector t.

The first argument, fcn, is a string, inline, or function handle that names the function f to call to compute the vector of residuals for the set of equations. It must have the form

res = f (x, xdot, t)

in which x, xdot, and res are vectors, and t is a scalar.

If fcn is a two-element string array or a two-element cell array of strings, inline functions, or function handles, the first element names the function f described above, and the second element names a function to compute the modified Jacobian

     df       df
jac = -- + c ------
     dx     d xdot

The modified Jacobian function must have the form


jac = j (x, xdot, t, c)

The optional second argument names a function that defines the constraint functions whose roots are desired during the integration. This function must have the form

g_out = g (x, t)

and return a vector of the constraint function values. If the value of any of the constraint functions changes sign, DASRT will attempt to stop the integration at the point of the sign change.

If the name of the constraint function is omitted, dasrt solves the same problem as daspk or dassl.

Note that because of numerical errors in the constraint functions due to round-off and integration error, DASRT may return false roots, or return the same root at two or more nearly equal values of T. If such false roots are suspected, the user should consider smaller error tolerances or higher precision in the evaluation of the constraint functions.

If a root of some constraint function defines the end of the problem, the input to DASRT should nevertheless allow integration to a point slightly past that root, so that DASRT can locate the root by interpolation.

The third and fourth arguments to dasrt specify the initial condition of the states and their derivatives, and the fourth argument specifies a vector of output times at which the solution is desired, including the time corresponding to the initial condition.

The set of initial states and derivatives are not strictly required to be consistent. In practice, however, DASSL is not very good at determining a consistent set for you, so it is best if you ensure that the initial values result in the function evaluating to zero.

The sixth argument is optional, and may be used to specify a set of times that the DAE solver should not integrate past. It is useful for avoiding difficulties with singularities and points where there is a discontinuity in the derivative.

After a successful computation, the value of istate will be greater than zero (consistent with the Fortran version of DASSL).

If the computation is not successful, the value of istate will be less than zero and msg will contain additional information.

You can use the function dasrt_options to set optional parameters for dasrt.

See also: dasrt_options, daspk, dasrt, lsode.

Package: octave