MATLAB: How to resolve algebraic loops in the Simulink model in Simulink 6.5 (R2006b)

1e8algebraicashowatraceconvergeexitholdiciterationloopmemorysimulinksldebugsolvertest

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:
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?

Best Answer

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 this simple model 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.
As general diagnostics, follow the instructions given below to troubleshoot algebraic loop issues:
1. Type the following at the MATLAB command prompt:
sldebug('modelname')
2. To view a list of all the Simulink debugger commands:
help
3. Show list of algebraic loops.
ashow
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:
continue
To quit the Simulink Debugger and return to the MATLAB Command Prompt:
quit
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.
Related Question