In my Simulink model, I use two enabled subsystems that activate and deactivate in opposition—when one is active, the other is not, and vice versa. One of the outputs from these two subsystems is a pressure value. This pressure serves as an input to another subsystem that calculates flow rates, which in turn are fed back into the enabled subsystems.
I initially attempted to provide the flow rate subsystem with the sum of the pressures from the two enabled subsystems, each multiplied by the corresponding Boolean activation signal. However, this caused an error, and the simulation failed to start, returning the following message:
Error: An error occurred during simulation and the simulation was terminated
Caused by:
Algebraic state in algebraic loop containing 'LAVAGGIO_SEMPLICE/Aspirazione//Scarico/Sum' computed at time 0.0 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.
To solve this issue, I added a Data Store Read block inside the enabled subsystems to overwrite the pressure value at each time step. This pressure value is then accessed via a Data Store Write block in the flow rate subsystem. While this solution resolved the algebraic loop problem, it has significantly slowed down the simulation.
How can I improve the performance of my model while still avoiding the algebraic loop issue? Are there more efficient ways to handle this kind of dependency between enabled subsystems and other components?
Thank you in advance for any suggestions!