Interacting Tanks
Introduction
This worksheet models liquid flow between three tanks connected by two pipes (the first pipe connecting Tank 1 and 2, and the second pipe connecting Tank 2 and 3).
The flow is opposed by pipe friction, and the level of liquid in each tank oscillates to an equilibrium. Differential equations that describe the dynamic change in liquid height in each tank and a momentum balance are solved numerically.
restart;
Physical Parameters
The cross-sectional area of the tanks:
A1≔1:A2≔5:A3≔2:
Diameter, length, and roughness of the pipe:
Dia≔0.3:L≔100:e≔0.001:
Density and viscosity of the liquid:
ρ≔1000:μ≔0.001:
Gravitational constant:
g≔9.81:
Momentum Balance
Friction Factor
friction≔procQlocal Rey,fL,fT: if typeQ,numeric then Rey≔4 Q ρevalfπ Dia μ: fL≔64Rey: fT≔11.8⁢log106.9Rey+e3.7⁢Dia1.112: if Rey>0 and Rey<2000 then return fL: elif Rey≥2000 and Rey<4000 then return fL+fT−fL⋅Rey−20004000−2000 elif Rey≥4000 then return fT else return 0 end if; else return 'friction'Q end ifend proc:
Differential Equations
The rate of change of liquid height in Tank 1:
height1≔ⅆⅆt⁢H1t=−Q1tA1:
The rate of change of liquid height in Tank 2:
height2≔ⅆⅆt⁢H2t=Q1t−Q2tA2:
The rate of change of liquid height in Tank 3:
height3≔ⅆⅆ t H3t=Q2tA3:
A momentum balance:
momentumBalance1≔ⅆⅆt⁢Q1t=π⁢Dia2⁢g⁢H1t4⁢L−π⁢Dia2⁢g⁢H2t4⁢L−2⋅frictionabsQ1t⁢absQ1t⋅Q1tπ⁢Dia3:
momentumBalance2≔ⅆⅆt⁢Q2t=π⁢Dia2⁢g⁢H2t4⁢L−π⁢Dia2⁢g⁢H3t4⁢L−2⋅frictionabsQ2t⁢absQ2t⋅Q2tπ⁢Dia3:
The initial conditions:
initialConditions≔Q10=0,Q20=0, H10=1.5,H20=1.2,H30=2:
Numerical Solution of Governing Equations
res≔dsolveheight1,height2,height3,momentumBalance1,momentumBalance2,initialConditions, H1t,H2t,H3t,Q1t,Q2t, numeric,output=listprocedure,known=friction:
H1≔subsres,H1t:H2≔subsres,H2t:H3≔subsres,H3t:Q1:=subsres,Q1t:Q2≔subsres,Q2t:
Results
plotH1t,H2t,H3t,t=0..200, legend=Level in Reservoir 1, Level in Reservoir 2,Level in Reservoir 3, labels=Time, Liquid Height, labeldirections=horizontal,vertical, labelfont=Calibri, titlefont=Calibri,16,bold, background=ColorTools:-ColorRGB,218/255,223/255,225/255, legendstyle=font=Calibri, axis=gridlines=color=ColorTools:-ColorRGB,1,1,1, size=1000,400;
Download Help Document