index theory and structural analysis for multi-mode dae ... · overview of our approach nonstandard...
TRANSCRIPT
Index Theoryand Structural Analysis
for multi-mode DAE Systems
Albert Benveniste Benoît CaillaudKhalil Ghorbal Mathias Malandain
(Inria, Rennes)
March 15, 2019
1 / 36
Motivations
An unexpected simulation example
The clutch exampleSeparate analysis of each modeThe mode transitions
The clutch example: a comprehensive approachOverview of our approachNonstandard structural analysisBack-Standardization
How to make this work in generalStructural analysisResults and code for the clutch
Standardization
Further results and conclusion
Additional materialThe railcar example
2 / 36
Compositionality and reuse: Simulink→ ModelicaFrom Block Diagram to Component Diagram
3 / 36
Compositionality and reuse: ODE→ DAE
from Simulink (ODE):HS in state space form{
x ′ = f (x , u)y = g(x , u)
the state space formdepends on the context
reuse is difficult
−→
to Modelica (DAE):HS as physical balance equations{
0 = f (x ′, x , u)0 = g(x , u)
Ohm & Kirchhoff laws, bond graphs,multi-body mechanical systems
reuse is much easier
4 / 36
Compositionality and reuse: ODE→ DAE
I Modeling tools supporting DAE
I Most modeling tools provide a library of predefined modelsready for assembly (Mathworks/Simscape,Siemens-LMS/AmeSim, Mathematica/NDSolve)
I Modelica comes with a full programming language that is apublic standard https://www.modelica.org/ ;
I Simscape and NDSolve use Matlab extended with “==”
I Also Spice dedicated to EDA
5 / 36
A sketch of Modelica and its semantics [Fritzson]
17
Sunday, October 12, 2003
Multi-domain Modeling and Simulation with Modelica 34
Model of Resistorp.i n.i
p.v n.v
model Resistorpackage SIunits = Modelica.SIunits;package Interfaces = Modelica.Electrical.Analog.Interfaces; parameter SIunits.Resistance R = 1 "Resistance";SIunits.Voltage v "Spannungsabfall über Element";Interfaces.PositivePin p;Interfaces.NegativePin n;
equation0 = p.i + n.i;v = p.v - n.v;v = R*p.i;
end Resistor;
Sunday, October 12, 2003
Multi-domain Modeling and Simulation with Modelica 35
Summarymodel SimpleDrive
..Rotational.Inertia Inertia1 (J=0.002);
..Rotational.IdealGear IdealGear1(ratio=100)
..Basic.Resistor Resistor1 (R=0.2)...
equationconnect(Inertia1.flange_b, IdealGear1.flange_a);connect(Resistor1.n, Inductor1.p);
...end SimpleDrive;
model Resistorpackage SIunits = Modelica.SIunits; parameter SIunits.Resistance R = 1;SIunits.Voltage v;..Interfaces.PositivePin p;..Interfaces.NegativePin n;
equation0 = p.i + n.i;v = p.v - n.v;v = R*p.i;
end Resistor;
connector PositivePinpackage SIunits = Modelica.SIunits;SIunits.Voltage v;flow SIunits.Current i;
end PositivePin;
type Voltage = Real(quantity="Voltage",
unit ="V");
6 / 36
A sketch of Modelica and its semantics [Fritzson]
I Modelica Reference v3.3:
“The semantics of the Modelica language is specified by means ofa set of rules for translating any class described in the Modelicalanguage to a flat Modelica structure”
I the good:
I Semantics of continuous-time 1-mode Modelica models: Cauchyproblem on the DAE resulting from the inlining of all components
I Modelica supports multi-mode systemsx*x + y*y = 1;der(x) + x + y = 0;when x <= 0 do reinit(x,1); end;when y <= 0 do reinit(y,x); end;
I the bad: What about the semantics of multi-mode systems?
I and . . . : Questionable simulations (examples later)
6 / 36
Examples of multi-mode systems
Cup-and-Ball game(a two-modeextension of
the pendulum)
A Clutch
A Circuit Breaker
7 / 36
Motivations
An unexpected simulation example
The clutch exampleSeparate analysis of each modeThe mode transitions
The clutch example: a comprehensive approachOverview of our approachNonstandard structural analysisBack-Standardization
How to make this work in generalStructural analysisResults and code for the clutch
Standardization
Further results and conclusion
Additional materialThe railcar example
8 / 36
Examples of unexpected results: causal loops
A case in Modelica
model schedulingReal x(start=0);Real y(start=0);
equationder(x)=1;der(y)=x;when x>=2 thenreinit(x,-3*pre(y));
end when;when x>=2 thenreinit(y,-4*pre(x));
end when;end scheduling
At the instant of reset, x and y each have avalue defined in terms of their values just priorto the reset.
9 / 36
Examples of unexpected results: causal loops
A case in Modelica
model schedulingReal x(start=0);Real y(start=0);
equationder(x)=1;der(y)=x;when x>=2 thenreinit(x,-3*y);
end when;when x>=2 thenreinit(y,-4*x);
end when;end scheduling
Take the pre away: At the time of reset, x and yare in cyclic dependency chain. The simulationruntime (of both OpenModelica and Dymola),chooses to reinitialize x first, with the value −6as before, and then to reinitialize y with 24.
9 / 36
Examples of unexpected results: causal loops
A case in Modelica
model schedulingReal x(start=0);Real y(start=0);
equationder(x)=1;der(y)=x;when x>=2 thenreinit(y,-4*x);
end when;when x>=2 thenreinit(x,-3*y);
end when;end scheduling
What happens, if we reverse the order of thetwo reinit? The simulation result changes, asshown on the bottom diagram. The same phe-nomenon occurs if the two reinit are placedunder the same when clause.
9 / 36
Examples of unexpected results: causal loops
A case in Modelica
I The causal version (with the pre) is scheduled properly and simulates asexpected.
I The non-causal programs are accepted as well, but the result is notsatisfactory.
I Algebraic loops cannot be rejected, even in resets, since they are justanother kind of equation. They should be accepted, but the semantics of amodel must not depend on its layout!
I Studying causality can help to understand the detail of interactions betweendiscrete and continuous code.
More strange examples later.
9 / 36
Motivations
An unexpected simulation example
The clutch exampleSeparate analysis of each modeThe mode transitions
The clutch example: a comprehensive approachOverview of our approachNonstandard structural analysisBack-Standardization
How to make this work in generalStructural analysisResults and code for the clutch
Standardization
Further results and conclusion
Additional materialThe railcar example
10 / 36
Examples of multi-mode systems
Cup-and-Ball game(a two-modeextension of
the pendulum)
⇒ A Clutch
A Circuit Breaker
11 / 36
The clutch example: separate analysis of each mode
ω′1 = f1(ω1, τ1) (e1)ω′2 = f2(ω2, τ2) (e2)
when γ do ω1 − ω2 = 0 (e3) clutch engagedand τ1 + τ2 = 0 (e4) · · ·
when not γ do τ1 = 0 (e5) clutch releasedand τ2 = 0 (e6) · · ·
Note that τ1 + τ2 = 0 holds in all modes, reflecting that the angular momentum ispreserved everywhere (we assume the system to be closed)
12 / 36
The clutch example: separate analysis of each mode
ω′1 = f1(ω1, τ1) (e1)ω′2 = f2(ω2, τ2) (e2)
when γ do ω1 − ω2 = 0 (e3) clutch engagedand τ1 + τ2 = 0 (e4) · · ·
when not γ do τ1 = 0 (e5) clutch releasedand τ2 = 0 (e6) · · ·
Mode γ = F: it is just an ODE system, nothing fancyω′1 = f1(ω1, τ1) (e1)ω′2 = f2(ω2, τ2) (e2)τ1 = 0 (e5)τ2 = 0 (e6)
12 / 36
The clutch example: separate analysis of each mode
ω′1 = f1(ω1, τ1) (e1)ω′2 = f2(ω2, τ2) (e2)
when γ do ω1 − ω2 = 0 (e3) clutch engagedand τ1 + τ2 = 0 (e4) · · ·
when not γ do τ1 = 0 (e5) clutch releasedand τ2 = 0 (e6) · · ·
Mode γ = T: it is now a DAE systemω′1 = f1(ω1, τ1) (e1)ω′2 = f2(ω2, τ2) (e2)ω1 − ω2 = 0 (e3)ω•1 = ω•2 (e•3 )τ1 + τ2 = 0 (e4)
Looking for an execution scheme? Try a 1st-order Euler scheme
12 / 36
The clutch example: separate analysis of each mode
ω′1 = f1(ω1, τ1) (e1)ω′2 = f2(ω2, τ2) (e2)
when γ do ω1 − ω2 = 0 (e3) clutch engagedand τ1 + τ2 = 0 (e4) · · ·
when not γ do τ1 = 0 (e5) clutch releasedand τ2 = 0 (e6) · · ·
Mode γ = T: it is now a dAE systemω•1 = ω1 + δ.f1(ω1, τ1) (eδ1)ω•2 = ω2 + δ.f2(ω2, τ2) (eδ2)ω1 − ω2 = 0 (e3)ω•1 = ω•2 (e•3 )τ1 + τ2 = 0 (e4)
(1)
Regard (1) as a transition system: for a given (ω1, ω2) satisfying (e3),find (ω•1 , ω
•2 , τ1, τ2) using eqns (eδ1 , e
δ2 , e4).
We have 4 unknowns but only 3 eqns: it does not work!
12 / 36
The clutch example: separate analysis of each mode
ω′1 = f1(ω1, τ1) (e1)ω′2 = f2(ω2, τ2) (e2)
when γ do ω1 − ω2 = 0 (e3) clutch engagedand τ1 + τ2 = 0 (e4) · · ·
when not γ do τ1 = 0 (e5) clutch releasedand τ2 = 0 (e6) · · ·
Mode γ = T: it is now a dAE systemω•1 = ω1 + δ.f1(ω1, τ1) (eδ1)ω•2 = ω2 + δ.f2(ω2, τ2) (eδ2)ω1 − ω2 = 0 (e3)ω•1 = ω•2 (e•3 )τ1 + τ2 = 0 (e4)
(2)
Regard (2) as an algebraic system of eqns: for a given (ω1, ω2) satisfying (e3),find (ω•1 , ω
•2 , τ1, τ2) using eqns (eδ1 , e
δ2 , e•3 , e4): structurally nonsingular.
12 / 36
The clutch example: separate analysis of each mode
ω′1 = f1(ω1, τ1) (e1)ω′2 = f2(ω2, τ2) (e2)
when γ do ω1 − ω2 = 0 (e3) clutch engagedand τ1 + τ2 = 0 (e4) · · ·
when not γ do τ1 = 0 (e5) clutch releasedand τ2 = 0 (e6) · · ·
Mode γ = T: it is now a DAE systemω′1 = f1(ω1, τ1) (e1)ω′2 = f2(ω2, τ2) (e2)ω1 − ω2 = 0 (e3)ω′1 = ω′2 (e′3)τ1 + τ2 = 0 (e4)
(3)
Regard (3) as an algebraic system of eqns: for a given (ω1, ω2) satisfying (e3),find (ω′1, ω
′2, τ1, τ2) using eqns (e1, e2, e′3, e4): structurally nonsingular.
12 / 36
The clutch example: separate analysis of each mode
ω′1 = f1(ω1, τ1) (e1)ω′2 = f2(ω2, τ2) (e2)
when γ do ω1 − ω2 = 0 (e3) clutch engagedand τ1 + τ2 = 0 (e4) · · ·
when not γ do τ1 = 0 (e5) clutch releasedand τ2 = 0 (e6) · · ·
Mode γ = T: it is now a DAE systemω′1 = f1(ω1, τ1) (e1)ω′2 = f2(ω2, τ2) (e2)ω1 − ω2 = 0 (e3)ω′1 = ω′2 (e′3)τ1 + τ2 = 0 (e4)
(4)
I The structural analyses we performed
I in continuous time, andI in discrete time using Euler schemes
mirror each other (this is a general fact)12 / 36
The clutch example: mode transitions
ω′1 = f1(ω1, τ1) (e1)ω′2 = f2(ω2, τ2) (e2)
when γ do ω1 − ω2 = 0 (e3)and ω′1 − ω′2 = 0 (e′3)and τ1 + τ2 = 0 (e4)
when not γ do τ1 = 0 (e5)and τ2 = 0 (e6)
I Intuition: structural analysis in each mode is enough
I Problems:
I reset 6= initialization(initialization has 1 degree of freedom in mode γ = T)
I transition released→ engaged has impulsive torques(to adjust the rotation speeds in zero time)
The results obtained by Modelica and Mathematica are interesting
13 / 36
The clutch example: mode transitions
ω′1 = f1(ω1, τ1) (e1)ω′2 = f2(ω2, τ2) (e2)
when γ do ω1 − ω2 = 0 (e3)and ω′1 − ω′2 = 0 (e′3)and τ1 + τ2 = 0 (e4)
when not γ do τ1 = 0 (e5)and τ2 = 0 (e6)
I Intuition: structural analysis in each mode is enough
I Problems:
I reset 6= initialization(initialization has 1 degree of freedom in mode γ = T)
I transition released→ engaged has impulsive torques(to adjust the rotation speeds in zero time)
The results obtained by Modelica and Mathematica are interesting
13 / 36
The clutch example: mode transitions
ω′1 = f1(ω1, τ1) (e1)ω′2 = f2(ω2, τ2) (e2)
when γ do ω1 − ω2 = 0 (e3)and ω′1 − ω′2 = 0 (e′3)and τ1 + τ2 = 0 (e4)
when not γ do τ1 = 0 (e5)and τ2 = 0 (e6)
I Intuition: structural analysis in each mode is enough
I Problems:
I reset 6= initialization(initialization has 1 degree of freedom in mode γ = T)
I transition released→ engaged has impulsive torques(to adjust the rotation speeds in zero time)
The results obtained by Modelica and Mathematica are interesting
13 / 36
The clutch example: mode transitions
ω′1 = f1(ω1, τ1) (e1)ω′2 = f2(ω2, τ2) (e2)
when γ do ω1 − ω2 = 0 (e3)and ω′1 − ω′2 = 0 (e′3)and τ1 + τ2 = 0 (e4)
when not γ do τ1 = 0 (e5)and τ2 = 0 (e6)
I Intuition: structural analysis in each mode is enough
I Problems:
I reset 6= initialization(initialization has 1 degree of freedom in mode γ = T)
I transition released→ engaged has impulsive torques(to adjust the rotation speeds in zero time)
The results obtained by Modelica and Mathematica are interesting
13 / 36
The clutch in Modelica and Mathematica
Clutch
ω′1 = f1(ω1, τ1)ω′2 = f2(ω2, τ2)
when γ do ω1 − ω2 = 0and τ1 + τ2 = 0
when not γ do τ1 = 0and τ2 = 0
Changes γ : F → T → F at t = 5, 10
When the clutch gets engaged, an impulsivetorque occurs if the two rotation speeds dif-fered before the engagement. The commonspeed after engagement should sit betweenthe two speeds before it.
14 / 36
The clutch in Modelica and Mathematica
Clutch in Modelica
ω′1 = f1(ω1, τ1)ω′2 = f2(ω2, τ2)
when γ do ω1 − ω2 = 0and τ1 + τ2 = 0
when not γ do τ1 = 0and τ2 = 0
Changes γ : F → T → F at t = 5, 10
The following error was detected at time:5.002Error: Singular inconsistent scalar systemfor f1 = ((if g then w1-w2 else 0.0))/(-(ifg then 0.0 else 1.0)) = -0.502621/-0Integration terminated before reaching"StopTime" at T = 5
model ClutchBasicparameter Real w01=1;parameter Real w02=1.5;parameter Real j1=1;parameter Real j2=2;parameter Real k1=0.01;parameter Real k2=0.0125;parameter Real t1=5;parameter Real t2=7;Real t(start=0, fixed=true);Boolean g(start=false);Real w1(start = w01, fixed=true);Real w2(start = w02, fixed=true);Real f1;Real f2;
equationder(t) = 1;g = (t >= t1) and (t <= t2);j1*der(w1) = -k1*w1 + f1;j2*der(w2) = -k2*w2 + f2;0 = if g then w1-w2 else f1;f1 + f2 = 0;
end ClutchBasic;
14 / 36
The clutch in Modelica and Mathematica
Clutch in Modelica
ω′1 = f1(ω1, τ1)ω′2 = f2(ω2, τ2)
when γ do ω1 − ω2 = 0and τ1 + τ2 = 0
when not γ do τ1 = 0and τ2 = 0
Changes γ : F → T → F at t = 5, 10
The reason is that Dymola has symbolicallypivoted the system of equations, regardlessof the mode.By doing so, it has produced an equationdefining f1 that is singular in mode g.
model ClutchBasicparameter Real w01=1;parameter Real w02=1.5;parameter Real j1=1;parameter Real j2=2;parameter Real k1=0.01;parameter Real k2=0.0125;parameter Real t1=5;parameter Real t2=7;Real t(start=0, fixed=true);Boolean g(start=false);Real w1(start = w01, fixed=true);Real w2(start = w02, fixed=true);Real f1;Real f2;
equationder(t) = 1;g = (t >= t1) and (t <= t2);j1*der(w1) = -k1*w1 + f1;j2*der(w2) = -k2*w2 + f2;0 = if g then w1-w2 else f1;f1 + f2 = 0;
end ClutchBasic;
14 / 36
The clutch in Modelica and Mathematica
Clutch in Mathematica
ω′1 = f1(ω1, τ1)ω′2 = f2(ω2, τ2)
when γ do ω1 − ω2 = 0and τ1 + τ2 = 0
when not γ do τ1 = 0and τ2 = 0
Changes γ : F → T → F at t = 5, 10
The simulation does not crash but yieldsmeaningless results highly sensitive to littlevariations of some parameters.Suggests that a cold restart, not a reset, isperformed.
NDSolve[{w1’[t] == -0.01 w1[t] + t1[t],2 w2’[t] == -0.0125 w2[t] + t2[t],t1[t] + t2[t] == 0,s[t] (w1[t] - w2[t]) + (1 - s[t]) t1[t] == 0,w1[0] == 1.0, w2[0] == 1.5, s[0] == 0,WhenEvent[t == 5,
s[t] -> 1] },
w1, w2, t1, t2,s,t, 0, 7, DiscreteVariables -> s]
14 / 36
Motivations
An unexpected simulation example
The clutch exampleSeparate analysis of each modeThe mode transitions
The clutch example: a comprehensive approachOverview of our approachNonstandard structural analysisBack-Standardization
How to make this work in generalStructural analysisResults and code for the clutch
Standardization
Further results and conclusion
Additional materialThe railcar example
15 / 36
Overview of our approach
mdAEmDAEdomain
nonstandardmapping to
causality analysislatent equations
DAE modelcontinuous modes
reset equationsat events
standardizationimpulse analysisstandardization
16 / 36
Nonstandard structural analysis
mDAE
DAE modelcontinuous modes
reset equationsat events
standardizationimpulse analysisstandardization
causality analysislatent equations
mdAE
mapping tononstandard
domain
17 / 36
Nonstandard structural analysis
Nonstandard analysisI Nonstandard reals ?R ⊃ R: conservative extension offering infinitesimals
(smaller in size than any ε>0) and infinities; +,×, etc. extend to ?R
I Standardization: say x ≈ y if x − y is infinitesimalEach finite x ∈ ?R has a unique standard part st(x) ∈ R such that x ≈ st(x)
I Nonstandard integers ?Z ⊃ Z: conservative extension offering infinities
Using itI Pick ∂ > 0 infinitesimal and consider T = {n∂ | n ∈ ?Z}; T is both
I discrete: each n∂ has a predecessor (n−1)∂ and a successor (n+1)∂I dense in R: each t ∈ R has a τ ∈ T such that t ≈ τ
I We will “faithfully” approximate multimode DAE systems by multimode dAEsystems over T; reverse mapping by performing standardization
I “faithful” means “up to an infinitesimal error”I this way we unify continuous dynamics and mode changes
18 / 36
Nonstandard structural analysis
Nonstandard analysisI Nonstandard reals ?R ⊃ R: conservative extension offering infinitesimals
(smaller in size than any ε>0) and infinities; +,×, etc. extend to ?R
I Standardization: say x ≈ y if x − y is infinitesimalEach finite x ∈ ?R has a unique standard part st(x) ∈ R such that x ≈ st(x)
I Nonstandard integers ?Z ⊃ Z: conservative extension offering infinities
Using itI Pick ∂ > 0 infinitesimal and consider T = {n∂ | n ∈ ?Z}; T is both
I discrete: each n∂ has a predecessor (n−1)∂ and a successor (n+1)∂I dense in R: each t ∈ R has a τ ∈ T such that t ≈ τ
I We will “faithfully” approximate multimode DAE systems by multimode dAEsystems over T; reverse mapping by performing standardization
I “faithful” means “up to an infinitesimal error”I this way we unify continuous dynamics and mode changes
18 / 36
Nonstandard structural analysis
∂ infinitesimal; ?T =def {n.∂ | n ∈ ?N}; nonstandard clutch model:
ω•1 = ω1 + ∂.f1(ω1, τ1) (e∂1 )ω•2 = ω2 + ∂.f2(ω2, τ2) (e∂2 )
when γ do ω1 − ω2 = 0 (e3)and ω•1 − ω•2 = 0 (e•3 )and τ1 + τ2 = 0 (e4)
when not γ do τ1 = 0 (e5)and τ2 = 0 (e6)
Latent equations were added for each mode
19 / 36
Nonstandard structural analysis
∂ infinitesimal; ?T =def {n.∂ | n ∈ ?N}; nonstandard clutch model:
ω•1 = ω1 + ∂.f1(ω1, τ1) (e∂1 )ω•2 = ω2 + ∂.f2(ω2, τ2) (e∂2 )
when γ do ω1 − ω2 = 0 (e3)and ω•1 − ω•2 = 0 (e•3 )and τ1 + τ2 = 0 (e4)
when not γ do τ1 = 0 (e5)and τ2 = 0 (e6)
Latent equations were added for each mode
OK inside each of the two modes:
I γ=T: activate (e3, e•3 , e4) and disable (e5, e6)
I γ=F: disable (e3, e•3 , e4) and activate (e5, e6)
19 / 36
Nonstandard structural analysis
∂ infinitesimal; ?T =def {n.∂ | n ∈ ?N}; nonstandard clutch model:
ω•1 = ω1 + ∂.f1(ω1, τ1) (e∂1 )ω•2 = ω2 + ∂.f2(ω2, τ2) (e∂2 )
when γ do ω1 − ω2 = 0 (e3)and ω•1 − ω•2 = 0 (e•3 )and τ1 + τ2 = 0 (e4)
when not γ do τ1 = 0 (e5)and τ2 = 0 (e6)
Latent equations were added for each mode
Conflict at mode change γ : F → T between:
I (e3) at instant of mode change, requires ω1 = ω2
I (e∂1 , e∂2 ) at previous instant, sets ω•1 , ω
•2 with no guarantee that ω•1 = ω•2
19 / 36
Nonstandard structural analysis
∂ infinitesimal; ?T =def {n.∂ | n ∈ ?N}; nonstandard clutch model:
ω•1 = ω1 + ∂.f1(ω1, τ1) (e∂1 )ω•2 = ω2 + ∂.f2(ω2, τ2) (e∂2 )
when γ do ω1 − ω2 = 0 (e3)and ω•1 − ω•2 = 0 (e•3 )and τ1 + τ2 = 0 (e4)
when not γ do τ1 = 0 (e5)and τ2 = 0 (e6)
Latent equations were added for each mode
Solve the conflict at mode change γ : F → T based on causality (no UNDO)
I (e3) at instant of mode change, requires ω1 = ω2 inhibited
I (e∂1 , e∂2 ) at previous instant, sets ω•1 , ω
•2 with no guarantee that ω•1 = ω•2
19 / 36
Nonstandard structural analysis
∂ infinitesimal; ?T =def {n.∂ | n ∈ ?N}; nonstandard clutch model:
ω1 = •ω1 + ∂.f1(•ω1,•τ1) (•e∂1 )
ω2 = •ω2 + ∂.f2(•ω2,•τ2) (•e∂2 )
ω•1 = ω1 + ∂.f1(ω1, τ1) (e∂1 )ω•2 = ω2 + ∂.f2(ω2, τ2) (e∂2 )
when γ do ω1 − ω2 = 0 (e3)when iiiiiiitγ do ω•1 − ω•2 = 0 (e•3 )
and τ1 + τ2 = 0 (e4)
Resulting code at mode change γ : F → T:
I context inherited from the past
I latent equations
I other equations
19 / 36
Nonstandard structural analysis: summary
I Each continuous mode comes with its structural analysis
I Conflicts may occur at mode changes
I Resolve conflicts by removing, at the current instant,the equations conflicting with the past
I Conflicts disappear in finitely many (nonstandard) instants,i.e., in zero (standard) time
20 / 36
Back-Standardization
time:?R; both x•, x ′
mdAEmDAEdomain
nonstandardmapping to
causality analysislatent equations
impulse analysisstandardizationstandardization
DAE model reset equationsat eventscontinuous modes
time: R; derivatives x ′ time: discrete; shift x•
21 / 36
Back-Standardization
∂ infinitesimal; ?T =def {n.∂ | n ∈ ?N}; nonstandard clutch model:
ω•1 = ω1 + ∂.f1(ω1, τ1) (e∂1 )ω•2 = ω2 + ∂.f2(ω2, τ2) (e∂2 )
when γ do ω1 − ω2 = 0 (e3)and ω•1 − ω•2 = 0 (e•3 )and τ1 + τ2 = 0 (e4)
when not γ do τ1 = 0 (e5)and τ2 = 0 (e6)
OK inside each individual mode:
I Apply usual continuous time structural analysis for each mode, separately
I This can be justified by standardization of the nonstandard model;
consists in moving backward, from nonstandard Euler scheme to DAE
I The usual numerical schemes for DAE can then be applied
22 / 36
Back-Standardization
∂ infinitesimal; ?T =def {n.∂ | n ∈ ?N}; nonstandard clutch model:ω•1 = ω1 + ∂.f1(ω1, τ1) (e∂1 )ω•2 = ω2 + ∂.f2(ω2, τ2) (e∂2 )ω•1 − ω•2 = 0 (e•3 )τ1 + τ2 = 0 (e4)
This is the nonstandard dynamics at mode change γ : F → T.
How to map it to effective code?
I again by standardization, by, however
I targeting discrete time dynamics (for stepwise computing restart values)
I the issue: getting rid of the infinitesimal ∂ acting in space in (e∂1 , e∂2 )
Let us proceed for the simple case where fi (ωi , τi ) = aiωi + biτi
22 / 36
Back-Standardization
∂ infinitesimal; ?T =def {n.∂ | n ∈ ?N}; nonstandard clutch model: ω•1 = ω1 + ∂(a1ω1 + b1τ) (e∂1 )ω•2 = ω2 + ∂(a2ω2 − b2τ) (e∂2 )ω•1 − ω•2 = 0 (e•3 )
1st step: impulse analysis
I because of ∂ in (e∂1 , e∂2 ), ω•1 − ω•2 = 0 and ω1 − ω2 6= 0 together requires
either (a1ω1 + b1τ) or (a2ω2 − b2τ) to be infinite (in nonstandard setting)
I requires τ to be infinite, expressing that τ is impulsive
22 / 36
Back-Standardization
∂ infinitesimal; ?T =def {n.∂ | n ∈ ?N}; nonstandard clutch model: ω•1 = ω1 + ∂(a1ω1 + b1τ) (e∂1 )ω•2 = ω2 + ∂(a2ω2 − b2τ) (e∂2 )ω•1 − ω•2 = 0 (e•3 )
2nd step: eliminating impulsive variables
I because of ∂ in (e∂1 , e∂2 ), ω•1 − ω•2 = 0 and ω1 − ω2 6= 0 together requires
either (a1ω1 + b1τ) or (a2ω2 − b2τ) to be infinite (in nonstandard setting)
I requires τ to be infinite, expressing that τ is impulsive
I we cannot directly set ∂ ← 0 because we get a conflict!
⇒ we first need to eliminate τ . Yields, with ω• =def ω•1 = ω•2 :
(b1 + b2)ω• = b2(1+∂.a1)ω1 + b1(1+∂.a2)ω2
22 / 36
Back-Standardization
∂ infinitesimal; ?T =def {n.∂ | n ∈ ?N}; nonstandard clutch model: ω•1 = ω1 + ∂(a1ω1 + b1τ) (e∂1 )ω•2 = ω2 + ∂(a2ω2 − b2τ) (e∂2 )ω•1 − ω•2 = 0 (e•3 )
3rd step: perform safe standardization of
(b1 + b2)ω• = b2(1+∂.a1)ω1 + b1(1+∂.a2)ω2
Now we can safely set ∂ ← 0, which yields
(b1 + b2)ω• = b2ω1 + b1ω2
which we interpret as the restart equation for the velocities:
(b1 + b2)ω+ = b2ω−1 + b1ω
−2
22 / 36
Our simulation results
mode changes γ : F → T → F at t = 5, 10
23 / 36
Motivations
An unexpected simulation example
The clutch exampleSeparate analysis of each modeThe mode transitions
The clutch example: a comprehensive approachOverview of our approachNonstandard structural analysisBack-Standardization
How to make this work in generalStructural analysisResults and code for the clutch
Standardization
Further results and conclusion
Additional materialThe railcar example
24 / 36
Extending the structural analysis
The new issues wrt (single-mode) DAE systems
I Maybe not all guards are known at the start of an instant. Then:
I Need to handle partial models, possibly non-square(more variables than equations)
I Need to extend structural analysis to non-square DAE systems
I How to resolve conflicts between past and present, structurally?
25 / 36
Extending the structural analysis
Background on the Σ-method [Pryce2001] for square DAE systems
I Consider F=0, where F = vec(fj ) and fj (the xi and their derivatives)
I GF weighted bipartite graph of F=0
(e, n, x) ∈ GF iff x has differentiation degree n in equation e; let dex := n
25 / 36
Extending the structural analysis
Background on the Σ-method [Pryce2001] for square DAE systems
I Consider F=0, where F = vec(fj ) and fj (the xi and their derivatives)
I GF weighted bipartite graph of F=0
(e, n, x) ∈ GF iff x has differentiation degree n in equation e; let dex := n
I Find a complete matchingM⊆ GF (bijection F 7→ X )
and integer offsets (ce)e∈F and (dx )x∈X , such that
dx − ce ≥ dex with equality iff (e, dex , x) ∈Mce ≥ 0
25 / 36
Extending the structural analysis
Background on the Σ-method [Pryce2001] for square DAE systems
I Consider F=0, where F = vec(fj ) and fj (the xi and their derivatives)
I GF weighted bipartite graph of F=0
(e, n, x) ∈ GF iff x has differentiation degree n in equation e; let dex := n
I Find a complete matchingM⊆ GF (bijection F 7→ X )
and integer offsets (ce)e∈F and (dx )x∈X , such that
dx − ce ≥ dex with equality iff (e, dex , x) ∈Mce ≥ 0
(5)
I Differentiating ce times each e yields an algebraic systemFΣ(leading/other vars) = 0 that is structurally nonsingular wrt leading(FΣ is equivalent to an ODE)
I John Pryce found a linear programming problem equivalent to (5)
25 / 36
Extending the structural analysis
Extending the Σ-method to non-square systems
F = 0 possibly non-square in:
1. Find an equation complete matching of GF (injection F 7→ X ); if success then
2. Applying Σ-method to GF yields a FΣ, possibly non regular (non-square!)
3. Dulmage-Mendelsohn decomposition:
FΣ = FH︸ ︷︷ ︸underdetermined
] FS︸ ︷︷ ︸regular
] FV︸ ︷︷ ︸overdetermined: ∅
4. If F was not empty but FS is, we are stuck and report underspecification
5. Otherwise, return FS as a partial DAE model for solving,which, hopefully, enables evaluating additional variables and guards
25 / 36
Extending the structural analysis
Resolving conflicts between past and present, structurally
1. W dependent variables in: F (W ,X ) = F past(W ,X ) ] F pres(W ,X )
2. Dulmage-Mendelsohn decomposition:
F = FH︸ ︷︷ ︸underdetermined
] FS︸ ︷︷ ︸regular
] FV︸ ︷︷ ︸overdetermined
3. Remove, from F , the present part of FV , i.e., F pres ∩ FV
Since F past had no overdetermined part, so has the reduced F
4. The final question is: is the so reduced F structurally regular?
I Yes: we solve F=0, which opens the way to evaluating more guardsI No: the model lacks information and we return this info to the designer
25 / 36
Clutch: structural analysis
ω1, ω2start
γ, ω1, ω2,e3, e4
γ, ω1, ω2,τ1, τ2, ω
•1 , ω
•2 ,
e∂1 , e∂2 , e3,
e4, e5, e6
γ, ω1, ω2,e5, e6
γ, ω1, ω2,τ1, τ2, ω
•1 , ω
•2 ,
e∂1 , e∂2 , e•3 ,
e4, e5, e6
ω1, ω2, ]e3
γ, ω1, ω2,e3, e4
γ, ω1, ω2,τ1, τ2, ω
•1 , ω
•2 ,
e∂1 , e∂2 , e3,
e4, e5, e6
γ, ω1, ω2,e3, e5, e6
γ, ω1, ω2,τ1, τ2, ω
•1 , ω
•2 ,
e∂1 , e∂2 , e3, e•3 ,
e4, e5, e6
γ; e3; e4
γ; e5; e6
e5; e6;e∂1 ; e∂2
Tick
e∂1 + e∂2 + e•3 + e4
Tickγ; e3; e4
γ; e5; e6; PR(e3)
e5; e6; e∂1 ; e∂2
Tick
e∂1 + e∂2 +e•3 + e4
Tick
26 / 36
Motivations
An unexpected simulation example
The clutch exampleSeparate analysis of each modeThe mode transitions
The clutch example: a comprehensive approachOverview of our approachNonstandard structural analysisBack-Standardization
How to make this work in generalStructural analysisResults and code for the clutch
Standardization
Further results and conclusion
Additional materialThe railcar example
27 / 36
Clutch: (standard) executable code
Our executable code yields this simulation
28 / 36
Clutch: (standard) executable code
mode ¬γ : index 0τ1 = 0; τ2 = 0;ω′1 = a1ω1 + b1τ1;ω′2 = a2ω2 + b2τ2
start
mode γ : index 1τ1 = (a2ω2 − a1ω1)/(b1 + b2); τ2 = −τ1;ω′1 = a1ω1 + b1τ1; ω′2 = a2ω2 + b2τ2;constraint ω1 − ω2 = 0
when γ doτ1 = NaN; τ2 = NaN;
ω+1 = ω+
2 =b2ω
−1 + b1ω
−2
b1 + b2done
when ¬γ doτ1 = 0; τ2 = 0;ω+
1 = ω−1 ;ω+
2 = ω−2done
How do we obtain this in general?
28 / 36
Clutch: (standard) executable code
Standardization:
I Inside each continuous mode: target continuous time and map backward
x• − x∂
7→ x ′
I At mode changes:
I We target discrete time and must get rid of ∂ in space
I Setting ∂ ← 0 generally yields a structurally singular system
I This is due to impulsive variablesIdentify them by performing impulse analysisand then eliminate them (if possible)
I Having done this we can safely set ∂ ← 0 and produce the codethat computes restart values for non impulsive variables (enough)
28 / 36
Motivations
An unexpected simulation example
The clutch exampleSeparate analysis of each modeThe mode transitions
The clutch example: a comprehensive approachOverview of our approachNonstandard structural analysisBack-Standardization
How to make this work in generalStructural analysisResults and code for the clutch
Standardization
Further results and conclusion
Additional materialThe railcar example
29 / 36
Further results
I We used the following nonstandard interpretation of the derivative:
x ′ ← x• − x∂
What if we use instead
x ′ ← 1∂
∑n
αn (x• − x)•n where∑
n
αn = 1
Theorem: Provided we can eliminate impulsive variables, nothing dependson the particular choice of (αn)M≤n≤N
I While performing structural analysis, we can equally well differentiate orshift forward equations—both transform the bipartite graph the same way
There are strategies to take the best option for an easier standardization(work in progress)
30 / 36
Further results
I We used the following nonstandard interpretation of the derivative:
x ′ ← x• − x∂
What if we use instead
x ′ ← 1∂
∑n
αn (x• − x)•n where∑
n
αn = 1
Theorem: Provided we can eliminate impulsive variables, nothing dependson the particular choice of (αn)M≤n≤N
I While performing structural analysis, we can equally well differentiate orshift forward equations—both transform the bipartite graph the same way
There are strategies to take the best option for an easier standardization(work in progress)
30 / 36
Concluding remarks
I We proposed a systematic approach for the compilation of multimodeDAE system models, from source specification to simulation code
I Our approach is physics-agnostics (better than multi-physics?)
I We reject some models, considered “spurious” by the structural analysis:
I overconstrained (within modes or at mode changes)I underspecified (some missing information at restart events)I causality cycle: var→guard→eqn→var,
a fixpoint equation that we do not support (new to multi-mode)
I One particular key condition is: being able to eliminate impulsive variables:
I Is this a restriction?I How does it relate to physics?
31 / 36
Concluding remarks
I We proposed a systematic approach for the compilation of multimodeDAE system models, from source specification to simulation code
I Our approach is physics-agnostics (better than multi-physics?)
I We reject some models, considered “spurious” by the structural analysis:
I overconstrained (within modes or at mode changes)I underspecified (some missing information at restart events)I causality cycle: var→guard→eqn→var,
a fixpoint equation that we do not support (new to multi-mode)
I One particular key condition is: being able to eliminate impulsive variables:
I Is this a restriction?I How does it relate to physics?
31 / 36
Concluding remarks
I We proposed a systematic approach for the compilation of multimodeDAE system models, from source specification to simulation code
I Our approach is physics-agnostics (better than multi-physics?)
I We reject some models, considered “spurious” by the structural analysis:
I overconstrained (within modes or at mode changes)I underspecified (some missing information at restart events)I causality cycle: var→guard→eqn→var,
a fixpoint equation that we do not support (new to multi-mode)
I One particular key condition is: being able to eliminate impulsive variables:
I Is this a restriction?I How does it relate to physics?
31 / 36
Thank you
32 / 36
Motivations
An unexpected simulation example
The clutch exampleSeparate analysis of each modeThe mode transitions
The clutch example: a comprehensive approachOverview of our approachNonstandard structural analysisBack-Standardization
How to make this work in generalStructural analysisResults and code for the clutch
Standardization
Further results and conclusion
Additional materialThe railcar example
33 / 36
The Railcar example
The model
R=10
restriction1
R=10
restriction2
valve
C=0.001
piston
C=0.020
tank
ground1
R=100000
leakage
V
brakeForce
pin_p pin_n
v
boundary conditions: vn=vp=0
class RailcarFlatparameter Real R1 = 10.0;parameter Real R2 = 10.0;parameter Real R3 = 100000.0;parameter Real C1 = 0.001;parameter Real C2 = 0.02;Boolean g;Real u2(start=0,fixed=true);Real u1(start=0,fixed=true);equationv1 = R1 * ip;v1 = vp - u1 - u2;v2 = R2 * (- in);v2 = u1 + u2 - vn;g = s < 0.0;u1 = s * (if g then 1.0 else 0.0);i = s * (if g then 0.0 else 1.0);i1 = C1 * der(u1);i2 = C2 * der(u2);u1 = R3 * j;ip + in - i - i1 - j = 0.0;i + i1 - i2 + j = 0.0;end RailcarFlat;
34 / 36
The Railcar example
0 = v1 − R1ip (e1)0 = v1 + u1 + u2 (e2)0 = v2 + R2in (e3)0 = v2 − u1 − u2 (e4)0 = u1 − R3j (e5)0 = ip + in − i − i1 − j (e6)0 = i + i1 − i2 + j (e7)0 = i1 − C1u′1 (e8)0 = i2 − C2u′2 (e9)γ = [s < 0] (e10)
when γ do 0 = u1 − s (e11)and 0 = i (e12)
when not γ do 0 = u1 (e13)and 0 = i − s (e14)
34 / 36
The Railcar example
0 = v1 − R1ip (e1)0 = v1 + u1 + u2 (e2)0 = v2 + R2in (e3)0 = v2 − u1 − u2 (e4)0 = u1 − R3j (e5)0 = ip + in − i − i1 − j (e6)0 = i + i1 − i2 + j (e7)0 = i1 − C1u′1 (e8)0 = i2 − C2u′2 (e9)γ = [s < 0] (e10)
when γ do 0 = u1 − s (e11)and 0 = i (e12)
when not γ do 0 = u1 (e13)and 0 = i − s (e14)
34 / 36
The Railcar example
(e1) : v1, ip(e2) : v1
(e3) : v2, in(e4) : v2
(e5) : j(e6) : ip, in, i , i1, j(e7) : i , i1, i2, j(e8) : i1, u′1(e9) : i2, u′2
.
(e6) : ip, in, i , i1, j(e7) : i , i1, i2, j(e8) : i1, u′1
βu (e9) : i2, u′2======= =========βe (e3) : v2, in
(e4) : u1, u2, v2
−−− −−−−−−−(e1) : v1, ip(e2) : u1, u2, v1
−−− −−−−−−−(e5) : u1, j︸ ︷︷ ︸Dulmage−Mendelsohn
1. we solve βe,which determinesin, v2, ip, v1, j .
2. we return to βu,which remainsunderdeterminedsince i isunmatched.
3. we get stuck:the program isrejected(underdetermined)with diagnosis
34 / 36
The Railcar example
(e1) : v1, ip(e2) : v1
(e3) : v2, in(e4) : v2
(e5) : j(e6) : ip, in, i , i1, j(e7) : i , i1, i2, j(e8) : i1, u′1(e9) : i2, u′2
.
(e6) : ip, in, i , i1, j(e7) : i , i1, i2, j(e8) : i1, u′1
βu (e9) : i2, u′2======= =========βe (e3) : v2, in
(e4) : u1, u2, v2
−−− −−−−−−−(e1) : v1, ip(e2) : u1, u2, v1
−−− −−−−−−−(e5) : u1, j︸ ︷︷ ︸Dulmage−Mendelsohn
1. we solve βe,which determinesin, v2, ip, v1, j .
2. we return to βu,which remainsunderdeterminedsince i isunmatched.
3. we get stuck:the program isrejected(underdetermined)with diagnosis
34 / 36
The Railcar example
(e1) : v1, ip(e2) : v1
(e3) : v2, in(e4) : v2
(e5) : j(e6) : ip, in, i , i1, j(e7) : i , i1, i2, j(e8) : i1, u′1(e9) : i2, u′2
.
(e6) : ip, in, i , i1, j(e7) : i , i1, i2, j(e8) : i1, u′1
βu (e9) : i2, u′2======= =========βe (e3) : v2, in
(e4) : u1, u2, v2
−−− −−−−−−−(e1) : v1, ip(e2) : u1, u2, v1
−−− −−−−−−−(e5) : u1, j︸ ︷︷ ︸Dulmage−Mendelsohn
1. we solve βe,which determinesin, v2, ip, v1, j .
2. we return to βu,which remainsunderdeterminedsince i isunmatched.
3. we get stuck:the program isrejected(underdetermined)with diagnosis
34 / 36
The Railcar example, corrected
0 = v1 − R1ip (e1)0 = v1 + u1 + u2 (e2)0 = v2 + R2in (e3)0 = v2 − u1 − u2 (e4)0 = u1 − R3j (e5)0 = ip + in − i − i1 − j (e6)0 = i + i1 − i2 + j (e7)0 = i1 − C1u′1 (e8)0 = i2 − C2u′2 (e9)γ• = [s < 0]; γ(0) = T (e10)
when γ do 0 = u1 − s (e11)and 0 = i (e12)
when not γ do 0 = u1 (e13)and 0 = i − s (e14)
35 / 36
The Railcar example, corrected
0 = v1 − R1ip (e1)0 = v1 + u1 + u2 (e2)0 = v2 + R2in (e3)0 = v2 − u1 − u2 (e4)0 = u1 − R3j (e5)0 = ip + in − i − i1 − j (e6)0 = i + i1 − i2 + j (e7)0 = i1 − C1u′1 (e8)0 = i2 − C2u′2 (e9)γ• = [s < 0]; γ(0) = T (e10)
when γ do 0 = u1 − s (e11)and 0 = i (e12)
when not γ do 0 = u1 (e13)and 0 = i − s (e14)
Case γ = T.
1. We solve (e1, ..., e9, e11, e12) (structurally nonsingular)
2. We evaluate γ• and we are done
35 / 36
The Railcar example, corrected
0 = v1 − R1ip (e1)0 = v1 + u1 + u2 (e2)0 = v2 + R2in (e3)0 = v2 − u1 − u2 (e4)0 = u1 − R3j (e5)0 = ip + in − i − i1 − j (e6)0 = i + i1 − i2 + j (e7)0 = i1 − C1u′1 (e8)0 = i2 − C2u′2 (e9)γ• = [s < 0]; γ(0) = T (e10)
when γ do 0 = u1 − s (e11)and 0 = i (e12)
when not γ do 0 = u1 (e13)and 0 = i − s (e14)
Case γ = F. (e13) causes an index problem.
35 / 36
The Railcar example, corrected
0 = v1 − R1ip (e1)0 = v1 + u1 + u2 (e2)0 = v2 + R2in (e3)0 = v2 − u1 − u2 (e4)0 = u1 − R3j (e5)0 = ip + in − i − i1 − j (e6)0 = i + i1 − i2 + j (e7)0 = i1 − C1u′1 (e8)0 = i2 − C2u′2 (e9)γ• = [s < 0]; γ(0) = T (e10)
when γ do 0 = u1 − s (e11)and 0 = i (e12)
when not γ do 0 = u1 (e13)when not γ do 0 = u•1 (e•13)
and 0 = i − s (e14)
1. •γ = F: we replace (e13) by (e•13) and solve the system
2. •γ = T: (e13) causes conflict with the past and is thus deleted. And so on35 / 36
Discussion
I We can go ahead with standardization and generate final code:
I Impulse analysis finds that i, i1, s are impulsive at mode change γ:T→FI We eliminate them and get reinit code for this mode changeI Other modes or mode changes raise no problem.
I However, there is no physical reason for having index reduction norimpulsive variables at mode change γ:T→F.
I Intelligent solution:
I s = 0 holds at mode changes, ignored by our structural algorithmI add this info via a mechanism of assertion, used by our algorithm
when γ and not •γ assert s = 0
when not γ and •γ assert s = 0
I Stupid solution: what we did. Gives same reinit code after standardization.
36 / 36