Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

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 &gt; 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

Attachments:

Re: Tank emptying

By the moment, I'm treating it similarly to an electrical switch.

Regards

There are 0 guests and 0 other users also viewing this topic