Compiled models, JMUs, FMUs and FMUXes, are loaded in the JModelica.org Python interface with the
JMUModel class from the
pyjmi module, the
FMUModel class from the
pyfmi module and the
CasadiModel class from the
pyjmi module respectively. This will be demonstrated in Section 3.4, Section 3.5 and Section 3.6.
The model classes contain many methods with which models can be manipulated after instantiation. Amongst the most important
optimize is only relevant for JMU model instances.) These are explained in Chapter 7 and Chapter 8. For more information on how to use the CasadiModel for optimization purposes, see Section 7 in Chapter 8. The more basic methods for variable and parameter manipulation are explained in Section 4.
The JMU is a compressed file which contains all files needed to load and work with the compiled model in JModelica.org. The
JMU contains the shared object file, the XML files with model variable and parameter data and some other files created during
compilation of the model. The JMU file format is a JModelica.org specific format but is designed to follow the FMU file format
from the FMI standard as much as possible. A JMU is created when compiling a Modelica or Optimica model with
pymodelica.compile_jmu, see Section 2.
The FMU (Functional Mock-up Unit) is a compressed file which follows the FMI (Functional Mock-up Interface) standard. An FMU
is created when compiling a Modelica model with
Read more about the FMI/FMU standard in Chapter 5.
The FMUX is a compressed file which only contains an XML file and a couple of resource files created during the flattening
of the model. The XML file follows the FMI standard with some JModelica.org specific extra elements and a section of equations.
The equations part contains all equations used in the model. The FMUX is created when compiling a Modelica or Optimica model
A JMU file is loaded in JModelica.org with the class
JMUModel in the
pyjmi module. The following simple example demonstrates how to do this in a Python shell or script.
# Import JMUModel from pyjmi from pyjmi import JMUModel myModel = JMUModel('myPackage_myModel.jmu')
The only parameter in the
JMUModel constructor is the name of the JMU file, including any file path. When compiling and loading it is therefore practical to
use the return argument from
compile_jmu, which is the path to the JMU created. The following example demonstrates this.
# Import compile_jmu and JMUModel from pymodelica import compile_jmu from pyjmi import JMUModel # Compile and load model jmu_name = compile_jmu('myPackage.myModel','myPackage.mo') myModel = JMUModel(jmu_name)
The FMU file can be loaded in JModelica.org with the class
FMUModel in the
pyfmi module. The following short example demonstrates how to do this in a Python shell or script.
# Import FMUModel from pyfmi from pyfmi import FMUModel myModel = FMUModel('myFMU.fmu')
FMUModel instance can then be used to set parameters and used for simulations.