Using CasADi for Optimization and Symbolic Linearization/Extraction of Causality Graphs of Modelica Models via JModelica.Org
MetadataVis full innførsel
- HiT rapport 
OriginalversjonPerera, A. Using CasADi for Optimization and Symbolic Linearization/Extraction of Causality Graphs of Modelica Models via JModelica.Org. Porsgrunn, Telemark University College, 2014
The Modelica language has become a handy modeling tool for multi-domain complex physical systems. Its object-oriented and equation-based approach eases the modeling process to a great extent. Dynamic models which are scripted according to the Modelica standards demand a simulation environment. There are many simulation tools such as OpenModelica, Dymola, JModelica.org, OPTIMICA Studio, etc. OpenModelica and JModelica are two examples of free Modelica-based simulation environments. Dynamic Optimization is also an important aspect in control engineering. JModelica.org, among others, provides support of Dynamic Optimization and it is free. Apart from being freeware, there are many other attractive features in it. Python, which is again free, is the scripting language used in the JModelica.org platform and it is possible to integrate various Python libraries on demand so as to get required functionalities that we seek. Often used Python libraries are Numpy, Scipy, MatPlotLib, etc. The JModelica.org installer installs those necessary packages automatically. More interestingly, JModelica interfaces to CasADi which is a symbolic framework for Automatic Differentiation and Nonlinear Optimization. The JModelica.org-CasADi interface is at our main interest in this report due to two main reasons: (1) it is possible to translate Modelica/Optimica models into a symbolic representation via the JModelica.org-CasADi interface and use the power of CasADi to find Jacobian matrices both symbolically and numerically - this can be used to linearize dynamic models and in particular symbolic Linearization is possible to use in analyzing structural properties of dynamic systems, and (2) CasADi is already interfaced with state of the art nonlinear optimizers (e.g. IPOPT.), integrators (e.g. SUNDIALS.), etc. and consequently, JModelica.org freely inherit those well-known integrators/nonlinear solvers so that we can use them in Python. The report treats three main tasks: (1) interfacing nonlinear optimizers and integrators | like IPOPT, CVODES, etc. - into Python, (2) linearization of Modelica models at a given operating point, and (3) extracting causality of Modelica models. All these objectives are achieved via JModelica.org within its limitations. Most of the content of this report depends on the JModelica.org-CasADi interface. Therefore a good understanding of CasADi is a prerequisite. Chapter 2 gives an introduction to basic symbolic manipulation in CasADi with several examples. Here defining and usage of symbolic expressions and functions are explained. A discussion on how to use built-in optimizers and integrators available in CasADi is given in Chapter 3. Chapters 2 and 3 cover tasks (1) and (2). Several modifications are made in the Python script casadi_interface.py (which is available in the JModelica.org installation directory.) to linearize Modelica models both symbolically and numerically as well as to do structural observability analysis, system decompositions, etc. This is given Chapter in 4. It is assumed that JModelica.org has been installed.