the need for formulae manipulation in the object-oriented modeling of physical systems

50
Start of Presentation Maplesoft Conference 2006 The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems François E. Cellier, Ph.D. Institute of Computational Science ETH Zurich Switzerland July 26, 2006

Upload: maxima

Post on 25-Feb-2016

40 views

Category:

Documents


0 download

DESCRIPTION

François E. Cellier, Ph.D. Institute of Computational Science ETH Zurich Switzerland July 26, 2006. The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

The Need for Formulae Manipulationin the Object-oriented Modeling

of Physical Systems

François E. Cellier, Ph.D.Institute of Computational Science

ETH ZurichSwitzerland

July 26, 2006

Page 2: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

• Today’s modeling needs extend to physical systems that are described by many thousands of mathematical equations.

• Such models are being created and maintained by employing the principles of object-oriented graphical modeling.

• Each object contains a number of different layers (aspects, realities) that are to be described shortly.

• Symbolic formula manipulation plays a central role in converting these object-oriented descriptions to a form that can be simulated effectively and efficiently.

Object-oriented Modeling

Page 3: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

Object Descriptions• Objects may contain an iconic representation that is being

used to embed the object at the next higher hierarchical level.

• Objects may contain a geometric representation that is being used for animation.

• Objects may contain a topological description that shows its decomposition structure.

• Objects may contain a mathematical description that shows the equations that the model is formed of.

• Objects may contain a parametric description that shows parameters and their default values.

• Objects may contain a documentation layer that describes the object verbally.

Page 4: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

Heterogeneous Modeling Formalisms

inertialx

y

axis1

axis2

axis3

axis4

axis5

axis6r3Drive1

1r3Motor

r3ControlqdRef1

S

qRef1

S

k2

i

k1

i

qddRef cut joint

q: angleqd: angular velocity

qdd: angular acceleration

qd

tn

Jmotor=J

gear=i

spring=c

fric

=Rv0

Srel

joint=0

S

Vs

-

+diff

-

+pow er

emf

La=(250/(2*D*wm

))Ra=250

Rd2=100

C=0.004*D/w m

-

+OpI

Rd1=100

Ri=10

Rp1=200Rp

2=50

Rd4=100

hall2

Rd3=

100

g1

g2

g3

hall1

g4

g5

rw

cut in

iRef

qd q

rate2

b(s)

a(s)

rate3

340.8

S

rate1

b(s)

a(s)

tacho1

PT1

Kd

0.03

w Sum

-

sum

+1

+1

pSum

-

Kv

0.3

tacho2

b(s)

a(s)

q qd

iRefqRef

qdRef

Page 5: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

Heterogeneous Modeling Formalisms II

inertialx

y

axis1

axis2

axis3

axis4

axis5

axis6

Page 6: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

A First Example

Page 7: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

The circuit contains 5 components and 3 nodes.

We require 13 equations in 13 unknowns.

Component equations:

U0 = f(t) U0 = v1 – v0

uR1 = R1· iR1 uR1 = v1 – v2

uR2 = R2· iR2 uR2 = v2 – v0

iC = C1· duC/dt uC = v2 – v0

uL = L1· diL/dt uL = v1 – v0

v0 = 0

Node equations:

i0 = iR1 + iL iR1 = iR2 + iC

A First Example II

Page 8: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

The Structure Incidence Matrix

1: U0 = f(t)2: i0 = iL + iR1

3: uL = U0

4: diL/dt = uL / L1

5: v1 = U0

6: uR1 = v1 – v2

7: iR1 = uR1 / R1

8: v2 = uC

9: iC = iR1 – iR2

10: duC/dt = iC / C1

11: uR2 = uC

12: iR2 = uR2 / R2

diL

dtduC

dt

S =

010203040506070809101112

101010000000

010000000000

001100000000

000100000000

000011000000

000001100000

010000101000

000001010000

000000001100

000000000100

000000000011

000000001001

U0 i0 uL v1 v2 iCuR1 iR1 iR2uR2

Page 9: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

The Structure Digraph

1: U0 = f(t)2: i0 = iL + iR1

3: uL = U0

4: diL/dt = uL / L1

5: v1 = U0

6: uR1 = v1 – v2

7: iR1 = uR1 / R1

8: v2 = uC

9: iC = iR1 – iR2

10: duC/dt = iC / C1

11: uR2 = uC

12: iR2 = uR2 / R2

010203040506070809101112

EquationsU0

i0

uL

diL/dt v1

uR1

iR1

v2

iC

duC/dtuR2

iR2

Unknowns

Page 10: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

The Tarjan Algorithm• The Tarjan Algorithm is based on the structure digraph.• It is a graph coloring algorithm.

equations with only a single black line leading to them, color that line in red and color all black lines that emanate from the indicated unknown in blue. Renumber the equations anew starting with 1.

unknowns with only a single black line leading to them, color that line in red and color all black lines that emanate from the indicated equation in blue. Renumber the equations anew starting with n, where n denotes the number of equations.

Page 11: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

The Tarjan Algorithm: An Example

010203040506070809101112

EquationsU0

i0

uL

diL/dt v1

uR1

iR1

v2

iC

duC/dtuR2

iR2

Unknowns

1: U0 = f(t)2: i0 = iL + iR1

3: uL = U0

4: diL/dt = uL / L1

5: v1 = U0

6: uR1 = v1 – v2

7: iR1 = uR1 / R1

8: v2 = uC

9: iC = iR1 – iR2

10: duC/dt = iC / C1

11: uR2 = uC

12: iR2 = uR2 / R2

01U0

U0

U0

02v2

v2

03

uR2uR2

12du /dtC iC

11di /dtL uL

10i0 iR1

Page 12: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

The Tarjan Algorithm: An Example II

010203040506070809101112

EquationsU0

i0

uL

diL/dt v1

uR1

iR1

v2

iC

duC/dtuR2

iR2

Unknowns

1: U0 = f(t)2: i0 = iL + iR1

3: uL = U0

4: diL/dt = uL / L1

5: v1 = U0

6: uR1 = v1 – v2

7: iR1 = uR1 / R1

8: v2 = uC

9: iC = iR1 – iR2

10: duC/dt = iC / C1

11: uR2 = uC

12: iR2 = uR2 / R2

01U0

U0

U0

02v2

v2

03

uR2uR2

12du /dtC iC

11di /dtL uL

10i0 iR1

04uL

05v1v1

06

iR2

R2i09

iC iR1

Page 13: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

The Tarjan Algorithm: An Example III

010203040506070809101112

EquationsU0

i0

uL

diL/dt v1

uR1

iR1

v2

iC

duC/dtuR2

iR2

Unknowns

1: U0 = f(t)2: i0 = iL + iR1

3: uL = U0

4: diL/dt = uL / L1

5: v1 = U0

6: uR1 = v1 – v2

7: iR1 = uR1 / R1

8: v2 = uC

9: iC = iR1 – iR2

10: duC/dt = iC / C1

11: uR2 = uC

12: iR2 = uR2 / R2

01U0

U0

U0

02v2

v2

03

uR2uR2

12du /dtC iC

11di /dtL uL

10i0 iR1

04uL

05v1v1

06

iR2

R2i09

iC iR1

07uR1uR1 08

iR1

Page 14: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

The Tarjan Algorithm: An Example IV010203040506070809101112

EquationsU0

i0

uL

diL/dt v1

uR1

iR1

v2

iC

duC/dtuR2

iR2

Unknowns

01

02

03

12

11

10

04

05

06

09

0708

1: U0 = f(t)2: v2 = uC

3: uR2 = uC

4: uL = U0

5: v1 = U0

6: iR2 = uR2 / R2

7: uR1 = v1 – v2

8: iR1 = uR1 / R1

9: iC = iR1 – iR2

10: i0 = iL + iR1

11: diL/dt = uL / L1

12: duC/dt = iC / C1

Page 15: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

The structure incidence matrix of the completely sorted equation system is brought into lower triangular form.

The Structure Incidence Matrix II

1: U0 = f(t)2: v2 = uC

3: uR2 = uC

4: uL = U0

5: v1 = U0

6: iR2 = uR2 / R2

7: uR1 = v1 – v2

8: iR1 = uR1 / R1

9: iC = iR1 – iR2

10: i0 = iL + iR1

11: diL/dt = uL / L1

12: duC/dt = iC / C1

diLdt

duCdt

S =

010203040506070809101112

100110000000

010000100000

001001000000

000100000010

000010100000

000001001000

000000110000

000000011100

000000001001

000000000100

000000000010

000000000001

U0 i0uR2v2 v1 iCuR1 iR1iR2uL

Page 16: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

Algebraic LoopsComponent equations:

U0 = f(t) u3 = R3· i3

u1 = R1· i1uL = L· diL/dt

u2 = R2· i2

Node equations:

i0 = i1 + iLi1 = i2 + i3

Mesh equations:

U0 = u1 + u3 uL = u1 + u2

u3 = u2

The circuit contains 5 components

We require 10 equations in 10 unknowns

Page 17: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

Algebraic Loops: An Example

1: U0 = f(t)

2: u1 = R1· i1

3: u2 = R2· i2

4: u3 = R3· i3

5: uL = L· diL/dt

6: i0 = i1 + iL

7: i1 = i2 + i3

8: U0 = u1 + u3

9: u3 = u2

10: uL = u1 + u2

01020304050607080910

EquationsU0

i0

uL

diL/dt u1

i1

u2

i2

u3

i3

Unknowns

Page 18: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

Algebraic Loops: An Example II

1: U0 = f(t)

2: u1 = R1· i1

3: u2 = R2· i2

4: u3 = R3· i3

5: uL = L· diL/dt

6: i0 = i1 + iL

7: i1 = i2 + i3

8: U0 = u1 + u3

9: u3 = u2

10: uL = u1 + u2

01020304050607080910

EquationsU0

i0

uL

diL/dt u1

i1

u2

i2

u3

i3

Unknowns

01

10

09

Page 19: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

Algebraic Loops: An Example III

1: U0 = f(t)

2: u1 = R1· i1

3: u2 = R2· i2

4: u3 = R3· i3

5: uL = L· diL/dt

6: i0 = i1 + iL

7: i1 = i2 + i3

8: U0 = u1 + u3

9: u3 = u2

10: uL = u1 + u2

01020304050607080910

EquationsU0

i0

uL

diL/dt u1

i1

u2

i2

u3

i3

Unknowns

01

10

0908

The algorithm fails as there are no longer single black lines to either equations or unknowns.

Page 20: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

The Tearing of Algebraic Loops• The following heuristic may be used to find suitable

tearing variables:Determine those equations in the digraph that contain the largest number of black lines.

For each of these equations, find the unknown with the largest number of black lines emanating from it.

Determine for each of these variables, how many additional equations can be causalized, when this variable is assumed known.

Choose that variable as the next tearing variable that causalizes the largest number of additional equations.

Page 21: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

Algebraic Loops: An Example IV

10

0908

01020304050607080910

EquationsU0

i0

uL

diL/dt u1

i1

u2

i2

u3

i3

Unknowns

01

02

1: U0 = f(t)

2: u1 = R1· i1

3: u2 = R2· i2

4: u3 = R3· i3

5: uL = L· diL/dt

6: i0 = i1 + iL

7: i1 = i2 + i3

8: U0 = u1 + u3

9: u3 = u2

10: uL = u1 + u2 Choice

Page 22: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

Algebraic Loops: An Example V

1: U0 = f(t)

2: u1 = R1· i1

3: u2 = R2· i2

4: u3 = R3· i3

5: uL = L· diL/dt

6: i0 = i1 + iL

7: i1 = i2 + i3

8: U0 = u1 + u3

9: u3 = u2

10: uL = u1 + u2 Choice

10

0908

01020304050607080910

EquationsU0

i0

uL

diL/dt u1

i1

u2

i2

u3

i3

Unknowns

01

02

03

Page 23: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

Algebraic Loops: An Example VI

1: U0 = f(t)

2: u1 = R1· i1

3: u2 = R2· i2

4: u3 = R3· i3

5: uL = L· diL/dt

6: i0 = i1 + iL

7: i1 = i2 + i3

8: U0 = u1 + u3

9: u3 = u2

10: uL = u1 + u2 Choice

10

0908

01020304050607080910

EquationsU0

i0

uL

diL/dt u1

i1

u2

i2

u3

i3

Unknowns

01

02

03

07

06

Page 24: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

Algebraic Loops: An Example VII

1: U0 = f(t)

2: u1 = R1· i1

3: u2 = R2· i2

4: u3 = R3· i3

5: uL = L· diL/dt

6: i0 = i1 + iL

7: i1 = i2 + i3

8: U0 = u1 + u3

9: u3 = u2

10: uL = u1 + u2 Choice

10

0908

01020304050607080910

EquationsU0

i0

uL

diL/dt u1

i1

u2

i2

u3

i3

Unknowns

01

02

03

07

0604

Page 25: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

Algebraic Loops: An Example VIII

1: U0 = f(t)

2: u1 = R1· i1

3: u2 = R2· i2

4: u3 = R3· i3

5: uL = L· diL/dt

6: i0 = i1 + iL

7: i1 = i2 + i3

8: U0 = u1 + u3

9: u3 = u2

10: uL = u1 + u2 Choice

10

0908

01020304050607080910

EquationsU0

i0

uL

diL/dt u1

i1

u2

i2

u3

i3

Unknowns

01

02

03

07

0604

05

Page 26: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

Algebraic Loops: An Example IX

1: U0 = f(t)

2: i1 = i2 + i3

3: u1 = R1· i1

4: u3 = U0 - u1

5: u2 = u3

6: i2 = u2 / R2

7: i3 = u3 / R3

8: uL = u1 + u2

9: i0 = i1 + iL

10: diL/dt = uL / LChoice

10

0908

01020304050607080910

EquationsU0

i0

uL

diL/dt u1

i1

u2

i2

u3

i3

Unknowns

01

02

03

07

0604

05

Page 27: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

The structure incidence matrix now assumes a block lower triangular (BLT) form.

The Structure Incidence Matrix III

diLdt

S =

01020304050607080910

1001000000

0110000010

0011000100

0001101000

0000110100

0100010000

0100001000

0000000101

0000000010

0000000001

U0 i0i2u3 i2u1i1 i3 uL1: U0 = f(t)

2: i1 = i2 + i3

3: u1 = R1· i1

4: u3 = U0 - u1

5: u2 = u3

6: i2 = u2 / R2

7: i3 = u3 / R3

8: uL = u1 + u2

9: i0 = i1 + iL

10: diL/dt = uL / LChoice

u2

Page 28: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

The Solving of Algebraic Loops I• The Tarjan algorithm identifies and isolates algebraic

loops.• It transforms the structure incidence matrix to BLT form,

whereby the diagonal blocks are made as small as possible.• The selection of the tearing variables is not done in a truly

optimal fashion. This is not meaningful, because the optimal selection of tearing variables has been shown to be an np-complete problem. Instead, a set of heuristics is being used, which usually comes up with a small number of tearing variables, although the number may not be truly minimal.

• The Tarjan algorithm does not concern itself with how the resulting algebraic loops are being solved.

Page 29: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

The Solving of Algebraic Loops II

1. u1 = R1· i1

2. u2 = R2· i2

3. u3 = R3· i3

4. i1 = i2 + i3

5. U0 = u1 + u3

6. u3 = u2 i2 i1 u1

u3i3u2 U0

4.

4.

1.

2.

3.

5.

6.

Algebraic Loops

Structure diagram

Page 30: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

Solution of Algebraic Loops III

1. u1 = R1· i1

2. u2 = R2· i2

3. u3 = R3· i3

4. i1 = i2 + i3

5. U0 = u1 + u3

6. u3 = u2

1. u1 = R1· i1

2. i2 = u2 / R2

3. i3 = u3 / R3

4. i1 = i2 + i3

5. u3 = U0 - u1

6. u2 = u3

i1 = i2 + i3

= u2 / R2 + u3 / R3

= u3 / R2 + u3 / R3

= ((R2 + R3 ) / (R2 · R3 )) · u3

= ((R2 + R3 ) / (R2 · R3 )) · (U0 - u1 )

= ((R2 + R3 ) / (R2 · R3 )) · (U0 - R1· i1 )

i1 =R2 + R3

R1 R2 + R1 R3 + R2 R3 · U0

Equation 4. is replaced by the new equation.

Page 31: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

The Solving of Algebraic Loops IV

• The algebraic loops can be solved either analytically or numerically.

• If the loop equations are non-linear, a Newton iteration on the tearing variables may be optimal.

• If the loop equations are linear and if the set is fairly large, Newton iteration may still be the method of choice.

• If the loop equations are linear and if the set is of modest size, the equations can either be solved by matrix techniques or by means of explicit formulae manipulation.

Page 32: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

Structural Singularities: An Example I

I1

I2

I3

iC

iL1iL2

iR

v1

v2v3

v0

We compose a model using the currents, the Voltages and the potentials. Consequently, the mesh equations are being ignored.

We have 7 circuit components plus the ground, therefore 27 + 1 = 15 equations. In addition, there are 4 nodes giving rise to another 3 equations. Therefore, we expect 18 equations in 18 unknowns.

For passive components, it is customary to normalize the Voltages in the same direction as the currents. For active components (sources), the reverse is true.

Page 33: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

Structural Singularities: An Example II

1: I1 = f1(t)

2: I2 = f2(t)3: I3 = f3(t)4: uR = R · iR

5: uL1 = L1 · diL1 /dt6: uL2 = L2 · diL2 /dt7: iC = C · duC /dt8: v0 = 0

9: u1 = v0 – v1

10: u2 = v3 – v2

11: u3 = v0 – v1

12: uR = v3 – v0

13: uL1 = v2 – v0

14: uL2 = v1 – v3

15: uC = v1 – v2

16: iC = iL1 + I2

17: iR = iL2 + I2

18: I1 + iC + iL2 + I3 = 0

01

02

03

04

05

06

07

08

09

10

11

12

13

14

15

16

17

18

I1

I2

I3

uR

iR

uL1

diL1 /dt

uL2

diL2 /dt

iC

duC /dt

v0

v1

v2

v3

u1

u2

u3

Page 34: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

Structural Singularities: An Example III

1: I1 = f1(t)

2: I2 = f2(t)3: I3 = f3(t)4: uR = R · iR

5: uL1 = L1 · diL1 /dt6: uL2 = L2 · diL2 /dt7: iC = C · duC /dt8: v0 = 0

9: u1 = v0 – v1

10: u2 = v3 – v2

11: u3 = v0 – v1

12: uR = v3 – v0

13: uL1 = v2 – v0

14: uL2 = v1 – v3

15: uC = v1 – v2

16: iC = iL1 + I2

17: iR = iL2 + I2

18: I1 + iC + iL2 + I3 = 0

01

02

03

04

05

06

07

08

09

10

11

12

13

14

15

16

17

18

I1

I2

I3

uR

iR

uL1

diL1 /dt

uL2

diL2 /dt

iC

duC /dt

v0

v1

v2

v3

u1

u2

u3

010203

04

181716

15

14

13

Page 35: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

Structural Singularities: An Example IV

1: I1 = f1(t)

2: I2 = f2(t)3: I3 = f3(t)4: uR = R · iR

5: uL1 = L1 · diL1 /dt6: uL2 = L2 · diL2 /dt7: iC = C · duC /dt8: v0 = 0

9: u1 = v0 – v1

10: u2 = v3 – v2

11: u3 = v0 – v1

12: uR = v3 – v0

13: uL1 = v2 – v0

14: uL2 = v1 – v3

15: uC = v1 – v2

16: iC = iL1 + I2

17: iR = iL2 + I2

18: I1 + iC + iL2 + I3 = 0

01

02

03

04

05

06

07

08

09

10

11

12

13

14

15

16

17

18

I1

I2

I3

uR

iR

uL1

diL1 /dt

uL2

diL2 /dt

iC

duC /dt

v0

v1

v2

v3

u1

u2

u3

010203

04

181716

15

14

13

05

Constraint Equation

All connections are blue

Page 36: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

The Algorithm by Pantelides

• As soon as a constraint equation has been found, this equation must be differentiated.

• In the algorithm of Pantelides, the differentiated constraint equation is added to the set of equations.

• Consequently, the set of equations has now one equation too many.

• In order to re-equalize the number of equations and unknowns, one of the integrators that is associated with the constraint equation is being eliminated.

Page 37: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

The Algorithm by Pantelides II

dxdt x

unknown known, since this is a state variable

dxdt x

unknown unknown

dx x

unknown unknown

An additional unknown was created by the elimination of the integrator. x and dx are now algebraic variables, for which there must be found equations.

Page 38: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

The Algorithm by Pantelides III• When differentiating constraint equations, it can happen

that additional new variables are being created, e.g. v dv, where v is an algebraic variable.

• Since v was already blue (otherwise, this would not have been a constraint equation), there already exists another equation to compute v.

• This equation must also be differentiated.• The differentiation of additional equations continues until

no additional variables are being created.

Page 39: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

The Algorithm by Pantelides : An Example

1: I1 = f1(t)

2: I2 = f2(t)3: I3 = f3(t)4: uR = R · iR

5: uL1 = L1 · diL1 /dt6: uL2 = L2 · diL2 /dt7: iC = C · duC /dt8: v0 = 0

9: u1 = v0 – v1

10: u2 = v3 – v2

11: u3 = v0 – v1

12: uR = v3 – v0

13: uL1 = v2 – v0

14: uL2 = v1 – v3

15: uC = v1 – v2

16: iC = iL1 + I2

17: iR = iL2 + I2

18: I1 + iC + iL2 + I3 = 0

dI1 + diC + diL2 + dI3 = 0

eliminated integrator

newly introduced variables

Page 40: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

The Algorithm by Pantelides : An Example II

1: I1 = f1(t)

2: I2 = f2(t)3: I3 = f3(t)4: uR = R · iR

5: uL1 = L1 · diL1 /dt6: uL2 = L2 · diL2 /dt7: iC = C · duC /dt8: v0 = 0

9: u1 = v0 – v1

10: u2 = v3 – v2

11: u3 = v0 – v1

12: uR = v3 – v0

13: uL1 = v2 – v0

14: uL2 = v1 – v3

15: uC = v1 – v2

16: iC = iL1 + I2

17: iR = iL2 + I2

18: I1 + iC + iL2 + I3 = 019: dI1 + diC + diL2 + dI3 = 0

9: u1 = v0 – v1

10: u2 = v3 – v2

11: u3 = v0 – v1

12: uR = v3 – v0

13: uL1 = v2 – v0

14: uL2 = v1 – v3

15: uC = v1 – v2

1: I1 = f1(t)

2: I2 = f2(t)3: I3 = f3(t)4: uR = R · iR

5: uL1 = L1 · diL1 /dt6: uL2 = L2 · diL2

7: iC = C · duC /dt8: v0 = 016: iC = iL1 + I2

17: iR = iL2 + I2

18: I1 + iC + iL2 + I3 = 019: dI1 + diC + diL2 + dI3 = 0

Page 41: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

The Algorithm by Pantelides : An Example III

9: u1 = v0 – v1

10: u2 = v3 – v2

11: u3 = v0 – v1

12: uR = v3 – v0

13: uL1 = v2 – v0

14: uL2 = v1 – v3

15: uC = v1 – v2

20: dI1 = df1(t)/dt21: dI3 = df3(t)/dt22: diC = diL1 /dt + dI2

16: iC = iL1 + I2

17: iR = iL2 + I2

18: I1 + iC + iL2 + I3 = 019: dI1 + diC + diL2 + dI3 = 0

1: I1 = f1(t)

2: I2 = f2(t)3: I3 = f3(t)4: uR = R · iR

5: uL1 = L1 · diL1 /dt6: uL2 = L2 · diL2

7: iC = C · duC /dt8: v0 = 0

uL1 = L1 · diL1 /dt newly introduced variable

23: dI2 = df2(t)/dt

Page 42: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

The Algorithm by Pantelides : An Example IV

9: u1 = v0 – v1

10: u2 = v3 – v2

11: u3 = v0 – v1

12: uR = v3 – v0

13: uL1 = v2 – v0

14: uL2 = v1 – v3

15: uC = v1 – v2

16: iC = iL1 + I2

17: iR = iL2 + I2

18: I1 + iC + iL2 + I3 = 019: dI1 + diC + diL2 + dI3 = 0

1: I1 = f1(t)

2: I2 = f2(t)3: I3 = f3(t)4: uR = R · iR

5: uL1 = L1 · diL1 /dt6: uL2 = L2 · diL2

7: iC = C · duC /dt8: v0 = 0

20: dI1 = df1(t)/dt21: dI3 = df3(t)/dt22: diC = diL1 /dt + dI223: dI2 = df2(t)/dt

Page 43: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

Inline Integration

• Higher-order models are almost invariably stiff.• Stiff models require an implicit ODE solver for

their simulation.• Implicit ODE solvers call for an additional

iteration during each integration step.• Inline integration may be able to reduce the

number of iteration variables by merging the solver equations with the model equations.

Page 44: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

Inline Integration: An Example

1: U0 = f(t)

2: u1 = R1· i1

3: u2 = R2· i2

4: u3 = R3· i3

5: uL = L· diL/dt

6: i0 = i1 + iL

7: i1 = i2 + i3

8: U0 = u1 + u3

9: u3 = u2

10: uL = u1 + u2

11: iL = pre(iL) + h · diL/dt

01020304050607080910

EquationsU0

i0

uL

diL/dt u1

i1

u2

i2

u3

i3

Unknowns

11 iL

Page 45: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

Inline Integration: An Example II

1: U0 = f(t)

2: u1 = R1· i1

3: u2 = R2· i2

4: u3 = R3· i3

5: uL = L· diL/dt

6: i0 = i1 + iL

7: i1 = i2 + i3

8: U0 = u1 + u3

9: u3 = u2

10: uL = u1 + u2

11: iL = pre(iL) + h · diL/dt

01020304050607080910

EquationsU0

i0

uL

diL/dt u1

i1

u2

i2

u3

i3

Unknowns

11 iL

0111

10

0908

Page 46: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

Inline Integration: An Example III1: U0 = f(t)

2: u1 = R1· i1

3: u2 = R2· i2

4: u3 = R3· i3

5: uL = L· diL/dt

6: i0 = i1 + iL

7: i1 = i2 + i3

8: U0 = u1 + u3

9: u3 = u2

10: uL = u1 + u2

11: iL = pre(iL) + h · diL/dt

01020304050607080910

EquationsU0

i0

uL

diL/dt u1

i1

u2

i2

u3

i3

Unknowns

11 iL

0111

10

0908

Choice

02

Page 47: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

Inline Integration: An Example IV1: U0 = f(t)

2: u1 = R1· i1

3: u2 = R2· i2

4: u3 = R3· i3

5: uL = L· diL/dt

6: i0 = i1 + iL

7: i1 = i2 + i3

8: U0 = u1 + u3

9: u3 = u2

10: uL = u1 + u2

11: iL = pre(iL) + h · diL/dt

01020304050607080910

EquationsU0

i0

uL

diL/dt u1

i1

u2

i2

u3

i3

Unknowns

11 iL

0111

10

0908

Choice

02

03

07

060405

Page 48: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

Inline Integration II

• DASSL would have required to use all state variables (1) plus all tearing variables (1) as iteration variables.

• With inline integration, we got away with a single iteration variable in this example.

• Determining a good (small) set of tearing variables is thus essential, as it ultimately determines the efficiency of the simulation.

• Dymola offers a highly sophisticated selection of heuristics to determine small sets of tearing variables. These heuristics have not been published, as the company views them as their technological edge.

Page 49: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

Discontinuity Handling

• Discontinuity handling requires special considerations during the (symbolic) translation. (Switching equations change their computational causality as a function of the switch position.)

• Discontinuity handling also requires special considerations during the (numerical) simulation. (Extrapolation polynomials don’t exhibit discontinuities.)

Page 50: The Need for Formulae Manipulation in the Object-oriented Modeling of Physical Systems

Start of Presentation

Maplesoft Conference 2006

Mixed Symbolic and Numerical Processing