How can I resolve algebraic loops in my Simulink model?

57 views (last 30 days)
I am looking for some general diagnostic steps which I can follow so as to troubleshoot algebraic loop issues.
For example, I have a simple algebraic loop model consisting of a Constant and a Sum block. When I increase the value of the Constant to 1e8 and above, I receive the following error:
ERROR: Trouble solving algebraic loop containing 'algebraicloop_problem/Sum1' at
time 0. Stopping simulation. 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).
I do not receive this error when the Constant value is less than 1e8. What would be the best way to troubleshoot such an issue?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 26 Jul 2023
Edited: MathWorks Support Team on 25 Jul 2023

What This Issue Means:

Algebraic loop solving is an iterative process. A successful solution results only if the algebraic loop solver converges to a definite answer. Some algebraic loops will not converge and the algebraic loop solver in Simulink tests to determine when this is the case. When the algebraic loop fails to converge, or converges too slowly, the iterative procedure will not yield a result and will exit with no solution, thereby resulting in an error message.
As an example, consider the simple model (attached above) that implements an algebraic loop with the Constant block value set to more than 1e8. Use the IC block under Signal Attributes in the Simulink Library and place it after the algebraic variable which in this case is the Sum block in algebraicloop_problem.mdl. Set the IC value to the value in the Constant block. This loop would converge to a solution for the constant value of 1e7, but fails when the constant is 1e8. By providing an initial condition closer to the solution the convergence tests pass, and a solution is found.

How To Diagnose The Issue:

As general diagnostics, follow the instructions given below to troubleshoot algebraic loop issues using Simulink Debugger:
1. Type the following at the MATLAB command prompt:
2. To view a list of all the Simulink Debugger commands:
3. Show list of algebraic loops.
4. Set the algebraic loop trace level to 4, i.e. everything:
atrace level 4
5. Set the solver trace level to 4, i.e. everything:
strace level 4
6. Go to the next simulation point:
step top
Or continue to the next break point:
To quit the Simulink Debugger and return to the MATLAB Command Prompt:
The output obtained with these commands will also provide information on the number of iterations taken by the algebraic loop solver to solve the algebraic variable.

More Answers (0)


Find more on Configure Simulation Conditions in Help Center and File Exchange




Community Treasure Hunt

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

Start Hunting!