modelica / Reference-FMUs

Functional Mock-up Units for development, testing and debugging
Other
129 stars 60 forks source link

Simulation is not terminated when terminateSimulation = true #482

Closed PTaeuberDS closed 2 months ago

PTaeuberDS commented 3 months ago

In the Stair FMU, in each event update a counter that is initialized with 1 is increased by 1. The events occur each full second beginning at t=1.0. When the counter is >= 10, the terminateSimulation "return value" of fmi3UpdateDiscreteStates is set to true. This is the case at t=9.0. However, fmusim does not terminate the simulation but calculates until t=10.0, because this is the pre-defined stopTime in the FMU.

fmusim command:

fmusim.exe --interface-type cs --output-file Stair.csv --event-mode-used Stair.fmu

If event mode is not used, the simulation also does not terminate correctly, but this is also a problem with the FMU, because terminateSimulation is set to false and never updated in the fmi3DoStep function. terminateSimulation should be set in the fmi3DoStep function in the same way it is set in the fmi3UpdateDiscreteStates function: if (terminateSimulation) *terminateSimulation = S->terminateSimulation;