You are on page 1of 23

1

Systems Realization Laboratory


Solving
Differential Algebraic Equations
(based on Continuous System Simulation by Cellier and Kofman)
Chris Paredis
G W Woodruff School of Mechanical Engineering
2009, Chris Paredis
G.W. Woodruff School of Mechanical Engineering
Systems Realization Laboratory
Product and Systems Lifecycle Management Center
Georgia Institute of Technology
Lecture Overview
Converting implicit DAE into semi-explicit DAE
Graph-based algorithm
Challenge 1: Algebraic Loops Challenge 1: Algebraic Loops
Tearing algorithm
Challenge 2: Structural singularities
What is it? How to deal with it?
Higher-index problems
Challenge 3: Handling Discrete Events
Systems Realization Laboratory 2009, Chris Paredis
Zero crossings
Overview of Dymola solvers and their properties
For more info refer to: Continuous System Simulation by Cellier and Kofman
2
DAE problems in Dymola
Object-oriented model results in implicit DAE system:
0 ( , , , ) F y y z t = &
Before solving, Dymola converts this into a semi-explicit DAE:
P bl th t d t b dd d
0
( , , )
( , , ) 0
(0)
y f y z t
g y z t
y y
=

&
0 ( , , , ) F y y z t = &
Systems Realization Laboratory 2009, Chris Paredis
Problems that need to be addressed:
Selection of state variables, y
Causality assignment: For each equation determine which variable is the
dependent variable
Order in which equations should be evaluated
Simple System Convert to Explicit ODE
0
1 1 1
2 2 2
( ) u f t
u R i
u R i
=
=
=
0 1
L
L
C
C
C
di
u L
dt
du
i C
dt
u u u
u u u
=
=
= +
+
Systems Realization Laboratory 2009, Chris Paredis
1 2
2
0 1
1 2
L
C
L
C
u u u
u u
i i i
i i i
= +
=
= +
= +
3
Causality Assignment and State Selection
State variables?
Variables for which derivatives appear
State variables can be considered as known
0
1 1 1
2 2 2
( ) u f t
u R i
u R i
=
=
=
Which are the unknowns?
Causality assignment:
If equation has only 1 unknown
it t l f k
0 1
L
L
C
C
C
di
u L
dt
du
i C
dt
u u u
u u u
=
=
= +
+
Systems Realization Laboratory 2009, Chris Paredis
use it to solve for unknown
If unknown appears only in 1 equation
use it to solve for unknown
1 2
2
0 1
1 2
L
C
L
C
u u u
u u
i i i
i i i
= +
=
= +
= +
Causality Assignment and State Selection
State variables?
Variables for which derivatives appear
State variables can be considered as known
0
1 1 1
2 2 2
( ) u f t
u R i
u R i
=
=
=
Which are the unknowns?
Causality assignment:
If equation has only 1 unknown
it t l f k
0 1 2 0 1 2

C L
L C
du di
u u u u i i i i
dt dt
0 1
L
L
C
C
C
di
u L
dt
du
i C
dt
u u u
u u u
=
=
= +
+
Systems Realization Laboratory 2009, Chris Paredis
use it to solve for unknown
If unknown appears only in 1 equation
use it to solve for unknown
1 2
2
0 1
1 2
L
C
L
C
u u u
u u
i i i
i i i
= +
=
= +
= +
4
Graph-Based Approach for Causality Assignment:
Tarjan Algorithm
0 0
1 1 1 1
( ) u f t u
u R i u
u R i u
=
=
=
2 2 2 2
0
0 1 1
1 2 2
( / )
( / )

L L L
C C
C
L
u R i u
u L di dt u
i C du dt i
u u u i
u u u i
=
=
=
= +
= +
Systems Realization Laboratory 2009, Chris Paredis
2
0 1
1 2
/
/
C C
L L
C C
u u i
i i i di dt
du dt i i i
=
= +
= +
Step 0: Connect Equations and Unknowns
0 0
1 1 1 1
( ) u f t u
u R i u
u R i u
=
=
=
2 2 2 2
0
0 1 1
1 2 2
( / )
( / )

L L L
C C
C
L
u R i u
u L di dt u
i C du dt i
u u u i
u u u i
=
=
=
= +
= +
Systems Realization Laboratory 2009, Chris Paredis
2
0 1
1 2
/
/
C C
L L
C C
u u i
i i i di dt
du dt i i i
=
= +
= +
5
Step 1: Identify Equations with Only 1 Unknown
Color Scheme:
Acausal equation =only black and blue lines
Causal equation =one red line
Unknownvariable =only black and blue lines Unknown variable only black and blue lines
Known variable =one red line
Algorithm step 1:
f or al l acausal equations do
i f equation has only one black line t hen
number equat i on wi t h l owest f r ee number
Systems Realization Laboratory 2009, Chris Paredis
number equat i on wi t h l owest f r ee number
col or l i ne r ed
f ol l ow l i ne t o var i abl e
col or al l ot her l i nes f or var i abl e bl ue
Step 2: Identify Variables in Only 1 Equation
Color Scheme:
Acausal equation =only black and blue lines
Causal equation =one red line
Unknownvariable =only black and blue lines Unknown variable only black and blue lines
Known variable =one red line
Algorithm step 1:
f or al l unknown variables do
i f variable has only one black line t hen
number equat i on wi t h hi ghest f r ee number
Systems Realization Laboratory 2009, Chris Paredis
number equat i on wi t h hi ghest f r ee number
col or l i ne r ed
f ol l ow l i ne t o equat i on
col or al l ot her l i nes f or equat i on bl ue
6
Final Result
(1)
(5)
(3)
0 0
1 1 1 1
( ) u f t u
u R i u
u R i u
=
=
= (3)
(10)
(9)
(4)
(7)
2 2 2 2
0
0 1 1
1 2 2
( / )
( / )

L L L
C C
C
L
u R i u
u L di dt u
i C du dt i
u u u i
u u u i
=
=
=
= +
= +
Systems Realization Laboratory 2009, Chris Paredis
(2)
(8)
(6)
2
0 1
1 2
/
/
C C
L L
C C
u u i
i i i di dt
du dt i i i
=
= +
= +
Final Result Sorted & Causality Assigned
0 0
2 2
: ( )
:
: /
C
u f t u
u u u
i u R i
=
=
=
(1)
(2)
(3)
2 2 2 2
1 0 1
1 1 1 1
1 2
1 2
: /
:
: /

:
:
C
C C
L L
i u R i
u u u u
i i u R
i i i i
u u u u
=
=
=
=
= +
(3)
(4)
(5)
(6)
(7)
Systems Realization Laboratory 2009, Chris Paredis
0 0 1
:
/ / : /
/ / : /
L
C C C
L L L
i i i i
du dt du dt i C
di dt di dt u L
= +
=
=
(8)
(9)
(10)
7
Lecture Overview
Converting implicit DAE into semi-explicit DAE
Graph-based algorithm
Challenge 1: Algebraic Loops Challenge 1: Algebraic Loops
Tearing algorithm
Challenge 2: Structural singularities
What is it? How to deal with it?
Higher-index problems
Challenge 3: Handling Discrete Events
Systems Realization Laboratory 2009, Chris Paredis
Zero crossings
Overview of Dymola solvers and their properties
System 2 Algebraic Loop
0
1 1 1
2 2 2
( ) u f t
u R i
u R i
=
=
=
2 2 2
3 3 3
0 1 3
1 2
L
L
L
u R i
di
u L
dt
u R i
u u u
u u u
=
=
= +
= +
Systems Realization Laboratory 2009, Chris Paredis
1 2
2 3
0 1
1 2 3
L
L
u u
i i i
i i i
=
= +
= +
8
0 0
1 1 1 1
( ) u f t u
u R i u
u R i u
=
=
=
Step 0: Connect Equations and Unknowns
2 2 2 2
3 3 3 0
0 1 3 1
1 2 2
( / )

L L L
L
u R i u
u L di dt u
u R i i
u u u i
u u u i
=
=
=
= +
= +
Systems Realization Laboratory 2009, Chris Paredis
3 2 3
0 1
3 1 2 3
/
L L
u u i
i i i di dt
u i i i
=
= +
= +
0 0
1 1 1 1
( ) u f t u
u R i u
u R i u
=
=
=
Step 1: Identify Equations
(1)
2 2 2 2
3 3 3 0
0 1 3 1
1 2 2
( / )

L L L
L
u R i u
u L di dt u
u R i i
u u u i
u u u i
=
=
=
= +
= +
Systems Realization Laboratory 2009, Chris Paredis
3 2 3
0 1
3 1 2 3
/
L L
u u i
i i i di dt
u i i i
=
= +
= +
9
0 0
1 1 1 1
( ) u f t u
u R i u
u R i u
=
=
=
Step 2: Identify Variables
(1)
2 2 2 2
3 3 3 0
0 1 3 1
1 2 2
( / )

L L L
L
u R i u
u L di dt u
u R i i
u u u i
u u u i
=
=
=
= +
= +
(10)
Systems Realization Laboratory 2009, Chris Paredis
3 2 3
0 1
3 1 2 3
/
L L
u u i
i i i di dt
u i i i
=
= +
= +
(9)
0 0
1 1 1 1
( ) u f t u
u R i u
u R i u
=
=
=
Step 1: Identify Equations None Available
(1)
2 2 2 2
3 3 3 0
0 1 3 1
1 2 2
( / )

L L L
L
u R i u
u L di dt u
u R i i
u u u i
u u u i
=
=
=
= +
= +
(10)
Systems Realization Laboratory 2009, Chris Paredis
3 2 3
0 1
3 1 2 3
/
L L
u u i
i i i di dt
u i i i
=
= +
= +
(9)
10
0 0
1 1 1 1
( ) u f t u
u R i u
u R i u
=
=
=
Step 2: Identify Variables
(1)
2 2 2 2
3 3 3 0
0 1 3 1
1 2 2
( / )

L L L
L
u R i u
u L di dt u
u R i i
u u u i
u u u i
=
=
=
= +
= +
(10)
(8)
Systems Realization Laboratory 2009, Chris Paredis
3 2 3
0 1
3 1 2 3
/
L L
u u i
i i i di dt
u i i i
=
= +
= +
(9)
STUCK!! Algebraic Loop
(1)
0 0
1 1 1 1
( ) u f t u
u R i u
u R i u
=
=
=
(10)
(8)
2 2 2 2
3 3 3 0
0 1 3 1
1 2 2
( / )

L L L
L
u R i u
u L di dt u
u R i i
u u u i
u u u i
=
=
=
= +
= +
Systems Realization Laboratory 2009, Chris Paredis
(9)
3 2 3
0 1
3 1 2 3
/
L L
u u i
i i i di dt
u i i i
=
= +
= +
11
Algebraic Loop Tearing Algorithm
6 equations in 6 unknowns
Simplify problem by assuming one of the unknown
variable to be known: e.g. i
3
variable to be known: e.g. i
3
If we knew i
3
, we could compute i
3new
Guess i
3
, and iterate until the residual is zero:
i
3new
- i
3
= 0 (residual equation)
Also works for nonlinear equations
With symbolic differentiation,
It ti i f t
3 3 3
2 3
2 2 2
1 0 3
1 1
:
:
: /
:
: /
i
u R i
u u
i u R
u u u
i u R
=
=
=
=
=
Systems Realization Laboratory 2009, Chris Paredis
Iteration is very fast
Multiple tearing variables may be needed
Tricky part: How to choose the tearing variable?
can only be determined using heuristics
3 1 2
:
new
i i i =
Tearing Algorithm
(1)
0 0
1 1 1 1
( ) u f t u
u R i u
u R i u
=
=
=
(10)
(8)
2 2 2 2
3 3 3 0
0 1 3 1
1 2 2
( / )

L L L
L
u R i u
u L di dt u
u R i i
u u u i
u u u i
=
=
=
= +
= +
Systems Realization Laboratory 2009, Chris Paredis
(9)
tear
3 2 3
0 1
3 1 2 3
/
L L
u u i
i i i di dt
u i i i
=
= +
= +
12
Tearing Algorithm
(1)
0 0
1 1 1 1
( ) u f t u
u R i u
u R i u
=
=
=
(10)
(8)
(2*)
2 2 2 2
3 3 3 0
0 1 3 1
1 2 2
( / )

L L L
L
u R i u
u L di dt u
u R i i
u u u i
u u u i
=
=
=
= +
= +
Systems Realization Laboratory 2009, Chris Paredis
(9)
tear
3 2 3
0 1
3 1 2 3
/
L L
u u i
i i i di dt
u i i i
=
= +
= +
Tearing Algorithm
(1)
0 0
1 1 1 1
( ) u f t u
u R i u
u R i u
=
=
=
(10)
(8)
(2*)
(3*)
2 2 2 2
3 3 3 0
0 1 3 1
1 2 2
( / )

L L L
L
u R i u
u L di dt u
u R i i
u u u i
u u u i
=
=
=
= +
= +
Systems Realization Laboratory 2009, Chris Paredis
(9)
tear (4*)
3 2 3
0 1
3 1 2 3
/
L L
u u i
i i i di dt
u i i i
=
= +
= +
13
Tearing Algorithm
(1)
(5*)
(6*)
0 0
1 1 1 1
( ) u f t u
u R i u
u R i u
=
=
=
(10)
(8)
(6 )
(2*)
(3*)
2 2 2 2
3 3 3 0
0 1 3 1
1 2 2
( / )

L L L
L
u R i u
u L di dt u
u R i i
u u u i
u u u i
=
=
=
= +
= +
Systems Realization Laboratory 2009, Chris Paredis
(9)
tear (4*)
residual
3 2 3
0 1
3 1 2 3
/
L L
u u i
i i i di dt
u i i i
=
= +
= +
Algebraic Loop Example Summary
0
( , , )
( , , ) 0
(0)
y f y z t
g y z t
y y
=

&
0 ( , , , ) F y y z t = &
0
(0) y y

: /
L
L
di
u L
dt
=
3 3 3
2 3
2 2 2
:
:
: /
:
u R i
u u
i u R
u u u
=
=
=
0
: ( ) u f t =
1 2
0 1
:
:
L
L
u u u
i i i
= +
= +
Algebraic Equations
Differential Equation
Systems Realization Laboratory 2009, Chris Paredis
dt
1 0 3
1 1
3 1 2
:
: /
:
i
new
u u u
i u R
i i i
=
=
=
Solve Iteratively
0 1 L
14
Lecture Overview
Converting implicit DAE into semi-explicit DAE
Graph-based algorithm
Challenge 1: Algebraic Loops Challenge 1: Algebraic Loops
Tearing algorithm
Challenge 2: Structural singularities
What is it? How to deal with it?
Higher-index problems
Challenge 3: Handling Discrete Events
Systems Realization Laboratory 2009, Chris Paredis
Zero crossings
Overview of Dymola solvers and their properties
System 3 Structural Singularity
0
1 1 1
2 2 2
( ) u f t
u R i
u R i
=
=
=
0 1
L
L
C
C
L
di
u L
dt
du
i C
dt
u u u
u u u
=
=
= +
+
Systems Realization Laboratory 2009, Chris Paredis
1 2
2
0 1
1 2
C
L
C
L
u u u
u u
i i i
i i i
= +
=
= +
= +
15
0 0
1 1 1 1
( ) u f t u
u R i u
u R i u
=
=
=
Step 0: Connect Equations and Unknowns
2 2 2 2
0
0 1 1
2 1 2
( / )
( / )

L L L
C C
L
C
u R i u
u L di dt u
i C du dt i
u u u i
i u u u
=
=
=
= +
= +
Systems Realization Laboratory 2009, Chris Paredis
2
0 1
1 2
/
/
C L
L C
C L
i u u
di dt i i i
du dt i i i
=
= +
= +
0 0
1 1 1 1
( ) u f t u
u R i u
u R i u
=
=
=
Apply Both Rules
(1)
2 2 2 2
0
0 1 1
2 1 2
( / )
( / )

L L L
C C
L
C
u R i u
u L di dt u
i C du dt i
u u u i
i u u u
=
=
=
= +
= +
(10)
(9)
Systems Realization Laboratory 2009, Chris Paredis
2
0 1
1 2
/
/
C L
L C
C L
i u u
di dt i i i
du dt i i i
=
= +
= +
(8)
16
STUCK! Structural Singularity
(1)
0 0
1 1 1 1
( ) u f t u
u R i u
u R i u
=
=
=
(10)
(9)
2 2 2 2
0
0 1 1
2 1 2
( / )
( / )

L L L
C C
L
C
u R i u
u L di dt u
i C du dt i
u u u i
i u u u
=
=
=
= +
= +
Systems Realization Laboratory 2009, Chris Paredis
(8)
2
0 1
1 2
/
/
C L
L C
C L
i u u
di dt i i i
du dt i i i
=
= +
= +
What is the problem?
0
1 1 1
2 2 2
( ) u f t
u R i
u R i
=
=
=
0 1
L
L
C
C
L
di
u L
dt
du
i C
dt
u u u
u u u
=
=
= +
+
Systems Realization Laboratory 2009, Chris Paredis
1 2
2
0 1
1 2
C
L
C
L
u u u
u u
i i i
i i i
= +
=
= +
= +
17
Structural Singularity
Main approach Pantelides Algorithm
Use symbolic differentiation to remove singularity in equations
1. Determine constraint equation (could be hidden use tearing)
2. Differentiate constraint equation and assign dummy derivatives
3. Remove corresponding integration equations remain square
Details of algorithm are tricky
(For details see: Continuous System Simulation by Cellier and Kofman)
Systems Realization Laboratory 2009, Chris Paredis
Algorithm is also called an index reduction algorithm
What is an index?
Characteristic of DAE: Perturbation Index
Loosely defined:
The number of differentiations needed
to turn a DAE into a pure ODE
Examples:
Pure ODE is index-0
Systems Realization Laboratory 2009, Chris Paredis
ODE with algebraic loop is index-1
Structurally singular system index-2 (or larger)
18
Lecture Overview
Converting implicit DAE into semi-explicit DAE
Graph-based algorithm
Challenge 1: Algebraic Loops Challenge 1: Algebraic Loops
Tearing algorithm
Challenge 2: Structural singularities
What is it? How to deal with it?
Higher-index problems
Challenge 3: Handling Discrete Events
Systems Realization Laboratory 2009, Chris Paredis
Zero crossings
Overview of Dymola solvers and their properties
Mixed Systems: DAE + Discrete event
mg
At impact: v -v*k
[]
equation
Discrete Event
Systems Realization Laboratory 2009, Chris Paredis
mg
equation
when height <=radius then
reinit( velocity, -k*pre(velocity) )
end when
end
19
Mixed DAEs
Hybrid systems require additional solver
capabilities:
1. Event Detection solving for zero-crossings g g
Height changes continuously as function of time
step size needs to be selected such that height =radius
2. Event Handling
Stop the integration algorithm
Find a new state consistent with the algebraic constraints
Restart the integrationalgorithm
Systems Realization Laboratory 2009, Chris Paredis
Restart the integration algorithm
Be careful!
Event handling can be slow
Chattering
Summary of Method Characteristics
Appropriate for DAE or only ODE?
Capable of finding initial conditions?
Especiallyimportant for hybrid DAE Especially important for hybrid DAE
Capable of solving Stiff systems?
Stiff implies implicit method
Capable of handling overdetermined systems?
More convenient than having to remove redundant constraints
manually
Systems Realization Laboratory 2009, Chris Paredis
Order of method?
Typically higher is better
20
Dymola Methods
Method Model
Type
Order Stiff Root
Find
Algorithm
DEABM ODE 1-12 No No Adams/Bashforth/Moulton; reliable, maybe slow
LSODE1 ODE 1-12 No No Adams/Bashforth/Moulton; faster than DEABM
LSODE2 ODE 1-5 Yes No Backward Difference Formulae; Gear method
LSODAR ODE 1-12, 1-5 Both Yes Adams/Bashforth/Moulton
DOPRI5 ODE 5 No No Runge-Kutta by Dormand and Prince
DOPRI8 ODE 8 No No Runge-Kutta by Dormand and Prince
GRK4T ODE 4 Yes No Linearly-implicit Rosenbrock
Systems Realization Laboratory 2009, Chris Paredis
DASSL DAE 1-5 Yes Yes BDF; default choice in Dymola
ODASSL ODAE 1-5 Yes Yes Modified DASSL for overdetermined DAEs
MEXX ODAE 2-24 No No Special index-2 DAE; not for ODE!
Summary
Identify types and properties of ODE systems
Identify types and properties of ODE solvers
Accuracy
Convergence Convergence
Stability
Stiffness
Higher Order Methods and their properties
Causalization, tearing, index reduction
Complexities of mixed DAE problems
Overview of Dymola solvers and their properties
Systems Realization Laboratory 2009, Chris Paredis
Solver implementation is for Professionals Only
Do not try this at home
Not-so-fine print:
21
Step 1: Identify Equations with Only 1 Unknown
(1)
0 0
1 1 1 1
( ) u f t u
u R i u
u R i u
=
=
=
2 2 2 2
0
0 1 1
1 2 2
( / )
( / )

L L L
C C
C
L
u R i u
u L di dt u
i C du dt i
u u u i
u u u i
=
=
=
= +
= +
Systems Realization Laboratory 2009, Chris Paredis
(2)
2
0 1
1 2
/
/
C C
L L
C C
u u i
i i i di dt
du dt i i i
=
= +
= +
Solution for Example 1
Step 2: Identify Variables in Only 1 Equation
(1)
0 0
1 1 1 1
( ) u f t u
u R i u
u R i u
=
=
=
(10)
(9)
2 2 2 2
0
0 1 1
1 2 2
( / )
( / )

L L L
C C
C
L
u R i u
u L di dt u
i C du dt i
u u u i
u u u i
=
=
=
= +
= +
Systems Realization Laboratory 2009, Chris Paredis
(2)
(8)
2
0 1
1 2
/
/
C C
L L
C C
u u i
i i i di dt
du dt i i i
=
= +
= +
Solution for Example 1
22
Repeat Step 1: Identify Equations
(1)
(3)
0 0
1 1 1 1
( ) u f t u
u R i u
u R i u
=
=
= (3)
(10)
(9)
(4)
2 2 2 2
0
0 1 1
1 2 2
( / )
( / )

L L L
C C
C
L
u R i u
u L di dt u
i C du dt i
u u u i
u u u i
=
=
=
= +
= +
Systems Realization Laboratory 2009, Chris Paredis
(2)
(8)
2
0 1
1 2
/
/
C C
L L
C C
u u i
i i i di dt
du dt i i i
=
= +
= +
Solution for Example 1
Repeat Step 2: Identify Variables
(1)
(3)
0 0
1 1 1 1
( ) u f t u
u R i u
u R i u
=
=
= (3)
(10)
(9)
(4)
(7)
2 2 2 2
0
0 1 1
1 2 2
( / )
( / )

L L L
C C
C
L
u R i u
u L di dt u
i C du dt i
u u u i
u u u i
=
=
=
= +
= +
Systems Realization Laboratory 2009, Chris Paredis
(2)
(8)
(6)
2
0 1
1 2
/
/
C C
L L
C C
u u i
i i i di dt
du dt i i i
=
= +
= +
Solution for Example 1
23
Repeat Step 1: Identify Equations
(1)
(5)
(3)
0 0
1 1 1 1
( ) u f t u
u R i u
u R i u
=
=
= (3)
(10)
(9)
(4)
(7)
2 2 2 2
0
0 1 1
1 2 2
( / )
( / )

L L L
C C
C
L
u R i u
u L di dt u
i C du dt i
u u u i
u u u i
=
=
=
= +
= +
Systems Realization Laboratory 2009, Chris Paredis
(2)
(8)
(6)
2
0 1
1 2
/
/
C C
L L
C C
u u i
i i i di dt
du dt i i i
=
= +
= +
Solution for Example 1

You might also like