Algebraic Loop Error in Simulink Model with Enabled Subsystems – Performance Issue

8 ビュー (過去 30 日間)
Marco
Marco 2025 年 3 月 18 日
回答済み: Sam Chak 2025 年 3 月 18 日
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!

回答 (1 件)

Sam Chak
Sam Chak 2025 年 3 月 18 日
Your case sounds similar to the flip-flop. It creates a circular dependency between the output and input values of the NOR block within the same time step. In reality, electrical signals in circuits travel at speeds close to, but slightly slower than, the speed of light; thus, there should be a slight delay between the input signal and the output signal delivered by the NOR logic gate. This brief delay can be reasonably modeled using a 1st-order transfer function, , with very fast dynamics, where T is the time constant that affects the length of the delay.
There are also other approaches to remove algebraic loops in a Simulink model. Please see the following:
A naive Flip-Flop in Simulink that is constructed according to Logic gate diagrams in most Textbooks:
Algebraic loop error message:
My solution:

カテゴリ

Help Center および File ExchangeSubsystems についてさらに検索

製品


リリース

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by