Functional Mockup Interface

The Functional Mock-up Interface (FMI) is an open standard for exchanging and coupling simulation models between different engineering tools. It defines a common format in which a model can be exported from one tool as a Functional Mock-up Unit (FMU)—a file that contains the model description, parameters, and compiled code or equations. Other tools that support FMI can import and run these FMUs, typically in order to connect them to other models. The FMI standard is used in areas such as control design, system simulation, and engineering analysis, where models from different domains or software environments need to interact. By providing a consistent way to share and execute models, FMI helps avoid tool-specific integrations and makes it easier to reuse models across projects and development stages.

FMI Standard

The FMI standard defines three interface types:

  • The Model Exchange (ME) interface exposes an ordinary differential equation system to the solver of the importing tool. The integration algorithm of the importing tool is responsible for advancing time, setting states, handling events, etc.

  • The Co-Simulation (CS) interface is designed to couple two separate solvers that are synchronized at distinct communication times. The FMU can either just serve as a communication link between the importing tool and the exporting tool (tool-coupling) or contain both a model and its solver as runnable code.

  • The Scheduled Execution (SE) interface provides support for the concurrent computation model partitions on a single computational resource. This interface is not supported by PLECS.

FMI Version

PLECS implements versions 2.0 and 3.0 of the FMI standard. Version 3.0 introduces the following features:

  • More integer data types and a 32-bit float type. (Note that PLECS does not support 64-bit integers.)

  • Advanced co-simulation features (see below).

PLECS supports both the import and export of Co-Simulation and Model Exchange FMUs. To import an FMU that was exported from another tool, use the FMU block. The remainder of this chapter describes the export of FMUs from PLECS.

Common Concepts for FMU Export

An FMU file is a ZIP archive that contains several standardized components:

  • Model description: an XML file that defines the exposed model variables (such as inputs, outputs, states, parameters) and model capabilities

  • Platform binaries: platform-specific compiled libraries conforming to the FMI Application Programming Interface (API) for different operating systems that implement the model behavior

  • Resources: Optional additional files

  • Documentation: Optional documentation

PLECS can export any atomic subsystem to an FMU (see Virtual and Atomic Subsystems). The input and output terminals of the subsystem determine the inputs and outputs of the FMU. If the subsystem has a mask, the mask parameters define the FMU parameters (see Mask Dialog), and the mask description defines the FMU description.

When you export an atomic subsystem to an FMU, PLECS will embed the subsystem schematic in a compressed and encrypted model file inside the FMU resources folder. The FMU will parse and execute this model at runtime.

PLECS Model Exchange FMU

When you export a subsystem to a Model Exchange FMU, PLECS must discretize the model so that the FMU is executed with a fixed sample time. The platform binaries contain the code required to execute such a discretized model.

Note

Exporting a Model Exchange FMU from PLECS requires a PLECS Coder license. The resulting FMU can be used on a target computer without the need to install PLECS, and no license is required to run the FMU.

Limitations

Discrete-Variable Sample Times

Since PLECS discretizes a models when exporting it to an ME-FMU, the model cannot contain components that have a variable sample time.

Thermal Description Parameters

Thermal description parameters are inlined and cannot be modified in the exported FMU.

Masked Subsystems

The shared FMU libraries contain a basic MATLAB parser for interpreting simple initialization commands of masked subsystems (see Initialization Commands). This parser supports only a limited subset of the MATLAB language.

During an FMU export, PLECS checks whether the exported model contains masked subsystems whose mask initialization commands cannot be executed by the internal MATLAB interpreter. In such a case PLECS will show a warning message, remove the mask initialization commands and instead replace all parameter expressions of all components below the mask with their evaluated values, i.e. inline them. As a consequence, the behavior of such inlined subsystems can no longer be modified in the exported FMU via FMU parameters.

This limitation applies for instance to the following components from the PLECS library:

PLECS Co-Simulation FMU

PLECS exports a tool-coupling Co-Simulation FMU. The platform binaries implement a communication link between the importing tool and a PLECS installation that must be running on the target computer. When a simulation is started by the importing tool, the FMU sends the embedded model file to PLECS and synchronizes the simulation progress between PLECS and the importing tool. To enable the co-simulation mode in PLECS, check the option Enable FMU Co-Simulation endpoint on the General page of the PLECS Preferences dialog (see Configuring PLECS).

Note

Exporting a Co-Simulation FMU from PLECS does not require a separate license. However, to use the resulting FMU, PLECS must be installed on the target computer, and a PLECS license is required at runtime.

FMU with Discrete Inputs

If you export a PLECS Co-Simulation FMU with discrete input signals such as gate signals, it is recommended to select version 3.0 of the FMI standard. This will allow the importing tool to utilize the Event Mode in order to properly handle the discontinuities introduced by gate signal changes.

Limitations

Thermal Description Parameters

Thermal description parameters are inlined and cannot be modified in the exported FMU.

Exporting an FMU

To export an atomic subsystem to an FMU, select the Subsystem block, then choose Export FMU… from the Edit > Subsystem menu or the block’s context menu. This will open the FMU Export dialog that allows you to configure the FMU as described below. When you click on Export, the FMU is created.

General Options

../_images/fmuexport_general.png

Fig. 120 General Options tab of FMU Export dialog

Type

This parameter lets you choose between the Co-Simulation and Model Exchange types.

Version

This parameter lets you choose between the FMI standard versions 2.0 and 3.0. Note that the importing tool must support the same version in order to use the FMU.

Sample time

This parameter is applicable only to Model Exchange FMUs. It specifies the sample time used to discretize the exported subsystem. It is recommended to run a simulation with a fixed-step solver using this sample time before the export to verify the proper behavior of the discretized model.

Interactive execution

This parameter is applicable only to Co-Simulation FMUs. If this is set to enabled and the importing tool supports it, PLECS will open the schematic of the FMU model at runtime and allow the importer to interact e.g. with scopes.

Target platform(s)

These checkboxes let you choose the binary platform(s) on which you intend to run the exported FMU. PLECS will embed the corresponding shared libraries into the FMU.

Before you can export an FMU for the first time, you need to install the shared library files on your computer. This is indicated by blue arrows next to the checkbox items as shown below. When you click on any of them, a dialog opens that lets you download and install the required package automatically.

Output file

This parameter specifies the file path of the exported FMU.

Terminal Order

../_images/fmuexport_terminals.png

Fig. 121 Terminal Order tab of FMU Export dialog

On this page you can configure the order in which the input and output terminals of the subsystem appear in the exported FMU.

Documentation

../_images/fmuexport_documentation.png

Fig. 122 Documentation tab of FMU Export dialog

Icon file

This parameter allows you to specify a PNG image file that is included as a model icon in the exported FMU.

Documentation

This parameter allows you to provide documentation that is included in the exported FMU. You can choose to include a single HTML file or a folder with HTML and resource files.