Why does XY Graph affect algebraic loop solver?
조회 수: 2 (최근 30일)
이전 댓글 표시
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:
댓글 수: 0
채택된 답변
Doug Eastman
2013년 1월 11일
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
Azzi Abdelmalek
2013년 1월 11일
편집: Azzi Abdelmalek
2013년 1월 11일
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
2013년 1월 11일
편집: Doug Eastman
2013년 1월 11일
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.
추가 답변 (1개)
Azzi Abdelmalek
2013년 1월 8일
편집: Azzi Abdelmalek
2013년 1월 8일
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
Azzi Abdelmalek
2013년 1월 10일
편집: Azzi Abdelmalek
2013년 1월 10일
Replace your xy-graph with scopes, you will have the same message. I know that with viewers scope it works.
참고 항목
카테고리
Help Center 및 File Exchange에서 Classical Control Design에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!