import math
#calculate Head lost to friction
Q=50*10**-3; ## m^3/s
d=0.15; ## m
l=300.; ## m
v=1.14*10**-6; ## m^2/s
g=9.81; ## m/s^2
## For galvanised steel
k=0.00015; ## m
t=0.001; ## ratio of k to d ; (k/d)
f=0.00515;
A1=math.pi/4.*d**2;
u=Q/A1;
Re=u*d/v;
h_f=4*f*l*u**2/d/(2*g);
print'%s %.3f %s'%("Head lost to friction =",h_f,"m")
import math
#calculate rate of discharge
k=0.00025; ## m
d=0.1; ## m
l=120.; ## m
h_f=5.; ## m
g=9.81; ## m/s^2
v=10**-5; ## m^2/s
f=0.0079042;
u=math.sqrt(h_f*d*(2.*g)/(4.*f*l));
Re=u*d/v;
Q=u*math.pi/4*d**2;
print'%s %.4f %s'%("Rate =",Q,"m^3/s")
import math
#calculate The size of galvanized steel pipe
h_f=9.; ## m
l=180.; ## m
Q=85.*10**-3; ## m^3/s
f=0.00475;
k=0.00015; ## m
v=1.14*10**-6; ## m^2/s
g=9.81; ## m/s^2
d=(4.*f*l*Q**2./h_f/(math.pi/4.)**2/(2.*g))**(1/5.);
Re=(Q/(math.pi*d**2/4))*d/v;
print'%s %.3f %s'%("The size of galvanized steel pipe =",d,"m ")
import math
#calculate Revised estimate of the optimum pipe diameter
## D1=(5*b1/3/a)^(1/8)
## D2=(5*b1/3/a)^(1/8)
## But b2=2.5*b1
## Therefore D2=(2.5)^(1/8)*D1
D1=600.; ## mm
D2=(2.5)**(1/8.)*D1;
print'%s %.1f %s'%("Revised estimate of the optimum pipe diameter =",D2,"mm")
import math
#calculate Pressure difference and Feed is at the centre of the main and Pressure difference
Q0=4.5*10**-3; ## m**3/s
d=0.1; ## m
l=4.5*10**3; ## m
g=9.81; ## m/s**2
f=0.006;
rho=1000.; ## kg/m**3
u0=Q0/(math.pi/4.*d**2);
h_f=4.*f*u0**2*l/3./(d*2*g);
dp=h_f*rho*g;
print'%s %.1f %s'%("Pressure difference =",dp,"N/m**2")
print("Feed is at the centre of the main")
Q0_b=Q0/2.;
u0_b=u0/2.;
l_b=l/2.;
dp_b=(u0_b/u0)**2*(l_b/l)*dp;
print'%s %.1f %s'%("Pressure difference =",dp_b,"N/m**2")
import math
#calculate The change in the level in larger tank
d1=3.; ## m
d2=2.; ## m
f=0.007;
l=75.; ## m
d=0.05; ## m
g=9.81; ## m/s**2
h1=1.8; ## m
A1=math.pi/4.*d1**2;
A2=math.pi/4.*d2**2;
## dh/dt=dz1/dr*(1+A1/A2)
## Q=-A1*dz1/dt = -4/13*A1*dh/dt
## u=(Q/2)**2/(%pi/4*d**2)
## h=(4*f*l/d + 1.5)*u**2/2g = 1.438*10**5*Q**2
## t=integrate('-1/(1+A1/A2)*A1*(1.438*10**5/h)**(1/2)','h',h1,H)
## By integrating, we get
H=(h1**(1/2.)-(900./2./824.7))**2;
h=h1-H;
dz1=1./(1+A1/A2)*h;
print'%s %.3f %s'%("The change in the level in larger tank =",dz1,"m")