MATLAB: “Algebraic Loop” Question

algebraic loopsimulink

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

Best Answer

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.
Related Question