Example on using an FMU with PyFMI (FMI for Co-Simulation 2.0)

The example uses a simple model of a DC-Motor built with the electrical library, a linear drive which could be a screwDrive and a displacement control for the connected mass using a PID control with Anti-Windup strategy.

The set value for the control is defined in a curve (set_value) but an additional input is reserved to be added by the user later when using the FMU.

The example uses FMI for Co-Simulation 2.0.

Further information on PyFMI can be found here: https://pypi.org/project/PyFMI/

Screenshot of the model in SimulationX

Modelview

Generate an FMU (manually)

Start the Code-Export Wizard

Start the Code-Export Wizard

Select the project type and define a path for the exported code. Here FMI for Co-Simulation 2.0 is selected.

Code-Export Wizard page 1

Set the targets for compilation and if all states shall be accessable later at the FMU.

Code-Export Wizard page 2

Specify time variant inputs which shall be passed to the FMU later.

Code-Export Wizard page 3

Specify constant parameters which shall be passed to the FMU later.

Code-Export Wizard page 4

Specify constant outputs which shall be accessible at the FMU later.