FMU example models

PLECS 4.9 supports import and export of Functional Mock-up Units (FMU) of Version 2 (Model Exchange). Support for FMU Version 3 and Co-Simulation will soon be released. FMU features require a PLECS Coder license.

Attached are two examples highlighting the FMU Version 2 export and import workflow in PLECS. Both examples consist of separate export and import models.

  • Example 1: Thyristor Rectifier

thy_rect_fmu_export.plecs (89.3 KB)

thy_rect_fmu_import.plecs (103.9 KB)

  • Example 2: PMSM with sensorless control

sensorless_vector_control_pmsm_fmu_export.plecs (358.5 KB)

sensorless_vector_control_pmsm_fmu_import.plecs (367.5 KB)

The following is a step-by-step instruction on how to export and import FMU files in PLECS.

Exporting an FMU file from a PLECS model

In this example, the Tyristor Rectifier Circuit is exported as FMU file

  1. The subsystem to be exported is set to atomic with auto sample time.
    (This step is preconfigured in the example model)
    The auto sample time setting ensures that the subsystem is simulated at variable time-steps with a variable-step solver selected.

  1. Simulate the model twice: first with a variable-step solver, then with a fixed-step solver, and compare the results in the plots. The comparison highlights the loss of accuracy introduced by discretizing the model at a fixed sample time. The quality of the fixed-step results reflects what can be expected from the exported FMU model later.

    Note: a fixed-step simulation will fail if the model contains blocks with variable-step discrete tasks. This applies to Example 2 (PMSM with sensorless control). In this case, skip the fixed-step simulation and proceed with the next step.

  1. Right-Click on Subsystem to open the FMU export dialog

  1. By default, the sample time is set to the fixed-step size configured in the solver settings
  2. Select the Target platform(s) and enter a name for the FMU File
  3. Export the FMU file

Importing an FMU File into a PLECS model

  1. Open the import PLECS model
  2. Import the FMU file into the configurable “Circuit” Subsystem

  1. Simulate the model and compare “FMU” Configuration to “Original” Configuration

Due to the discrete-time execution, the accuracy of the FMU model is reduced compared to the “Original” PLECS plant, which is simulated using a variable step solver. If more accuracy is required, the discretization step size needs to be reduced when exporting the FMU model.

2 Likes