ghorwin / FMICodeGenerator

A Code Generator that creates native C/C++ code to build Functional Mock-Up Units (FMU) with support for FMI version 2.0 (rollback)
BSD 3-Clause "New" or "Revised" License
49 stars 25 forks source link

The problems of FMU in Simulink #54

Open HeisenbergDJ opened 3 months ago

HeisenbergDJ commented 3 months ago

Thank you for your code,

I used your Generator to create an FMU implementation and imported it into the Simulink canvas. Simulink prompted me to choose between Co-simulation and Model-exchange mode. I selected Model-exchange mode. However, during the simulation, I received the following message: 'TerminateSimulation' flag was set to true by FMU 'FMUDemo/FMU' during event iteration. Simulation will stop after the current time step at '0'. This seems to prevent the subsequent simulation from running correctly.

Could you please let me know in which part of the implementation code the 'TerminateSimulation' flag is set?

ghorwin commented 1 month ago

Hi, sorry for the late reply, but I'm a litte busy in other projects.

Regarding the ModelExchange: the FMI CodeGenerator does not create any code that deals with the TerminateSimulation flag. In any case, could you pass the source code of your Demo-FMU for checking? Often, the TerminateSimulation flag is set by the ModelExchange master if the FMU has invalid/undefined behavior and thus fails to solve equations suitable for Jacobian matrix generation in the master solver.

Can you maybe provide a minimal example?