Main Content

decic

Find consistent initial conditions for first-order implicit ODE system with algebraic constraints

Description

example

[y0,yp0] = decic(eqs,vars,constraintEqs,t0,y0_est,fixedVars,yp0_est,options) finds consistent initial conditions for the system of first-order implicit ordinary differential equations with algebraic constraints returned by the reduceDAEToODE function.

The call [eqs,constraintEqs] = reduceDAEToODE(DA_eqs,vars) reduces the system of differential algebraic equations DA_eqs to the system of implicit ODEs eqs. It also returns constraint equations encountered during system reduction. For the variables of this ODE system and their derivatives, decic finds consistent initial conditions y0, yp0 at the time t0.

Substituting the numerical values y0, yp0 into the differential equations subs(eqs, [t; vars(t); diff(vars(t))], [t0; y0; yp0]) and the constraint equations subs(constr, [t; vars(t); diff(vars(t))], [t0; y0; yp0]) produces zero vectors. Here, vars must be a column vector.

y0_est specifies numerical estimates for the values of the variables vars at the time t0, and fixedVars indicates the values in y0_est that must not change during the numerical search. The optional argument yp0_est lets you specify numerical estimates for the values of the derivatives of the variables vars at the time t0.

Examples

Find Consistent Initial Conditions for ODE System

Reduce the DAE system to a system of implicit ODEs. Then, find consistent initial conditions for the variables of the resulting ODE system and their first derivatives.

Create the following differential algebraic system.

syms x(t) y(t)
DA_eqs = [diff(x(t),t) == cos(t) + y(t),...
          x(t)^2 + y(t)^2 == 1];
vars = [x(t); y(t)];

Use reduceDAEToODE to convert this system to a system of implicit ODEs.

[eqs, constraintEqs] = reduceDAEToODE(DA_eqs, vars)
eqs =
                 diff(x(t), t) - y(t) - cos(t)
 - 2*x(t)*diff(x(t), t) - 2*y(t)*diff(y(t), t)
 
constraintEqs =
1 - y(t)^2 - x(t)^2

Create an option set that specifies numerical tolerances for the numerical search.

options = odeset('RelTol', 10.0^(-7), 'AbsTol', 10.0^(-7));

Fix values t0 = 0 for the time and numerical estimates for consistent values of the variables and their derivatives.

t0 = 0;
y0_est = [0.1, 0.9];
yp0_est = [0.0, 0.0];

You can treat the constraint as an algebraic equation for the variable x with the fixed parameter y. For this, set fixedVars = [0 1]. Alternatively, you can treat it as an algebraic equation for the variable y with the fixed parameter x. For this, set fixedVars = [1 0].

First, set the initial value x(t0) = y0_est(1) = 0.1.

fixedVars = [1 0];
[y0,yp0] = decic(eqs,vars,constraintEqs,t0,y0_est,fixedVars,yp0_est,options)
y0 =
    0.1000
    0.9950

yp0 =
    1.9950
   -0.2005

Now, change fixedVars to [0 1]. This fixes y(t0) = y0_est(2) = 0.9.

fixedVars = [0 1];
[y0,yp0] = decic(eqs,vars,constraintEqs,t0,y0_est,fixedVars,yp0_est,options)
y0 =
   -0.4359
    0.9000

yp0 =
    1.9000
    0.9202

Verify that these initial values are consistent initial values satisfying the equations and the constraints.

subs(eqs, [t; vars; diff(vars,t)], [t0; y0; yp0])
ans =
 0
 0
subs(constraintEqs, [t; vars; diff(vars,t)], [t0; y0; yp0])
ans =
0

Input Arguments

collapse all

System of implicit ordinary differential equations, specified as a vector of symbolic equations or expressions. Here, expressions represent equations with zero right side.

Typically, you use expressions returned by reduceDAEToODE.

State variables of original DAE system, specified as a vector of symbolic functions or function calls, such as x(t).

Example: [x(t),y(t)] or [x(t);y(t)]

Constraint equations encountered during system reduction, specified as a vector of symbolic equations or expressions. These expressions or equations depend on the variables vars, but not on their derivatives.

Typically, you use constraint equations returned by reduceDAEToODE.

Initial time, specified as a number.

Estimates for the values of the variables vars at the initial time t0, specified as a numeric vector.

Input vector indicating which elements of y0_est are fixed values, specified as a vector with 0s or 1s. Fixed values of y0_est correspond to values 1 in fixedVars. These values are not modified during the numerical search. The zero entries in fixedVars correspond to those variables in y0_est for which decic solves the constraint equations. The number of 0s must coincide with the number of constraint equations. The Jacobian matrix of the constraints with respect to the variables vars(fixedVars == 0) must be invertible.

Estimates for the values of the first derivatives of the variables vars at the initial time t0, specified as a numeric vector.

Options for numerical search, specified as an options structure, returned by odeset. For example, you can specify tolerances for the numerical search here.

Output Arguments

collapse all

Consistent initial values for variables, returned as a numeric column vector.

Consistent initial values for first derivatives of variables, returned as a numeric column vector.

Introduced in R2014b