Das functional mockup interface zum austausch ... - QTronic
Das functional mockup interface zum austausch ... - QTronic
Das functional mockup interface zum austausch ... - QTronic
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>Das</strong> Functional Mockup Interface<br />
<strong>zum</strong> Austausch Dynamischer Modelle<br />
Martin Otter (DLR-RM)<br />
Torsten Blochwitz (ITI)<br />
Hilding Elmqvist (<strong>Das</strong>sault Systèmes – Dynasim)<br />
Andreas Junghanns (<strong>QTronic</strong>)<br />
Jakob Mauss (<strong>QTronic</strong>)<br />
Hans Olsson (<strong>Das</strong>sault Systèmes – Dynasim)<br />
ASIM Workshop, 4. - 5. März 2010
Contents<br />
1. Functional Mockup Interface (FMI) – Overview<br />
2. FMI - Motivation<br />
3. FMI for Model Exchange – Overview<br />
4. Model Distribution<br />
5. Model Description Schema<br />
6. Model C-Interface<br />
7. Tool Support for FMI<br />
8. Comparison with SIMULINK S-Function Interface<br />
9. Outlook<br />
10. Acknowledgements<br />
Functional Mockup Interface > ASIM Workshop, 4.-5. März 2010 > Slide 2
1. Functional Mock-up Interface (FMI) – Overview<br />
The FMI development is part of the ITEA2 MODELISAR project.<br />
FMI development initiated, organized and headed by Daimler AG<br />
Improved Software/Model/Hardware-in-the-Loop Simulation,<br />
of physical models and of AUTOSAR controller models<br />
from different vendors for automotive applications with<br />
different levels of detail.<br />
Open Standard<br />
14 automotive use cases for evaluation in MODELISAR<br />
Engine<br />
with ECU<br />
Gearbox<br />
with ECU<br />
Thermal<br />
systems<br />
Automated<br />
cargo door<br />
Chassis components,<br />
roadway, ECU (e.g. ESP)<br />
<strong>functional</strong> <strong>mockup</strong> <strong>interface</strong> for model exchange and tool coupling<br />
etc.<br />
courtesy Daimler<br />
Functional Mockup Interface > ASIM Workshop, 4.-5. März 2010 > Slide 3
Task is complex since the different parts are complex by themselves:<br />
Model Exchange (ODE/DAE components without integrators)<br />
Co-Simulation (ODE/DAE components with integrators)<br />
Co-Simulation with PDE solver (MpCCI)<br />
AUTOSAR (discrete components with complex communication)<br />
Simulation Backplane<br />
In Jan. 2010, the first version of "FMI for Model Exchange" was released.<br />
It was mainly developed by <strong>Das</strong>sault Systèmes (Dynasim), DLR, ITI, <strong>QTronic</strong>.<br />
www.<strong>functional</strong>-<strong>mockup</strong>-<strong>interface</strong>.org<br />
specification<br />
xml schema files<br />
C header files<br />
software development kit (<strong>QTronic</strong>)<br />
Functional Mockup Interface > ASIM Workshop, 4.-5. März 2010 > Slide 4
MODELISAR<br />
ITEA2 project<br />
3 years (2008 – 2011)<br />
29 project partners<br />
Coordinators<br />
<strong>Das</strong>sault<br />
Systèmes<br />
Daimler AG<br />
Budget / Funding<br />
30M€ / 10M€<br />
Funded by<br />
Germany (BMBF)<br />
France (DGCIS)<br />
Sweden (VINNOVA)<br />
Belgium<br />
Austria<br />
Functional Mockup Interface > ASIM Workshop, 4.-5. März 2010 > Slide 5
2. FMI - Motivation<br />
Problems / Needs<br />
Component development by supplier<br />
Integration by OEM<br />
Many different simulation tools<br />
Solution<br />
Reuse of supplier models by OEM:<br />
DLL (model import) and/or<br />
Tool coupling (co-simulation)<br />
Protection of model IP of supplier<br />
Added Value<br />
Early validation of design<br />
Increased process<br />
efficiency and quality<br />
slide from Nick Suyam, Daimler (adapted)<br />
supplier1 supplier2 supplier3 supplier4 supplier5<br />
supplier1<br />
tool 1<br />
supplier1<br />
supplier2<br />
supplier2 supplier3 supplier4 supplier5<br />
tool 2 tool 3 tool 4 tool 5<br />
FMI<br />
OEM<br />
Functional Mockup Interface > ASIM Workshop, 4.-5. März 2010 > Slide 6<br />
!<br />
?<br />
OEM<br />
OEM<br />
supplier3
Example Scenario: Power Lift Gate<br />
supplier1 supplier2 supplier3<br />
AMESim<br />
(Modelica)<br />
OEM, dept. 1<br />
Dymola<br />
(Modelica)<br />
FMI model exchange (DLL)<br />
model import<br />
Simpack (multi-body)<br />
SimulationX<br />
(Modelica)<br />
model export<br />
OEM, dept. 2<br />
TargetLink (software)<br />
model export<br />
FMI tool coupling FMI model exchange (C)<br />
Silver (system model) + TestWeaver (testing)<br />
models solved with<br />
SIMPACK integrators<br />
(= central integration)<br />
model import co-simulation<br />
slide from Nick Suyam, Daimler (adapted)<br />
Functional Mockup Interface > ASIM Workshop, 4.-5. März 2010 > Slide 7
3. FMI for Model Exchange - Overview<br />
Import and export of input/output blocks (FMU – Functional Mock-up<br />
Unit)<br />
described by<br />
differential-, algebraic-, discrete equations,<br />
with time-, state, and step-events<br />
An FMU can be large (e.g. 100000 variables)<br />
An FMU can be used in an embedded system (small overhead)<br />
FMUs can be connected together<br />
Functional Mockup Interface > ASIM Workshop, 4.-5. März 2010 > Slide 8
Signals of an FMU:<br />
For example: 10 input/output signals (u/y) for connection and<br />
100000 internal variables (v) for plotting<br />
Functional Mockup Interface > ASIM Workshop, 4.-5. März 2010 > Slide 9
Mathematical description of an FMU:<br />
Functional Mockup Interface > ASIM Workshop, 4.-5. März 2010 > Slide 10
4. Model Distribution<br />
A model is distributed as one zip-file with extension ".fmu". Content:<br />
XML model description file<br />
All model information that is not needed during integration of model,<br />
e.g., signal names and attributes. Advantage:<br />
No overhead for model execution.<br />
Tools can read this information (= complicated data structure)<br />
with their prefered language (C++, C#, Java, ...)<br />
Model equations defined by a small set of C-functions. In zip-file:<br />
C source code and/or<br />
Binary code (DLL) for one or more platforms (Windows, Linux, ...)<br />
Resources<br />
Documentation (html files)<br />
Model icon (bitmap file)<br />
Maps and tables (read by model during initialization)<br />
Functional Mockup Interface > ASIM Workshop, 4.-5. März 2010 > Slide 11
Structure of an FMU zip-file<br />
modelDescription.xml // Description of model (required file)<br />
model.png // Optional image file of model icon<br />
documentation // Optional directory containing the model<br />
// documentation<br />
_main.html // Entry point of the documentation<br />
<br />
sources // Optional directory containing all C-sources<br />
// all needed C-sources and C-header files to compile and link the model<br />
// with exception of: fmiModelTypes.h and fmiModelFunctions.h<br />
binaries // Optional directory containing the binaries<br />
win32 // Optional binaries for 32-bit Windows<br />
.dll // DLL of the model <strong>interface</strong> implementation<br />
VisualStudio8 // Microsoft Visual Studio 8 (2005)<br />
.lib // Binary libraries<br />
gcc3.1 // Binaries for gcc 3.1.<br />
win64 // Optional binaries for 64-bit Windows<br />
...<br />
linux32 // Optional binaries for 32-bit Linux<br />
...<br />
resources // Optional resources needed by the model<br />
< data in model specific files which will be read during initialization ><br />
Functional Mockup Interface > ASIM Workshop, 4.-5. März 2010 > Slide 12
control<br />
simulator<br />
GUI<br />
model.dll<br />
simulator<br />
solver<br />
reads<br />
run 1 or many<br />
XML schema (.xsd)<br />
defined by the<br />
FMI specification<br />
references<br />
modelDescription.xml .fmu<br />
Functional Mockup Interface > ASIM Workshop, 4.-5. März 2010 > Slide 13
5. Model Description Schema<br />
All model information not needed for execution is stored in one xml-file<br />
(modelVariables.xml in zip-file) defined by xml schema files.<br />
Advantage:<br />
Complex data structures give still simple <strong>interface</strong>, and tool can use its favorite<br />
programming language for reading (e.g., C++, C#, Java).<br />
Definition of display units<br />
Definition of type defaults<br />
Default stop time, tol. etc.<br />
Tool specific data<br />
Variable names and attributes<br />
Functional Mockup Interface > ASIM Workshop, 4.-5. März 2010 > Slide 14
Model attributes. Most important<br />
modelIndentifier is a C-name that is<br />
used as prefix for the C-functions<br />
(model <strong>interface</strong>)<br />
guid is a globally unique identifier<br />
("fingerprint" of all releveant information<br />
in the xml file) that is also stored in the<br />
C-functions to gurantee consisteny<br />
Number of continuous states and<br />
of event indicators; numbers are fixed<br />
(meaning of states can change dynamically<br />
during simulation)<br />
Functional Mockup Interface > ASIM Workshop, 4.-5. März 2010 > Slide 15
ordered set of scalar variables<br />
(arrays, records, etc. must be<br />
mapped to scalars when<br />
generating code).<br />
ModelVariables<br />
data types<br />
Functional Mockup Interface > ASIM Workshop, 4.-5. März 2010 > Slide 16
Attributes of ModelVariables<br />
...<br />
unique name<br />
handle to identify<br />
variable in C-functions<br />
Functional Mockup Interface > ASIM Workshop, 4.-5. März 2010 > Slide 17
Data types allow to store all (relevant) Modelica attributes, including units.<br />
Defaults from TypeDefinitions<br />
Functional Mockup Interface > ASIM Workshop, 4.-5. März 2010 > Slide 18
Example<br />
modelDescription.xml<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
...<br />
<br />
<br />
Functional Mockup Interface > ASIM Workshop, 4.-5. März 2010 > Slide 19
6. Model C-Interface<br />
Two C-header files<br />
Platform dependent definitions (basic types)<br />
C-function <strong>interface</strong>s<br />
18 core functions<br />
6 utility functions<br />
no macros<br />
C-function name: _, z.B. "Drive_fmiSetTime"<br />
Functional Mockup Interface > ASIM Workshop, 4.-5. März 2010 > Slide 20
Example:<br />
// Set input arguments<br />
fmiSetTime(m, time);<br />
fmiSetReal(m, id_u1, u1, nu1);<br />
fmiSetContinuousStates(m, x, nx);<br />
// Get results<br />
fmiGetContinuousStates(m, derx, nx);<br />
fmiGetEventIndicators (m, z, nz);<br />
Functional Mockup Interface > ASIM Workshop, 4.-5. März 2010 > Slide 21
Caching for efficient model evaluation<br />
Functional Mockup Interface > ASIM Workshop, 4.-5. März 2010 > Slide 22
Clean Definition of State Events<br />
A state event occurs when an event indicator z changes its domain from<br />
Always well defined!<br />
z > 0 to z ≤ 0 or vice versa<br />
Usual definition z(t i )*z(t i-1 ) ≤ 0 is not always well-defined<br />
Functional Mockup Interface > ASIM Workshop, 4.-5. März 2010 > Slide 23
7. Tool Support for FMI (planned for 2010 in MODELISAR)<br />
7.1 FMU import and export<br />
AMESim<br />
(Modelica)<br />
CATIA Systems<br />
(CAD/Modelica)<br />
Dymola 7.4<br />
(Modelica)<br />
already available<br />
Functional Mockup Interface > ASIM Workshop, 4.-5. März 2010 > Slide 24
EXITE ACE<br />
(co-simulation of<br />
software/AUTOSAR)<br />
SimulationX<br />
(Modelica)<br />
Functional Mockup Interface > ASIM Workshop, 4.-5. März 2010 > Slide 25
7.2 FMU import<br />
EXITE<br />
(co-simulation)<br />
Silver/TestWeaver<br />
(FMU integration,<br />
cosimulation, testing)<br />
Simpack<br />
(multi-body)<br />
Functional Mockup Interface > ASIM Workshop, 4.-5. März 2010 > Slide 26
8. Comparison with SIMULINK S-Function Interface<br />
SIMULINK has two <strong>interface</strong>s:<br />
S-Function for offline simulation<br />
Realtime Workshop for embedded Systems<br />
FMI is targeted for both offline simulation and embedded systems (one <strong>interface</strong>)<br />
Simulink and FMI have different goals and therefore have different solutions:<br />
S-function targeted to import models in SIMULINK:<br />
Main <strong>interface</strong> to implement an S-Functions.<br />
(many macros to fill S-Function data structure)<br />
Incomplete <strong>interface</strong> to call S-Functions.<br />
Whenever a small detail of the S-Function data structure is changed,<br />
existing DLLs must be newly build.<br />
If used in 3 simulation environments → 3 DLLs of the same model<br />
FMI targeted to import models in many simulation environments<br />
Only <strong>interface</strong> to call model in simulation environment.<br />
Model data structure is secret of model generation environment.<br />
If used in 3 simulation environments on same platform → 1 DLL<br />
Functional Mockup Interface > ASIM Workshop, 4.-5. März 2010 > Slide 27
S-function not suited for embedded systems, due to large memory overhead<br />
since all information of a model is stored in the Model DLL (therefore<br />
separate code generation for embedded systems via Realtime Workshop)<br />
FMI: Only the minimum necessary part is stored in C source code or in Model<br />
DLL. All information not needed for execution, is provided in an XML file<br />
(which is needed on host, but not on target microprocessor)<br />
S-function has very complex definition (> 100 C-functions/macros)<br />
Generating S-function is fine. However, there is no simulator that can import<br />
all S-function models (with exception of SIMULINK).<br />
FMI: Simple definition (20 C-functions, no macros, XML schema file)<br />
S-function proprietary format, gives legal problems if used in other simulators<br />
FMI: Wikipedia license for specification, BSD license for schema/header<br />
Functional Mockup Interface > ASIM Workshop, 4.-5. März 2010 > Slide 28
Technical issues that are missing in S-Function <strong>interface</strong> and are available in FMI:<br />
Reliable state event handling<br />
Event iteration over simulation model (not only component model)<br />
Request from submodel to reduce step-size<br />
(for non-linear equations in model that do not converge)<br />
Dynamic selection of states<br />
(as needed for order-reduced higer index systems)<br />
Alias variables<br />
(FMI: alias variables are marked; need to be stored only once, not several<br />
times; important for Modelica models, since many alias variables)<br />
Caching of computed results<br />
(FMI: more efficient solution)<br />
Functional Mockup Interface > ASIM Workshop, 4.-5. März 2010 > Slide 29
9. Outlook<br />
"FMI for Model Exchange" released at end of January 2010<br />
(technical specification finalized; some discussion about precise license text)<br />
"FMI for Co-Simulation" in a good stage. Will be released in first half year:<br />
Support for: extrapolation/interpolation of <strong>interface</strong> variables,<br />
variable communication step-size, re-doing a step<br />
→ step-size control possible).<br />
"FMI for Model Exchange" will be further developed. A lot of requirements<br />
available, such as:<br />
Sparse Jacobian<br />
Direct support for arrays and records in xml schema<br />
Improved sample time definition (for embedded systems)<br />
Online changeable parameters<br />
Saving/restoring model state<br />
Other tool vendors are encouraged to support FMI, especially:<br />
VHDL-AMS simulators<br />
Multi-Body simulators<br />
Note: Much simpler as SIMULINK S-Function <strong>interface</strong> and more powerful.<br />
Functional Mockup Interface > ASIM Workshop, 4.-5. März 2010 > Slide 30
10. Acknowledgments<br />
FMI initiated and organized : Daimler AG (Bernd Relovsky, ....)<br />
Head of FMI development : Dietmar Neumerkel (Daimler AG)<br />
Head of FMI-for-Model-Exchange: Martin Otter (DLR-RM)<br />
FMI-for-Model-Exchange Torsten Blochwitz (ITI)<br />
Core-Design by: Hilding Elmqvist (<strong>Das</strong>sault Systèmes -Dynasim)<br />
Andreas Junghanns (<strong>QTronic</strong>)<br />
Jakob Mauss (<strong>QTronic</strong>)<br />
Hans Olsson (<strong>Das</strong>sault Systèmes -Dynasim)<br />
Martin Otter (DLR-RM)<br />
Other MODELISAR contributors: Ingrid Bausch-Gall, Bausch-Gall GmbH<br />
Alex Eichberger, SIMPACK AG<br />
Rainer Keppler, SIMPACK AG<br />
Gerd Kurzbach, ITI GmbH<br />
Carsten Kübler, TWT<br />
Johannes Mezger, TWT<br />
Thomas Neidhold, ITI GmbH<br />
Dietmar Neumerkel, Daimler AG<br />
Peter Nilsson, <strong>Das</strong>sault Systèmes-Dynasim<br />
Antoine Viel, LMS International<br />
Daniel Weil, <strong>Das</strong>sault Systèmes<br />
Other contributors: Johan Akesson, Lund University<br />
Joel Andersson, KU Leuven<br />
Roberto Parrotto, Politecnico di Milano<br />
Partially funded by: BMBF, VINNOVA, DGCIS, organized by ITEA2<br />
Prototypes for FMI evaluation:<br />
Dymola by Peter Nilsson, Sven Erik Mattsson,<br />
Carl Fredrik Abelson, Dan Henriksson<br />
(<strong>Das</strong>sault Systèmes, Dynasim)<br />
JModelica.org by Tove Bergdahl (Modelon)<br />
Silver by Andreas Junghanns, Jakob Mauss<br />
(<strong>QTronic</strong>)<br />
Functional Mockup Interface > ASIM Workshop, 4.-5. März 2010 > Slide 31