Modelica-OpenModelica-slides para aprender.pdf

CarlosParedes28 242 views 108 slides Mar 20, 2024
Slide 1
Slide 1 of 108
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45
Slide 46
46
Slide 47
47
Slide 48
48
Slide 49
49
Slide 50
50
Slide 51
51
Slide 52
52
Slide 53
53
Slide 54
54
Slide 55
55
Slide 56
56
Slide 57
57
Slide 58
58
Slide 59
59
Slide 60
60
Slide 61
61
Slide 62
62
Slide 63
63
Slide 64
64
Slide 65
65
Slide 66
66
Slide 67
67
Slide 68
68
Slide 69
69
Slide 70
70
Slide 71
71
Slide 72
72
Slide 73
73
Slide 74
74
Slide 75
75
Slide 76
76
Slide 77
77
Slide 78
78
Slide 79
79
Slide 80
80
Slide 81
81
Slide 82
82
Slide 83
83
Slide 84
84
Slide 85
85
Slide 86
86
Slide 87
87
Slide 88
88
Slide 89
89
Slide 90
90
Slide 91
91
Slide 92
92
Slide 93
93
Slide 94
94
Slide 95
95
Slide 96
96
Slide 97
97
Slide 98
98
Slide 99
99
Slide 100
100
Slide 101
101
Slide 102
102
Slide 103
103
Slide 104
104
Slide 105
105
Slide 106
106
Slide 107
107
Slide 108
108

About This Presentation

software modelica para aprender


Slide Content

Presentation at
RISE SICS East, Sweden
October 6, 2018 Peter Fritzson [email protected]
Full Professor at Linköping University
Director Open Source Modelica Consortium
Vice Chairman of Modelica Association
Director of the MODPROD Center for
model-based development
Modeling, Simulation, and Development of Cyber-
Physical Systems with OpenModelicaand FMI

2
Industrial Challenges for Complex Cyber-Physical
System Products of both Software and Hardware • Increased SoftwareFraction
•ShorterTime-to-Market
• Higher demands on effective
strategic decisionmaking
•Cyber-Physical(CPS) –Cyber (software)
Physical (hardware) products

3
Peter Fritzson Principles of Object Oriented
Modeling and Simulation with
Modelica 3.3
A Cyber-Physical Approach
Can be ordered from Wiley or Amazon
Wiley-IEEE Press, 2014, 1250 pages
• OpenModelica
•www.openmodelica.org
• ModelicaAssociation
•www.modelica.org
Big Book on Modelicaand Technology, Dec 2014
Download Free OpenModelicaSoftware

4
September 2011
232 pages
Translations
available in
Chinese,
Japanese,
Spanish
Wiley
IEEE Press
For Introductory
Short Courses on
Object Oriented
Mathematical Modeling
Introductory
Modelica Book

5
Part I
Introductionto Modelica

6
Modelica Background: Stored Knowledge
Model knowledge is stored in books and human
minds which computers cannot access
“The change of motion is proportional
to the motive force impressed “ –Newton

7
Modelica Background: The Form –Equations • Equations were used in the third millennium B.C.
• Equality sign was introduced by Robert Recorde in 1557
Newton still wrote text (Principia, vol. 1, 1686) “The change of motion is prop ortional to the motive force
impressed ” CSSL (1967) introduced a special form of “equation”:
variable = expression
v = INTEG(F)/m
Programming languages usually do not allow equations!

8
What is Modelica?
• Robotics
• Automotive
• Aircrafts
• Satellites
• Power plants
• Systems biology
A language for modeling of complex cyber-physical systems

9
What is Modelica? A language for modeling of complex cyber-physical systems
Primary designed for simulation, but there are also other
usages of models, e.g. optimization.

10
What is Modelica? A language for modeling of complex cyber-physical systems
i.e., Modelica is nota tool
Free, open language
specification: There exist several free and commercial
tools, for example:

OpenModelica from OSMC
• Dymola from Dassault systems
• Wolfram System Modeler fr
Wolfram MathCore
• SimulationX from ITI – ESI Group
• MapleSim from MapleSoft
•AMESIM from LMS
• JModelica.org from Modelon
• MWORKS from Tongyang Sw & Control
• IDA Simulation Env, from Equa
Available at: www.modelica.org
Developed and standardized
by Modelica Association

11
Declarative language
Equations and mathematical functions allow acausal modeling,
high level specification, increased correctness
Multi-domain modeling
Combine electrical, mechanical, thermodynamic, hydraulic,
biological, control, event, real-time, etc...
Everything is a class
Strongly typed object-oriented language with a general class
concept, Java & MATLAB-like syntax
Visual component programming
Hierarchical system architecture capabilities
Efficient, non-proprietary
Efficiency comparable to C; advanced equation compilation,
e.g. 300 000 equations, ~150 000 lines on standard PC
Modelica –
The Next Generation Modeling Language

12
What is acausalmodeling/design?
Why does it increase reuse?
The acausality makes Modelica library classes more
reusablethan traditional classes containing assignment
statements where the input-output causality is fixed.
Example: a resistor equation:
R*i = v;
can be used in three ways:
i := v/R;
v := R*i;
R := v/i;
Modelica Acausal Modeling

13
What is Special about Modelica?
• Multi-Domain Modeling
• Visual acausal hierarchical component modeling
• Typed declarative equation-based textual language
• Hybrid modeling and simulation

14
What is Special about Modelica? Multi-Domain
Modeling
Cyber-Physical Modeling
Physical
Cyber
3 domains
-electric
-mechanics
-control

15
What is Special about Modelica? Multi-Domain
Modeling
Acausal model (Modelica)
Causal block-based
model
(Simulink)
Keeps the physical
structure
Visual Acausal
Hierarchical
Component
Modeling

16
inertial
x
y
axis1axis2axis3axis4axis5axis6
r3Drive1
1
r3Motor
r3Control
qdRef
1
S
qRef
1 S
k2 i k1 i
qddRef
cut joint
l
qd
tn
Jmotor=J
gear=i
spring=c
fric=Rv0S rel
joint=0
S
Vs
-
+
dif f
-
+
pow er
emf
La=(250/(2*D*w m))Ra=250
Rd2=100
C=0 . 0 0 4 * D/ w m
-
+
Op I
Rd1=100
Ri=1 0
Rp1=200
Rp2=50
Rd4=100
hall2
Rd3=100
g1
g2
g3
hall1
g4
g5
r
w
qdq
rate2 b(s )
a(s )
rate3 340.8
S
rate1 b(s )
a(s )
tacho1
PT1
Kd
0.03
wSum
-
sum
+1
+1
pSum
-
Kv
0.3
tac ho2
b(s )
a(s )
q
qd
iRef qRef
qdRef
What is Special about Modelica?
Visual Acausal
Hierarchical
Component
Modeling
Multi-Domain
Modeling
Hierarchical system
modeling
Courtesy of Martin Otter
Srel = n*transpose(n)+(identity(3)- n*transpose(n))*cos(q)- skew(n)*sin(q);
wrela = n*qd;
zrela = n*qdd;
Sb = Sa*transpose(Srel);
r0b = r0a;
vb = Srel*va;
wb = Srel*(wa + wrela);
ab = Srel*aa;
zb = Srel*(za + zrela + cross(wa, wrela));

17
What is Special about Modelica? Multi-Domain
Modeling
Typed
Declarative
Equation-based
Textual Language
A textual class-basedlanguage
OO primary used for as a structuring concept
Behaviour described declaratively using
• Differential algebraic equations (DAE) (continuous-time)
• Event triggers (discrete-time)
classVanDerPol "Van der Pol oscillator model"
Real x(start = 1) "Descriptive string for x”;
Real y(start = 1) "y coordinate”;
parameterReal lambda = 0.3;
equation
der(x) = y;
der(y) = -x + lambda*(1 - x*x)*y;
endVanDerPol;
Differential equations
Variable
declarations
Visual Acausal
Hierarchical
Component
Modeling

18
What is Special about Modelica?
Hybrid
Modeling
Visual Acausal
Component
Modeling
Multi-Domain
Modeling
Typed
Declarative
Equation-based
Textual Language
time
Continuous-time
Discrete-time
Hybrid modeling =
continuous-time + discrete-time modeling
Clocked discrete-time

19
Modelica vs Simulink Block Oriented Modeling
Simple Electrical Model
R1=10

C=0.01

L=0.1

R2=100

G

A
C=220

p
n
p
p p
p
p

n
n
n n
-1
1
sum3
+1
-1
sum1
+1
+1
sum2
1
s
l2 1
s
l1
sinln
1/R1
Res1
1/C
Cap
1/L
Ind
R2
Res2
Modelica:
Physical model –
easy to understand
Simulink:
Signal-flow model –hard to
understand
Keeps the
physical
structure

20
OpenModelicaToolGraphical Editor and Plotting
GraphicalModelingUsingDrag and Drop

21GraphicalModelingwithOpenModelicaEnvironment

22• A DC motor can be thought of as an electrical circuit which
also contains an electromechanical component
modelDCMotor
Resistor R(R=100);
Inductor L(L=100);
VsourceDC DC(f=10);
Ground G;
ElectroMechanicalElement EM(k=10,J=10, b=2);
Inertia load;
equation
connect(DC.p,R.n);
connect(R.p,L.n);
connect(L.p, EM.n);
connect(EM.p, DC.n);
connect(DC.n,G.p);
connect(EM.flange,load.flange);
endDCMotor
load

EM

DC
G
R L
Multi-Domain (Electro-Mechanical) ModelicaModel

23
Automatic transformation to ODE or DAE for simulation:
(loadcomponent not included)
Corresponding DCMotor Model Equations The following equations are automatically derived from the Mode lica model:

24
ModelTranslationProcess to Hybrid DAE to Code
Modelica Model
Flat model Hybrid DAE
Sorted equations
C Code
Executable
Optimized sorted
equations
Modelica
Model
Modelica
Graphical Editor
Modelica Source code Translator Analyzer Optimizer Code generator C Compiler Simulation
Modelica Textual Editor
Frontend
Backend
"Middle-end"
Modeling
Environment

25
Brief Modelica History • First Modelica design group meeting in fall 1996
• International group of people with expert knowledge in both la nguage design
and physical modeling
• Industry and academia
• Modelica Versions
• 1.0 released September 1997
• 2.0 released March 2002
• 2.2 released March 2005
• 3.0 released September 2007
• 3.1 released May 2009
• 3.2 released March 2010
• 3.3 released May 2012
• 3.2 rev 2 released November 2013
• 3.3 rev 1 released July 2014
• 3.4 released May 2017
• Modelica Association established 2000 in Linköping
• Open, non-profit organization

26
Modelica in Power Generation
GTX Gas Turbine Power Cutoff Mechanism
Hello
Courtesy of Siemens Industrial Turbomachinery AB
Developed
by MathCore
for Siemens

27
Modelica in Automotive Industry

28
Modelica in Avionics

29
Application of Modelica in Robotics Models
Real-time Training Simulator for Flight, Driving
Courtesy of Tobias Bellmann, DLR,
Oberphaffenhofen, Germany
• Using Modelica models
generating real-time
code
• Different simulation
environments (e.g.
Flight, Car Driving,
Helicopter)
• Developed at DLR
Munich, Germany
• Dymola Modelica tool

30
Large Robotic Flight Simulator (Demo)

31
• GT unit, ST unit, Drum
boilers unit and HRSG units,
connected by thermo-fluid
ports and by signal buses
• Low-temperature parts
(condenser, feedwater
system, LP circuits) are
represented by trivial
boundary conditions.
• GT model: simple law
relating the electrical load
request with the exhaust gas
temperature and flow rate.
Combined-Cycle Power Plant Plant model –system level
Courtesy Francesco Casella, Politecnico di Milano – Italy
and Francesco Pretolani, CESI SpA - Italy

32
Attitude control for satellites
using magnetic coils as actuators
Torque generation mechanism:
interaction between coils and
geomagnetic field
Formation flying on elliptical orbits
Control the relative motion of two or more
spacecraft
Modelica Spacecraft Dynamics Library
Courtesy of Francesco Casella, Politecnico di Milano, Italy

33BiggestImmediateChallenge for Humanity – Createa SustainableSociety–AvoidGlobal Collapsein 50 Years
World System Dynamics
Simulation with OpenModelica – World3 model
, Meadows et al
Sustainable, Scenario 9
4% improvement per year
Collapse ca 2070, Scenario 2
Close to current developments
Climate change, pollution, desertification, etc.
www.openmodelica.org
Download software from
World
population
Year

34
World3 Model in Modelica, Meadows et al, Cellier Comprehensive model –13 areas
• Population
dynamics
• Human fertility
• Human ecological
footprint
• Pollution
dynamics
• Industrial
investment
• Human welfare
• Arable land
• Labor utilization
• Life expectancy
• Food production
• Land fertility
• Non-recover
resource
• Service sector

35EachYearNew Record for Global MeanTemperature
Thisis February2016

36World3 Simulations with Different Start Years
for Sustainable Policies –Collapse if starting too late

37

How the world could be in 80-100 years
at a global warming of 4 degrees
See level rise 2 m
flooding coastal cities Uninhabitable
New Scientist, 28 february 2009
IPCC, business as usual scenario
www.climate-lab-book.ac.uk www.atmosfair.de References
Cities, agriculture
Uninhabitable desert
Uninhabitable due
to extreme weather
Flooded
Business-as-usual
scenario, IPCC
Massive migration to
to northern Europe,
Russia, and Canada
Example Emissions
CO2e / person
- Earth can handle 2 ton/yr
- Flight Spain – 1 ton
- Flight Canaryisl – 2 ton
- Flight Thailand – 4 ton

39
Year 1750‐2000:  • Mean temperature 
north hemisphere, 
• Population,
• CO
2
‐concentration, 
• BNP, 
• Loss av rain forest,
• Water usage 
• Paper consumption, 
• Exterminated species 
• Oil consumtion, 
• Motor vehicles
• Destroyed fish 
populations 
• Destruction of ozon 
layer 
• Foreign investments
A Unique Point in History –Exponential Trends
Approaches Planet Earth Boundaries

40
NeedSmart Systems to Support a CircularEconom
y
for a SustainableSociety
•Circularmanagement of products, material, throughout the life-cycle
• Optimize manufacturing and usage over the entire life cycle

41What Can You Do? NeedGlobal SustainabilityMassMovement
• Develop smart Cyber-Physical systems for reduced energy and material footprint
• Model-based circular economy for re-use of products and materi als
• Promote sustainable lifestyle and technology
• Install electric solar PV panels
• Buy shares in cooperative wind power
20 sqm solar panels on garage roof, Nov 2012
Generated 2700 W at noon March 10, 2013
Expanded to 93 sqm, 12 kW, March 2013
House produced 11600 kwh, used 9500 kwh
Avoids 10 ton CO
2
emission per year

42
Example Electric Cars Can be charged by electricity from own solar panels
Renault ZOE; 5 seat; Range:
22kw (2014) vs 41 kwbattery (2017)
•RealisticSwedish drive cycle:
•Summer: 165 km, now 300 km
•Winter: 110 km, now200 km
Cheap fast AC chargers (22kw, 43kw)
Tesla model S
range 480 km
DLR ROboMObil
•experimental electric car
•Modelica models

43
What Can You Do? MoreTrainTravel–Less Air Travel • Air travel by Swedish Citizens
–about the same emissions
as all personal car traffic in
Sweden!
• By train from Linköping to
Munich and back –saves
almost 1 ton of CO2e
emissions compared to flight
• Leave Linköping 07.00
in Munich 23.14
More Examples, PF travel 2016:
• Train Linköping-Paris, Dec 3-
6, EU project meeting
• Train Linköping-Dresden,
Dec 10-16, 1 week workshop
Train
travel
Linköping
-Munich

44
Small rectangles –surface needed
for 100% solar energy for humanity

45
Part II
Introduction to the OpenModelica Environment

The OpenModelica Environment
www.openmodelica.org

47
OpenModelica–FreeOpen Source Tool Developedby the OpenSource ModelicaConsortium(OSMC
)
• Graphical editor
• Model compiler
and simulator
• Debugger
• Performance
analyzer
• Dynamic optimizer
• Symbolic modeling
• Parallelization
• Electronic
Notebook and
OMWebbook
for teaching
• Spokentutorial for
teaching
EngineV6 11116 equation model

48
• Advanced Interactive Modelica compiler (OMC)
• Supports most of the Modelica Language
•Modelicaand Python scripting
• Basic environment for creating models
•OMShell– an interactive command handler
•OMNotebook– a literate programming notebook
•MDT– an advanced textual environment in Eclipse
48
•OMEditgraphic Editor
•OMDebuggerfor equations
•OMOptimoptimization tool
•OM Dynamic optimizercollocation
•ModelicaMLUML Profile
•MetaModelicaextension
•ParModelicaextension
•OMSimulator– FMI/TLM simulator
The OpenModelica Open Source Environment www.openmodelica.org
new

49
The OpenModelicaToolArchitecture
Simulation
Execution
OMEdit Graphic
and Textual
Model Editor
OMNotebook
Interactive
Notebooks
Debugger
OMC
Interactive Compiler
Server
ModelicaML
UML/Modelica
and requirement
verification
MDT
Eclipse Plugin
OMOptim
Optimization
3D
Visualization
OMShell
Modelica
Scripting
OMPython
Python
Scripting
OMSimulator FMI Simulation
OMJulia
Julia
Scripting
OMWebbook
Interactive
Notebooks
OMMatlab
Matlab
Scripting
OMSens
sensitivity
analysis
OMSysident

50
Industrial members •ABB AB, Sweden
•Berger IT-Cosmos, Germany
•Bosch Rexroth AG, Germany
•Brainheart Energy AB, Sweden
•CDAC Centre, Kerala, India
•Creative Connections, Prague
•DHI, Aarhus, Denmark
•Dynamica s.r.l., Cremona, Italy
•EDF, Paris, France
•Equa Simulation AB, Sweden
•Fraunhofer IWES, Bremerhaven
•INRIA, Rennes, France
•ISID Dentsu, Tokyo, Japan
Open-source community services
•Website and Support Forum
•Version-controlled source base
•Bug database
•Development courses
•www.openmodelica.org
Code Statistics
•FH Bielefeld, Bielefeld, Germany
•University of Bolivar, Colombia
•TU Braunschweig, Germany
•University of Calabria, Italy
•Univ California, Berkeley, USA
•Chalmers Univ, Control,Sweden
•Chalmers Univ, Machine, Sweden
•TU Darmstadt, Germany
•TU Delft, The Netherlands
•TU Dresden, Germany
•Université Laval, Canada
•Georgia Inst of Technology, USA
•Ghent University, Belgium
•Halmstad University, Sweden University members
OSMC –International Consortium for Open Source
Model-based Development Tools,
53 members Febr2018
Founded Dec 4, 2007
•Maplesoft, Canada
•RTE France, Paris, France
•Saab AB, Linköping, Sweden
•Scilab Enterprises, France
•SKF, Göteborg, Sweden
•TLK Thermo, Germany
•Siemens Turbo, Sweden
•Sozhou Tongyuan, China
•Talent Swarm, Spain
•VTI, Linköping, Sweden
•VTT, Finland
•Wolfram MathCore, Sweden
•Heidelberg University, Germany
•TU Hamburg/Harburg Germany
•IIT Bombay, Mumbai, India
•KTH, Stockholm, Sweden
•Linköping University, Sweden
•Univ of Maryland, Syst Eng USA
•Univ of Maryland, CEEE, USA
•Politecnico di Milano, Italy
•Ecoles des Mines, CEP, France
•Mälardalen University, Sweden
•Univ Pisa, Italy
•Univ College SouthEast Norway
•Tsinghua Univ, Beijing, China
•Vanderbilt Univ, USA

51
OpenModelica Graphical Editor and Plotting

52
OpenModelica Simulation in Web Browser Client
OpenModelica compiles
to efficient
Java Script code which is
executed in web browser
MultiBody RobotR3.FullRobot

53Spoken-Tutorial step-by-step OpenModelicaand Modelica
Tutorial Using OMEdit.
Link from www.openmodelica.org
1,600,000
1,400,000
1,200,000
1,000,000
800,000
600,000
400,000
200,000
0
2,011 2,012 2,013 2,014 2,015 2,016
Number of students/teachers trained in their colleges/schools

54
OMnotebook Interactive Electronic Notebook
Here Used for Teaching Control Theory

55
OM Web Notebook Generated from
OMN
o
t
e
b
oo
k
Edit, Simulate, Plot Models on a Web Page
http://omwebbook.openmodelica.org/
OMweb
book
OMNote
book

56
OMPython –Python Scripting with OpenModelica • Interpretation of Modelica
commands and expressions
• Interactive Session handling
• Library / Tool
• Optimized Parser results
• Helper functions
• Deployable, Extensible and
Distributable

57
General Tool Interoperability & Model Exchange
Functional Mock-up Interface (FMI)
• FMI development was started by ITEA2 MODELISAR project. FMI is a
Modelica Association Project now
•Version 1.0
• FMI for Model Exchange (released Jan 26,2010)
• FMI for Co-Simulation (released Oct 12,2010)
•Version 2.0
• FMI for Model Exchange and Co-Simulation (released July 25,2014)
•> 80 toolssupporting it (https://www.fmi-standard.org/tools)
Engine
with ECU
Gearbox
with ECU
Thermal
systems
Automated
cargo door
Chassis components,
roadway, ECU (e.g. ESP)
etc.
functional mockup interface for model exchange and tool coupling
courtesy Daimler

58
Functional Mockup Units • Import and export of input/output blocks –
Functional Mock-Up Units – FMUs, described by
• differential-, algebraic-, discrete equations,
• with time-, state, and step-events
•An FMUconsists of (compiled) C-code, + interface description in XML
• An FMU can be large (e.g. 100 000 variables)
• An FMU can be used in an embedded system (small overhead)
• FMUs can be connected together

59
OpenModelica Functional Mockup Interface (FMI)

60
OMSimulatorComposite Model Editor with 3D Viewer Combine External (FMI) Models into New Models
•Composite model editor
with 3D visualization of
connected mechanical
model components which
can be FMUs, Modelica
models, etc., or co-simulated
components
•3D animation possible
• Composite model saved as
XML-file

61OMSimulator–Integrated FMI and TLM-based
Cosimulator/Simulator in OpenModelica
OMSimulator
Integrated TLM & FMI
libOMSimulator
Simulink wrapper Beast wrapper ADAMS wrapper
TLM component
C-API
interface
OMEdit Papyrus
Scripting …
OMC
FMI component
FMI component
FMI FMU Modelica model
Composite FMI
component

62
Embedded System Support in OpenModelica
• Code generation of real-time Controllers from Modelica
models for small foot-print platforms

63
Single board heating system (IIT
Bombay
)

Use for teaching basic control
theory

Usually controlled by serial
port (set fan value, read
temperature, etc)

OpenModelica can generate
code targeting the ATmega16
on the board (AVR-ISP
programmer in the lower left).
Program size is 4090
bytes including LCD driver
and PID-controller (out of 16
kB flash memory available).
Use Case: SBHS (Single Board Heating System)
Movie Demo!

64
Example –Code Generation to SHBS

65
Code Generator Comparison, Full vs Simple
Full Source-code FMU
targeting 8-bit AVR proc
Simple code generator
targeting 8-bit AVR proc
Hello World
(0 equations)
43 kB flash memory
23 kB variables (RAM)
130 B flash memory
0 B variables (RAM)
SBHS Board (real-time
PID controller, LCD, etc)
68 kB flash memory
25 kB variables (RAM)
4090 Bflash memory
151 Bvariables (RAM)
The largest 8-bit AVR processor MCUs (Micro Controller Units) have 16 kB SRAM.
One of the more (ATmega328p; Arduino Uno) has 2 kB SRAM.
The ATmega16 we target has 1 kB SRAM available (stack, heap, and global variabl
e

66
•Free libraryfor interfacing hardware drivers
•Cross-platform(Windows and Linux)
• UDP, SharedMemory, CAN, Keyboard,
Joystick/Gamepad
• DAQ cards for digital and analog IO (only
Linux)
• Developed forinteractive real-
timesimulations
Communication&I/ODevices:
M
ODELICA
_D
EVICE
D
RIVERS
Library

67
OMEdit 3D Visualization of Multi-Body Systems • Built-in feature of OMEdit to
animate MSL-Multi-Body
shapes
• Visualization of simulation
results
• Animation of geometric
primitives and CAD-Files
New
Animation
Window
Simulate
with
Animation

68
OpenModelica3D Animation Demo

69
OpenModelica3D Animation Demo –Excavator

70
Visualization using Third-Party Libraries:
DLR Visualization Library • Advanced, model-integrated
and vendor-unspecific
visualization tool for
Modelica models
• Offline, online and real-time
animation
• Video-export function
• Commercial library, feature
reduced free Community
Edition exists
Courtesy of Dr. Tobias Bellmann (DLR)

71
Problems
Solved problems
Result plot
Export result data .csv
OMOptim–Parameter Sweep Design Optimization
Here
Pareto
front
optimiza-
tion

72
Optimization of Dynamic Trajectories Using
Multiple-Shooting and Collocation • Minimize a goal function subject to model
equation constraints, useful e.g. for NMPC
• Multiple Shooting/Collocation
• Solve sub-problem in each sub-interval
0.0
2.0
4.0
6.0
8.0
10.0
12.0
14.0
16.0
124816
MULTIPLE_COLLOCATION
ipopt [scaled]
jac_g [scaled]
Example speedup, 16 cores:
In OpenModelica 1.9.1
beta release Jan 2014.

73
OpenModelica Dynamic Optimization Collocation

74
Failure Mode and Effects Analysis (FMEA) in OM
• Modelica models augmented with reliability properties can be u sed to generate
reliability models in Figaro, which in turn can be used for sta tic reliability analysis
• Prototype in OpenModelica integrated with Figaro tool
Modelica Library
Application
Modelica model
Simulation
Figaro Reliability Library
Reliability model in Figaro
FT generation
FT processing
Automated generation

75
OpenModelica Model Parallelization
Faster Simulation on Multi-Core
Automated parallelization of models
Parallelizing numeric Jacobian
computations in simulation
0
0.5
1
1.5
2
2.5
3
3.5
4
4.5
5
123468101214
Speedup ScalableTestSuite
N=39 nnz= 818
Sp…
number of threads
Speedup about 4
using 8 threads

76
Recent Large-scale ABB OpenModelicaApplication Generate code for controlling 7.5 to 10% of German Power Production
ABB OPTIMAX PowerFit
• Real-time optimizing control of large-
scale virtual power plant for system
integration
•Software including OpenModelica now
used in managing more than 2500
renewable plants, total up to 1.5 GW
High scalability supporting growth
• 2012: initial delivery (for 50 plants)
• 2013: SW extension (500 plants)
• 2014: HW+SW extension (> 2000)
• 2015: HW+SW extension,
incl. OpenModelica generating optimizing
controller code in FMI 2.0 form Manage 7.5% - 10% of German Power • 2015, Aug: OpenModelica Exports FMUs
for real-time optimizing control (seconds)
of about 5.000 MW (7.5%) of power in
Germany

77
Part III
Equation-Based Model Dynamic Debugging
and Performance Analysis

78
Need for Debugging Tools
Map Low vs High Abstraction Level
•A major part of the total costof software projects
is due to testing and debugging
• US-Study 2002:
Software errors cost the US economy annually~ 60 Billion $
•Problem: Large Gap in Abstraction Level
from Equationsto Executable Code
• Example error message (hard to understand)
Error solving nonlinear system 132
time = 0.002
residual[0] = 0.288956
x[0] = 1.105149
residual[1] = 17.000400
x[1] = 1.248448
...

79
OpenModelica Equation Model Debugger
0 = y + der(x * time * z); z = 1.0;
(1) substitution:
y + der(x * (time * z))
=>
y + der(x * (time * 1.0))
(2) simplify:
y + der(x * (time * 1.0))
=>
y + der(x * time)
(3) expand derivative (symbolic
diff):
y + der(x * time)
=>y + (x + der(x) * time)
(4) solve:
0.0 = y + (x + der(x) * time)
=>
der(x) = ((-y) - x) / time
time <> 0
Example of
equation
transformations
on a model:

80Mapping dynamic run-time error to source model position
Integrated Static-Dynamic
OpenModelica Equation Model Debugger Showing
equation
transfor
mations
of a
model:
Efficient handling
of
Large
Equation
Systems

81
Transformations Browser –EngineV6 Overview
(11 116 equations in model)

82
Performance Profiling (Here: Profiling all equations in MSL 3.2.1 DoublePendulum)

83
• ABB OPTIMAX® provides advanced model based
control products for power generation and water utilities.
• ABB: “OpenModelica provides outstanding debugging
features that help to save a lot of time during model
development.”
ABB Commercial Application Use of Debugger

84
Equation Model Debugging on Siemens Model (used on Siemens Evaporator test model, 1100 equations)
84

85Equation Model Debugger on Siemens Model (Siemens Evaporator test model, 1100 equations)
Pointing out the buggy equation
y = u1/u2;
that gives division by zero

86Performance Profiling for faster Simulation (Here: Profiling equations of Siemens Drum boiler model with evaporator
• Measuring performanceof equation blocks to find bottlenecks
• Useful as input before model simplification for real-time appl ications
• Integrated with the debugger to point out the slow equations
• Suitable for real-time profiling (collect less information), or a complete
view of all equation blocks and function calls
Conclusion from the evaluation:
“…the profiler makes the process
of performance optimization
radically shorter.”

87
Part IV
Dynamic Verification/Testing of
Requirements vs Usage Scenario Models
Wladimir Schamai, Lena Buffoni, Peter Fritzson
and contributions from MODRIO partners

88OpenModelica and Papyrus Based Model-Based
Development Environment to Cover Product-Design V
Product
models
Requirements
models
Unified Modeling: Meta-modeling& Modelica& UML &OWL
Business
Process
Control
Requirements
Capture
Model-Driven
Design
(PIM)
Compilation
& Code Gen
(PSM)
System
Simulation
Software &
Syst Product
Feedback
Platform
models
Process
models
Product
models
Requirements
models
Unified Modeling: Meta-modeling& Modelica& UML
Business
Process
Control
Requirements
Capture
Model
-
Driven
Design
Compilation
& Code Gen
System
Simulation
Software &
System Product
Platform
models
Process
models
Specification
Design
Design
Refinement
Component verification
Subsystem level integration and
verification
Subsystem level integration test
calibration and verification
Product verification and
deployment
Maintenance
Realization
Detailed feature design and
implementation
Architectural design and
system functional design
Preliminary feature design
System
requirements
Level of Abstraction
Documentation, Version and Configuration Management
Verification
Integration
Calibration
Experience Feedback

89
Business Process Control and Modeling
Product
models
Requirements
models
Unified Modeling: Meta-modeling& Modelica& UML & OWL
Business
Process
Control
Requirements
Capture
Model-Driven
Design
(PIM)
Compilation
& Code Gen
(PSM)
System
Simulation
Software &
Syst Product
Feedback
Platform
models
Process
models
Product
models
Requirements
models
Unified Modeling: Meta-modeling& Modelica& UML
Business
Process
Control
Requirements
Capture
Model
-
Driven
Design
Compilation
& Code Gen
System
Simulation
Software &
System Product
Platform
models
Process
models
Metso Business model & simulation V
TT Simantics Graphic Modeling To
o
OpenModelica based simulation
Simulation of 3 strategies with
outcomes
VTT Simantics
Business process modeler
OpenModelica
compiler & simulator

90
Requirement Capture
Product
models
Requirements
models
Unified Modeling: Meta-modeling& Modelica& UML & OWL
Business
Process
Control
Requirements
Capture
Model-Driven
Design
(PIM)
Compilation
& Code Gen
(PSM)
System
Simulation
Software &
Syst Product
Feedback
Platform
models
Process
models
Product
models
Requirements
models
Unified Modeling: Meta-modeling& Modelica& UML
Business
Process
Control
Requirements
Capture
Model
-
Driven
Design
Compilation
& Code Gen
System
Simulation
Software &
System Product
Platform
models
Process
models
OpenModelica based simulation
vVDR (virtual Verification of
Designs against Requirements)
in ModelicaML UML/Modelica
Profile, part of OpenModelica
Design Model
Scenario Model
Requirement
Models
Verification Model
Binding
Provider from
design model
Client from requirement model

91
OpenModelica –ModelicaMLUML Profile Based on Open-Source Papyrus UML and OpenModelica • ModelicaMLis a UML Profile for SW/HW modeling
• Applicable to “pure”UML or to other UML profiles, e.g. SysML
• Standardized Mapping UML/SysMLto Modelica
• Defines transformation/mapping for executablemodels
• Being standardizedby OMG
• ModelicaML
• Defines graphical concrete syntax (graphical notation for diag ram) for
representing Modelica constructs integrated with UML
• Includes graphical formalisms (e.g. State Machines, Activities ,
Requirements)
• Which do not yet exist in Modelica language (extension work on going)
• Which are translated into executable Modelica code
• Is defined towards generation of executable Modelica code
• Current implementation based on the Papyrus UML tool + OpenModelica

92
Example: Simulation and Requirements Evaluation
Req. 001 is instantiated 2 times
(there are 2 tanks in the system)
tank-height is 0.6m Req. 001 for the tank2 is violated Req. 001 for the tank1 is not violated

93ModelicaML: Graphical Notation
a
Structure
Behavior
Requirements

94Example: Representation of System Structure
Interconnections
Inheritance
Components

95
Example: Representation of System Behavior
State
Machine of
the Tank
State Machine
of the Controller
Conditional Algorithm (Activity
Diagram)

96
Example: Representation of System Requirements
Textual Requirement Formalized Requirement

97
vVDRMethod –
virtual Verification of Designs vsRequirements
Formalize
Requirements
Formalize Designs
Formalize
Scenarios
Create Verification
Models
Execute and
Create Report Analyze Results
RMM
Requirement
Monitor Models
Scenario
Models
SM
Designs Alternative
Models
DAM
VM
Verification Models
AUTOMATED
Task Created Artifact
Goal: Enable on-demand
verification of designs
against requirements
using automated model
composition at any time
during development.
AUTOMATED
Actor
Reports
*

98
Challenge We want to verify different design alternativesagainst sets of requirements
using different scenarios. Questions: 1) How to find valid combinationsof design alternatives, scenarios and requirements in
order to enable an automated composition of verification models ?
2) Having found a valid combination: How to bind all components correctly?

Create Verification
Models

RMM
1. Verification
Model
VM
DAM
SM
2. Verification
Model
VM


Requirement
Models
Scenario
Models
Designs Alternative
Models
DAM
SM
DAM
DAM
SM
SM
SM
SM
SM
RMM
1
RMM
RMM
RMM
RMM
SM
RMM
RMM
RMM
RMM
……
n. Verification
Model
*

99
Composing Verification Models main idea • Collect all scenarios, requirements, import mediators
• Generate/compose verification modelsautomatically:
• Select the system modelto be verified
• Find all scenariosthat can stimulate the selected system model (i.e., for
each mandatory client check whether the binding expression can be inferred)
• Find requirementsthat are implemented in the selected system model (i.e.,
checkwhether for each requirementfor all mandatory clients binding
expressions can be inferred)
• Present the list of scenarios and requirements to the user
• The user can select only a subset or scenarios or requirements he/she
wishes to consider

100
Generating/Composing Verification Models algorithm

101
Simulation and Report Generation in ModelicaML
Verification models are
simulated.
The generated Verification
Reportis a prepared summary of:
• Configuration, bindings
• Violations of requirements
•etc.

102
Continuousand DiscreteTime Locatorsfor
Time-relatedRequirements
• A Continuous Time Locator(CTL) specifies one or more time
intervals
• Time intervals have a duration
• They usually have a position in time,
but a sliding time window defines any
time period of a given duration
• A Discrete Time Locator (DTL) defines one or more positions in time
and has no duration
• An event is associated with a DTL
that specifies when the event occurred
• The difference between events and
DTLs is that a DTL is not an object
• That position may be relative to the initialisation of the sys tem or
to another DTL
time
time
duration
time

103
Time Locators Expressed in Modelica
Special FORML-L syntax StandardModelica syntax
duringAnyduration duringAny(duration)
aftereventafter(event)
afterevent1untilNextevent2 afterUntil(event1, event2)
aftereventfordurationafterFor(event, duration)
aftereventwithindurationafterWithin(event, duration)
untilevent until(event)
everyduration1forduration2everyFor(duration1, duration2)
when conditionchangesMaps to Modelicaif

104
From Text to Simulated Requirement
–Modelica Extended with new Operators modelP2a extendsCondition;
inputConditionStatus bPSNeeded, sARequired, set1Powered;
equation
status = ifafterWithin (bPSNeeded == notViolatedand
sARequired == notViolated, 20) then
ifset1Powered == notViolatedthen
notViolatedelseviolated elseundefined;
endP2a;
BPS.NeededandSA.Required
s20
s20
t = 0
time
BPS.NeededandSA.Required
Set1.Powered must become true within the
timeframe s20 and remain true afterwards
From a text requirement expressing a condition:
A - In the absence of any Backup Power Supply (BPS) component failure or in the presence of
a single sensor failure, when the BPS is not under mai ntenance, in case of loss of MPS, and if
safety injection is required, Set1 must be powered within 20 s

105
From Text to Simulated Requirement –
Requirement not Violated –
OpenModelica Simulation
Within 20s
BPS Powered
Requirement
undefined
outside the
specified time
window
Requirement
validated
BPS.NeededandSA.Required
s20
t= 0
time
t= 10
t= 25
Set1.Powered
3-valued logic
prototype:
1 – true
0 – false
-1 – undefined

106Outlook:
New OpenModelicaFrontend for Large-Scale models
• Soon: New OMC
Compiler frontend for fast
compilation and large-
scale models
• Been under development
the past 2-3 years
• Now (sept 24) simulates
67% of MSL models,
coverage increases about
6% per month
• About 10-200 times faster
than the old frontend,
depending on model

107
OpenModelicaDAEModefor Large-Scale models
• Goal –to handle hundreds of thousands to millions of
equations
• Introduced sparse solvers in the solution chain:
• KLU for linear algebraic equations,
• Kinsol for nonlinear algebraic equations, and
• IDA for causalized differential equations.
• Largest system so far: electro-mechanical power system
model with about 600.000 differential-algebraic
equations
• Under development for even larger systems

108
Summary and Questions
Hybrid
Modeling
Visual Acausal
Component
Modeling
Multi-Domain
Modeling
Typed
Declarative
Textual Language
Thanks for listening!
www.modelica.org–Language, Standard Library
www.openmodelica.org–Open Source Tool Modelica
®
is a registered trademark of the Modelica Association