Modeling and Simulation from Physics to Languages and Software Karl Johan Åström Department of Automatic Control LTH Lund University Collège de France March 19 2013 Modeling 

Download Report

Transcript Modeling and Simulation from Physics to Languages and Software Karl Johan Åström Department of Automatic Control LTH Lund University Collège de France March 19 2013 Modeling 

Slide 1

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 2

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 3

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 4

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 5

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 6

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 7

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 8

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 9

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 10

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 11

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 12

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 13

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 14

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 15

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 16

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 17

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 18

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 19

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 20

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 21

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 22

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 23

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 24

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 25

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 26

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 27

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 28

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 29

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 30

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 31

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 32

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 33

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 34

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 35

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 36

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 37

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 38

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 39

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 40

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 41

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 42

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 43

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 44

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 45

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 46

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 47

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 48

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 49

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 50

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 51

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 52

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 53

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 54

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 55

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 56

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 57

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 58

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 59

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013


Slide 60

Modeling and Simulation
from Physics to Languages and Software

Karl Johan Åström
Department of Automatic Control LTH
Lund University

Collège de France March 19 2013

Modeling
 Important for the development of science,
example: Brahe, Kepler, Newton
 Essential element of all engineering
 Process design and optimization
 Insight and understanding
 Control design and optimization
 Implementation – The internal model principle
 Simulation: Illustrate behavior of model, HIL
hardware in the loop, SIL software in the loop
 Validation and verification
 Diagnostics, fault detection, reconfiguration
Collège de France March 19 2013

Many Views on Modeling
 Physics: Mass, energy, momentum balances
constitutive material equations
 Mathematics: ODE, DAE, PDE
 Engineering: Free body diagrams, circuit
diagrams, block diagrams, P&I diagrams
 Computer Science: Languages, datastructures,
programming, imperative, declarative
 Block Diagram Modeling: Causal modeling,
imperative
 Equation Based Modeling: Physics based,
acausal, declarative, behavioral
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

1. Introduction
2. Block Diagram Modeling

3. Equation Based Modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Complexity
 Many different physical domains
 Large physical dimensions
 Large number of components
 Complex behavior
 Tight coupling: Computers and physical
devices, Recirculation, heat recovery, just-intime production
 Concurrent design: Toyota Prius
 Mixed continuous- and discrete-time
behavior: gear box
Collège de France March 19 2013

Dealing with Complexity
 Abstractions and formal methods

 Mathematics and computer science
 Information hiding
 Object orientation (classes, inheritance)
 Standardization
 Libraries, reuse
 Normalization and scaling
Collège de France March 19 2013

Block Diagram Modeling
 Information hiding
 Blocks described by ODE
 Causal inputs-output models
 Very useful abstraction
 Key for analog computing
 Essential for control
 BUT not for serious physical
modeling
Oppelt 1954
Collège de France March 19 2013

Vannevar Bush 1927
Engineering can progress no faster than the
mathematical analysis on which it is based. Formal
mathematics is frequently inadequate for numerous
problems, a mechanical solution offers the most
promise. => The mechanical differential analyzer.

Simulation shows behaviors of a model
Collège de France March 19 2013

Analog Computing








Solving ordinary differential equations ODE
A feedback loop is used to solve ODE
Integrators and function generation
Parallelism
Algebraic loops
Granularity and aggregation
Alarms for out of scale!!

Collège de France March 19 2013

Example: Motor Drive
controller

Jl=10

motor

wr

PI
n=100

La=0.05

Ra=0.5

Jm=1.0E-3
Vs

emf

G

Collège de France March 19 2013

wl

Mathematical Model
Physical model (equations) Transform to state model ODE

7 equations
4 differentiated variables
3 algebraic equations
3 states in ODE
Parameters aggregated
Collège de France March 19 2013

Analog Circuit Diagram

Algebraic loop?

Collège de France March 19 2013

Analog Simulation & HIL
 Ordinary differential equations dx/dt=f(x,p)
 Scaling, patching, potentiometer setting
 Algebraic loops
 Set initial conditions and parameters
 Direct manipulation of parameters
 Print results
 Simulation centers
 Hardware in the loop simulation

Collège de France March 19 2013

HILS Today

Collège de France March 19 2013

The Whirlwind Computer
 Flight trainer-analyzer 1944-56
 MIT Servomechanism Laboratory Forrester 1944
 From analog to digital computing

 Core memory 1953
 Ken Olsen Digital Equipment 1957

 PDP 8 1965

Collège de France March 19 2013

Digital Emulators











MIMIC Wright-Patterson 1965
CSMP IBM 1962
Babels tower > 30 emulators by 1965
CSSL Simulation Council 1967
ACSL Gauthier and Mitchell 1975
SIMNON Elmqvist 1975
MATLAB Cleve Moler 1980
System Build, MatrixX 1984
LabView 1986
Simulink 1991

Collège de France March 19 2013

CSSL
PROGRAM test
INITIAL
a=1
END $ ”of initial”
DYNAMIC
DERIVATIVE
f=a*x^2+b
b=1
xdot=f
END $ ”of DERIVATIVE”
termt(t.ge.tmx or x.gt.1)
END $ ”of DERIVATIVE”
END $ ”of DYNAMIC”
END $ ”of PROGRAM”

Collège de France March 19 2013

 Declarative
 Sorting
 Algebraic loops
 FORTRAN preprocessor
 FORTRAN compilation
 Predefined functions termt
 Run time library
 Explicit integration algorithm
 Parameter changes without
recompilation

LTH in the 70s
 New department (1965) at new school LTH (1961)
close to an old university (Lund University 1666)
 Research program in Control Department:
Optimization, Computer Control, System Identification,
Adaptive Control + Honest applications, real industrial
projects => Computer Aided Control Engineering, CACE
 Interactive computing: INTRAC, SYNPAC, IDPAC,
MODPAC (Wieslander), FORTRAN, widely distributed to
industry and universities
 A nonlinear simulator was missing

 IBM San Jose and CSMP development (Brennan)
Collège de France March 19 2013

Simnon Elmqvist 1972
Block diagram language, interactive simulator: continuous and discrete systems
Formal syntax in Bachus Naur format
Scripting language: 6 basic commands: SYST, PAR, INIT SIMU, PLOT, AXES
8 auxiliary: STORE, SHOW, DISP, SPLIT, HCOPY, ALGOR, ERROR, MACRO
CONTINUOUS SYSTEM proc
Input u
Output y
State x
Der dx
dx=sat(u,0.1)
END

CONNECTING SYSTEM
yr(reg)=1; y(reg)=y(proc)
u(proc)=u(reg)
END
Collège de France March 19 2013

DISCRETE SYSTEM reg
Input yr y
Output u
State I
New nI
Tsamp ts
ts=t+h
v=k*e+I
u=sat(v.0.1)
nI=I+k*h*e/Ti+u-v
k:1
h:0.1
END

Matlab
 Linpac, Cleve Moler 1980: MATLAB – An Interactive
Matrix Laboratory, Workshop on Numerical Methods in
Automatic Control Lund Sept 1980. MATLAB users
guide June 1980, Rev. June 1981 (FORTRAN)
 Systems Control Inc Palo Alto CTRL-C – Control
extensions and graphics to Moler’s MATLAB code
 Integrated Systems Inc (ISI), Matrix-X 1982,
SystemBuild 1984, Code generation
 John Little, MathWorks, PC Matlab1984, Simulink 1991,
Toolboxes
 Blaise 1984, Scilab INRIA 1994, Octave GNU 1993,
SysQuake (interactive) Calerga 1998
 Comsol FemLab (PDE modeling) 2000
Collège de France March 19 2013

Simulink the Ultimate
Block Diagram Tool
 Mimics the analog computer with more general blocks
 Each block a state model

 MATLAB, Stateflow
 Granularity and Structuring
 Graphical aggregation and disaggregation

 Much manual manipulation from physics to blocks
 Syntax and semantics not publically available
Collège de France March 19 2013

But!!
States may disappear when systems areconnected –
warning algebraic loop

a

b

c

d

Composition does not work
Much manual labor, the same
parameter in many blocks
Lesson 1: Block diagrams not suitable for serious physical
modeling
Lesson 2: Don’t stick to a paradigm based on old technology
when new technology emerges!!
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Boiler Control Project

 Experiments, modeling, system identification
 Eklund Drum Boiler-Turbine Models 1971
 Lindahl Design and Simulation of a Coordinated
Drum Boiler-Turbine Controller Dec 1976 (Simnon)
Collège de France March 19 2013

Electronics
 Electric circuits: multi port systems
 Component based: resistor, capacitor, inductor,
transistor. Model components and connect them.
 Nagel, Peterson Berkeley 1973, SPICE2 1975, …
 FORTRAN
 Kirchoffs voltage and current laws
 Node equations
 Nonlinear equations - Tearing
 Differential algebraic equations DAE, W. Gear
 Important part of Tool Chain for VLSI design
 IEEE Mile stone
Collège de France March 19 2013

Bond Graphs
 Henry Paynter MIT, Analysis and design of engineering
systems, The M.I.T. Press, Boston, 1961
 Graphical representation of bi-directional exchange of
energy using across and through variables

 Difficult to handle mass, energy and
momentum balances, boiler model very
complicated
Collège de France March 19 2013

Dymola
SPICE Electrical Circuits – Physics much richer
DAE Solvers Gear Petzold
SPEEDUP Chemical Engineering
Multibody Mechanical Adams
1978
Dymola Elmqvist LTH BNF
Equation based
Object orientation (Simula)
Extensive symbolic computing
Boiler-turbine test case
 Great idea but premature due to
limitations of computers and software






www.control.lth.se/Publication/elm78dis.html

Collège de France March 19 2013

Physical Modeling





Wide physical domains require generality
Divide a system into subsystems, define interfaces
Use object orientation for structuring
Mass, momentum and energy balances for
subsystems
 Model subsystems by DAE not ODE
 Constitutive equations and data bases for material
properties
 Libraries for reuse
 Symbolic computation to generate code for
simulation and optimization
Collège de France March 19 2013

Computations

Eliminate trivial equation
Reduction to BLT (Block lower triangular form)
Analytic solution of linear equations
Solve nonlinear equations (Newton, Tearing)
Integrate DAEs (index reduction)
Collège de France March 19 2013

Tarjan’s Algorithm
 Represent equations and variables
as a directed graph
 Algorithm gives
strongly connected
components
 The BLT form

Collège de France March 19 2013

Kron’s Tearing
 Solving large nonlinear equations
 Gabriel Kron: Diakoptics – The Piecewise Solution
of Large-Scale Systems Electrical Journal London
1957-59
 Reduce a large equation to a set of smaller
equations
 Select tearing variables and a corresponding set of
equations whose errors are called residuals.
 Iterate until residuals are sufficiently small

Collège de France March 19 2013

Tearing

Collège de France March 19 2013

Tearing
Variables

Transform BLT-blocks (algebraic loops) into
bordered triangular matrices
Exploit that many equations can be solved
analytically – diagonal incidence (L)
Only a small number of residual
equation remains (J)
Lm ∙ m
Finding smallest k is NP-complete
Intuition: if tearing variables are
known, L-part can be solved Residual
Equation
Bk ∙ m
analytically in sequence
s
 Exploit physics, heuristics

Ak ∙ m

Jk ∙ k

33

ODE and DAE
Differential algebraic equation

Special case

Natural for capturing connnections:

Collège de France March 19 2013

Index - Linear DAE
DAE regular if the matrix pencil
is regular
for all . A regular matrix pencil can be transformed
to the Weierstrass-Kronecker normal form

where C is on Jordan form and
is a block diagonal matrix where all elements are
nonzero except the super diagonal which are 1
Collège de France March 19 2013

Linear ODE - Index

The smallest integer m such that
differentiation index of the ODE

is called the

Index tells how many times input is differentiated
Collège de France March 19 2013

Omola-Omsim
 We terminated research on CACE around 1980
because of computers, FORTRAN and MATLAB
 New research project 1990 Object Oriented Modeling
and Simulation: Sven Erik Mattsson, Mats Andersson,
Bernt Nilsson, Dag Bruck
 Experimentation in Lisp & KEE
 C++ for object orientation
 Language (Omola) and simulator (OmSim)
 Refining symbolic manipulations (Mattsson)

 Index reduction for DAE
Collège de France March 19 2013

Dynasim ++
 Founded by Elmqvist in Lund 1992
 Collaboration with Lund University and DLR
 Extensively used in design of Toyota Prius from 1996
 Migration of researchers from LU to Dynasim

 Acquired by Dassault Systèmes 2006
 Integration with Catia
 Synchronous extensions
 Modelon: Eborn, Tummescheit, Gäfvert,
 Optimica and Jmodelica: Åkesson
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling
 Wide range of physics: EE, ME, ChemE,
BioEng, …
 Control and optimization
 Computer Science
 Numerical Mathematics
 Software
 Many tools are required
 Very strong incentive for collaboration
 How to maintain flexibility?
Collège de France March 19 2013

Modelica
 Lund University (Omola, Omsim) & Dynasim (Dymola)
 Discussions of future development
 ESPRIT Simulation in Europe, Lund Sept 2-6, 1996
 COSY meeting Lund Sept 5-7, 1996

 23 participants from European groups: Dynasim and
LTH Lund, ETH Zurich, INRIA Paris, DLR Munich, VTT
Helsinki, Imperial College London, RWTH Aachen,
universities of Barcelona, Groningen, Valencia, Wien
 Formation of the Modelica language group
 First Modelica language specification Sept 1997
Collège de France March 19 2013

Collège de France March 19 2013

 Modelica® is a non-proprietary, object-oriented,
equation based language for modeling complex
physical systems
 The Modelica Association is a non-profit, nongovernmental organization with the aim of developing
and promoting the Modelica modeling language
https://www.modelica.org
 Research projects within Europe spend 75 Mill. € in
the years 2007-2015 to further improve Modelica and
Modelica related technology. This is performed within
the ITEA2 projects EUROSYSLIB, MODELISAR,
OPENPROD, and MODRIO
Collège de France March 19 2013

 Modelica conference 10th 2014
 Design meetings 82nd 2014
 Modelica standard library
 Modelica Simulation Environments: CATIA
Systems,CyModelica, Dymola, LMS AMESim,
JModelica.org, MapleSim, OpenModelica, SCICOS,
Simulation X, Vertex and Wolfram SystemModeler
 Home page www.modelica.org

Collège de France March 19 2013

Overview Transparency and Details
k2
i
qddRef

qdRef

qRef

1

1

S

S

k1

cut joint

r3Control
r3Motor

i

axis6

tn

r3Drive1
1

qd

qdRef

Kd

q: angle
qd: angular velocity
qdd: angular acceleration

S
rel

0.03
Jmotor=J

pSum

-

Kv
0.3

sum

w Sum

+1
+1

-

rate2

rate3

b(s)

340.8

a(s)

S

joint=0

spring=c

S

iRef

axis4

gear=i

fric=Rv0

qRef

axis5

axis3
rate1

tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1
g5

q

C=0.004*D/w m

Rd1=100

Rp1=200

Rd2=100
Ri=10

-

cut in

-

+
diff

+

+

pow er
OpI

Ra=250 La=(250/(2*D*w m))

Rp2=50

qd

axis2

axis1

Vs

Rd4=100
emf
Rd3=100

iRef

y

g3

x
inertial

g1

hall2

Collège de France March 19 2013

hall1

g2

qd

g4

w

r

q

Modelica Libraries
R=

C=

Info

L=

Info

body=

bar=

bodyBar=

inertial

G

cylBody=
bodyShape=
shaftS=
shaft3DS= shaft3D=

S

S

S
gear2= S
univS

shaft=

S

planarS= sphereS

freeS

S
D

T

gear1=

diff= +

Op

: bearing
1

sun=
fixTooth

E
c=

S
planetary=
ring=
cyl=

planet=
V
i

screw =
S
y
moveS barC=move
d=

C

torque

force

fricTab

clutch=

a

fric=

t

S

Collège de France March 19 2013

rev=

univ

planar=

sphere

sphereC

c=

d=

prism=

free

cSer=

C
sensor

lineForce=
lineTorque=

advanced

drive

translation

Library

Library

Library

fixedBase

state

S

S

torque
r
converter

w

x
barC2=

S

prismS= screw S=

revS=

Is

Vs

DC=

AC=

Info

cylS=

S

lineSensor
s

sd

MSL
Electric analog
Electric digital
Electrical machines
Electromagnetics
1D mechanics
3D multibody
Control blocks
Finite state machines
Synchronous
Logical
Functions
Matrices

Vehicle Simulation
Detailed vehichle model with chassi and power train
Original model:
Number of components: 6863
Variables: 53495
Differentiated variables: 1683 scalars

After reduction:
States: 330
Largest nonlinear systems: {3, 3, 3, 3}
100 x real time on Xeon E5649 with 4 cores
Slide courtesy of Johan Andreasson Modelon AB
Collège de France March 19 2013

Mill Wide Control
Dynamic
mass balance

Billerud Gruvön
plant

Lockmannkolonn
inletPulp
outletNCG

inletSteam

7
6

8

Diffusören är
inbakad i kokaren
Flash 1-spliten är
en intern loop
outletCondensate

inletWL

Modelica modeling
inletWater

25
38
250
250
2500

Production units
Buffer tanks
Streams
Measurements
Variables

Slide courtesy of Alf Isaksson ABB
Collège de France March 19 2013

outletBL

outletPulp

Combined Cycle Power Plant
Alexandra Lind and Elin Sällberg
Ms Thesis on Start-up Optimization LTH,
Siemens, Modelon
www.control.lth.se/Publication/5900.html

Continuous states: 28
Scalar eq: 389
Algebraic eq: 361
Discrete NLP eq: 18772

Collège de France March 19 2013

Automotive Climate Control
 Audi, BMW, DaimlerCrysler,
Volkswagen and their suppliers have
standardized on Modelica
 Suppliers provide components and
validated Modelica models based on
the AirConditioning library from
Modelon
 Car manufacturers evaluate
complete system by simulation
 IP protected by extensive encryption

Picture courtesy of Behr GmbH & Co.
Collège de France March 19 2013

1. Introduction
2. Block diagram modeling

3. Equation based modeling
4. Modelica
5. Summary
Collège de France March 19 2013

Modeling is Important
There will be growth in areas of
simulation and modeling around the
creation of new engineering “structures”.
Computer-based design-build
engineering ... will become the norm for
most product designs, accelerating the
creation of complex structures for which
multiple subsystems combine to form a
final product.
NAE The Engineer of 2020
Collège de France March 19 2013

More than Simulation
 From requirements to hardware in operation
 Static modeling and system design
 Integrated process and control design
 Architecture exploration
 Optimization
 Model reduction (reduced order models)
 Parameter estimation
 Embedded systems
 Incorporation in tool chain
Collège de France March 19 2013

The Tool Chain
 One tool cannot do everything

 Requirements
 Architecture: System structure, sensors,
actuators, computers, communication, HMI
 Modeling and simulation: Physics and data
 Control Design: Models, algorithms and logic
 Implementation code generation: V&V
 HIL and MIL simulation
 Commissioning and tuning
 Operation: Diagnostics, assessment, fault
detection
 Reconfiguration and upgrading
Collège de France March 19 2013

Combining Tools
Functional mockup interface FMI

Collège de France March 19 2013

Validity ranges

Amplitude

 Extend alarm bell in analog computers
 The uncertainty lemon Gille, Pelegrin,
1
Decaulne 1959
10
10
10

0

−1

10

1

2

10
Frequency

 Amplitude ranges easy
 Frequency ranges by using dy/dt=w*y
Collège de France March 19 2013

10

3

Many Challenges
 Good beginning
 Many challenges
Improvements at many levels: language,
representation, symbolic and numeric
computations
 Role of formal methods
 Tool chain from requirements to system
 Modelica association is a good vehicle
 Join the effort and influence development!
Collège de France March 19 2013

Computing

Mathematics

Control

Communication

Collège de France March 19 2013

Physics
Engineering
Biology
Economy

Modeling
 Solomon Golomb: Mathematical models – Uses
and limitations. Aeronautical Journal 1968

Solomon Wolf Golomb (1932) mathematician
and engineer and a professor of electrical
engineering at the University of Southern
California. Best known to the general public and
fans of mathematical games as the inventor of
polyominoes, the inspiration for the computer
game Tetris. He has specialized in problems
of combinatorial analysis, number theory,
coding theory and communications.

Collège de France March 19 2013

Golomb On Modeling
 Don’t apply a model until you understand the
simplifying assumptions on which it is based and can
test their applicability. Validity ranges

 Distinguish at all times between the model and the
real world. You will never strike oil by drilling through
the map!
 Don’t expect that by having named a demon you
have destroyed him
 The purpose of notation and terminology should be
to enhance insight and facilitate computation – not to
impress or confuse the uninitiated
Collège de France March 19 2013