Why does XY Graph affect algebraic loop solver?

1 vue (au cours des 30 derniers jours)
Ben
Ben le 8 Jan 2013
I have a model involving an algebraic loop that mysteriously refuses to solve ONLY when an XY Graph is attached. I don't think the model's exact purpose is important, but you can read more about it here. I'm using Matlab & Simulink 2011a. The observations I think are important are:
  • This model works fine as-is
  • When you change Constant1 from 4.8 to 5, the model will no longer solve -- you'll get the error message "Algebraic state in algebraic loop containing 'algebraicscope/Sum1' computed at time 0.0 is Inf or NaN"
  • When you then delete the XY Graph block from the model (and leave Constant1 as 5), the model will again solve just fine (the normal scope can be used to verify results; there should be a constant line of value 0 and a constant line of value 4)
It is the simple presence of the XY Graph that prevents Simulink from solving the model under certain conditions! As a beginner in Simulink, it is extremely disturbing to me that the presence of a read-only debugging tool can affect the solution of a model. Am I thinking about something wrong, or is this actually a bug?
This is a graphic of the model in question:

Réponse acceptée

Doug Eastman
Doug Eastman le 11 Jan 2013
The problem is that adding blocks to your model (such as the XY Graph) causes the sorted order of all the blocks to change. Since there are no clear data dependencies in an algebraic system like this (which Simulink normally can use to provide a consistent sorted order), adding blocks can cause seemingly random changes. There is nothing special about the XY Block in particular, you will get the same issue if you add a display block to both the X and Y signals for example.
I believe the problem with changing the sorted order is that depending on which blocks are executing first, Simulink will automatically select an initial guess for that block's output. If that guess happens to be poor, the solution will diverge and you get no answer. If that guess is reasonable then it will converge on a solution.
When you want to force Simulink to solve an algebraic equation, a good approach is to use the Algebraic Constraint block. This allows you to explicitly specify an initial guess for one of the parameters and have a more consistent result. For example, here is a revision of your model using the Algebraic Constraint block with X as the algebraic state:
  4 commentaires
Azzi Abdelmalek
Azzi Abdelmalek le 11 Jan 2013
Modifié(e) : Azzi Abdelmalek le 11 Jan 2013
I 'm not really convinced by that the sorted order will be changed by the scope, because that scope is not in the loop. Also in the algebraic loop there is no any sorted order, if there is any, I don't think it will be called an algebraic loop.
Doug Eastman
Doug Eastman le 11 Jan 2013
Modifié(e) : Doug Eastman le 11 Jan 2013
You can very easily prove to yourself that the sorted order changes by displaying the block sorted order before and after deleting the XY Scope (or other blocks for that matter). You'll notice the order shifts dramatically.
Here is the sorted order with the scope:
---- Sorted list for 'algebraicscope' [9 nonvirtual blocks, directFeed=0]
0:0 'algebraicscope/Constant2' (Constant, tid=1)
0:1 'algebraicscope/Constant1' (Constant, tid=1)
0:2 'algebraicscope/rl^2' (Product, tid=1)
0:3 'algebraicscope/Constant3' (Constant, tid=1)
0:4 'algebraicscope/rr^2' (Product, tid=1)
0:5 'algebraicscope/Constant' (Constant, tid=1)
0:6 'algebraicscope/<< Synthesized_Atomic_Subsystem_For_Alg_Loop_1 >>' (SubSystem, tid=0)
0:7 'algebraicscope/XY Graph' (SubSystem, tid=1)
0:8 'algebraicscope/Scope' (SignalViewerScope, tid=0)
---- Sorted list for 'algebraicscope/<< Synthesized_Atomic_Subsystem_For_Alg_Loop_1 >>' [8 nonvirtual blocks, directFeed=1]
1:0 'algebraicscope/dx^2' (Product, tid=0) [algId=1#1]
1:1 'algebraicscope/Sum' (Sum, tid=0) [algId=1#1]
1:2 'algebraicscope/Sqrt' (Sqrt, tid=0) [algId=1#1]
1:3 'algebraicscope/y^2' (Product, tid=0) [algId=1#1]
1:4 'algebraicscope/Sum2' (Sum, tid=0) [algId=1#1]
1:5 'algebraicscope/Sqrt1' (Sqrt, tid=0) [algId=1#1]
1:6 'algebraicscope/Sum3' (Sum, tid=0) [algId=1#1]
1:7 'algebraicscope/Sum1' (Sum, tid=0) [algId=1#1, algVar]
And the order without:
---- Sorted list for 'algebraicscope' [8 nonvirtual blocks, directFeed=0]
0:0 'algebraicscope/Constant' (Constant, tid=1)
0:1 'algebraicscope/Constant1' (Constant, tid=1)
0:2 'algebraicscope/Constant2' (Constant, tid=1)
0:3 'algebraicscope/Constant3' (Constant, tid=1)
0:4 'algebraicscope/rr^2' (Product, tid=1)
0:5 'algebraicscope/rl^2' (Product, tid=1)
0:6 'algebraicscope/<< Synthesized_Atomic_Subsystem_For_Alg_Loop_1 >>' (SubSystem, tid=1)
0:7 'algebraicscope/Scope' (SignalViewerScope, tid=1)
---- Sorted list for 'algebraicscope/<< Synthesized_Atomic_Subsystem_For_Alg_Loop_1 >>' [8 nonvirtual blocks, directFeed=1]
1:0 'algebraicscope/Sum2' (Sum, tid=1) [algId=1#1]
1:1 'algebraicscope/Sqrt1' (Sqrt, tid=1) [algId=1#1]
1:2 'algebraicscope/Sum3' (Sum, tid=1) [algId=1#1]
1:3 'algebraicscope/Sum1' (Sum, tid=1) [algId=1#1]
1:4 'algebraicscope/dx^2' (Product, tid=1) [algId=1#1]
1:5 'algebraicscope/Sum' (Sum, tid=1) [algId=1#1]
1:6 'algebraicscope/Sqrt' (Sqrt, tid=1) [algId=1#1]
1:7 'algebraicscope/y^2' (Product, tid=1) [algId=1#1, algVar]
You can see that with the scope, the algebraic variable is chosen as the output of Sum1. Without the scope the algebraic variable is chosen as the output of y^2.

Connectez-vous pour commenter.

Plus de réponses (1)

Azzi Abdelmalek
Azzi Abdelmalek le 8 Jan 2013
Modifié(e) : Azzi Abdelmalek le 8 Jan 2013
Ben, In the previous question http://www.mathworks.com/matlabcentral/answers/58271-why-does-algebraic-loop-not-solve I've simulated the model without XY graph, it works, then added an XY graph, it works again. I've also simulated the second model which did'nt work for reasons that I ignore, but have nothing to do with xy graph
  6 commentaires
Ben
Ben le 10 Jan 2013
I don't think you understand what I'm asking and/or my observations. The model I posted for this question has two display mechanisms; the X and Y signals are each connected both to the XY Graph block, and to a scope not shown (you can tell they are connected to that scope by observing the two blue sunglasses icons in the model). There is a single, correct solution in all scenarios I've mentioned in this question. When the model doesn't crash, the off-screen scope always displays the correct answer. However, the model crashes when the XY Graph is present, and then doesn't crash when the XY Graph is removed.
If the algebraic loop has solution it works, otherwise it does'nt.
Yes. The question is why simply removing the XY Graph changes whether the algebraic loop has a solution.
when you add xy-graph
I never add an XY Graph; the original model starts with one, and then I remove it.
replace this xy graph with any display block(scope, to workspace,...)
No replacement is necessary; there is already a second display mechanism present in the original model.
when you remove those display blocks, the simulation does'nt work
No, that's reversed; the simulation works when the XY Graph display block is removed and doesn't work when it's present.
because you are not asking for displaying result, simulink does not show errors.
I am asking for a result to be displayed in all scenarios via the off-screen scope indicated by the two blue glasses icons in the model.
In fact it's not an error, it's just that the solution is [], which can't be displayed.
No. This is the error:
This shows the exact same model that produced that message above working properly. The only change was to delete the XY Graph block.
Azzi Abdelmalek
Azzi Abdelmalek le 10 Jan 2013
Modifié(e) : Azzi Abdelmalek le 10 Jan 2013
Replace your xy-graph with scopes, you will have the same message. I know that with viewers scope it works.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Equations dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by