Where is the algebraic loop? How to get rid of it?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I want to simulate a simple feedback amplifier in Simulink:

where the "Open Loop Amplifier" looks as follows:

Most of the time I get "Simulink cannot solve the algebraic loop containing '...' at time 4.1951420214177304E-9 using the TrustRegion-based algorithm due to one of the following reasons: the model is ill-defined i.e., the system equations do not have a solution; or the nonlinear equation solver failed to converge due to numerical issues.
for fixed step as well as variable step.
I built exactly the same model in a Spice simulator where it works flawlessly without any issues. For that reason I do not see what's the problem. There are dyanmic elements in the loop such that there should be no "algebraic loop".
But in any case ... How do I get (reliably) rid of this error in this setup?
It is important to note that sometimes I may be able to avoid this by inserting some high frequency filters or adjusting simulation parameters but not reproducible and not reliably.
For example, inserting 1/(1+10e-12 s) directly after "Vin" in the open loop amplifier block gets rid of the error but then I run into "Derivative of state '1' in block '...' at time 3.9498179964744583E-9 is not finite." errors.
No matter where I place these, I either get algebraic loop of derivative not zero errors.
(No, 10e-12 is not too small - it is only a factor of 10 smaller than the smallest dynamic)
2 comentarios
Respuestas (1)
Sourabh
el 23 de Abr. de 2025
Editada: Sourabh
el 23 de Abr. de 2025
Hey @Daniel H
I too got an algebraic loop when I simulated the attached model.
- To view where the algebraic loop is, click the “Open” button as suggested in the Diagnostic Viewer by Simulink

The yellow highlighted section is where the algebraic loop is:

2. To solve the loop, insert an integrator block on the “Vout” signal as shown below:

3. Then, open “Model Settings” in Modelling > Setup > Model Settings.
Expand the solver details and change the fixed step size from “1/84e6/20” to “1/84e7/20” as shown below:

Click Apply and Ok.
The model now runs successfully without any errors.
For more information on algebraic loop, kindly refer the following MATLAB documentations:
- https://www.mathworks.com/help/simulink/ug/algebraic-loops.html
- https://www.mathworks.com/help/simulink/ug/identify-algebraic-loops-in-your-model.html
- https://www.mathworks.com/help/simulink/ug/remove-algebraic-loops.html
I hope this helps!
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!