Upload
trandiep
View
222
Download
3
Embed Size (px)
Citation preview
1
Simulation and Optimization of Modelica Models with Optimica and JModelica.org
Outline
• The JModelica.org open source project • Dynamic optimization and Optimica • The JModelica.org platform • Tutorial examples • What’s next?
Outline
• The JModelica.org open source project • Dynamic optimization and Optimica • The JModelica.org platform • Tutorial examples • What’s next?
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
JModelica.org • Simulation • Optimization • Analysis • Visualization
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
Benefits • Increased flexibility • React quickly to market changes • Economic optimization
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
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
Outline
• The JModelica.org open source project • Dynamic optimization and Optimica • The JModelica.org platform • Tutorial examples • What’s next?
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
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
Typical workcycle
Modelica
Optimica
Result C code The Optimica Compiler
Executable
Generate and solve
Analyze and tune
Dynamic optimization
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
An example
A Modelica model
An Optimica model
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
Plate reactor results
Reactant injection rates
Sta
te p
rofil
es
Feed and cooling temperatures
Inpu
t pro
files
Benefits • Faster start-up sequences
Profitability
• Safety • Process understanding • Rapid design cycle
Outline
• The JModelica.org open source project • Dynamic optimization and Optimica • The JModelica.org platform • Tutorial examples • What’s next?
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
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”
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
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
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
Community
• Documentation • News • Forums
• Transparency • Track activity • Releases
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
Outline
• The JModelica.org open source project • Dynamic optimization and Optimica • The JModelica.org platform • Tutorial examples • What’s next?
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
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
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
Outline
• The JModelica.org open source project • Dynamic optimization and Optimica • The JModelica.org platform • Tutorial examples • What’s next?
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)
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
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
Join the community
• Use in industrial applications • Education • Interfacing your algorithms • Research • Develop