Tutorial: FMU Import and Export
Learn how to import the FMU (Functional Mock-up Unit) into your model for data exchange, and export the FMU for co-simulation.
Files for This Tutorial
Controller.scm; Controller_FMU.scm; controller.fmu
About FMI and Requirements
The Functional Mock-up Interface (FMI) is a tool-independent standard that supports both model exchange and co-simulation of dynamic models using a combination of XML files and compiled C-code.
- Activate supports FMI 1.0 import and FMI 2.0 import and export processes.
- A Functional Mock-Up Unit (FMU) can be imported into an Activate model as a single block. Additionally, an Activate super block can be exported as an FMU in order to be exchanged and co-simulated with other tools supporting the FMI standard.
- The use of the Functional Mock-up Interface with Activate requires the selection of a solver and installation of a compiler.
Compiler Requirements
Activate requires a C-compiler to compile super blocks into C-code and the FMU. Activate detects if Microsoft Visual Studio or GCC is installed on your system and automatically invokes the compiler toolchain without any manual intervention.
If you do not have one of the supported compilers installed, you can complete the tutorial by loading the FMU that is provided with the tutorial model files: <installation_directory>\tutorial_models\controller.fmu. If loading this file, skip the section, Exporting a Super Block to the FMU, and proceed to Importing the FMU through Model Exchange.
Supported Compilers on Windows Platforms
TCC is the default compiler provided for Windows. Some use cases require the installation of a third-party compiler. The following are the supported compilers for the Functional Mock-Up Interface (FMI), Modelica components, and C-code generation.
Compiler | FMI Export | Modelica Support | C-Code Generation |
---|---|---|---|
Microsoft® Visual Studio 2022; 2019: Community, Professional | Yes | Yes | Yes |
Microsoft® Visual Studio 2017: Express, Community, Professional | Yes | Yes | Yes |
Microsoft® Visual Studio C++ Build Tools 2022; 2019;
2017; 2015 Note: The option for Windows 10 SDK must be
selected.
|
Yes | Yes | Yes |
Microsoft® Visual Studio C++ 2015 (VC 14.0 Community and Professional) | Yes | Yes | Yes |
Microsoft® Visual Studio C++ 2013 (VC EXPRESS/VC Pro 12.0) | Yes | Yes | Yes |
Microsoft® Visual Studio C++ 2012 (VC EXPRESS/VC Pro 11.0) | Yes | No | Yes |
Microsoft® Visual Studio C++ VC 10.0 (VC Pro 10.0) | Yes | Yes | Yes |
Microsoft® Visual Studio C++ SDK 7.1 (VC EXPRESS 10.0) | Yes | No | Yes |
TCC (default provided with Activate installation) | Yes | Yes | Yes |
Supported Compilers on Linux Platforms
GCC is the default compiler provided for Linux. Some use cases require the installation of a third-party compiler. The following are the supported compilers for the Functional Mock-Up Interface (FMI), Modelica components, and C-code generation.
Compiler | FMI Export | Modelica Support | C-Code Generation |
---|---|---|---|
GCC | Yes | Yes | Yes |
Required Development Tools for Linux Platforms
The installation of development tools is required for Linux platforms to compile C code. The proposed commands will ensure that the required development and build tools are installed for GCC and G++.
Linux Platform | Installation Command |
---|---|
SUSE 15 SP 2 |
|
RHEL/Oracle Linux 8.3 | or
|
FMU Export on Linux Platforms
FMU exporting on Linux requires ld version 2.27 or greater.
To export an FMU in 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
.
Selecting a Solver
Exporting a Super Block to the FMU
Export a super block from the controller model into the FMU.
Importing the FMU through Model Exchange
Import the FMU into a controller model with the Model Exchange option.
Importing the FMU Through Co-Simulation
Import the FMU into a controller model with the Co-Simulation option.