Functional Mock-Up Interface Support
The Functional Mock-Up Interface (FMI) is an emerging standard for creating interfaces between different tools.
The FMI standard defines two main interfacing solutions: Model Exchange and CoSimulation. The export from one tool to another is made through FMU files. Twin Activate can simulate FMU blocks from the FMI-1.0, 2.0, and 3.0 standards, and supports both the Model-Exchange and CoSimulation block types.
FMU Import
The FMU block lets you import and simulate FMU blocks.
The block is located in the palette
.The FMU block automatically detects the FMI version, 1.0, 2.0, or 3.0, and FMI type, Model Exchange or CoSimulation, and applies a simulation method accordingly. Double-clicking the FMU Import block displays the block dialog:
The block dialog lets you select and load an FMU block. You can enter values in the fields such as the number of inputs, outputs, and states, or click Reload to read the FMU block and populate the fields automatically. In the Parameters table, the FMU variables that have an editable start value are displayed. Changes to the values are incorporated before a simulation starts.
After the dialog is populated, the FMU block can be added to a model diagram. The following example shows an FMU block in a diagram facilitating co-simulation with a hydraulics software product.
FMU Export
The FMU Export feature enables Twin Activate super blocks to be exported as FMU modules.
- Export as FMI-2.0 or 3.0.
- Export FMU as Model Exchange or CoSimulation or both.
- Internal information of the super block is hidden for IP protection.
- Internal block parameters are displayed in the FMU.
- Several fixed-step and variable-step solvers can be exported into the FMI for co-simulation.
- Exported FMU can be imported into Twin Activate or any other FMI compatible tool.
- Signal import blocks such as ReadfromMat and SignalIn.
- Signal export blocks such as WritetoMat and SignalOut.
- Signal Viewer blocks such as Scope and Display.
- Co-simulation blocks such as MotionSolve and Spice.
- Memory block is not supported.
-
To export to the FMU, select the area of a diagram that you want to export and
convert it into a super block.
For example, in the following model you can select the super block controller_to_export.
The controller-to-export super block contains a linear system and matrix gain block with one scalar input and two vector outputs:
-
After creating the super block, on the ribbon, select
.You can also right-click the super block, and select Code Generation and Export.
- For Target, select FMU.
-
For Code generator: Standard code generation or
Inlined code generation.
- Standard code generation: The same libraries used in Twin Activate is packaged inside the FMU. This method supports more Twin Activate blocks for FMU export, but since all necessary libraries binaries are included in the FMU, the FMU size might be big.
- Inlined code generation: An optimized C code is
generated for Twin Activate block. The generated C code can be
exported in the FMU and recompiled for another OS. Note: Note that Modelica blocks can be exported in standard code generation, as well as in inlined code generation for CoSimulation.Note: Some Twin Activate blocks, such as Modelica blocks, cannot be exported with inlined code generation for Model Exchange.Note: Inlined code generation also can export as FMI-3.0 and supports arrays and clocks.
-
Select an FMU Type: Model Exchange,
CoSimulation, or CoSimulation and Model
Exhange.
The name and identifier of the exported FMU keeps the name of the super block. Therefore any unsupported characters in the name of the super block are converted into ASCII characters. For example if the name of your super blocks is SuperB !\%lock, the name is converted into sb_SuperB32339237lock.
If you selected the Co-Simulation export method, the Twin Activate simulator as well as the Simulation Parameters are exported with the model.
Note:The FMI export feature requires a C/C++ compiler.
On Windows platforms, a Microsoft Visual Studio C/C++ compiler is required. Ensure that you have the correct compiler installed on your system to compile the generated C code, otherwise the binary will not be available for the FMU and the FMI export will fail.
On Linux platforms, Twin Activate uses the GCC compiler available on your system.
Note:Twin Activate automatically detects the C compiler on your system. The OML command
vssGetCompilerName()
displays the C compiler that is recognized by Twin Activate. - After selecting the export method, Twin Activate exports the super block and prompts you to specify a location to save the FMU. The default location is the folder where the model file is saved.
FMU Export with Documentation
Issue the OML command to export FMU information in an .html file.
When exporting an FMU, you can generate and include an .html file with a description of the super block in the FMU. The description that is exported is the model report of the super block diagram.
By default, the .html page is not generated. To enable this feature, in the OML Command
Window, enter: setenv('Activate_FMU_export_DOC','true')
FMU Export on Linux Platforms
FMU exporting on Linux requires ld version 2.27 or greater.
To export an FMU in Twin Activate on Linux platforms, the
compilation and linking of the C code requires ld version 2.27 or greater. You can ensure
that you are working with a compatible version of ld by installing or updating Binutils with
the command: yum install binutils
.
FMU Editor
The FMU Editor lets you interact within the hierarchy of an FMU, hide or expose variables and attributes to customize information for a particular audience, and save and export a customized FMU.
- On the ribbon, select
-
In the FMU Editor, select
and navigate to your FMU.The FMU Editor includes FMU Variables and FMU Attributes tabs.
-
Select the FMU Variables tab to customize variables with
multiple options:
- Navigate inside the FMU with the tree view.
- Select the variables that you want to display.
- Deselect the variables that you want to hide.
- Modify the descriptions of the variables.
- Use the FMU editor tools to work with the variables: select/deselect all, reverse order, find and search.
-
Select the FMU Attributes tab to customize the FMU with
these options:
- Modify the FMU attribute descriptions.
- Modify editable attribute fields. Grayed out fields cannot be modified.
-
Click the Save FMU As button and name and save your
customized version of the FMU.
A customized version of the FMU is ready for sharing. The source FMU remains unchanged.