DAE Example 3: local truncation error order one.Backward Difference Formula
Using the backward difference formula directly on the equations, without algebraic manipulation, results in a system of equations that provides solutions for:
- C1 and C2 (with delta t2 order error)
- C3 (with delta t order error)
Executing Successive Approximations
Executing successive approximations (many steps of time) does not guarantee that the constraint (e.g., C1 + C2 = 0) is fulfilled exactly due to error propagation. The formulation of the model is crucial. This problem, where C3 = 0, is similar to the Stirred Tank Problem 2, losing one order of accuracy.
Using Constraints
Using constraints to simplify equations and eliminate variables can be beneficial, but it may lead to numerical solutions that no longer satisfy the constraint exactly, drifting away from the algebraic equation.
Differential Index
This behavior is referred to as the Differential Index of a DAE system.
Defining and Calculating Differential Index
The index of a DAE system is characterized by how many time derivatives are required to transform it into a system of independent ODEs with differentials of all the unknowns.
Stirred Tank Example 1 Index
Two unknowns: C1, C2.
There is one equation with a differential of C2.
Differentiating the algebraic equation (eq 2) gives a differential equation for C1.
Now, there are ODEs for C1 and C2. Just one derivative of the algebraic constraint was required. DAEs of this form are referred to as index one DAE. Index one DAEs are simple to solve and act like ODE IVPs, with identical local truncation error (order delta t2).
Stirred Tank Example 2 Index
Same equations, but use C2 in the algebraic equation instead of C1. Differentiate the algebraic equation to provide a differential equation for C2, but there already is one. To obtain an ODE for C1, substitute the known DC2DT into the derived equation and solve for C1.
Take another derivative of this resulting equation to obtain a differential equation for C1. Two derivatives were required to produce a system of independent ODEs. This is referred to as index 2. Index 2 problems are more likely to drop an order of accuracy and are more sensitive.
DAE Example 3 Index
C1 = DC2DT, C2 = DC3DT, C3 = gamma(t). There is a missing ODE for C1. Take a derivative of the algebraic equation C3 = gamma. Obtain DC3DT = gamma dot. Plug into C2 = DC3DT to obtain C2 = gamma dot.
This is not an ODE for C1. Take the derivative once more to obtain C2 dot = gamma dot dot. C2 dot equals C1 (from the original equation). Plug in again and take a third derivative of the original algebraic constraint (three derivatives total). This results in a differential equation for C1 (DC1DT = gamma dot dot dot). ODEs can be created for C1, C2, and C3. This is an index 3 DAE. Substituting the DAE with these derivatives is not always advisable because solutions may drift away from the constraints. Solutions need to be restricted to the manifold described by the DAE, so additional initial conditions or constraints are needed. This relates to consistent initialization. The calculation of the index aids in comprehending the system's sensitivity.
Formal Definition (Semi-Explicit DAE)
For a semi-explicit DAE system (x dot = f(x, y, t), 0 = g(x, y, t)), the differential index is the minimum number of differentiations needed to transform it into a system of independent ODEs. Differentiating the algebraic equation g = 0 with respect to time gives an equation depending on dx/dt, dy/dt, x, y, and t. Inserting dx/dt = f provides an equation that can be solved for dy/dt. If the Jacobian of g with respect to y (dg/dy) is of full rank (invertible), then dy/dt can be solved for, and the system is of index one. Issues occur when dg/dy is not full rank (singular), making it difficult to solve for y using techniques such as Newton-Raphson since the Jacobian becomes singular. Index one DAEs share this invertible Jacobian characteristic; higher index DAEs do not.
Examples of Index Calculation (Mixing Tanks)
The differential index is the most important thing to know about a model, as it indicates its sensitivity to perturbations.
Mixing Tanks Example 1:
Two mixing tanks with flows and concentrations. Material balances give differential equations for C2 and C4. Algebraic constraints: C1 = gamma1(t), C3 = gamma2(t) (inputs are measured/prescribed).
Example 2: Same tanks, different algebraic constraints:
- C3=gamma1(t), C4=gamma2(t) (outputs are measured/prescribed).
- Take a derivative of the algebraic equations (DC3DT, DC4DT).
- DC3DT=gamma1 dot is known, but there was previously an equation for DC3DT.
- Need ODEs for C1 and C2.
- DC4DT=gamma2 dot is known; plug this into the C4 material balance.
- This results in a new algebraic equation.
- Take a derivative of this new equation.
- Plug in known derivatives (DC2DT, DC3DT, DC4DT).
This results in an algebraic equation in terms of C1. Take an additional derivative (total three derivatives of the initial algebraic constraints). This provides a DC1DT term, so an ODE for C1 results. ODEs can be constructed for all the variables. It's differential index three. This is to be expected since taking a measure of a downstream output (C4) to estimate an initial input (C1) is sensitive by its nature.
Sensitivity and Solvers
Sensitivity increases with index:
- Index 1 solutions are like ODEs, not sensitive.
- Index 2 solutions indicate sensitivity to the derivative of the forcing function (gamma dot).
- Index 3 solutions indicate enormous sensitivity to the second derivative of the forcing function (gamma dot dot).
Mechanical Systems and Consistent Initialization
Constrained mechanical systems are usually index 3 DAE. A back-and-forth swinging pendulum is one example.
- Equations: dx/dt=v, dv/dt equals gravity and spring force (spring constant k).
- Algebraic constraint on the position (constant arm length).
- Differential variables are velocity (v) and position (x), the algebraic variable is the spring constant k.
- k needs to change dynamically.
This system is demonstrated to be index 3. Derivatives of the algebraic constraint produce the hidden constraints:
- 1st derivative -> v and p are orthogonal
- 2nd derivative -> the relationship between k, x, and v
- 3rd derivative -> ODE for k.
Initial Conditions
Being converted into an equivalent ODE system is not necessarily desirable; the solutions may wander away from the original constraints. Solutions need the correct initial conditions. When initial conditions are in conflict, there will be:
- Step jumps
- Erratic behavior
- Solver error
- Divergence on a different manifold
Pendulum Initial Conditions
Can the initial position be random?
No, it has to obey the algebraic constraint (constant arm length).
Can the initial velocity be random?
No. The "hidden constraint" (velocity is orthogonal to position, determined through the 1st derivative of the algebraic constraint) has to be obeyed. Initial conditions need to be solutions to the equations, including the hidden ones.
Can k, the initial stiffness, be set arbitrarily?
No. The implicit constraint in the 2nd derivative ties k to position and velocity at first.
These implicit constraints are within the DAE framework.
Solving DAEs
Index one, semi-explicit DAEs can usually be treated safely by vanilla ODE solvers in MATLAB (such as ODExx) by giving a mass matrix.
If the DAE isn't index one, MATLAB might find it. Special DAE solvers such as Sundials or DAEpack are specially geared for higher index problems. They're rooted in schemes such as backward difference formulas but employ thoughtful examination to reduce errors and remain on the correct solution manifold. They need initial conditions.
Consistent Initialization Formalism
For an ODE IVP, initial values of the state (x) and its derivative (x dot) specify the beginning. For a fully implicit DAE F(x, x_dot, t)=0 with N unknowns (x, x_dot), there are N equations.
Constraints in Index Analysis
A constraint hidden from the index analysis (to obtain the ODE for C1) restricts DC2DT(0) (DC2DT(0)=gamma dot(0)).
Unknowns and Constraints
There are three unknowns:
Additionally, there are three known constraints.
Final Examples on Initial Conditions
No free variables to define; initial conditions are known by the measured signal (gamma and its derivative).
Example 1: Index 2
Timeframe: 43:20 - 45:20
In the example given above (index 2), there was an implicit constraint that:
- Initial values of C1 and C2 add up to zero
- C3 initially equals zero
This constraint is obtained from index analysis. There are five possible unknowns:
- C1(0)
- C2(0)
- C3(0)
- C1dot(0)
- C2dot(0)
And four constraints from DAE structure and index analysis. This provides one degree of freedom to assign one additional initial condition consistently. Overconstrained is fine; underconstrained is not.
Example 2: ODE for C3
Timeframe: 45:20 - 46:44
As a second example, reducing to an ODE for C3 does not add new constraints on the initial values/derivatives of C1, C2, and C3 from the initial DAE equations. There are:
- Five possible initial unknowns (C1(0), C2(0), C3(0), C1dot(0), C2dot(0))
- Three from the initial equations
This leaves two degrees of freedom to select initial conditions consistently.
Timeframe: 46:44 - 46:48 - Lecture end.