- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Tank emptying
Tank emptying
Tank emptying
Hello,
I trying to model a tank emptying (see model below, the file is also attached). It was flattened by hand. I wrote all the equations in the same model, including the equality equations for the across variables and conservation equations for the flow variables. When the level goes to zero, a division by zero occurs.
<p>division by zero at time 1.854376093259535, (a=0.5041528877565462) / (b=0), where divisor b expression is: if noEvent(Tank_Level > 0.0) then 1.0 else 0.0</p>
model EmptyTank4
parameter Real A = 1;
parameter Real Patm = 101325;
parameter Real rho = 1000;
parameter Real g = 9.8;
parameter Real c = 0.00001;
Real Tank_Level(start=1);
Real Tank_F;
Real Tank_P;
Real Tank_Port_F;
Real Tank_Port_P;
Real Valve_F(start = 1);
Real Valve_P;
Real Valve_Port_P;
Real Valve_Port_F(start = 1);
equation
// Tank
if noEvent(Tank_Level > 0) then
Tank_Port_F = Tank_F;
else
Tank_Port_F = 0;
end if;
A * der(Tank_Level) = - Tank_F;
Tank_P = rho * g * Tank_Level + Patm;
Tank_Port_P = Tank_P;
// Node
Tank_Port_F = Valve_Port_F;
Tank_Port_P = Valve_Port_P;
// Valve
Valve_F = c * (Valve_P - Patm/2);
Valve_F = Valve_Port_F;
Valve_P = Valve_Port_P;
end EmptyTank4;
Could you help me with this model?
Thanks and regards
zero-flow-4.mo
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Tank emptying