I am trying to implement a simple iterative guessing scheme within the equation section in a model, however, I am getting the following error: No viable alternative near token: while in OpenModelica. Is there a simple explanation to why this while-loop does not work?
while hf>=dh loop
v_guess = v_guess*0.95;
f_guess = Functions.f_Haaland(v=v_guess, D=d, rho=rho, mu=mu, eps=roughness);
hf = Functions.H_f(f=_guess, L=length, D=d, v=v_guess, g=system.g);
end while;
Say,
- hf=11
- dh=10
- v_guess=1
What I want is v_guess to become smaller and smaller until hf is approximately equal to dh. Then I'll use v_guess in the next step of my model because it is close to the real v occurring at dh. I also tried the same with for-loops and break, to no avail.
I'm looking at the syntax for while-loops and it looks exactly similar. Is there any fundamental thing that is wrong with my scheme, which I cannot see?