What is causing my algebraic loop?

I have a somewhat complex model utilizing the general blockset, Specialized Power Systems, and Simscape Electrical physical systems. I am receiving an error that I have an algebraic loop, containing blocks that contain persistent states, which are not allowed in algebraic loops. I have seen answers explaining that these blocks tend to be integrators, Stateflow charts, Matlab function blocks, and physical systems circuits. Of those things, I only have the physical systems circuit. The physical systems circuit contains capacitors which could count as "persistent states", but if that is the cause, I do not know the solution. The error message is copied below. Can anyone help me spot the cause of the error?
Edit: After digging further, the identified loop goes Voltage Measurement -> Gain -> Subtract -> Gain -> Controlled Current Source. The Controlled Current Source does not directly interact with the Voltage Measurement. I don't see loop here..
'Full_Model_2/Control/Voltage Loop/Solver Configuration' or the model referenced by it contains a block that updates persistent or state variables while computing outputs and is not supported in an algebraic loop. It is in an algebraic loop with the following blocks.
Component:Simulink | Category:Model error
Input ports (1) of 'Full_Model_2/powergui/EquivalentModel1/State-Space' are involved in the loop.
Component:Simulink | Category:Model error
Input ports (1) of 'Full_Model_2/Converter 3/Voltage Measurement/do not delete this gain' are involved in the loop.
Component:Simulink | Category:Model error
Input ports (1) of 'Full_Model_2/Control/LM5170/Current Loop 3/Gain1' are involved in the loop.
Component:Simulink | Category:Model error
Input ports (1) of 'Full_Model_2/Control/LM5170/Product' are involved in the loop.
Component:Simulink | Category:Model error
Input ports (1, 2) of 'Full_Model_2/Control/LM5170/Current Loop 3/Subtract' are involved in the loop.
Component:Simulink | Category:Model error
Input ports (1) of 'Full_Model_2/Control/LM5170/Current Loop 3/Gain' are involved in the loop.
Component:Simulink | Category:Model error
Input ports (1) of 'Full_Model_2/Control/LM5170/Current Loop 3/Saturation' are involved in the loop.
Component:Simulink | Category:Model error
Input ports (1) of 'Full_Model_2/Converter 2/Voltage Measurement/do not delete this gain' are involved in the loop.
Component:Simulink | Category:Model error
Input ports (1) of 'Full_Model_2/Control/LM5170/Current Loop 2/Gain1' are involved in the loop.
Component:Simulink | Category:Model error
Input ports (1, 2) of 'Full_Model_2/Control/LM5170/Current Loop 2/Subtract' are involved in the loop.
Component:Simulink | Category:Model error
Input ports (1) of 'Full_Model_2/Control/LM5170/Current Loop 2/Gain' are involved in the loop.
Component:Simulink | Category:Model error
Input ports (1) of 'Full_Model_2/Control/LM5170/Current Loop 2/Saturation' are involved in the loop.
Component:Simulink | Category:Model error
Input ports (1) of 'Full_Model_2/Converter 1/Voltage Measurement/do not delete this gain' are involved in the loop.
Component:Simulink | Category:Model error
Input ports (1) of 'Full_Model_2/Control/LM5170/Current Loop 1/Gain1' are involved in the loop.
Component:Simulink | Category:Model error
Input ports (1) of 'Full_Model_2/Control/Vbus^UF/do not delete this gain' are involved in the loop.
Component:Simulink | Category:Model error
Input ports (1) of 'Full_Model_2/Control/Voltage Loop/Solver Configuration' are involved in the loop.
Component:Simulink | Category:Model error
Input ports (2) of 'Full_Model_2/Control/Voltage Loop/Solver Configuration' are involved in the loop.
Component:Simulink | Category:Model error
Input ports (2, 3) of 'Full_Model_2/Control/Voltage Loop/Solver Configuration' are involved in the loop.
Component:Simulink | Category:Model error
Input ports (1, 2) of 'Full_Model_2/Control/LM5170/Current Loop 1/Subtract' are involved in the loop.
Component:Simulink | Category:Model error
Input ports (1) of 'Full_Model_2/Control/LM5170/Current Loop 1/Gain' are involved in the loop.
Component:Simulink | Category:Model error
Input ports (1) of 'Full_Model_2/Control/LM5170/Current Loop 1/Saturation' are involved in the loop.
Component:Simulink | Category:Model error

4 Comments

Algebraic loop can sometimes be caused by feedback without a delay. I.e., feeding the output back as an input without any delay, essentially using the current state as an input to calculate the current state. You can sometimes fix this by adding a delay in the output that feeds back into the input.
I'll look into this. I'm very confused by this issue, I didn't mention this in the above description but the model worked as-is for a very long time. I made a change recently and received an error (did not record what or why), with creating an algebraic loop suggested by Simulink as the solution. I clicked a "fix" button on the suggestion and didn't know what I was getting myself into. The "fix" seems to have broken the model that previously worked.
I'll consider adding the wait block, but I worry that will ruin the accuracy of the model. I'll also try re-creating the model in a new environment to see if it's a case of a bugged setting somewhere that I haven't found.
Jamie Shaffer
Jamie Shaffer on 13 Jan 2022
Edited: Jamie Shaffer on 13 Jan 2022
I've commented out possible causes and discovered the "Algebraic Loops" window that highlights involved blocks. The identified loop goes Voltage Measurement -> Gain -> Subtract -> Gain -> Controlled current source. The Powergui block is also somehow involved. The controlled current source does not interact directly with the Voltage Measurement. I don't see a loop here..
if you can't share model, could you please share some screenshots? it would be easy to find out the root cause. Solution is already mentioned by @James Tursa

Sign in to comment.

Answers (1)

Jamie Shaffer
Jamie Shaffer on 14 Jan 2022
I replaced a piece of the loop that was modeled with a Specialized Power Systems circuit with a transfer function block and the Algebraic loop disappeared. I believe this to be a bug in the solver.

Products

Release

R2021b

Asked:

on 12 Jan 2022

Answered:

on 14 Jan 2022

Community Treasure Hunt

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

Start Hunting!