mihaiginta / FMPy

Simulate Functional Mockup Units (FMUs) in Python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Status PyPI Conda Read the Docs

FMPy

FMPy is a free Python library to simulate Functional Mock-up Units (FMUs) that...

  • supports FMI 1.0 and 2.0
  • supports Co-Simulation and Model Exchange
  • runs on Windows, Linux and macOS
  • has a graphical user interface
  • compiles C code FMUs and generates CMake projects for debugging

Try this Jupyter notebook online!

Installation

Several options are available:

  • Install with conda: conda install -c conda-forge fmpy
  • Install with from PyPI: python -m pip install fmpy[complete]
  • Install a development build

If you don't have Python on your machine you can install Anaconda Python.

Start the Graphical User Interface

You can start the FMPy GUI with python -m fmpy.gui

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

Rectifier Result

Simulate an FMU on the command line

To get information about an FMU directly from the command line change to the folder where you've saved the FMU and enter

fmpy info Rectifier.fmu

Simulate the FMU and plot the results

fmpy simulate Rectifier.fmu --show-plot

Get more information about the available options

fmpy --help

Advanced Usage

To learn more about how to use FMPy in you own scripts take a look at the coupled_clutches.py, custom_input.py and parameter_variation.py examples.

Commercial Support

You're starting a project, need training or professional support? Our partners at LTX Simulation are ready to help you. Please send an e-mail to support@ltx.de for a quote.


© 2020 Dassault Systèmes

ezoic increase your site revenue

About

Simulate Functional Mockup Units (FMUs) in Python

License:Other


Languages

Language:Python 75.8%Language:C 17.1%Language:C++ 6.1%Language:CMake 1.0%