How to preserve initial conditions of a model when compiling it as an FMU?
6 views (last 30 days)
I have a working Simulink model where two of the output signals are passed back into the model as inputs for the next time step.
Currently I am defining the initial conditions inside integrator blocks to avoid algerbraic loop errors which works as expected. The initial conditions are stored as MATLAB variables so I can expose them to the user when compiling the model as a standalone FMU.
However, after compiling the model as a standalone FMU and importing the FMU back into the Simulink environment to test the functionality, I am now seeing algebraic loop errors and discontinuities where previously there weren't any.
See error messages below for more context.
Discontinuities detected within algebraic loop(s), may have trouble solving.
An error occurred while running the simulation and the simulation was terminated
Caused by: Algebraic state in algebraic loop containing 'Model_FMU/FMU' computed at time 0.00082000000000000009 is Inf or NaN. There may be a singularity in the solution. If the model is correct, try reducing the step size (either by reducing the fixed step size or by tightening the error tolerances) or tweak the initial guess of algebraic loop variable values.
Is there something I am missing that is changing the behaviour of the model when compiling?
The source of the error may not actually be the initial conditions changing but I am making an assumption based on the error messages.