Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. model TwoTanks_basic
  2. //Constants
  3. constant Real pi = 3.14;
  4. constant Real g = 9.81;
  5. //Parameters
  6.  
  7. parameter Real A1=1.0 "Area of tank1";
  8. parameter Real A2=2.0 "Area of tank2";
  9. parameter Real L=0.1 "Pipe length";
  10. parameter Real D=0.2 "Pipe diameter";
  11. parameter Real rho = 0.2 "Fluid density";
  12. parameter Real mu = 2e-3 "Fluid dynamic viscosity";
  13.  
  14. //variables
  15. Real p1 "pressure in tank1";
  16. Real p2 "pressure in tank2";
  17. Real h1( start=0) "liquid level in tank1";
  18. Real h2( start=50) "liquid level in tank2";
  19. Real q( start=0) "Volume flow rate between tanks";
  20.  
  21. equation
  22. //relation pressure and height
  23. p1=h1*g*rho;
  24. p2=h2*g*rho;
  25.  
  26. //Flow between tanks(positive out of tank1)
  27. q=(p1-p2)*(pi*D^4/(128*mu*L));
  28. //Mass Balances for each tank
  29. A1*der(h1)=-q;
  30. A2*der(h2)=q;
  31. annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(
  32. coordinateSystem(preserveAspectRatio=false)));
  33. end TwoTanks_basic;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement