# Is this the way to solve algebraic loops?

Asked by Ubaldo Tiberi on 4 Apr 2012
Latest activity Commented on by K E on 4 Apr 2012

So far, I understand that to solve common algebraic loop problems, it´s enough to decouple the input/output direct feedthrough of every direct feedthrough block by adding a state variable between the input and the output. And, as far as I understand, this can be easily done with an IC block. Inserting this block is also equivalent to equip the direct feedthrough block with a state x that evolves like x(k+1)=x(k) (or \dot x=0), and to consider a switch of the output so that we have y=x at t=t0 and y=f(u) for t>t0, where x,u and y represent the state, the input and the output respectively). This is equivalent to force the output at the value of the IC block at t=t0, and the algebraic loop would be solved, isn’t it? But at this point, I would argue that it is possible to use any block for which you can set a initial condition/output (e.g. rate transition blocks for example), isn’t it? So, to solve an algebraic loop is enough to break it in just one point, right? Or there is more?

## Products

Answer by Ubaldo Tiberi on 4 Apr 2012

I agree that using a delay block or a memory block is a solution. Actually you can use a delay block with inherited sample time even for continuous-time systems. The result is the same. However, by doing that, you are modifying the system behavior, and my challenge is to find a way to solve algebraic loops without changing the system dynamics... is it possible or it is necessary to insert this small time delay? :-)

## 1 Comment

K E on 4 Apr 2012

If you wanted to see the effect on your system's dynamics, try the following,
1) Simulate without the Unit Delay, so the algebraic loop is there. Simulink will use a solver on the algebraic loop, http://www.mathworks.com/support/solutions/en/data/1-SKT69/index.html?solution=1-SKT69 . I am not sure how the solver affects the accuracy of the results. If you are lucky the solver will converge and your simulation will complete.
2) Simulate with the Unit Delay inserted, eliminating the loop.

3) Compare estimates of the dynamics from #1 to #2 (example: do time series of simulated position have similar frequency content and rms values?). If no difference, stick with #2. If there is a difference, you may need to reformulate your model. You can avoid algebraic loops with SimScape, see http://www.mathworks.cn/matlabcentral/answers/16802-algebraic-loop-and-simscape .

Answer by K E on 4 Apr 2012

This note suggests an initial condition may not be sufficient to break algebraic loops. Instead you may need to directly introduce a time delay. If sample time is discrete, use the Unit Delay block. If sampling is continuous, use the Memory block. Introducing these delays can change your system's dynamics. This blog entry discusses reconsidering unphysical algebraic loops in your model.