Table Of Contents

ModelicaRes

Python utilities to set up and analyze Modelica simulation experiments

The goal of ModelicaRes is to provide an open-source tool to effectively manage Modelica simulations, interpret results, and create publishable figures. It is currently possible to auto-generate simulation scripts, run model executables with varying parameters, browse data, perform calculations, and produce various plots and diagrams. The figures are generated via matplotlib, which offers a rich set of plotting routines. ModelicaRes includes convenient functions to automatically pre-format and label some figures, like xy plots, Bode and Nyquist plots, and Sankey diagrams. ModelicaRes can be scripted or run from a Python command-line interpreter with math and matrix functions from NumPy.

variable browser Sankey digarams of three tanks model

plot of Chua circuit example for modelicares.LinRes.nyquist()

The links below describe the components of ModelicaRes. The top-level module, modelicares, provides direct access to the most important classes and functions. Others must be accessed through their submodules. The modelicares.base submodule has general supporting functions. The modelicares.exps submodule has classes and functions to set up and manage simulation experiments. The modelicares.linres submodule has a class to load, analyze, and plot results from linearizing a model. The modelicares.simres submodule has classes to load, analyze, and plot simulation results. The modelicares.multi submodule has functions to load and plot results from multiple data files at once. The last submodule, modelicares.texunit, has functions to translate Modelica unit and displayUnit strings into LaTeX-formatted strings. Finally, the loadres script loads data files and provides a Python command-line interpreter to help analyze them.

The authors are Kevin Davies and Kevin Bandy. Third-party code has been included from Jason Grout (ArrowLine class), Jason Heeris (efficient base-10 logarithm), Richard Murray (python-control), and Joerg Raedler (method to expand a Modelica variable tree—from DyMat).

A PDF version of this documentation is available here. Updates to ModelicaRes may be available at the main project site. ModelicaRes is also listed in the Python Package Index (direct link). The development site is https://github.com/kdavies4/ModelicaRes.

See also

The pysimulator, BuildingsPy, and DyMat projects provide other Python modules that are related. pysimulator includes a complete GUI and supports the Functional Model Interface (FMI). BuildingsPy has a Tester class that can be used for unit testing. DyMat has functions to export Modelica simulation data to comma separated values (CSV), Gnuplot, MATLAB®, and Network Common Data Form (netCDF).