1. Introduction to models

Modelica and Optimica models can be compiled and loaded in the JModelica.org Python interface as model objects. These model objects can then be used for simulation and optimization purposes. This chapter will cover how to compile Modelica and Optimica models, set compiler parameters and options, load the compiled model in a Python model object and use the model object to perform model manipulations such as setting and getting parameters.

1.1. The different model objects in JModelica.org

There are three different kinds of model objects that can be created with JModelica.org: JMUModel, FMUModel and CasadiModel. The JMUModel is created by loading a JMU, which is a compressed file with a JModelica.org specific structure. The FMUModel is created by loading an FMU (Functional Mock-up Unit), which is a compressed file following the FMI (Functional Mock-up Interface) standard. The CasadiModel is created by loading an FMUX which is a compressed file containing the XML file needed to work with CasADI.

JMUs are created by compiling Modelica or Optimica models with JModelica.org. The JMU can then be loaded in a JMUModel object and used for simulation and optimization purposes.

FMUs are created by compiling Modelica models with JModelica.org (or any other tool supporting FMU export). Optimica models can not be compiled into FMUs. The FMU can then be loaded in an FMUModel object and used for simulation purposes.

FMUXes are created by compiling Modelica or Optimica models with JModelica.org. The FMUX main content is an XML file which follows the FMI standard with some additional JModelica.org specific elements and an equation section in which all equations used in the model are represented. The FMUX can be loaded in a CasadiModel and thereby use the automatic differentiation tool CasADi for optimization purposes. Read more about CasADi and how a CasadiModel object can be used for optimization in Section 7 in Chapter 8.