You are on page 1of 23 Solving
Differential Algebraic Equations
(based on Continuous System Simulation by Cellier and Kofman)
Systems Realization Laboratory
Chris Paredis
G W
.
.
W
oo
d
ru
ff S
c
h
oo
l
o
f M
ec
h
an ca
i
l E
ng neer ng
i
i
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

Tearing algorithm

Challenge 2: Structural singularities

What is it?

How to deal with it?

Higher-index problems

Challenge 3: Handling Discrete Events

Zero crossings

Overview of Dymola solvers and their properties

For more info refer to: Continuous System Simulation by Cellier and Kofman Systems Realization Laboratory ### DAE problems in Dymola

Object-oriented model results in implicit DAE system:

### ,)

Before solving, Dymola converts this into a semi-explicit DAE:

### ,) ### y

0

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 Systems Realization Laboratory  Simple System – Convert to Explicit ODE
u
=
ft ( )
0
u
=
Ri
1
11
u
=
Ri
2
22
di
L
u
=
L
L
dt
du
C
i
=
C
C
dt
u
=
uu
+
0
1
C
u
=
uu
+
L
1
2
u
=
u
2
C
i
= +
ii
0
1
L
iii
=
+
1
2
C
Systems Realization Laboratory Causality Assignment and State Selection
u
=
ft ( )
0
State variables?
u
=
Ri
1
11
Variables for which derivatives appear
State variables can be considered as known
u
=
Ri
2
22
di
L
u
=
L
Which are the unknowns?
L
dt
du
C
i
=
C
C
dt
Causality assignment:
u
=
uu
+
0
1
C
If equation has only 1 unknown
use it to solve for unknown
u
=
uu
+
L
1
2
u
=
u
2
C
If unknown appears only in 1 equation
use it to solve for unknown
i
= +
ii
0
1
L
iii
=
+
1
2
C
Systems Realization Laboratory
Causality Assignment and State Selection
u
=
ft ( )
0
State variables?
u
=
Ri
Variables for which derivatives appear
State variables can be considered as known
1
11
u
=
Ri
2
22
di
L
u
=
L
Which are the unknowns?
L
dt
di
du
L
C
u
uu
u
iiii
du
0
1
2
L
012
C
C
i
=
C
dt
dt
C
dt
Causality assignment:
u
=
uu
+
0
1
C
If equation has only 1 unknown
use it to solve for unknown
u
=
uu
+
L
1
2
u
=
u
2
C
If unknown appears only in 1 equation
use it to solve for unknown
i
= +
ii
0
1
L
iii
=
+
1
2
C
Systems Realization Laboratory Graph-Based Approach for Causality Assignment:
Tarjan Algorithm
u
=
ft ( )
u
0
0
u
=
Ri
u
1
11
1
u
=
Ri
u
2
22
2
u
=
L
⋅ (
di
/)
dt
u
L
L
L
i
=
C
⋅ (
du
/)
dt
i
C
C
0
u
=
uu
+
i
0
1
C
1
u
=
uu
+
i
L
12
2
uu
=
i
C
2
C
i
= +
i
i
di
/
dt
0
1
L
L
iii
=
+
du
/
dt
1
2
C
C
Systems Realization Laboratory
Step 0: Connect Equations and Unknowns
u
=
ft ( )
u
0
0
u
=
Ri
u
1
11
1
u
=
Ri
u
2
22
2
u
=
L
⋅ (
di
/)
dt
u
L
L
L
i
=
C
⋅ (
du
/)
dt
i
C
C
0
u
=
uu
+
i
0
1
C
1
u
=
uu
+
i
L
12
2
uu
=
i
C
2
C
i
= +
i
i
di
/
dt
0
1
L
L
iii
=
+
du
/
dt
1
2
C
C
Systems Realization Laboratory Step 1: Identify Equations with Only 1 Unknown
Color Scheme:
Acausal equation = only black and blue lines
Causal equation = one red line
Unknown variable = only black and blue lines
Known variable = one red line
Algorithm – step 1:
for all acausal equations do
if equation has only one black line then
n mber e
u
qu
ation
w
ith lo est free n mber
w
u
color line red
color all other lines for variable blue
Systems Realization Laboratory
Step 2: Identify Variables in Only 1 Equation
Color Scheme:
Acausal equation = only black and blue lines
Causal equation = one red line
Unknown variable = only black and blue lines
Known variable = one red line
Algorithm – step 1:
for all unknown variables do
if variable has only one black line then
n mber e
u
qu
ation
w
ith hi hest free n mber
g
u
color line red
color all other lines for equation blue
Systems Realization Laboratory Final Result
(1)
u
=
ft ( )
u
0
0
(5)
u
=
Ri
u
1
11
1
(3)
u
=
Ri
u
2
22
2
(10)
u
=
L
⋅ (
di
/)
dt
u
L
L
L
(9)
i
=
C
⋅ (
du
/)
dt
i
C
C
0
(4)
u
=
uu
+
i
0
1
C
1
(7)
u
=
uu
+
i
L
12
2
(2)
uu
=
i
C
2
C
(8)
i
= +
i
i
di
/
dt
0
1
L
L
(6)
iii
=
+
du
/
dt
1
2
C
C
Systems Realization Laboratory (10)
du
di
(1)
(7)
(6)
(5)
(4)
(2)
(3)
(9)
(8)
i 0
u
u
u
u
C
C
L
L
0
2
i
i
i
1
:  u
L
: = ii −
uu
: = +
uu
uR
22
11
ii
: = u
2 : =
ft
/ C
/ L
du
C /
L /
()
dt
dt
dt
dt
di
: =
: =
R
=
+
=
=
=
i 0
u
u
u
u
u
i 1
C
C
C
C
L
L
/
/
0
2
2
2
2
i
i
i
1
1
1
1
:

/:

Systems Realization Laboratory 10

/:

### Lecture Overview

Converting implicit DAE into semi-explicit DAE

Graph-based algorithm 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

Zero crossings

Overview of Dymola solvers and their properties Systems Realization Laboratory ### System 2 – Algebraic Loop u

0

u

=

ft ( )

=

Ri

1 11 u
=
Ri
2
22
di
L
u
=
L
L
dt
u
=
Ri
3
33
u
=
uu
+
0
13
u
=
uu
+
L
1
2 u

2

i

0

1

=

u

3

ii

= +

1

L

iii

=

+

23 Systems Realization Laboratory  Step 0: Connect Equations and Unknowns
u
=
ft ( )
u
0
0
u
=
Ri
u
1
11
1
u
=
Ri
u
2
22
2
u
=
L
⋅ (
di
/)
dt
u
L
L
L
u
=
Ri
i
3
33
0
u
=
uu
+
i
0
13
1
u
=
uu
+
i
L
12
2
uu
=
i
32
3
i
= +
i
i
di
/
dt
0
1
L
L
iii
=
+
u
1
23
3
Systems Realization Laboratory
Step 1: Identify Equations
(1)
u
=
ft ( )
u
0
0
u
=
Ri
u
1
11
1
u
=
Ri
u
2
22
2
u
=
L
⋅ (
di
/)
dt
u
L
L
L
u
=
Ri
i
3
33
0
u
=
uu
+
i
0
13
1
u
=
uu
+
i
L
12
2
uu
=
i
32
3
i
= +
i
i
di
/
dt
0
1
L
L
iii
=
+
u
1
23
3
Systems Realization Laboratory Step 2: Identify Variables
(1)
u
=
ft ( )
u
0
0
u
=
Ri
u
1
11
1
u
=
Ri
u
2
22
2
(10)
u
=
L
⋅ (
di
/)
dt
u
L
L
L
u
=
Ri
i
3
33
0
u
=
uu
+
i
0
13
1
u
=
uu
+
i
L
12
2
uu
=
i
32
3
(9)
i
= +
i
i
di
/
dt
0
1
L
L
iii
=
+
u
1
23
3
Systems Realization Laboratory
Step 1: Identify Equations – None Available
(1)
u
=
ft ( )
u
0
0
u
=
Ri
u
1
11
1
u
=
Ri
u
2
22
2
(10)
u
=
L
⋅ (
di
/)
dt
u
L
L
L
u
=
Ri
i
3
33
0
u
=
uu
+
i
0
13
1
u
=
uu
+
i
L
12
2
uu
=
i
32
3
(9)
i
= +
i
i
di
/
dt
0
1
L
L
iii
=
+
u
1
23
3
Systems Realization Laboratory Step 2: Identify Variables
(1)
u
=
ft ( )
u
0
0
u
=
Ri
u
1
11
1
u
=
Ri
u
2
22
2
(10)
u
=
L
⋅ (
di
/)
dt
u
L
L
L
u
=
Ri
i
3
33
0
u
=
uu
+
i
0
13
1
(8)
u
=
uu
+
i
L
12
2
uu
=
i
32
3
(9)
i
= +
i
i
di
/
dt
0
1
L
L
iii
=
+
u
1
23
3
Systems Realization Laboratory
STUCK!! – Algebraic Loop
(1)
u
=
ft ( )
u
0
0
u
=
Ri
u
1
11
1
u
=
Ri
u
2
22
2
(10)
u
=
L
⋅ (
di
/)
dt
u
L
L
L
u
=
Ri
i
3
33
0
u
=
uu
+
i
0
13
1
(8)
u
=
uu
+
i
L
12
2
uu
=
i
32
3
(9)
i
= +
i
i
di
/
dt
0
1
L
L
iii
=
+
u
1
23
3
Systems Realization Laboratory

### 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

If we knew i 3 , we could compute i 3new

u

3

: =

Ri

33

Guess i 3 , and iterate until the residual is zero:

u

: =

u

i 3new - i 3 = 0 (residual equation)

Also works for nonlinear equations

2

i

2

:

u

1

i

1

:

i

3

new

Tricky part: How to choose the tearing variable?

=

3

/

uR

22

: =

uu

03

With symbolic differentiation, Iteration is very fast

=

/

uR

i

1

= ii

Multiple tearing variables may be needed

can only be determined using heuristics

:

12 Systems Realization Laboratory  Tearing Algorithm
(1)
u
=
ft ( )
u
0
0
u
=
Ri
u
1
11
1
u
=
Ri
u
2
22
2
(10)
u
=
L
⋅ (
di
/)
dt
u
L
L
L
u
=
Ri
i
3
33
0
u
=
uu
+
i
0
13
1
(8)
u
=
uu
+
i
L
12
2
uu
=
i
tear
32
3
(9)
i
= +
i
i
di
/
dt
0
1
L
L
iii
=
+
u
1
23
3
Systems Realization Laboratory Tearing Algorithm
(1)
u
=
ft ( )
u
0
0
u
=
Ri
u
1
11
1
u
=
Ri
u
2
22
2
(10)
u
=
L
⋅ (
di
/)
dt
u
L
L
L
(2*)
u
=
Ri
i
3
33
0
u
=
uu
+
i
0
13
1
(8)
u
=
uu
+
i
L
12
2
uu
=
i
tear
32
3
(9)
i
= +
i
i
di
/
dt
0
1
L
L
iii
=
+
u
1
23
3
Systems Realization Laboratory
Tearing Algorithm
(1)
u
=
ft ( )
u
0
0
u
=
Ri
u
1
11
1
u
=
Ri
u
2
22
2
(10)
u
=
L
⋅ (
di
/)
dt
u
L
L
L
(2*)
u
=
Ri
i
3
33
0
(3*)
u
=
uu
+
i
0
13
1
(8)
u
=
uu
+
i
L
12
2
(4*)
uu
=
i
tear
32
3
(9)
i
= +
i
i
di
/
dt
0
1
L
L
iii
=
+
u
1
23
3
Systems Realization Laboratory Tearing Algorithm
(1)
u
=
ft ( )
u
0
0
(5*)
u
=
Ri
u
1
11
1
(6 )
*
u
=
Ri
u
2
22
2
(10)
u
=
L
⋅ (
di
/)
dt
u
L
L
L
(2*)
u
=
Ri
i
3
33
0
(3*)
u
=
uu
+
i
0
13
1
(8)
u
=
uu
+
i
L
12
2
(4*)
uu
=
i
tear
32
3
(9)
i
= +
i
i
di
/
dt
0
1
L
L
residual
iii
=
+
u
1
23
3
Systems Realization Laboratory
Algebraic Loop Example – Summary
⎧ y & =
f
(
yzt
,
,)
0
= F ( yyzt
& ,
,
,)
g yzt
(
,
,)
=
0
y
(0) =
y
0
Algebraic Equations
u
: =
Ri
3
33
u
: =
u
Differential Equation
2
3
u
: =
uu
+
i
:
=
uR
/
L
1
2
di
u := ft ()
2
22
L
0
:
= u
/
L
i
: = ii +
L
u
: =
uu
0
1
L
d
t
1
03
i
:
=
uR
/
1
i
1
i
: = −
ii
3
new
12
Solve Iteratively
Systems Realization Laboratory Lecture Overview
Converting implicit DAE into semi-explicit DAE
Graph-based algorithm
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
Zero crossings
Overview of Dymola solvers and their properties
Systems Realization Laboratory
System 3 – Structural Singularity
u
=
ft ( )
0
u
=
Ri
1
11
u
=
Ri
2
22
di
L
u
=
L
L
dt
du
C
i
=
C
C
dt
u
=
uu
+
0
1
L
u
=
uu
+
C
1
2
u
=
u
2
L
i
= +
ii
0
1
C
iii
=
+
1
2
L
Systems Realization Laboratory Step 0: Connect Equations and Unknowns
u
=
ft ( )
u
0
0
u
=
Ri
u
1
11
1
u
=
Ri
u
2
22
2
u
=
L
⋅ (
di
/)
dt
u
LL
L
i
=
C
⋅ (
du
/)
dt
i
C
C
0
u
=
uu
+
i
0
1
L
1
u
=
uu
+
i
C
1
2
2
u
=
u
i
L
2
C
i
= +
ii
di
/
dt
0
1
C
L
iii
=
+
du
/
dt
1
2
L
C
Systems Realization Laboratory
Apply Both Rules
(1)
u
=
ft ( )
u
0
0
u
=
Ri
u
1
11
1
u
=
Ri
u
2
22
2
(10)
u
=
L
⋅ (
di
/)
dt
u
LL
L
(9)
i
=
C
⋅ (
du
/)
dt
i
C
C
0
u
=
uu
+
i
0
1
L
1
u
=
uu
+
i
C
1
2
2
u
=
u
i
L
2
C
(8)
i
= +
ii
di
/
dt
0
1
C
L
iii
=
+
du
/
dt
1
2
L
C
Systems Realization Laboratory STUCK! Structural Singularity
(1)
u
=
ft ( )
u
0
0
u
=
Ri
u
1
11
1
u
=
Ri
u
2
22
2
(10)
u
=
L
⋅ (
di
/)
dt
u
LL
L
(9)
i
=
C
⋅ (
du
/)
dt
i
C
C
0
u
=
uu
+
i
0
1
L
1
u
=
uu
+
i
C
1
2
2
u
=
u
i
L
2
C
(8)
i
= +
ii
di
/
dt
0
1
C
L
iii
=
+
du
/
dt
1
2
L
C
Systems Realization Laboratory What is the problem?
u
=
ft ( )
0
u
=
Ri
1
11
u
=
Ri
2
22
di
L
u
=
L
L
dt
du
C
i
=
C
C
dt
u
=
uu
+
0
1
L
u
=
uu
+
C
1
2
u
=
u
2
L
i
= +
ii
0
1
C
iii
=
+
1
2
L
Systems Realization Laboratory

### 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)

Algorithm is also called an index reduction algorithm

What is an index? Systems Realization Laboratory ### Examples:

Pure ODE is index-0

ODE with algebraic loop is index-1

Structurally singular system index-2 (or larger) Systems Realization Laboratory ### Lecture Overview

Converting implicit DAE into semi-explicit DAE

Graph-based algorithm

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

Zero crossings

Overview of Dymola solvers and their properties Systems Realization Laboratory  mg  reinit( velocity, -k*pre(velocity) )
Discrete Event
end when
equation
mg
end
[…]

Systems Realization Laboratory ### Mixed Systems: DAE + Discrete event

At impact: v -v*k  Mixed DAEs
capabilities:
1.
Event Detection – solving for zero-crossings
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 integration algorithm
Be careful!
Event handling can be slow
Chattering
Systems Realization Laboratory
Summary of Method Characteristics
Appropriate for DAE or only ODE?
Capable of finding initial conditions?
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
Order of method?
Typically higher is better
Systems Realization Laboratory No
DASSL
ODASSL
ODAE
MEXX
ODE
ODAE
5
No
DAE
Runge-Kutta by Dormand and Prince
No
No
No
Linearly-implicit Rosenbrock
4
Yes
1-12
ODE
ODE
DOPRI8
ODE
ODE
ODE
GRK4T
DEABM
LSODE1
8
LSODAR
ODE
DOPRI5
LSODE2
Type
Model
Method
Yes
Root
Stiff
1-5
Dymola Methods
Yes
Yes
BDF; default choice in Dymola
1-5
Order
Yes
No
Modified DASSL for overdetermined DAEs
No
2-24
Special index-2 DAE; not for ODE!
No
Backward Difference Formulae; Gear method
1-12
No
No
Yes
1-5
Runge-Kutta by Dormand and Prince
No
No
Both
Yes
1-12, 1-5
Algorithm
Find Systems Realization Laboratory ### Summary

Identify types and properties of ODE systems

Identify types and properties of ODE solvers

Accuracy

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

Not-so-fine print:

### Solver implementation is for Professionals Only Do not try this at home Systems Realization Laboratory  Step 1: Identify Equations with Only 1 Unknown
(1)
u
=
ft ( )
u
0
0
u
=
Ri
u
1
11
1
u
=
Ri
u
2
22
2
u
=
L
⋅ (
di
/)
dt
u
L
L
L
i
=
C
⋅ (
du
/)
dt
i
C
C
0
u
=
uu
+
i
0
1
C
1
u
=
uu
+
i
L
12
2
(2)
uu
=
i
C
2
C
i
= +
i
i
di
/
dt
0
1
L
L
iii
=
+
du
/
dt
1
2
C
C
Solution for Example 1
Systems Realization Laboratory
Step 2: Identify Variables in Only 1 Equation
(1)
u
=
ft ( )
u
0
0
u
=
Ri
u
1
11
1
u
=
Ri
u
2
22
2
(10)
u
=
L
⋅ (
di
/)
dt
u
L
L
L
(9)
i
=
C
⋅ (
du
/)
dt
i
C
C
0
u
=
uu
+
i
0
1
C
1
u
=
uu
+
i
L
12
2
(2)
uu
=
i
C
2
C
(8)
i
= +
i
i
di
/
dt
0
1
L
L
iii
=
+
du
/
dt
1
2
C
C
Solution for Example 1
Systems Realization Laboratory Repeat Step 1: Identify Equations
(1)
u
=
ft ( )
u
0
0
u
=
Ri
u
1
11
1
(3)
u
=
Ri
u
2
22
2
(10)
u
=
L
⋅ (
di
/)
dt
u
L
L
L
(9)
i
=
C
⋅ (
du
/)
dt
i
C
C
0
(4)
u
=
uu
+
i
0
1
C
1
u
=
uu
+
i
L
12
2
(2)
uu
=
i
C
2
C
(8)
i
= +
i
i
di
/
dt
0
1
L
L
iii
=
+
du
/
dt
1
2
C
C
Solution for Example 1
Systems Realization Laboratory
Repeat Step 2: Identify Variables
(1)
u
=
ft ( )
u
0
0
u
=
Ri
u
1
11
1
(3)
u
=
Ri
u
2
22
2
(10)
u
=
L
⋅ (
di
/)
dt
u
L
L
L
(9)
i
=
C
⋅ (
du
/)
dt
i
C
C
0
(4)
u
=
uu
+
i
0
1
C
1
(7)
u
=
uu
+
i
L
12
2
(2)
uu
=
i
C
2
C
(8)
i
= +
i
i
di
/
dt
0
1
L
L
(6)
iii
=
+
du
/
dt
1
2
C
C
Solution for Example 1
Systems Realization Laboratory Repeat Step 1: Identify Equations
(1)
u
=
ft ( )
u
0
0
(5)
u
=
Ri
u
1
11
1
(3)
u
=
Ri
u
2
22
2
(10)
u
=
L
⋅ (
di
/)
dt
u
L
L
L
(9)
i
=
C
⋅ (
du
/)
dt
i
C
C
0
(4)
u
=
uu
+
i
0
1
C
1
(7)
u
=
uu
+
i
L
12
2
(2)
uu
=
i
C
2
C
(8)
i
= +
i
i
di
/
dt
0
1
L
L
(6)
iii
=
+
du
/
dt
1
2
C
C
Solution for Example 1