필터 지우기
필터 지우기

"Algebraic Loop" Question

조회 수: 3 (최근 30일)
David Yu
David Yu 2015년 7월 1일
답변: alao ben 2019년 5월 29일
Hi!
I am working on a school project using Simulink and I would like to ask if anyone knows why can't Simulink solve the following system.
I have tried using "Trust-Region" and "Line-Search" solvers, changed the stepsize, tolerances without any luck. Here is the error I get:
Algebraic state in algebraic loop containing 'test_valve_10/Pressure Valve1/Sum2' computed at time 0.0 is Inf or NaN. There may be a singularity in the solution. If the model is correct, try reducing the step size (either by reducing the fixed step size or by tightening the error tolerances)
I have also uploaded an image of the formula and the Simulink file, I need to find out p2.
It would be great if any of you knew about this.
Thank you so much in advance!
Best Regards,
David

채택된 답변

Martin Brown
Martin Brown 2015년 7월 1일
From a very quick look, you appear to be computing p2 as the dependent variable in the Simulink simulation, but you're also giving it an initial value of 100000, without it being a dynamic equation? I'd imagine Simulink can't make the equation consistent which is giving the error message. p1, p3 etc appear to be constants, so if this really is an algebraic equation, you probably should be using "solve" (symbolic) or "fzero" (numeric) in Matlab.
  댓글 수: 3
Martin Brown
Martin Brown 2015년 7월 1일
OK, to better understand the question, p1, p3 and flow2 are really variables which can change and this algebraic equation allows you to compute p2 based on their values? Calculating p2 in a larger simulation is necessary?
The square roots probably make it difficult to get a closed form solution (symbolic) so why not just include a Matlab "User Defined Function" where you pass in p1, p3, flow 2, ... (or whatever is appropriate) and then call fzero to numerically calculate p2? This allows you to do this type of root finding in Simulink. There may be more efficient ways to do this.
David Yu
David Yu 2015년 7월 1일
Yes, that how I want to calculate p2. Have p1, p3 and flow2 as variables. The p2 will be used in a larger simulation, but I guess once is calculated in this small model it will be fine.
You are right! the square root is the thing that makes it hard for it to calculate. I changed the "function" of the square root into "signedSqrt" instead of "sqrt" and it was able to calculate it. I tried using the "Matlab function" block to simplify the entire calculation inside but unfortunately it won't take algebraic loops.
I hope this solved my problem, thank you very much! it really means a lot to me.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

alao ben
alao ben 2019년 5월 29일
ok

카테고리

Help CenterFile Exchange에서 Modeling에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by