Why does algebraic loop not solve?

I have what I thought was a pretty simple model that intentionally includes algebraic loops which I wanted to use to explore how Simulink deals with circular dependencies. But, Simulink 2011a can't seem to solve it and I'm not sure why or what to do to fix the problem. Here's what the model looks like in Simulink (mdl file link here):
The model is supposed to represent two poles (physical, rigid objects), each of which have one of their ends pinned to the X axis, and their other ends are pinned together. The components to the left of the XY Graph represent the behavior of the left pole. It accepts the X coordinate of its end not pinned to the X axis and computes the Y coordinate of that end based on the X coordinate of the end pinned to the X axis (-3 in this case) and the length of the pole (5 in this case). The components to the right of the XY Graph represent the behavior of the right pole. It accepts the Y coordinate of its non-X-axis end and computes the X coordinate of that end, which is fed back into the input of the left pole. Here's what the situation looks like physically -- black indicates given information and green is what Simulink should compute as the unique solution:
So, I expect the XY Graph to display a point at (0,4) which is time-invariant. Instead, I get this error message:
I'm new to Simulink and don't know how to go about resolving that error. What step size? There seem to be multiple step parameters, but all of them that I see seem to be related to time rather than algebraic loops, and almost all are set at 'auto' -- how can I figure out what a reasonable order of magnitude would be? Likewise, where can I set the error tolerance?

 Accepted Answer

Ben
Ben on 8 Jan 2013
Edited: Ben on 8 Jan 2013
The answer to this question appears to be "The Simulink XY Graph Source does something that makes no sense". The model works fine if one:
  • Deletes the XY Graph component
  • Right clicks on one of the signals -> Create & Connect to Viewer -> Simulink -> Scope [little blue glasses appear on signal]
  • Right clicks on the other signal -> Connect to Existing Viewer -> Scope -> Axis1
So, the actual model has not changed at all; only the XY Graph has been replaced by a two-channel scope. That fixes the problem, and two constant lines at 0 and 4 are observed on the scope (as expected). What in the world is going on here Simulink??
Here is the original version, and here is a working version.

More Answers (1)

Azzi Abdelmalek
Azzi Abdelmalek on 8 Jan 2013
Edited: Azzi Abdelmalek on 8 Jan 2013
If you have to simulate this equation:
y(n+1)=y(n)+1
you can't do it just by using one sum block, which causes an algebraic loop, you should use a memory block or unit delay block to do it. Your model don't contain any memory block

9 Comments

I'm not sure I understand. This model has exactly one correct/self-consistent answer/state, and that answer/state is invariant with time. This particular model can easily be simplified to avoid the algebraic loop, but my real application will be unable to avoid an algebraic loop. That's why I intentionally created this algebraic loop to see how Simulink deals with it. Is the answer "Simulink can't deal with algebraic loops"? I thought it was just slower when algebraic loops are present.
The problem is that Simulink don't know how to start simulation, because the output y depends on the input u, which depends on the same output y. The unit delay block contains a initial value, which will be used by simulink to start simulation
No, that isn't the problem; just because y=2x+3 and x=6y+7 doesn't mean x and y can't be uniquely determined without an initial value. That's what's going on here; I have arranged two simultaneous equations in two variables into an algebraic loop. No initial value is necessary because there is only one possible correct value.
The problem was apparently in the XY Graph, which seems ridiculous. See my answer below.
it's not about y=2x+3 it's about y=2y+3
In your latter case, y=-3 is the only possible value for y to have; it doesn't make sense to assign an initial value to y when y=2y+3 because y can be uniquely determined without an initial value.
Try to simulate this model,
  1. the first one will simulate, but the result have no sens
  2. the second one make sens
The output of the first model is a constant -1. The interpretation is 1+2*y=y, and the only value of y that makes that statement true is -1. Simulink correctly solves that algebraic loop at all time steps.
Why do you believe that result has no sense?
You are right. I've never noticed that! Then what if the algebraic has multiple solutions, maybe it will cause an error?
Empirically with N=3, it seems that Simulink chooses the root closest to 0. For instance:

Sign in to comment.

Categories

Find more on General Applications in Help Center and File Exchange

Products

Asked:

Ben
on 8 Jan 2013

Community Treasure Hunt

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

Start Hunting!