Simulate Functional Mock-up Units (FMUs) in Python
Actively maintained. Last release 3 months ago. A safe choice.
pip install fmpyFMPy
FMPy is a free Python library to simulate Functional Mock-up Units (FMUs) that...
- supports FMI 1.0, 2.0, and 3.0
- supports Co-Simulation and Model Exchange
- runs on Windows, Linux and macOS
- has a command line, graphical user interface, and web app
- creates Jupyter Notebooks
- compiles C code FMUs and generates CMake projects for debugging
Installation
Install from PyPI with python -m pip install fmpy[complete]
Start the Graphical User Interface
You can start the FMPy GUI with python -m fmpy.gui

Simulate an FMU in Python
To follow this example download Rectifier.fmu for your platform by clicking on the respective link:
Linux,
macOS,
Windows.
Change to the folder where you've saved the FMU and open a Python prompt.
>>> from fmpy import *
>>> fmu = 'Rectifier.fmu'
>>> dump(fmu) # get information
Model Info
FMI Version 2.0
Model Name Rectifier
Description Model Rectifier
Platforms win64
Continuous States 4
Event Indicators 6
Variables 63
Generation Tool MapleSim (1267140/1267140/1267140)
Generation Date 2017-10-04T12:07:10Z
Default Experiment
Stop Time 0.1
Step Size 1e-07
Variables (input, output)
Name Causality Start Value Unit Description
outputs output 282.842712474619 V Rectifier1.Capacitor1.v
>>> result = simulate_fmu(fmu) # simulate the FMU
>>> from fmpy.util import plot_result # import the plot function
>>> plot_result(result) # plot two variables


