Sei sulla pagina 1di 21

Towards Unified Modeling with Modelica and

UML/SysML in the OpenModelica Environment


Presentation at MODPROD'2007
Link
Linkping University
2007-
2007-02-
02-07

Peter Fritzson

class x {
public
int a;
class x {float b;
public
int fu nc (i nt a ,int b);
int a; Asa as ad
class x {
float b;
public Asda a d
int fu ncAsd(i ad
nt acc
,int b);
int a;
class x { Asa as ad
float b; Aac sd scfcc c a
public Asda a d
int fu nc (i nt aAscccv
,int b); ca
int a; Asd ad cc
Asa as ad Ascc c ac
float b; Aac sd scfcc c a
Asda a d }
int fu nc (i nt aAscccv
,int b); ca
Asd ad cc
Asa as ad Ascc c ac
Aac sd scfcc c a
Asda a d }
Ascccv ca
Asd ad cc
Ascc c ac
Aac sd scfcc c a
}
Ascccv ca
Ascc c ac
}

Examples of Complex Products


Robotics
Automotive
Aircraft
Mobile Phone Systems
Business Software
Power plants
Heavy Vehicles
Process industry

2 Peter Fritzson pelab


Vision of Integrated
Model-Based Product Development

Model-based product development


Process technology Model-Based Optimization
Design and of Production
Requirements Optimization
Strategic
Business Management
Control Automated Model-Based
Code SoftwareTesting
Generation

Economic Requirements Product Production


models models models models

Unified Modeling Technology: Meta-modeling, UML, Modelica, XML ...

3 Peter Fritzson pelab

ECLIPSE as Integration Platform

OpenUP/Basic Capacity
CapacitySub-
Sub- UML-Modelica
OpenUP/Basic UML-Modelica
Process
ProcessAreas
Areas Plug-in OpenModelica
OpenModelica
Plug-in
MDT
MDT
ECLIPSE Process Framework (EPF)
Composer Specific components

Graphical Modeling Framework

ECLIPSE Modeling Framework

ECLIPSE Rich Client Platform (RCP) Runtime

Java C/C++ OpenModelica MetaModelica


runtime runtime runtime runtime

4 Peter Fritzson pelab


Modelica Background

5 Peter Fritzson pelab

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

6 Peter Fritzson pelab


Modelica The Next Generation Modeling
Language
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

7 Peter Fritzson pelab

Multi-Domain
Modelica Class Libraries for Reuse, Visual View
R= C= L=
body= bodyBar=
bar=
Info G Info
shaft3DS= shaft3D= shaftS= inertial

Info S S cylBody=bodyShape= cylS=


AC=

DC=

Vs

S S
Is

S S
shaft= S
gear2= revS= prismS= screw S=

univS planarS= sphereS


- gear1= freeS
planet= planetary= S
+ diff= V i ring= S S S
D T Op rev= prism=

sun= cyl= univ planar= sphere


:1 bearing fixTooth free

S
E screw =
moveS move

barC= y sphereC c= d= cSer=


c= d=

torque x C
C barC2=
fric=

force lineForce= sensor


lineSensor
r
fricTab clutch= torque lineTorque= s sd
converter

advanced drive translation


w a t
fixedBase Library Library Library

S
state

8 Peter Fritzson pelab


Application Example Industry Robot
k2

i
axis6
qddRef cut joint
qdRef
1
qRef
1
k1 r3Control
r3Motor r3Drive1 tn
i 1
S S
qd axis5

qdRef Kd
S
0.03 rel

Jmotor=J joint=0
spring=c axis4
S
qRef pSum Kv sum w Sum rate2 rate3 iRef gear=i

fric=Rv0
+1 b(s) 340.8
0.3
- +1 - a(s) S

axis3

rate1 tacho2 tacho1


b(s) b(s)
PT1
a(s) a(s)
axis2
g5

q
qd

Rp2=50

Ra=250 La=(250/(2*D*wm))
Rd1=100
C=0.004*D/w m Rp1=200 axis1

Rd2=100
Ri=10
- -
-
+ +
diff + pow er
OpI
Vs

Rd4=100
Srel = n*transpose(n)+(identity(3)- n*transpose(n))*cos(q)- emf
skew(n)*sin(q); y
Rd3=100

x
g3
wrela = n*qd; inertial
zrela = n*qdd; g1

Sb = Sa*transpose(Srel);
hall2

r0b = r0a; hall1 w r


vb = Srel*va;
wb = Srel*(wa + wrela);
ab = Srel*aa;
g2 qd
g4
q
zb = Srel*(za + zrela + cross(wa, wrela));

Courtesy of Martin Otter and Hiilding Elmqvist

9 Peter Fritzson pelab

Graphical Modeling Using Drag and Drop


(e.g. DCMotor as below)

Courtesy MathCore
Engineering AB

10 Peter Fritzson pelab


Multi-Domain (Electro-Mechanical) Modelica DCMotor Model
A DC motor can be thought of as an electrical circuit which
also contains an electromechanical component.

model DCMotor
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 R L
connect(DC.p,R.n);
EM
connect(R.p,L.n); DC
connect(L.p, EM.n);
connect(EM.p, DC.n); load
connect(DC.n,G.p);
connect(EM.flange,load.flange);
G
end DCMotor

11 Peter Fritzson pelab

Corresponding DCMotor Model Equations


The following equations are automatically derived from the Modelica model:

(load component not included)

Automatic transformation to ODE or DAE for simulation:

12 Peter Fritzson pelab


The OpenModelica Environment

13 Peter Fritzson pelab

OpenModelica

Goal: comprehensive Modelica modeling and


simulation environment for research, teaching,
and industrial usage
Free, open-source, for academic and
commercial use
Berkley New BSD open source license
The OpenModelica compiler (OMC) in an
extended subset of Modelica

14 Peter Fritzson pelab


OpenModelica Environment Architecture

Eclipse Plugin Graphical Model


Editor/Browser Editor/Browser

Interactive
Emacs session handler Textual
Editor/Browser Model Editor

DrModelica
OMNoteBook Execution Modelica
Model Editor Compiler

Modelica
Debugger

15 Peter Fritzson pelab

OpenModelica Client-Server Architecture

Parse
Client: Graphic
Model Editor
Server: Main Program
Corba
Including Compiler,
Interpreter, etc. Client: OMShell
Interactive
Session Handler

SCode Interactive
Client: Eclipse
Untyped API
Plugin MDT
Inst
Typed Checked Command API
system
plot
Ceval
etc.

16 Peter Fritzson pelab


OpenModelica MDT Eclipse Plugin
Browsing of packages, classes, functions
Automatic building of executables;
separate compilation
Syntax highlighting
Code completion,
Code query support for developers
Automatic Indentation
Debugger

17 Peter Fritzson pelab

OpenModelica Eclipse Plugin Usage Example

Code Assistance on
function calling.

18 Peter Fritzson pelab


ModelicaML
UML Profile for Modelica

19 Peter Fritzson pelab

ModelicaML UML Profile for Modelica

Extension of SysML subset


Features:
Supports Modelica constructs
Modelica generic class modeling
Modelica syntax in definitions
Equation-based modeling
Simulation modeling

20 Peter Fritzson pelab


UML
UML - specification of Object Management
Group (OMG)
Graphical modeling standard for software
specification
Widely used in software world
Categories: structure, behavior and interaction
Thirteen types of diagram
UML 2.0 - latest standard
Extension with UML Profiles

21 Peter Fritzson pelab

SysML
Extension of UML 2.0
Visual modeling language for system engineering
Unifies several modeling languages used by system
engineers
Adopted by OMG in May 2006
Goal:
Support specification, analysis, design, verification and validation of
broad range of systems that include hardware, software, data,
personnel, procedures and facilities
Diagram interchange capability included

22 Peter Fritzson pelab


SysML Diagrams

23 Peter Fritzson pelab

ModelicaML UML Profile for Modelica


Implementation in Eclipse
Eclipse utilized for prototype implementation
Universal platform for development tools integration
Based on plugin-in architecture
Implemented in Java language
Java Development Tools (JDT) - popular Java
Development Environment
Utilized Eclipse frameworks for ModelicaML
EMF - Eclipse Modeling Framework
GEF - Graphical Editing Framework
GMF - Graphical Modeling Framework
UML2 UML model implementation

24 Peter Fritzson pelab


ModelicaML Diagrams Overview

25 Peter Fritzson pelab

ModelicaML Class Internal Diagram

Modelica Connection Class Internal diagram


diagram Nested models
Better visual comprehension Top-model parameters and
Predefined connector variables
locations Flow direction
Other ModelicaML elements

26 Peter Fritzson pelab


Modelica Class Internal Diagram
Example 1

27 Peter Fritzson pelab

Modelica Class Internal Diagram


Example 2

28 Peter Fritzson pelab


ModelicaML Class Internal Diagram
Structure diagram
Describes the internal structure in terms of parts
and connectors
Based on SysML Block Internal Diagram
Similar to Modelica connection diagram
Some SysML constructs not supported or
replaced by Modelica counterparts (i.e. Standard
Ports, FlowSpecification, etc.)

29 Peter Fritzson pelab

ModelicaML Class Diagram


Example 1

30 Peter Fritzson pelab


ModelicaML Class Diagram
Example 2

31 Peter Fritzson pelab

ModelicaML Class Diagram


Structure diagram
Shows class definitions and their relationships
Support all Modelica restricted classes
Based on SysML Block Definition Diagram
Modelica Class definitions can be linked with
other elements like Requirements, Activities,
Equation blocks, etc.

32 Peter Fritzson pelab


Package diagram
Package hierarchy and inheritance example

33 Peter Fritzson pelab

Equations Diagram
Example 1

34 Peter Fritzson pelab


Requirements Diagram

35 Peter Fritzson pelab

Requirements Diagram
Introduced by SysML
Supports requirements specification
Graphical, tabular or tree formats
A Requirement can appear on other diagrams
Requirement relationships:
Containment
Derive
Satisfy
Verify
Refine
Trace

36 Peter Fritzson pelab


Simulation Diagram
Introduced by ModelicaML

37 Peter Fritzson pelab

Other Diagrams
Reused from SysML
Structure
Parametric diagram

Behavior
Activity diagram
Sequence diagram
State Machine diagram
Use Case diagram

38 Peter Fritzson pelab


ModelicaML Diagrams Summary

39 Peter Fritzson pelab

Conclusion & Future work ModelicaML


Conclusion
UML profile for Modelica designed
All Modelica language constructs supported
SysML-to-ModelicaML conversion considered
Prototype of Class diagrams implemented

Future work
ModelicaML diagrams implementation
Code generation/synchronization from ModelicaML models
Modelica code/library to ModelicaML model

40 Peter Fritzson pelab


Questions?

41 Peter Fritzson pelab

Potrebbero piacerti anche