Leveraging Modelica & FMI in
Scilab open-source engineering software
September 2015
1© Scilab Enterprises
Yann DEBRAY
: yann.debray@scilab-enterprises.com
: +33 1 80 77 04 73
: +49 157 51 49 49 15
Agenda
 Introduction
 Scilab Use cases
 Modelica in Scilab/Xcos
 Scilab/Xcos FMI import/export
 Demonstrations
 Questions - Answers
2© Scilab Enterprises
Introduction
Scilab History
Scilab Today
Scilab Distribution
3© Scilab Enterprises
Scilab History
1980:
First Scilab
Kernel
= Free Matlab
1990 - 2003:
1994: Scilab
freely distributed
on the net
2003 - 2012:
Scilab
Consortium
2012 - Today:
Scilab
Enterprises
drives the
evolution of
Scilab
4
1980 – 1990:
INRIA – French national
research institute for
Informatics & Automation
Integration of Modelica
Since 2005
© Scilab Enterprises
Scilab Today
From www.scilab.org
 ~ 100 000 monthly installations from 150 countries
5© Scilab Enterprises
Scilab Open Source Distribution
Workstation Software:
 Scilab
Powerful Computation Engine
 Xcos
Dynamic Systems Modelling and Simulation
Server Software:
 ATOMS Server
Modules/Toolboxes Management
6© Scilab Enterprises
Scilab Use cases
Main references
Industrial use cases
7© Scilab Enterprises
Main Scilab References
 Aerospace & Defense:
CNES, Astrium, DLR, Safran, Dassault Aviation, DGA, Thales
 Automotive:
PSA, Renault, Leoni, Valeo, Faurecia, TMD Friction, Continental
 Metallurgy:
ArcelorMittal, Aperam, Alcan, Eramet
 Energy:
CEA, EDF, RTE, ABB, Total, IFP, Alstom…
 Chemical & Pharmaceutical :
Solvay/Rhodia, Sanofi
8© Scilab Enterprises
From R&D to industrial implementation
Execution Engine (based on Scilab)
9
Components from the
Model Repository …
… for simulation
… in dedicated
applications
Can be used …
© Scilab Enterprises 9
Modelling of a metallurgical reactor
 Use of odedc (discrete/continuous
ordinary differential equations solver)
© Scilab Enterprises 10
Live Monitoring of Air Handling Units
 Problem: Heating,
Ventilation, Air
Climatisation amounts to
60 % of energy bill =
500k€/year
 oscillations in Air Handling
Units control
(blue= cooling valve,
red= heating valve)
Scilab Solutions:
 Energy simulation
OPTICLIM (+Excel import)
 Energy monitoring
Modbus over TCP/IP
© Scilab Enterprises 11
Thermal pre-dimensioning of electronic
circuit based on Thermal Impedance
 Goal: Dimension quickly but with enough precision in an early phase
Results: Errors limited to about 3°C
Blue = « 0D » Model /
Red = CFD Simulations
3 observed points (the 3
junction temperatures)
12© Scilab Enterprises
Post-treatment tools from aero-acoustic data
 Thin band spectrum  cartographic 2D
 Data acquisition (30 GB per test campaign)
 Convertion into spectral data
(Fourier transform)
 Grid definition
 Correction matrix
 Display
13Fast processing and visualization
© Scilab Enterprises
DoE, post-processing and visualization
Modules used
 DACE (ATOMS): kriging
 NSGA2 : multi-objective
optimization
 TOPSIS : multicriteria decision
making (specific development)
Development of a GUI to explore
simulation results (Excel imported)
GUI, graphics, advanced mathematics
© Scilab Enterprises 14
Sizelab: Application
for mechanical pre-sizing
15© Scilab Enterprises 15
Scilab used for the mission ROSETTA
 Reading/writing
inputs/outputs data of Flight
Dynamics System (proprietary)
 Mission frames transformation
 Comets environments
 Comets topography and
Digital Terrain Model
 Statistic and probability
analysis
 Geometry computations
16
© Scilab Enterprises
Scilab/Xcos + Modelica/FMI
Scilab / Xcos functional coverage
Modelica in Xcos
FMI: Model-Exchange & Co-simulation
17© Scilab Enterprises
© Scilab Enterprises 18
 Mathematics
 Statistics
 Optimization
 Signal Processing
 Control Systems
A powerful platform with more than 2,000 functions:
Scilab Architecture
19
Scilab
Hardware adaptation
File
types
support
Graphical
Modelling &
Simulation Xcos
Maths functions
d/dt
aX²
+bX
Scientific functions
Stats
Fftw +Signal
processing
Optim
User interfaces
Command line Graphing Editor
APIs/extensions:
Language binding
Dynamic link
functions
Editor Scinote
HMI/ GUI Builder
Call_scilab
ATOMS Module
definition
Sparse
Matrix
interp
olation
Rand
-lib
Language interpreter
AST Types, integer, string, sparse time
Matlab compatibility
compatibility conversion
Development environments
help
Localization
Preferences
Windows_tools
elementary_functions
Control
systems
Xcos: Hybrid Dynamic Systems Modeler & Simulator
Xcos features
Graphical
Output
Graphical
Editor
Hybrid
Simulation
Customizable
Palettes
Multiphysics
simulation
Simulation
Acceleration
Xcos external modules
Finite State
Machine
Embedded Code
Generation
Functional
Mockup
Interface
20© Scilab Enterprises
© Scilab Enterprises 21
Discrete Simulation
 The observation of a phenomenon is
activated by an event. During the
activation, the state of the system
changes et programs future events.
Continuous Simulation
 Observation of a phenomenon
during a fixed and regular step time.
Hybrid Simulation
 The observation of a phenomenon
is made during a fixed time step, but
can also be activated by an event.
Model building in Xcos
© Scilab Enterprises 22
To compute and plot
the values of I1 and I2:
We obtain that:
Modelica integration in Xcos
© Scilab Enterprises 23
Real life
Xcos and Modelica
© Scilab Enterprises 24
Xcos standard causal blocks
 Equation:
 Block: written in C, Scilab language
𝑦 = 𝑓 𝑢
 Equation:
 Block: written in Modelica language
Xcos acausal blocks
𝑓 𝑦, 𝑢 = 0
How does it work?
© Scilab Enterprises 25
Modelica compiler embedded into
Xcos
1. Flattening process
2. Solution of the DAE and
generation of an equivalent
simulation function in C
(causal): the implicit subset is
replaced par an equivalent
superblock for the simulation
3. Compilation and dynamic
linking to Scilab
Conclusion: Scilab+Xcos+Modelica
--> mixed Xcos/Modelica modelling
--> Integrated graphical environnement in a powerful pre-/post-processing engine: Scilab!
Modelica compiler written in Ocaml
support only a subset of Modelica 2.0
--> Help us integrate the
OpenModelica Compiler
FMI: Model-Exchange & Co-simulation
Scilab/Xcos
Control team
Software A
Thermal team
FMU
import/export
--> Separate the model authoring tool from the model execution tool
--> Deploy from few simulation specialists to designers, domain specialists, …
Demonstrations
Automotive suspension with Scilab / Xcos / Modelica
FMI in Xcos
Xcos Parameter identification with fminsearch
Datafitting with Excel data
Xcos solvers
28© Scilab Enterprises
Three ways for Physical modelling with Scilab/Xcos
1. Scilab: Simple mathematical description with Ordinary
Differential Equations
2. Xcos: Causal description with transfert functions
3. Coselica: Acausal description with multi-physical block
example: Automobile suspension
© Scilab Enterprises 29
Ordinary Differential Equations (ODE) in Scilab
function yp=quarter_car_ode(t, y)
v = 4; // Speed [m/s]
m = 50;
c_F = 10000; // [N/m]
c_D = 400; // [Ns/m]
x = v*t ;
yp = [y(2);
1/m*(c_D*(v*zp-y(2))+c_F*(z-y(1)))];
endfunction
t = linspace(t0,t1);
y= ode("rkf",[0;0],t0,t,quarter_car_ode);
© Scilab Enterprises 30
Causal design with Xcos:
Automotive suspension from PSA
© Scilab Enterprises 31
Acausal with Modelica blockset in Xcos
© Scilab Enterprises 32
Demo Xcos FMI Cruise Control
33© Scilab Enterprises
• Modelled in SCADE Simulated in Xcos
--> Link to established specialized proprietary software
Demo Xcos FMI PID Controller
34© Scilab Enterprises
• The same PID Controller natively and imported with
model-exchange and co-simulation:
--> Fidelity in simulation, ease to model
Xcos Parameter identification
with fminsearch
35© Scilab Enterprises
Datafitting with Excel data
36© Scilab Enterprises
Xcos solvers
37© Scilab Enterprises
Conclusion
 Scilab/Xcos + Modelica/FMI =
– Advanced simulation technologies, with the strength of
having a powerful computation platform
– Committed to open standards
– Let us do more in this direction together
Adopt Scilab, choose the open source
© Scilab Enterprises 38

Scilab Modelica conference 20150921

  • 1.
    Leveraging Modelica &FMI in Scilab open-source engineering software September 2015 1© Scilab Enterprises Yann DEBRAY : yann.debray@scilab-enterprises.com : +33 1 80 77 04 73 : +49 157 51 49 49 15
  • 2.
    Agenda  Introduction  ScilabUse cases  Modelica in Scilab/Xcos  Scilab/Xcos FMI import/export  Demonstrations  Questions - Answers 2© Scilab Enterprises
  • 3.
  • 4.
    Scilab History 1980: First Scilab Kernel =Free Matlab 1990 - 2003: 1994: Scilab freely distributed on the net 2003 - 2012: Scilab Consortium 2012 - Today: Scilab Enterprises drives the evolution of Scilab 4 1980 – 1990: INRIA – French national research institute for Informatics & Automation Integration of Modelica Since 2005 © Scilab Enterprises
  • 5.
    Scilab Today From www.scilab.org ~ 100 000 monthly installations from 150 countries 5© Scilab Enterprises
  • 6.
    Scilab Open SourceDistribution Workstation Software:  Scilab Powerful Computation Engine  Xcos Dynamic Systems Modelling and Simulation Server Software:  ATOMS Server Modules/Toolboxes Management 6© Scilab Enterprises
  • 7.
    Scilab Use cases Mainreferences Industrial use cases 7© Scilab Enterprises
  • 8.
    Main Scilab References Aerospace & Defense: CNES, Astrium, DLR, Safran, Dassault Aviation, DGA, Thales  Automotive: PSA, Renault, Leoni, Valeo, Faurecia, TMD Friction, Continental  Metallurgy: ArcelorMittal, Aperam, Alcan, Eramet  Energy: CEA, EDF, RTE, ABB, Total, IFP, Alstom…  Chemical & Pharmaceutical : Solvay/Rhodia, Sanofi 8© Scilab Enterprises
  • 9.
    From R&D toindustrial implementation Execution Engine (based on Scilab) 9 Components from the Model Repository … … for simulation … in dedicated applications Can be used … © Scilab Enterprises 9
  • 10.
    Modelling of ametallurgical reactor  Use of odedc (discrete/continuous ordinary differential equations solver) © Scilab Enterprises 10
  • 11.
    Live Monitoring ofAir Handling Units  Problem: Heating, Ventilation, Air Climatisation amounts to 60 % of energy bill = 500k€/year  oscillations in Air Handling Units control (blue= cooling valve, red= heating valve) Scilab Solutions:  Energy simulation OPTICLIM (+Excel import)  Energy monitoring Modbus over TCP/IP © Scilab Enterprises 11
  • 12.
    Thermal pre-dimensioning ofelectronic circuit based on Thermal Impedance  Goal: Dimension quickly but with enough precision in an early phase Results: Errors limited to about 3°C Blue = « 0D » Model / Red = CFD Simulations 3 observed points (the 3 junction temperatures) 12© Scilab Enterprises
  • 13.
    Post-treatment tools fromaero-acoustic data  Thin band spectrum  cartographic 2D  Data acquisition (30 GB per test campaign)  Convertion into spectral data (Fourier transform)  Grid definition  Correction matrix  Display 13Fast processing and visualization © Scilab Enterprises
  • 14.
    DoE, post-processing andvisualization Modules used  DACE (ATOMS): kriging  NSGA2 : multi-objective optimization  TOPSIS : multicriteria decision making (specific development) Development of a GUI to explore simulation results (Excel imported) GUI, graphics, advanced mathematics © Scilab Enterprises 14
  • 15.
    Sizelab: Application for mechanicalpre-sizing 15© Scilab Enterprises 15
  • 16.
    Scilab used forthe mission ROSETTA  Reading/writing inputs/outputs data of Flight Dynamics System (proprietary)  Mission frames transformation  Comets environments  Comets topography and Digital Terrain Model  Statistic and probability analysis  Geometry computations 16 © Scilab Enterprises
  • 17.
    Scilab/Xcos + Modelica/FMI Scilab/ Xcos functional coverage Modelica in Xcos FMI: Model-Exchange & Co-simulation 17© Scilab Enterprises
  • 18.
    © Scilab Enterprises18  Mathematics  Statistics  Optimization  Signal Processing  Control Systems A powerful platform with more than 2,000 functions:
  • 19.
    Scilab Architecture 19 Scilab Hardware adaptation File types support Graphical Modelling& Simulation Xcos Maths functions d/dt aX² +bX Scientific functions Stats Fftw +Signal processing Optim User interfaces Command line Graphing Editor APIs/extensions: Language binding Dynamic link functions Editor Scinote HMI/ GUI Builder Call_scilab ATOMS Module definition Sparse Matrix interp olation Rand -lib Language interpreter AST Types, integer, string, sparse time Matlab compatibility compatibility conversion Development environments help Localization Preferences Windows_tools elementary_functions Control systems
  • 20.
    Xcos: Hybrid DynamicSystems Modeler & Simulator Xcos features Graphical Output Graphical Editor Hybrid Simulation Customizable Palettes Multiphysics simulation Simulation Acceleration Xcos external modules Finite State Machine Embedded Code Generation Functional Mockup Interface 20© Scilab Enterprises
  • 21.
    © Scilab Enterprises21 Discrete Simulation  The observation of a phenomenon is activated by an event. During the activation, the state of the system changes et programs future events. Continuous Simulation  Observation of a phenomenon during a fixed and regular step time. Hybrid Simulation  The observation of a phenomenon is made during a fixed time step, but can also be activated by an event.
  • 22.
    Model building inXcos © Scilab Enterprises 22 To compute and plot the values of I1 and I2: We obtain that:
  • 23.
    Modelica integration inXcos © Scilab Enterprises 23 Real life Xcos and Modelica
  • 24.
    © Scilab Enterprises24 Xcos standard causal blocks  Equation:  Block: written in C, Scilab language 𝑦 = 𝑓 𝑢  Equation:  Block: written in Modelica language Xcos acausal blocks 𝑓 𝑦, 𝑢 = 0
  • 25.
    How does itwork? © Scilab Enterprises 25 Modelica compiler embedded into Xcos 1. Flattening process 2. Solution of the DAE and generation of an equivalent simulation function in C (causal): the implicit subset is replaced par an equivalent superblock for the simulation 3. Compilation and dynamic linking to Scilab
  • 26.
    Conclusion: Scilab+Xcos+Modelica --> mixedXcos/Modelica modelling --> Integrated graphical environnement in a powerful pre-/post-processing engine: Scilab! Modelica compiler written in Ocaml support only a subset of Modelica 2.0 --> Help us integrate the OpenModelica Compiler
  • 27.
    FMI: Model-Exchange &Co-simulation Scilab/Xcos Control team Software A Thermal team FMU import/export --> Separate the model authoring tool from the model execution tool --> Deploy from few simulation specialists to designers, domain specialists, …
  • 28.
    Demonstrations Automotive suspension withScilab / Xcos / Modelica FMI in Xcos Xcos Parameter identification with fminsearch Datafitting with Excel data Xcos solvers 28© Scilab Enterprises
  • 29.
    Three ways forPhysical modelling with Scilab/Xcos 1. Scilab: Simple mathematical description with Ordinary Differential Equations 2. Xcos: Causal description with transfert functions 3. Coselica: Acausal description with multi-physical block example: Automobile suspension © Scilab Enterprises 29
  • 30.
    Ordinary Differential Equations(ODE) in Scilab function yp=quarter_car_ode(t, y) v = 4; // Speed [m/s] m = 50; c_F = 10000; // [N/m] c_D = 400; // [Ns/m] x = v*t ; yp = [y(2); 1/m*(c_D*(v*zp-y(2))+c_F*(z-y(1)))]; endfunction t = linspace(t0,t1); y= ode("rkf",[0;0],t0,t,quarter_car_ode); © Scilab Enterprises 30
  • 31.
    Causal design withXcos: Automotive suspension from PSA © Scilab Enterprises 31
  • 32.
    Acausal with Modelicablockset in Xcos © Scilab Enterprises 32
  • 33.
    Demo Xcos FMICruise Control 33© Scilab Enterprises • Modelled in SCADE Simulated in Xcos --> Link to established specialized proprietary software
  • 34.
    Demo Xcos FMIPID Controller 34© Scilab Enterprises • The same PID Controller natively and imported with model-exchange and co-simulation: --> Fidelity in simulation, ease to model
  • 35.
    Xcos Parameter identification withfminsearch 35© Scilab Enterprises
  • 36.
    Datafitting with Exceldata 36© Scilab Enterprises
  • 37.
  • 38.
    Conclusion  Scilab/Xcos +Modelica/FMI = – Advanced simulation technologies, with the strength of having a powerful computation platform – Committed to open standards – Let us do more in this direction together Adopt Scilab, choose the open source © Scilab Enterprises 38