- Index
- » Programming
- » Modelica Language
- » Initial Value
Initial Value
Initial Value
Hi,
I have written the following code in Openmodelica:
***************************************************************
model Tank
parameter Real Rho;
parameter Real A;
parameter Real Aout;
parameter Real g;
Real mdot_In = 20;
Real mdot_Out;
Real m;
Real h(start = 2.1);
equation
der(m) = mdot_In - mdot_Out;
m = A * h * Rho;
mdot_Out = Rho * Aout * sqrt(2 * g * h);
end Tank;
model Tank1
Tank MyTank1(Rho = 1000, A = 1, Aout = 0.0025, g = 9.81);
Tank MyTank2(Rho = 1000, A = 2, Aout = 0.0025, g = 9.81);
end Tank1;
***************************************************************
As it can be seen, I have given an initial value of 2.1 to the variable h.. However, when i simulate it, the value of variable h starts from 0 .. i believe it should start from 2.1 .. can anyone tell me what am I doing wrong here.
Thanks
Re: Initial Value
Hi,
Start values are just a hint. You have to add (start = value, fixed = true) if you want them to be fixed.
But in your case h is a parameter, not a variable so I would say to have: parameter Real h = 2.1;
Cheers,
Adrian Pop/
- adrpo
- 885 Posts
- Index
- » Programming
- » Modelica Language
- » Initial Value