Skip to main content

Simulate Functional Mock-up Units (FMUs) in Python

Project description

PyPI

FMPy

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

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

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

Create a Jupyter Notebook

To create a Jupyter Notebook open an FMU in the FMPy GUI and select Tools > Create Jupyter Notebook... or run

fmpy create-jupyter-notebook Rectifier.fmu

on the command line and open the notebook in Jupyter with

jupyter notebook Rectifier.ipynb

Web App

Start the Web App

The FMPy Web App is built with Dash and a great way to share your FMUs with anyone that has a web browser. To start it run

python -m fmpy.webapp Rectifier.fmu

on the command line or use --help for more options.

Web App

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.


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fmpy-0.3.27-py3-none-any.whl (5.0 MB view details)

Uploaded Python 3

File details

Details for the file fmpy-0.3.27-py3-none-any.whl.

File metadata

  • Download URL: fmpy-0.3.27-py3-none-any.whl
  • Upload date:
  • Size: 5.0 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for fmpy-0.3.27-py3-none-any.whl
Algorithm Hash digest
SHA256 0c2c270dd39e4303e7200dd62626f4d80e76cda4a2ca3a8e542bd4f70522eddf
MD5 b67c0f4c47cabb9c8ffca53ffc552de1
BLAKE2b-256 3ff6524fab535e287fc4d39736602cb69b4d9622a795d6c5da397f8039ed4c38

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page