Download as pdf or txt
Download as pdf or txt
You are on page 1of 26

Equation-Based Object-Oriented Languages

for
Acausal Modeling and Simulation
Lecture 12a in EECS 144/244
University of California, Berkeley

April 17, 2013

David Broman
broman@eecs.berkeley.edu
EECS Department
University of California, Berkeley, USA
and

Linkping University, Sweden

Some of the slides are based OSMC tutorials and contributed by


Peter Fritzson (Based on book and lecture nodes), David Broman,
Emma Larsdotter Nilsson, Peter Bunus, Adrian Pop, Jan Brugrd,
Mohsen Torabzadeh-Tari, and Adeel Asghar.
Copyright Open Source Modelica Consortium.

Agenda

broman@eecs.berkeley.edu

Part II
Modelica Overview

Part I
EOO Languages for CPS
Platform 1
Actuator

Physical
Interface

Physical Plant 2
Network

Physical
Interface

Platform 2

Sensor
Computation 1

Delay 1

Computation 4

Computation 2

Sensor
Platform 3
Physical
Interface

Delay 2
Computation 3

Physical Plant
Plant 12
Physical

Physical
Interface

Actuator

Part III
OpenModelica Demo

Part I !
EOO Languages!
for CPS!

Part II !
Modelica
Overview!

Part IV
Modelyze
a research language

Part III
OpenModelica!
Demo!

Part IV
Modelyze a!
Research language!

3
broman@eecs.berkeley.edu

Part I
EOO Languages for CPS
Platform 1
Actuator

Physical
Interface

Physical Plant 2
Network

Physical
Interface

Platform 2

Sensor
Computation 1

Delay 1

Computation 4

Computation 2

Sensor
Platform 3
Physical
Interface

Delay 2
Computation 3

Physical Plant
Plant 12
Physical

Part I !
EOO Languages!
for CPS!

Part II !
Modelica
Overview!

Physical
Interface

Actuator

Part III
OpenModelica!
Demo!

Part IV
Modelyze a!
Research language!

Cyber-Physical Systems (CPS)

Power Plants

Industrial Robots

Part I !
EOO Languages!
for CPS!

Part II !
Modelica
Overview!

Part III
OpenModelica!
Demo!

broman@eecs.berkeley.edu

Aircraft

Part IV
Modelyze a!
Research language!

Modeling and Simulating Cyber-Physical Systems

broman@eecs.berkeley.edu

Platform 1
Actuator

Physical
Interface

Physical Plant 2
Network

Physical
Interface

Platform 2

Sensor
Computation 1

Delay 1

Computation 4

Computation 2

Simulation with
timing properties
Various models of computation (MoC)
Sensor

Platform 3

Physical
Interface

Delay 2

Computation 3

Physical Plant
Plant 12
Physical

Model
Equation-based model

Hardware-in-the-loop
(HIL) simulation

Modeling

Physical
Interface

Actuator

Modeling

Physical system
available?
Sensors

System

Actuators
Physical system (the plant)
Part I !
EOO Languages!
for CPS!

Part II !
Modelica
Overview!

Cyber system: Computation (embedded) + Networking


Part III
OpenModelica!
Demo!

Part IV
Modelyze a!
Research language!

Equation-Based Object-Oriented (EOO) Languages


broman@eecs.berkeley.edu

Domain-Specific
Language (DSL)

Models and Objects

Primarily domain:
Modeling of physical
systems
Multiple physical domains:
e.g., mechanical, electrical,
hydraulic

Part I !
EOO Languages!
for CPS!

Part II !
Modelica
Overview!

Equation-Based
Object-Oriented
(EOO)

Part III
OpenModelica!
Demo!

Object in e.g., Java, C++:


object = data + methods
Objects in EOO languages:
object = data + equations

Part IV
Modelyze a!
Research language!

Equation-Based Object-Oriented (EOO)


Languages
Domain-Specific
Language (DSL)

connections!

Primarily domain:
Modeling of physical
systems

objects (components)!

Models and Objects

Equation-Based
ports!
Object-Oriented

Multiple physical domains:


e.g., mechanical, electrical,
hydraulic

(EOO)

EOO model (textual)

Part I !
EOO Languages!
for CPS!

Part II !
Modelica
Overview!

broman@eecs.berkeley.edu

Object in e.g., Java, C++:


object = data + methods
Objects in EOO languages:
object = data + equations

EOO model (graphical)

Part III
OpenModelica!
Demo!

Equation-Based Object-Oriented (EOO)


Languages
Domain-Specific
Language (DSL)

Part IV
Modelyze a!
Research language!

8
broman@eecs.berkeley.edu

Models and Objects

Primarily domain:
Modeling of physical
systems
Multiple physical domains:
e.g., mechanical, electrical,
hydraulic

Equation-Based
Object-Oriented
(EOO)

Acausality

Object in e.g., Java, C++:


object = data + methods
Objects in EOO languages:
object = data + equations

At the equation-level
u=R*i
At the object connection level

Part I !
EOO Languages!
for CPS!

Part II !
Modelica
Overview!

Part III
OpenModelica!
Demo!

Part IV
Modelyze a!
Research language!

Equation-Based Object-Oriented (EOO)


Languages
Domain-Specific
Language (DSL)

Models and Objects

Multiple physical domains:


e.g., mechanical, electrical,
hydraulic

Equation-Based
acausal (non-causal)
Object-Oriented
(EOO)

Acausality
causal
Part II !
Modelica
Overview!

Object in e.g., Java, C++:


object = data + methods
Objects in EOO languages:
object = data + equations

Physical topology !
At the equation-level
u = Ris*lost!
i

At the object connection level

Part III
OpenModelica!
Demo!

Equation-Based Object-Oriented (EOO)


Languages
Domain-Specific
Language (DSL)

Part IV
Modelyze a!
Research language!

10
broman@eecs.berkeley.edu

Models and Objects

Primarily domain:
Modeling of physical
systems
Multiple physical domains:
e.g., mechanical, electrical,
hydraulic

Equation-Based
acausal (non-causal)
Object-Oriented
(EOO)

Acausality
causal
Part I !
EOO Languages!
for CPS!

broman@eecs.berkeley.edu

Direction not determined at modeling time!

Primarily domain:
Modeling of physical
systems

Part I !
EOO Languages!
for CPS!

Part II !
Modelica
Overview!

Object in e.g., Java, C++:


object = data + methods
Objects in EOO languages:
object = data + equations

At the equation-level
u=R*i
At the object connection level

Part III
OpenModelica!
Demo!

Part IV
Modelyze a!
Research language!

11

Equation-Based Object-Oriented (EOO)


Languages
Domain-Specific
Language (DSL)

Models and Objects

Primarily domain:
Modeling of physical
systems
Multiple physical domains:
e.g., mechanical, electrical,
hydraulic

Modelica
VHDL-AMS
gPROMS
Modelyze

Part I !
EOO Languages!
for CPS!

broman@eecs.berkeley.edu

Equation-Based
Object-Oriented
(EOO)

Acausality

Object in e.g., Java, C++:


object = data + methods
Objects in EOO languages:
object = data + equations

At the equation-level
u=R*i
At the object connection level

Part II !
Modelica
Overview!

Part III
OpenModelica!
Demo!

Part IV
Modelyze a!
Research language!

12
broman@eecs.berkeley.edu

Part II
Modelica Overview

Part I !
EOO Languages!
for CPS!

Part II !
Modelica
Overview!

Part III
OpenModelica!
Demo!

Part IV
Modelyze a!
Research language!

13

What is Modelica?

broman@eecs.berkeley.edu

A language for modeling of complex physical systems

Robotics
Automotive
Aircrafts
Satellites
Power plants
Systems biology

Part I !
EOO Languages!
for CPS!

Part II !
Modelica
Overview!

Part III
OpenModelica!
Demo!

Part IV
Modelyze a!
Research language!

14

What is Modelica?

broman@eecs.berkeley.edu

A language for modeling of complex physical systems

Primary designed for simulation, but there are also other


usages of models, e.g. optimization.

Part I !
EOO Languages!
for CPS!

Part II !
Modelica
Overview!

Part III
OpenModelica!
Demo!

Part IV
Modelyze a!
Research language!

15

What is Modelica?

broman@eecs.berkeley.edu

A language for modeling of complex physical systems


i.e., Modelica is not a tool

Free, open language specification:

Available at: www.modelica.org


Part I !
EOO Languages!
for CPS!

Part II !
Modelica
Overview!

Part III
OpenModelica!
Demo!

Part IV
Modelyze a!
Research language!

16

Modelica Tools

broman@eecs.berkeley.edu

Commercial Environments

Free Environments

Dymola by Dassault Systemes

OpenModelica supported by OSMC

SimulationX by ITI GmbH

Jmodelica.org supported by Modelon

LMS Imagine.Lab AMESim by LMS

Modelicac (part of Scilab)

MapleSim by Maplesoft

SimForge

MOSILAB by Fraunhofer FIRST


CyModelica by CyDesign Labs
OPTIMICA Studio by Modelon AB
MWorks by Suzhou Tongyuan
Wolfram SystemModeler by Wolfram

Part I !
EOO Languages!
for CPS!

Part II !
Modelica
Overview!

Part III
OpenModelica!
Demo!

Part IV
Modelyze a!
Research language!

17

What is special about Modelica?

broman@eecs.berkeley.edu

Multi-Domain
Modeling

Part I !
EOO Languages!
for CPS!

Part II !
Modelica
Overview!

Part III
OpenModelica!
Demo!

Part IV
Modelyze a!
Research language!

18

What is special about Modelica?


Multi-Domain
Modeling

Keeps the physical


structure!
!

broman@eecs.berkeley.edu

Visual Acausal
Component
Modeling

Acausal model
(Modelica)

Causal
block-based
model
(Simulink)

Part I !
EOO Languages!
for CPS!

Part II !
Modelica
Overview!

Part III
OpenModelica!
Demo!

Part IV
Modelyze a!
Research language!

19

What is special about Modelica?


Hierarchical system
modeling

Multi-Domain
Modeling
k2
i
qddRef

qdRef

Kd

qdRef

qRef

k1

cut joint

r3Control

r3Motor

qd

q: angle
qd: angular velocity
qdd: angular acceleration

0.3

sum

w Sum

+1
+1

rate2

rate3

b(s)

340.8

a(s)

joint=0

spring=c

iRef

axis4

gear=i

fric=Rv0

Kv

axis5

rel
Jmotor=J

pSum

Visual Acausal
Component
Modeling

0.03

qRef

axis6

tn

r3Drive1

broman@eecs.berkeley.edu

axis3
tacho2

b(s)

b(s)

a(s)

a(s)

tacho1
PT1

axis2

g5

qd

C=0.004*D/w m

Rd1=100
Rd2=100

cut in

Rp1=200

Ri=10

diff

+
pow er

OpI

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

Rp2=50

rate1

axis1

Vs

Rd4=100

g1

Rd3=100

emf

iRef

g3

hall2

Courtesy of Martin Otter

Part I !
EOO Languages!
for CPS!

y
x
inertial
hall1

Part II !
Modelica
Overview!
g2

qd

g4

Part III
OpenModelica!
Demo!

Part IV
Modelyze a!
Research language!

20

What is special about Modelica?


Multi-Domain
Modeling

broman@eecs.berkeley.edu

Visual Acausal
Component
A textual class-based language
Modeling
OO primary used for as a structuring concept

Behaviour described declaratively using


Differential algebraic equations (DAE) (continuous-time)
Event triggers (discrete-time)
Variable!
declarations!
!

Typed
Declarative
Textual Language
Part I !
EOO Languages!
for CPS!

class VanDerPol "Van der Pol oscillator model"


Real x(start = 1) "Descriptive string for x;
Real y(start = 1) "y coordinate;
parameter Real lambda = 0.3;
equation
der(x) = y;
der(y) = -x + lambda*(1 - x*x)*y;
end VanDerPol;

Differential equations!
!
Part II !
Modelica
Overview!

Part III
OpenModelica!
Demo!

Part IV
Modelyze a!
Research language!

21

What is special about Modelica?


Multi-Domain
Modeling

broman@eecs.berkeley.edu

Visual Acausal
Component
Modeling
Hybrid modeling =
continuous-time + discrete-time modeling
Continuous-time
Discrete-time

Typed
Declarative
Textual Language
Part I !
EOO Languages!
for CPS!

time

Part II !
Modelica
Overview!

Hybrid
Modeling
Part IV
Modelyze a!
Research language!

Part III
OpenModelica!
Demo!

22

Some Domains

broman@eecs.berkeley.edu

Domain
Type

Potential

Flow

Carrier

Modelica
Library

Electrical

Voltage

Current

Charge

Electrical.
Analog

Position

Force

Linear momentum

Mechanical.
Translational

Rotational

Angle

Torque

Angular
momentum

Mechanical.
Rotational

Magnetic

Magnetic
potential

Magnetic
flux rate

Magnetic flux

Hydraulic

Pressure

Volume flow

Volume

HyLibLight

Heat

Temperature

Heat flow

Heat

HeatFlow1D

Chemical

Chemical
potential

Particle flow

Particles

Under
construction

Presure

Mass flow

Air

Translational

Pneumatic

Part I !
EOO Languages!
for CPS!

Part II !
Modelica
Overview!

Part III
OpenModelica!
Demo!

PneuLibLight

Part IV
Modelyze a!
Research language!

23

Modelica Standard Library

Part I !
EOO Languages!
for CPS!

Part II !
Modelica
Overview!

Part III
OpenModelica!
Demo!

broman@eecs.berkeley.edu

Part IV
Modelyze a!
Research language!

24

Modelica in Autmotive Industry

Part I !
EOO Languages!
for CPS!

Part II !
Modelica
Overview!

Part III
OpenModelica!
Demo!

broman@eecs.berkeley.edu

Part IV
Modelyze a!
Research language!

25

Modelica in Avionics

Part I !
EOO Languages!
for CPS!

Part II !
Modelica
Overview!

broman@eecs.berkeley.edu

Part III
OpenModelica!
Demo!

Modelica in Power Generation


GTX Gas Turbine

Part IV
Modelyze a!
Research language!

26
broman@eecs.berkeley.edu

Developed
by MathCore
for Siemens

Hello

Courtesy of Siemens Industrial Turbomachinery AB

Part I !
EOO Languages!
for CPS!

Part II !
Modelica
Overview!

Part III
OpenModelica!
Demo!

Part IV
Modelyze a!
Research language!

27

Brief Modelica History

broman@eecs.berkeley.edu

Modelica design group meetings


First meeting in fall 1996
International group of people with expert knowledge in both
language design and physical modeling
Industry and academia

Modelica Language Versions


v1.0 (1997), v2.0 (2002) v.2.2 (2005) v.3.0 (2007) 3.1 (2009)
3.2 (2010), 3.2 revision 1 (2012)

Modelica Association established 2000


Open, non-profit organization

Modelica Conferences
9 international conferences (2000-2012)
Part I !
EOO Languages!
for CPS!

Part II !
Modelica
Overview!

Part III
OpenModelica!
Demo!

Part IV
Modelyze a!
Research language!

28

Typical Simulation Process

Part I !
EOO Languages!
for CPS!

Part II !
Modelica
Overview!

Part III
OpenModelica!
Demo!

broman@eecs.berkeley.edu

Part IV
Modelyze a!
Research language!

29

Acausal Modeling

broman@eecs.berkeley.edu

The order of computations is not decided at modeling time


Acausal

Causal

Visual
Component
Level

Equation
Level

Causal possibilities:
i := v/R;
v := R*i;
R := v/i;!

A resistor equation:
R*i = v;!

Part I !
EOO Languages!
for CPS!

Part II !
Modelica
Overview!

!"

Part IV
Modelyze a!
Research language!

Part III
OpenModelica!
Demo!

30

Simple model - Hello World!


Equation: x = - x
Initial condition: x(0) = 1

Name of model!

broman@eecs.berkeley.edu

Initial condition!

model HelloWorld "A simple equation"


Real x(start=1);
parameter Real a = -1;
equation
der(x)= a*x;
end HelloWorld;

Continuous-time!
variable !
Parameter, constant!
during simulation !

Simulation in OpenModelica environment

Differential equation !

1
0.8

simulate(HelloWorld, stopTime = 2)
plot(x)

0.6
0.4
0.2
0.5

Part I !
EOO Languages!
for CPS!

1.5

Part II !
Modelica
Overview!

Part III
OpenModelica!
Demo!

Part IV
Modelyze a!
Research language!

31

Differential Algebraic Equations


General representation of DAEs:

0 = f t , x (t ), x(t ), y (t ), u (t ), p

Force it to be the
start value!

Algebraic variable!
Differentiated
variable!

model DAEexample
Real x(start=0.9, fixed=true);
Real y;
equation
der(y)+sin(x)= sin(time);
x - y = exp(-0.9*x)*cos(y);
end DAEexample;

t
time
x (t ) vector of differentiated state variables
x(t ) vector of state variables
y (t ) vector of algebraic variables
u (t)

vector of input variables

vector of parameters and/or constants

broman@eecs.berkeley.edu

Built-in functions and


Typically, the compiler transforms the DAE to an
global time variable!
ODE before simulation, sometimes using an
index reduction algorithms (more about this in lecture 12b).
Part I !
EOO Languages!
for CPS!

Part II !
Modelica
Overview!

Part IV
Modelyze a!
Research language!

Part III
OpenModelica!
Demo!

32

Textual and Graphical Models

broman@eecs.berkeley.edu

R1
R=10
R=100!

L
L=1!
L=0.1

A
C

Used model (defined elsewhere)!


G

Enables later
modification of
component!

Named component =
model instance!
Modification of
parameter value!

Connect
equations!

Part I !
EOO Languages!
for CPS!

Part II !
Modelica
Overview!

Part III
OpenModelica!
Demo!

Part IV
Modelyze a!
Research language!

33

Equations and Inheritance

broman@eecs.berkeley.edu

R1

Pin p, n and
Reals v and i
are copied to the
subclass

R=10
R=100!

L
L=1!
L=0.1

A
C

Equations are
copied as well.
G

Inherits equations and !


components from !
TwoPin

Differential equation!
Algebraic equation!
Part I !
EOO Languages!
for CPS!

Part II !
Modelica
Overview!

Part IV
Modelyze a!
Research language!

Part III
OpenModelica!
Demo!

34

Connectors (Ports)

broman@eecs.berkeley.edu

R1
R=10
R=100!

L
L=1!
L=0.1

A
C

Connectors are instances !


of a connector class.

Part I !
EOO Languages!
for CPS!

Part II !
Modelica
Overview!

Part III
OpenModelica!
Demo!

Part IV
Modelyze a!
Research language!

35

Connections and Flow Variables

broman@eecs.berkeley.edu

R1
R=10
R=100!

L
L=1!
L=0.1

A
C

Fundamental
concept making
acausal modeling
work (simplified)

Equations from potential variables:


L.n.v = AC.n.v
AC.n.v = G.p.v
Equation from flow variables:!
L.n.i + AC.n.i + G.p.i = 0
Part I !
EOO Languages!
for CPS!

Part II !
Modelica
Overview!

Part III
OpenModelica!
Demo!

Part IV
Modelyze a!
Research language!

36

Models and Equation Generation


Positive port

Negative port

broman@eecs.berkeley.edu

Each port in electrical domain:


i flow variable (current)
v potential variable (voltage)
Modelica connect-equations
connect(VS.n,G.p)!
connect(R.n,G.p) !
Port set for a3
{G.p,R.n,VS.n} !
Potential equations (generated)
R.n.v = G.p.v!
VS.n.v = G.p.v!

Behavior equations
L * der(i) = v !
Inductor
Part I !
EOO Languages!
for CPS!

R * i = v !

G.p.i + R.n.i + VS.n.i = 0!

Resistor
Part II !
Modelica
Overview!

Sum-to-zero equation (generated)

Part III
OpenModelica!
Demo!

Part IV
Modelyze a!
Research language!

37

Abstraction and Composition

broman@eecs.berkeley.edu

VS.n.i + SC.n.i + G.p.i = 0!


(a) and (c) describes
the same circuit

Same port
(e.g. SC.n)
can be seen
as:

SC is an instance
of model (b)

inside port
outside port
Abstracted model
Part I !
EOO Languages!
for CPS!

Part II !
Modelica
Overview!

SC.R.n.i - SC.n.i = 0!
Part III
OpenModelica!
Demo!

Part IV
Modelyze a!
Research language!

38

Hybrid Modeling

broman@eecs.berkeley.edu

Hybrid modeling = continuous-time + discrete changes (events)


(Using Modelica terminology)
Continuous-time Real x;
Voltage v;
Current i;

Discrete changes
discrete
in time
time

Events!

Real x;
Integer i;
Boolean b;

A point in time that is instantaneous, i.e., has zero duration


An event condition so that the event can take place
A set of variables that are associated with the event
Some behavior associated with the event,
e.g. conditional equations that become active or are deactivated at
the event
Part I !
EOO Languages!
for CPS!

Part II !
Modelica
Overview!

Part III
OpenModelica!
Demo!

Part IV
Modelyze a!
Research language!

39

Event creation when

broman@eecs.berkeley.edu

when-equations
when <conditions> then
<equations>
end when;

event 1

event 2

event 3

time

Equations only active at event times

Time event

State event

when time >= 10.0 then


...
end when;

when sin(x) > 0.5 then


...
end when;

Only dependent on time, can be


scheduled in advance
Part I !
EOO Languages!
for CPS!

Part II !
Modelica
Overview!

Related to a state. Check for


zero-crossing
Part III
OpenModelica!
Demo!

Part IV
Modelyze a!
Research language!

40

Reinit - discontinuous changes

broman@eecs.berkeley.edu

The value of a continuous-time state variable can be instantaneously


changed by a reinit-equation within a when-equation
model BouncingBall "the bouncing ball model"
parameter Real g=9.81;
//gravitational acc.
parameter Real c=0.90;
//elasticity constant
Real height(start=10),velocity(start=0);
equation
der(height) = velocity;
der(velocity)=-g;
when height<0 then
reinit(velocity, -c*velocity);
end when;
end BouncingBall;

Reinit assigns
continuous-time variable
velocity a new value
Part I !
EOO Languages!
for CPS!

Part II !
Modelica
Overview!

Part III
OpenModelica!
Demo!

Initial conditions

Part IV
Modelyze a!
Research language!

41

Modelica large and complex

broman@eecs.berkeley.edu

We have just scratched on the surface of the language


Examples of the features which has not been covered
Functions and algorithm sections
Arrays and matrices
Inner / outer variables (lookup in instance hierarchy)
Annotations
Loop constructs
Partial classes
Packages, blocks...
And much more...

Part I !
EOO Languages!
for CPS!

Part II !
Modelica
Overview!

Part III
OpenModelica!
Demo!

Part IV
Modelyze a!
Research language!

42
broman@eecs.berkeley.edu

Part IV
Open Modelica Demo

Part I !
EOO Languages!
for CPS!

Part II !
Modelica
Overview!

Part III
OpenModelica!
Demo!

Part IV
Modelyze a!
Research language!

43

Open Source Modelica Consortium (OSMC)


broman@eecs.berkeley.edu
OSMC
Founded in 2007 in Linkping, Sweden
Seven founding organizations
Non-profit, non-governmental organization
Aim of developing and promoting the OpenModelica project
Non-commercial and commercial usage under the
OSMC public license

Part I !
EOO Languages!
4/24/13&
for CPS!

Part II !
Modelica
Overview!

Part III
OpenModelica!
Demo!

Part IV
Modelyze a!
Research language!

43&

44
broman@eecs.berkeley.edu

Part IV
Modelyze a Research Language

Part I !
EOO Languages!
for CPS!

Part II !
Modelica
Overview!

Part III
OpenModelica!
Demo!

Part IV
Modelyze a!
Research language!

45

What is Modelyze?

broman@eecs.berkeley.edu

Purpose: Research language


address the expressiveness and
analyzability problem by making the
language extensible

Modelyze

Small, simple, host language for


embedding domain-specific languages
(DSL) of different models of
computation (MoC)
Key aspect: Both the DSL and models
in the DSL are defined in Modelyze

(MODEL and analYZE)

Gradually typed functional language


(call-by-value)
Novelty: Typed symbolic expressions
Formal semantics for a core of the language.
Proven type soundness for the core.
Prototype implementation (interpreter).
Evaluated for series of equation-based DSLs.
Part I !
EOO Languages!
for CPS!

Part II !
Modelica
Overview!

Part III
OpenModelica!
Demo!

Part IV
Modelyze a!
Research language!

46

Modelica Environment

broman@eecs.berkeley.edu

Model
Model
Model
Library
Library
Library

Result
(e.g., simulation)

Modelica
Tool

Modelica Model

Language Specification
- Type checking
- Collapsing the instance hierarchy
- Connection Semantics
- Simulation (Runtime)
Part I !
EOO Languages!
for CPS!

Part II !
Modelica
Overview!

Part III
OpenModelica!
Demo!

Part IV
Modelyze a!
Research language!

47

Modelyze Environment

broman@eecs.berkeley.edu

Model
Model
Model
Library
Library
Library

Library for using models


Library forSemantics
using models
- Connection
Library for using models
- Connection Semantics
- Simulation
(Runtime)
- Connection
Semantics
- Simulation
(Runtime)
- Simulation (Runtime)

Part I !
EOO Languages!
for CPS!

Result
(e.g., simulation)

Modelyze
Tool

Modelyze DSL
Model

Part II !
Modelica
Overview!

LanguageSpecification
Specification
Language

Typechecking
checking
--Type
Collapsingthe
theinstance
instancehierarchy
hierarch
--Collapsing
- Connection Semantics
- Simulation (Runtime)
Part III
OpenModelica!
Demo!

Part IV
Modelyze a!
Research language!

48

Example DSL embedded in Modelyze


broman@eecs.berkeley.edu

Tension in the string!

Pendulum (y position)!
String breaks (3.2 s)!
Ball is flying freely!
Ball bounces on the
floor!

Part I !
EOO Languages!
for CPS!

Part II !
Modelica
Overview!

Part III
OpenModelica!
Demo!

Part IV
Modelyze a!
Research language!

49

Example DSL embedded in Modelyze


broman@eecs.berkeley.edu

Function as
model abstraction!
Unknowns!
Initial Values!

Two modes !

Guarded
Transition !

Differential equations !

Self transition,
updating the velocity!

Part I !
EOO Languages!
for CPS!

Part II !
Modelica
Overview!

Part III
OpenModelica!
Demo!

Part IV
Modelyze a!
Research language!

50

Conclusions

broman@eecs.berkeley.edu

Platform 1
Actuator

Physical
Interface

Physical Plant 2
Network

Physical
Interface

Platform 2

Sensor
Computation 1

Delay 1

Computation 4

Computation 2

Sensor
Platform 3
Physical
Interface

Delay 2

EOO Languages are particularly good for physical modeling


because of their acausal capability

Computation 3
Physical Plant
Plant 12
Physical

Physical
Interface

Actuator

Modelica is the current state-of-the-art EOO language. The


fundamental formalism is DAEs.

OpenModelica is a free Modelica environment that includes


both compiler and a graphical modeling IDE.

Modelyze is an extensible research language for embedding


equation-based languages.

Thank you for listening!


Part I !
EOO Languages!
for CPS!

Part II !
Modelica
Overview!

Part III
OpenModelica!
Demo!

Part IV
Modelyze a!
Research language!

51

References and Further Reading

broman@eecs.berkeley.edu

Sven Erik Mattsson, Hilding Elmqvist, and Martin Otter. Physical System Modeling with
Modelica. Control Engineering Practice 6. Pages 501-510, 1998.
Peter Fritzson. Principles of Object-Oriented Modeling and Simulation with Modelica 2.1.
Wiley-IEEE Press, New York, 2004.
Peter Fritzson, Peter Aronsson, Hkan Lundvall, Kaj Nystrm, Adrian Pop, Levon Saldamli,
and David Broman The OpenModelica Modeling, Simulation, and Software Development
Environment. Simulation News Europe. Issue 44, Pages 8-16, ARGESIM, 2005
David Broman, Peter Fritzson, and Sbastien Furic. Types in the Modelica Language. In
Proceedings of the Fifth International Modelica Conference, pages 303-315, Vienna,
Austria, 2006.
David Broman and Jeremy G. Siek. Modelyze: a gradually typed host language for
embedding equation-based modeling languages. Technical Report UCB/EECS-2012-173,
EECS Department, University of California, Berkeley, June 2012.

See http://www.modelica.org for more information on Modelica, including the latest language
specification.

Part I !
EOO Languages!
for CPS!

Part II !
Modelica
Overview!

Part III
OpenModelica!
Demo!

Part IV
Modelyze a!
Research language!

You might also like