Simulation and Optimization of Modelica Models with Optimica and ...
Transcript of Simulation and Optimization of Modelica Models with Optimica and ...
![Page 1: Simulation and Optimization of Modelica Models with Optimica and ...](https://reader031.fdocuments.in/reader031/viewer/2022022000/58a2ea051a28abf0458bee6c/html5/thumbnails/1.jpg)
1
Simulation and Optimization of Modelica Models with Optimica and JModelica.org
![Page 2: Simulation and Optimization of Modelica Models with Optimica and ...](https://reader031.fdocuments.in/reader031/viewer/2022022000/58a2ea051a28abf0458bee6c/html5/thumbnails/2.jpg)
Outline
• The JModelica.org open source project • Dynamic optimization and Optimica • The JModelica.org platform • Tutorial examples • What’s next?
![Page 3: Simulation and Optimization of Modelica Models with Optimica and ...](https://reader031.fdocuments.in/reader031/viewer/2022022000/58a2ea051a28abf0458bee6c/html5/thumbnails/3.jpg)
Outline
• The JModelica.org open source project • Dynamic optimization and Optimica • The JModelica.org platform • Tutorial examples • What’s next?
![Page 4: Simulation and Optimization of Modelica Models with Optimica and ...](https://reader031.fdocuments.in/reader031/viewer/2022022000/58a2ea051a28abf0458bee6c/html5/thumbnails/4.jpg)
The JModelica.org open source project
What? JModelica.org is an extensible Modelica-based open source platform for optimization, simulation and analysis of complex dynamic systems.
Origin: JModelica.org is the result of research at the Department of Automatic control, Lund University, and is now maintained and developed by Modelon AB in cooperation with academia.
Our mission: To offer a community-based, free, open source, accessible, user and application oriented Modelica environment for optimization and simulation of complex dynamic systems, built on well-recognized technology and supporting major platforms
![Page 5: Simulation and Optimization of Modelica Models with Optimica and ...](https://reader031.fdocuments.in/reader031/viewer/2022022000/58a2ea051a28abf0458bee6c/html5/thumbnails/5.jpg)
JModelica.org • Simulation • Optimization • Analysis • Visualization
![Page 6: Simulation and Optimization of Modelica Models with Optimica and ...](https://reader031.fdocuments.in/reader031/viewer/2022022000/58a2ea051a28abf0458bee6c/html5/thumbnails/6.jpg)
Industrial Applications • Grade change optimization • Polyethylene production • Decision support • Flexible production • Raw material prices vary • Minimize off-spec
• JModelica.org for optimization • Grade changes and parameter
estimation • Collaboration between Lund Univ.
and Borealis • Per-Ola Larsson • Niklas Andersson
![Page 7: Simulation and Optimization of Modelica Models with Optimica and ...](https://reader031.fdocuments.in/reader031/viewer/2022022000/58a2ea051a28abf0458bee6c/html5/thumbnails/7.jpg)
Benefits • Increased flexibility • React quickly to market changes • Economic optimization
![Page 8: Simulation and Optimization of Modelica Models with Optimica and ...](https://reader031.fdocuments.in/reader031/viewer/2022022000/58a2ea051a28abf0458bee6c/html5/thumbnails/8.jpg)
JModelica.org is open source
• Source code is freely available Open Source Initiative approved licenses GPL (CPL)
• Infrastructure supporting a community Transparency of development Interactive web site User forums
• Dual licensing Commercial licenses available Bundling with commercial solvers Support
![Page 9: Simulation and Optimization of Modelica Models with Optimica and ...](https://reader031.fdocuments.in/reader031/viewer/2022022000/58a2ea051a28abf0458bee6c/html5/thumbnails/9.jpg)
One year with JModelica.org JM-1.5 • FMU export • Symbolic algs. • External funcs. • Sparse solvers • Sampled systems
JM-1.4 • Python model classes • Enumerations • Sensitivity alalysis • Improved initialization
JM-1.3 • FMU simulation • Stream connectors • Redeclare/replaceable
JM-1.2 • Vectors • Functions • Assimulo
April 2010
March 2011
![Page 10: Simulation and Optimization of Modelica Models with Optimica and ...](https://reader031.fdocuments.in/reader031/viewer/2022022000/58a2ea051a28abf0458bee6c/html5/thumbnails/10.jpg)
Outline
• The JModelica.org open source project • Dynamic optimization and Optimica • The JModelica.org platform • Tutorial examples • What’s next?
![Page 11: Simulation and Optimization of Modelica Models with Optimica and ...](https://reader031.fdocuments.in/reader031/viewer/2022022000/58a2ea051a28abf0458bee6c/html5/thumbnails/11.jpg)
Optimization and Modelica • Modelica increasingly used in industry
Expert knowledge Capital investments
• Mainly simulation... ...but new areas emerge Model reduction Parameter identification Dynamic optimization Model predictive control
• Usages reported so far Cope with simulation-oriented interfaces Treat model essentially as a black box
• Fast algorithms explores model structure Real-time optimization
![Page 12: Simulation and Optimization of Modelica Models with Optimica and ...](https://reader031.fdocuments.in/reader031/viewer/2022022000/58a2ea051a28abf0458bee6c/html5/thumbnails/12.jpg)
Dynamic optimization
• Many algorithms Applicability highly model-dependent (ODE, DAE, PDE, hybrid)
• Calculus of variations • Single/Multiple shooting • Simultaneous methods • Simulation-based methods (GA, simulated annealing)
• Analogy with different simulation algorithms Heavy burden to use numerical algorithms Fortran, C, (AMPL)
• Engineering need for high-level descriptions Shift focus from encoding to formulation of optimization problem
![Page 13: Simulation and Optimization of Modelica Models with Optimica and ...](https://reader031.fdocuments.in/reader031/viewer/2022022000/58a2ea051a28abf0458bee6c/html5/thumbnails/13.jpg)
Typical workcycle
Modelica
Optimica
Result C code The Optimica Compiler
Executable
Generate and solve
Analyze and tune
![Page 14: Simulation and Optimization of Modelica Models with Optimica and ...](https://reader031.fdocuments.in/reader031/viewer/2022022000/58a2ea051a28abf0458bee6c/html5/thumbnails/14.jpg)
Dynamic optimization
![Page 15: Simulation and Optimization of Modelica Models with Optimica and ...](https://reader031.fdocuments.in/reader031/viewer/2022022000/58a2ea051a28abf0458bee6c/html5/thumbnails/15.jpg)
Optimization with Modelica
• Strong support for modeling of dynamic systems • Missing elements
Cost function Constraints What to optimize Initial guesses
• Optimica Small extension of Modelica Enable high-level formulation of optimization problems
![Page 16: Simulation and Optimization of Modelica Models with Optimica and ...](https://reader031.fdocuments.in/reader031/viewer/2022022000/58a2ea051a28abf0458bee6c/html5/thumbnails/16.jpg)
An example
![Page 17: Simulation and Optimization of Modelica Models with Optimica and ...](https://reader031.fdocuments.in/reader031/viewer/2022022000/58a2ea051a28abf0458bee6c/html5/thumbnails/17.jpg)
A Modelica model
![Page 18: Simulation and Optimization of Modelica Models with Optimica and ...](https://reader031.fdocuments.in/reader031/viewer/2022022000/58a2ea051a28abf0458bee6c/html5/thumbnails/18.jpg)
An Optimica model
![Page 19: Simulation and Optimization of Modelica Models with Optimica and ...](https://reader031.fdocuments.in/reader031/viewer/2022022000/58a2ea051a28abf0458bee6c/html5/thumbnails/19.jpg)
Optimal Start-up of a Plate Reactor
• Start-up of a plate reactor with exothermic reaction • Tubular reactor inside a heath-exchanger • Multiple injection points (hot spots) • Generate open loop start-up trajectories using dynamic
optimization • Large scale system
>100 equations and variables
• Multiple objectives Bounded temperature profiles Maximum conversion Minimum start-up times Robust to parameter variations
![Page 20: Simulation and Optimization of Modelica Models with Optimica and ...](https://reader031.fdocuments.in/reader031/viewer/2022022000/58a2ea051a28abf0458bee6c/html5/thumbnails/20.jpg)
Plate reactor results
Reactant injection rates
Sta
te p
rofil
es
Feed and cooling temperatures
Inpu
t pro
files
![Page 21: Simulation and Optimization of Modelica Models with Optimica and ...](https://reader031.fdocuments.in/reader031/viewer/2022022000/58a2ea051a28abf0458bee6c/html5/thumbnails/21.jpg)
Benefits • Faster start-up sequences
Profitability
• Safety • Process understanding • Rapid design cycle
![Page 22: Simulation and Optimization of Modelica Models with Optimica and ...](https://reader031.fdocuments.in/reader031/viewer/2022022000/58a2ea051a28abf0458bee6c/html5/thumbnails/22.jpg)
Outline
• The JModelica.org open source project • Dynamic optimization and Optimica • The JModelica.org platform • Tutorial examples • What’s next?
![Page 23: Simulation and Optimization of Modelica Models with Optimica and ...](https://reader031.fdocuments.in/reader031/viewer/2022022000/58a2ea051a28abf0458bee6c/html5/thumbnails/23.jpg)
Technologies • Modelica • JastAdd meta-compiler tool
Modelica/Optimica compiler front-ends pure Java Easily embedded jar-files
• Python Scientific computing environment Scripting and visualization Custom application development
• XML Model meta data
• Eclipse Modelica IDE
![Page 24: Simulation and Optimization of Modelica Models with Optimica and ...](https://reader031.fdocuments.in/reader031/viewer/2022022000/58a2ea051a28abf0458bee6c/html5/thumbnails/24.jpg)
Python
• Open source language (tools) • Interpreted language • Object-oriented • Many OSS packages
NumPy SciPy Matplotlib OpenOpt
• Easy to interface C, Java, Fortran… Compiled JModelica.org models SUNDIALS Commonly used as ”glue language”
![Page 25: Simulation and Optimization of Modelica Models with Optimica and ...](https://reader031.fdocuments.in/reader031/viewer/2022022000/58a2ea051a28abf0458bee6c/html5/thumbnails/25.jpg)
Optimization
• Optimization is a standard engineering technology • Automate manual search procedures • Problem classes
Parameter optimization Optimal control On-line state estimation Model predictive control Design optimization
• Focus on high-performance methods Expose model structure Analytic derivatives Sparsity Fast convergence
![Page 26: Simulation and Optimization of Modelica Models with Optimica and ...](https://reader031.fdocuments.in/reader031/viewer/2022022000/58a2ea051a28abf0458bee6c/html5/thumbnails/26.jpg)
Algorithms in JModelica.org
• Simultaneous Collocation optimization algorithm JMI/C Large but sparse non-linear program Numerical solver Ipopt
• Pseudospectral collocation method AD tool CasADi XML export/import Convenient scripting in Python Ipopt
![Page 27: Simulation and Optimization of Modelica Models with Optimica and ...](https://reader031.fdocuments.in/reader031/viewer/2022022000/58a2ea051a28abf0458bee6c/html5/thumbnails/27.jpg)
JModelica.org architecture Modelica
Optimica
Compiler Fr
ont-
end
Mid
dle-
end
Bac
k-en
d Eclipse plugin (IDE)
C
XML ODE Opt. DAE Init.
DAE
FMI/JMI Runtime Library
Generated Code DLL
Python Integration
Algorithms
Scripts User Applications
![Page 28: Simulation and Optimization of Modelica Models with Optimica and ...](https://reader031.fdocuments.in/reader031/viewer/2022022000/58a2ea051a28abf0458bee6c/html5/thumbnails/28.jpg)
Community
• Documentation • News • Forums
• Transparency • Track activity • Releases
![Page 29: Simulation and Optimization of Modelica Models with Optimica and ...](https://reader031.fdocuments.in/reader031/viewer/2022022000/58a2ea051a28abf0458bee6c/html5/thumbnails/29.jpg)
Ecosystem
Department of Automatic Control (LU)
Department of Computer Science (LU)
Department of Mathematics
(LU)
Modelon AB
Texas A&M USA
Illmenau Germany
Heidelberg Germany
Leuven Belgium
Industry
Industry
Industry
![Page 30: Simulation and Optimization of Modelica Models with Optimica and ...](https://reader031.fdocuments.in/reader031/viewer/2022022000/58a2ea051a28abf0458bee6c/html5/thumbnails/30.jpg)
Outline
• The JModelica.org open source project • Dynamic optimization and Optimica • The JModelica.org platform • Tutorial examples • What’s next?
![Page 31: Simulation and Optimization of Modelica Models with Optimica and ...](https://reader031.fdocuments.in/reader031/viewer/2022022000/58a2ea051a28abf0458bee6c/html5/thumbnails/31.jpg)
Tutorial 1: Simulation of FMUs (UG 4.3)
• The Van der Pol Oscillator
• Compile Modelica models into FMUs • Load compiled models into Python • Set model parameter values • Batch simulation • Visualization • Scripting in Python
![Page 32: Simulation and Optimization of Modelica Models with Optimica and ...](https://reader031.fdocuments.in/reader031/viewer/2022022000/58a2ea051a28abf0458bee6c/html5/thumbnails/32.jpg)
Tutorial 2 – Hicks Ray CSTR (UG 8.4)
• Optimal control of the Hicks Ray Continuously Stirred Tank Reactor (CSTR)
• Exothermic reaction A+BC • Constant inflow F0 and input concentration c0
• States Concentration of reactant A, c Reactor temperature, T
• Control variable Temperature of cooling liquid, Tc
![Page 33: Simulation and Optimization of Modelica Models with Optimica and ...](https://reader031.fdocuments.in/reader031/viewer/2022022000/58a2ea051a28abf0458bee6c/html5/thumbnails/33.jpg)
Tutorial 2
1. Compile models Modelica models and Optimica models Compile sources into C code Compile a DLL and load it into Python
2. Solve DAE initialization problems Computation of stationary operating points
3. Solve an optimal control problem Transfer state from point A to point B Bounded input profile Bound on reactor temperature
4. Plot results
![Page 34: Simulation and Optimization of Modelica Models with Optimica and ...](https://reader031.fdocuments.in/reader031/viewer/2022022000/58a2ea051a28abf0458bee6c/html5/thumbnails/34.jpg)
Outline
• The JModelica.org open source project • Dynamic optimization and Optimica • The JModelica.org platform • Tutorial examples • What’s next?
![Page 35: Simulation and Optimization of Modelica Models with Optimica and ...](https://reader031.fdocuments.in/reader031/viewer/2022022000/58a2ea051a28abf0458bee6c/html5/thumbnails/35.jpg)
What’s next?
• Improved Modelica compliance MSL support Hybrid systems Strings
• Graphical editing Eclipse plugin
• Analytical Jacobians Extension of FMI (within OPENPROD)
• Continued work on optimization algorithms Integration of CasADi Derivative free optimization (DFO)
![Page 36: Simulation and Optimization of Modelica Models with Optimica and ...](https://reader031.fdocuments.in/reader031/viewer/2022022000/58a2ea051a28abf0458bee6c/html5/thumbnails/36.jpg)
JModelica.org in research
• Continued work on Optimica language extension Execution of Model predictive controllers
• PIC-LU (Process Industrial Center at Lund University) Grade change optimization at Borealis Poly-ethane process Economic optimization
• Parallelization of optimization algorithms Explore the power of multi and many core Decomposition schemes in interior point methods
• Safe refactoring Exploit research related to JastAdd Adapt and extend framework developed for Java
![Page 37: Simulation and Optimization of Modelica Models with Optimica and ...](https://reader031.fdocuments.in/reader031/viewer/2022022000/58a2ea051a28abf0458bee6c/html5/thumbnails/37.jpg)
Commercial packaging
• The Modelica Physical Modeling Toolbox for Matlab Intelligent Modelica editor Export of compiled models (FMUs) Simulation of Modelica models in Simulink Simulation of Modelica models in Matlab scripts
• Python Commercial optimization algorithms
• Support
JModelica.org Vendor session
Monday March 21 5:20pm-6:05pm
Room: HS2
![Page 38: Simulation and Optimization of Modelica Models with Optimica and ...](https://reader031.fdocuments.in/reader031/viewer/2022022000/58a2ea051a28abf0458bee6c/html5/thumbnails/38.jpg)
Join the community
• Use in industrial applications • Education • Interfacing your algorithms • Research • Develop