OpenModelica-Python Interoperability Applied to Monte Carlo Simulation

Mohsen Torabzadeh-Tari, Peter Fritzson, Martin Sjölund, Adrian Pop · KTH Publication Database DiVA (KTH Royal Institute of Technology) · 2009

During recent years the interest in computer aided modeling and simulation of complex multi-domain systems have increased significantly. The evolution of the declarative equation-based object-oriented (EOO) modeling language Modelica is a prime example of such a trend. The inherent acausal modeling possibilities and the hybrid modeling capabilities are two features that make Modelica superior. The Modelica community (Modelica 2009 [1], Fritzson 2004 [2]) has achieved considerable success through the development of libraries for a number of different technical domains. OpenModelica is an open source platform for modeling and simulation of complex physical systems based on Modelica (OpenModelica 2009 [3]). It is intended for both commercial and academic use. The development is supported by the non-profit organization Open Source Modelica Consortium. The most important parts of the platform are: OpenModelica Compiler (OMC), the interactive session handler (OMShell), and DrModelica with the electronic notebook, and an Eclipse plug-in MDT for large-scale library and compiler development [4]. For interoperability with other tools and languages Modelica models can be represented in XML (The Extensible Markup Language), is in ModelicaXML (Pop 2003[5]), and a general Java-Modelica interface [7]. Furthermore, within this platform the MetaModelica extension of the Modelica language is available for modeling the meaning of languages, e.g. Modelica, and mechanisms for model transformations. Often in a design process there is a need to make a model parameter sweep in order to find an optimal solution to a design problem, or as an improvement iteration of an existing design. For example, which design parameter values will give the minimum energy consumption in a car model. This often requires the interoperability of several tools. The aim of this paper is to illustrate the capabilities of the OpenModelica platform in this aspect. The parameter sweep is performed as a Monte Carlo simulation of a Modelica model (Kalldahl 2007 [6]). The Python language is used to set up the simulation parameters, the uncertainty distributions, as well as calling the OpenModelica compiler and simulator with the updated parameters in each step. The model variable of interest in the results can either be further analyzed in Python or exported to a Matlab file for further analyses.

Read the paper · More papers on PaperTik