Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- model TwoTanks_basic
- //Constants
- constant Real pi = 3.14;
- constant Real g = 9.81;
- //Parameters
- parameter Real A1=1.0 "Area of tank1";
- parameter Real A2=2.0 "Area of tank2";
- parameter Real L=0.1 "Pipe length";
- parameter Real D=0.2 "Pipe diameter";
- parameter Real rho = 0.2 "Fluid density";
- parameter Real mu = 2e-3 "Fluid dynamic viscosity";
- //variables
- Real p1 "pressure in tank1";
- Real p2 "pressure in tank2";
- Real h1( start=0) "liquid level in tank1";
- Real h2( start=50) "liquid level in tank2";
- Real q( start=0) "Volume flow rate between tanks";
- equation
- //relation pressure and height
- p1=h1*g*rho;
- p2=h2*g*rho;
- //Flow between tanks(positive out of tank1)
- q=(p1-p2)*(pi*D^4/(128*mu*L));
- //Mass Balances for each tank
- A1*der(h1)=-q;
- A2*der(h2)=q;
- annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(
- coordinateSystem(preserveAspectRatio=false)));
- end TwoTanks_basic;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement