FMU 3 does not contain all API functions. This leads to an error when using with FMPy

35 views (last 30 days)
I created a FMU from a Simulink model with the following settings:
- Matlab version: 2024b (Simulink compiler and FMU add-on is installed)
- FMI version: 3.0
- FMI type: Co-Simulation
I'm using the Python toolbox FMPy (0.3.21) to interact with the FMU. I run into a problem when initializing the FMU: "Function fmi3InstantiateModelExchange is missing in shared library". Apparently in the FMI spec 3.0.1 it states that the FMU must implement all API functions declared in fmi3Functions.h even f they are only needed for interface types or optional capabilities that the FMU does not support. Could it be possible to add the missing functions?
Best regards
  1 Comment
Hitesh
Hitesh on 18 Oct 2024
Could you share your simulink file as well as python file where you are using FMPy library to use exported FMU as I am not encountering any such issue?

Sign in to comment.

Answers (2)

Bavo
Bavo on 21 Oct 2024
Hi Hitesh
I included a zip file containing:
  • requirements.txt (defining the Python libraries; FMPy = 0.3.21)
  • main.py (Python script using the FMU)
  • A screenshot of the Simulink model
  • testModel.slx (Simple Simulink model to export as FMU3)
  • testModel.fmu (FMU3 of the Simulink model)
I'm executing the Python script with Python 3.11.4.
The line where the FMU slave is created an exception is thrown: "Function fmi3InstantiateModelExchange is missing in shared library".
According to the FMI spec 3.0.1 it states that the FMU must implement all API functions declared in fmi3Functions.h even if they are only needed for interace types or optional capabilities that the FMU does not support.
Best regards

Hitesh
Hitesh on 21 Oct 2024
Edited: Hitesh on 21 Oct 2024
Hi Bavo,
Based on my understanding of the error, it looks that the function "fmi3InstantiateModelExchange" is absent from the shared library linked to the FMU.This function is required for instantiating a Model Exchange FMU, and its absence suggests that the FMU might not support Model Exchange or there's an issue with the FMU file itself.
Since FMI is a third-party tool, they have recognized this issue on their forum and are currently addressing it. You can find more information at the following link:
  2 Comments
Bavo
Bavo on 21 Oct 2024
Hi Hitesh
The absence of "fmiInstantiateModelExchange" indeed suggests that there is something wrong with the FMU generated by Matlab. I posted this issue also on the Github FMPy issue list, but they say the Matlab FMU should follow the FMI 3.0.1 specifications. (Compatibility Matlab FMU3 with FMPy 3 · Issue #700 · CATIA-Systems/FMPy)
I was hoping to get the attention of Matlab (Simulink compiler toolbox), so they can provide an updated version of the FMU builder add-on.
Best regards

Sign in to comment.

Products


Release

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!