import math
#Initialization of variables
g = 9.81 #m/s**2
rho = 10.**3 #kg/m**3
h1 = 4. #m
muw = 0.001 #Ns/m**2
l = 1.5 #m
B = 0.15/1000 #m
lenth = 11.2 #m
#calculations
P1 = g*rho*h1
V = P1*B**2 /(12*muw*l)
A = B*lenth
Q = A*V
Q = 7112.4
tau = B/2 *(P1)/l
#results
print "Average velocity through the crack = %.3f m/s"%(V)
print " rate of leakage = %.1f l/hr"%(Q)
print " Shear stress = %.3f N/m**2"%(tau)
import math
#Initialization of variables
g = 9.81 #m/s**2
rho = 1200. #kg/m**3
mu = 0.005 #Ns/m**2
d = 0.006 #m
Re = 2000.
V = 0.15 #m/s
#calculations
Vc = Re*mu/(d*rho)
Vr = V/Vc
T0 = 8*mu*V/d
#results
print "Shear stress = %d N/m**2"%(T0)
import math
#Initialization of variables
g = 9.81 #m/s**2
rho = 10.**3 #kg/m**3
Q = 0.45/(60*1000) #m**3/s
d = 0.003 #m
depth = 0.95 #m
alpha = 2.
lenth = 1.25 #m
#calculations
A = math.pi/4 *d**2
V = Q/A
nu = (depth - alpha*V**2 /(2*g))*g*d**2 /(32*V*lenth)
Re = V*d/nu
#results
if Re<2000:
print "Flow is laminar"
else:
print "Flow is not laminar"
import math
#Initialization of variables
g = 9.81 #m/s**2
rho = 787. #specific gravity - kg/m**3
Q = 90.*10**-3 #m**3/hr
d = 0.015 #m
k = 0.0045*10**-2 #m
nu = 1.6e-6 #kinematic viscosity - m^2/s
l = 5. #m
#calculations
V = Q/(60*math.pi/4 *d**2)
Rn = V*d/nu
e = k/d
print ("From moody diagram, f = 0.028")
f = 0.028
hl = f*l/d *V**2 /(2*g)
Power = rho*g*Q/60 *hl
#result
print "Head loss = %.2f m"%(hl)
print " power required = %.3f kW"%(Power/1000)
import math
#Initialization of variables
g = 9.81 #m/s**2
rho = 870. #density - kg/m**3
Q = 2.*10**-3 #m**3/s
d = 0.03 #diameter - m
mu = 5.*10**-4 #dynamics viscosity(N-s/m^2)
l = 50. #length - m
#calculations
V = Q/(math.pi/4 *d**2)
RN = rho*V*d/mu
f = 0.017
hl = f*l/d *V**2/(2*g)
Ploss = rho*g*hl
#results
print "Loss of pressure = %.1f kN/m**2"%(Ploss/1000)
#The answers are a bit different due to rounding off error in textbook
import math
#Initialization of variables
g = 9.81 #m/s**2
rho = 813. #density - kg/m**3
Q = 0.007 #m**3/hr
d = 0.01 #m
mu = 0.002 #Ns/m**2
l = 30. #m
#calculations
V = Q/(60*math.pi/4*d**2)
RN = V*d*rho/mu
f = 0.316/RN**(0.25)
h = (1+f*l/d)*V**2 /(2*g)
#result
print "Height required = %.2f m"%(h)
# rounding off error.
import math
#Initialization of variables
g = 9.81 #m/s**2
rho = 10**3 #kg/m**3
hl = 0.02
d = 1.2 #diameter - m
l = 1. #m
k = 0.5 *10**-2 #m
#calculations
v2f = hl*(2*g*d)/l
e = k/d
f = 0.028
V = math.sqrt(v2f/f)
Q = math.pi/4 *d**2 *V
#results
print "Rate of flow = %.2f m**3/s"%(Q)
import math
#Initialization of variables
g = 9.81 #m/s**2
rho = 10.**3 #kg/m**3
e = 0.03*10**-2 #surface roughness - m
l = 3000. #distance - m
Q = 300.*10**-3 #m**3/s
nu = 10.**-5 #kinematic viscosity - m**2/s
hl = 24. #m
#calculations
d5f = l*Q/(math.pi/4) * Q/(math.pi/4) /(hl*2*g)
f = 0.022
d = (d5f*f)**(1./5)
#results
print "Size of the required pipe = %d cm"%(d*100)
import math
#Initialization of variables
g = 9.81 #m/s**2
rho = 10.**3 #kg/m**3
d = 0.3 #m
per = 25./100
Q = 0.1 #m**3/s
k0 = 0.025*10**-2 #m
nu = 0.000001
year = 10.
#calculations
V = Q/(math.pi/4 *d**2)
RN = V*d/nu
e1 = k0/d
f1 = 0.019
f2 = (1+per)*f1
e2 = 0.002
k2 = e2*d
rate = (k2-k0)*100/year
#results
print "Rate of increase = %.4f cm/year"%(rate)
import math
#Initialization of variables
g = 9.81 #m/s**2
rho = 10.**3 #kg/m**3
l = 1. #m
b = 0.3 #m
Q = 4.2 #m**3/s
#calculations
A = l*b
R = A/(2*(l+b))
d5 = 1.62/24.15
d = d5**(1./5)
Pr = 2*(l+b)/(math.pi*d)
#results
print "The rectangular cross section will cost %.2f times that of a circular cross section"%(Pr)
import math
#Initialization of variables
g = 9.81 #m/s**2
rho = 10.**3 #kg/m**3
d1 = 2.5*10**-2 #m
d2 = 7.2*10**-2 #m
Q = 100.*10**-3 #m**3/hr
#calculations
V1 = Q/(60*math.pi/4*d1**2)
V2 = (d1/d2)**2 *V1
dp = -(V2**2 -V1**2 + (V1-V2)**2)/(2*g)
Pdiff = dp*g*rho
#results
print "pressure difference = %.2f kN/m**2"%(Pdiff/1000)
# note : The answers are a bit different due to rounding off error
import math
#Initialization of variables
g = 9.81 #m/s**2
rho = 10.**3 #kg/m**3
d2 = 30./100 #cm
d1 = 60./100 #cm
Pu = 105. #kN/m**2
Pd = 75. #kN/m**2
Cc = 0.65
#calculations
V22 = (2*g/(1 - (d2/d1)**4 + (1/Cc -1)**2)) *(Pu-Pd)*10**3 /(rho*g)
V2 = math.sqrt(V22)
Q = math.pi/4 *V2 *d2**2
hl = (1/Cc -1)**2 *V2**2 /(2*g)
#results
print "Flow rate = %.3f m**3/s"%(Q)
print " Head loss = %.3f m"%(hl)
import math
#Initialization of variables
g = 9.81 #m/s**2
rho = 10.**3 #kg/m**3
d = 9. #m
dia = 0.3 #m
#calculations
V302 = 2*g*d/(0.5 + 20 + 2.53+101+0.66+41.47+2.07)
V30 = math.sqrt(V302)
Q = math.pi/4 *dia**2 *V30
#results
print "Flow rate = %.3f m**3/s"%(Q)
import math
#Initialization of variables
h = 6. #m
rho = 930. #kg/m**3
Q = 3./60 #m**3/s
d = 0.15 #m
L = 20. #m
mu = 0.006 #viscosity
g = 9.81 #m/s**2
#calculations
V = Q/(math.pi/4 *d**2)
RN = V*d*rho/mu
f = 0.316/RN**0.25
hl = f*L/d *V**2 /(2*g)
Hp = h+hl
gam = rho*g
W = gam*Q
Power = W*Hp
#results
print "Power required = %.3f kW"%(Power/1000)
import math
from scipy.integrate import quad
#Initialization of variables
d = 0.02 #m
d2 = 1.2 #diameter - m
f = 0.01
L = 250.
ken = 0.5
g = 9.81
h1 = 8. #m
h2 = 4. #m
#calculations
V2 = 2*g/(1+ken+ f*L/d)
V = math.sqrt(V2)
Q = math.pi/4 *d**2 *V
def time(h):
return -math.pi/4 *d2**2 /Q /math.sqrt(h)
ti = quad(time,h1,h2)[0]
hours = ti/3600
mins = ti%3600/60
secs = ti%3600%60
#results
print "Time required = %d hours %d mins %d seconds"%(hours,mins,secs)
# rounding off error.
#Initialization of variables
d1 = 0.1 #m
d2 = 0.05 #m
l1 = 20. #m
l2 = 20. #m
f = 0.02
#calculations
Kl = (f*l2/d2 *(d1/d2)**4 - f*l1/d1)
#results
print "Loss coefficient = %d "%(Kl)
#Initialization of variables
g = 9.81
ratio = 1.265
#calculations
percent = (ratio-1)*100
#results
print "Increase in discharge = %.1f %%"%(percent)
import math
#Initialization of variables
Q = 0.6 #m**3/s
l1 = 1200. #m
l2 = 800. #m
d1 = 0.3 #m
#calculations
V1 = 1.02 #m/s
d5 = d1*l2*4**2 *Q**2 /(l1*math.pi**2 *V1**2)
d = d5**(1./5)
#results
print "diameter of the single pipe = %.2f m"%(d)
import math
#Initialization of variables
g = 9.81
Q = 0.18 #m**3/s
d3 = 0.3 #m
f = 0.032 #friction factor
L3 = 360. #m
z = 25.5 #m
z2 = 30. #m
L2 = 450. #m
d2 = 0.45 #m
L1 = 950. #m
d1 = 0.45 #m
zn = 18. #m
rho = 1000.
#calculations
V3 = Q/(math.pi/4 *d3**2)
hl3 = f*L3/d3 *(V3**2 /(2*g))
Z2 = z+hl3
hl2 = Z2-z2
V2 = math.sqrt(2*g*d2*hl2/(f*L2))
Q2 = math.pi/4 *d2**2 *V2
V1 = V2+ (d3/d2)**2 *V3
hl1 = f*L1/d1*V1**2 /(2*g)
Hp = hl1+ Z2-zn
gam = rho*g
P = gam*Hp
#results
print "Discharge into the reservoir = %.3f m**3/s"%(Q2)
print " Pressure maintained by the pump = %.2f kN/m**2"%(P/1000)
import math
from numpy import *
#Initialization of variables
z1 = 10. #m
z2 = 5. #m
z3 = 7.5 #m
f = 0.04
l1 = 100. #m
l2 = 50. #m
l3 = 70. #m
d1 = 0.1 #m
d2 = 0.075 #m
d3 = 0.06 #m
g = 9.81 #m/s**2
h = array([1, 2, 1.9, 1.96])
#calculations
Q1 = sqrt(d1**5 *(math.pi/4)**2 *2*g/(f*l1)) *sqrt(z1-h)
Q2 = sqrt(d2**5 *(math.pi/4)**2 *2*g/(f*l2)) *sqrt(h+z2)
Q3 = sqrt(d3**5 *(math.pi/4)**2 *2*g/(f*l3)) *sqrt(h+z3)
for i in range(4):
Q = Q2[i]+Q3[i]
if (Q1[i] == Q):
break;
print "height h = %.2f m"%(h[i])
print "Discharge in BC Q2 = %.2f lps"%((Q2[i])*1000)
print "Discharge in BD Q3 = %.2f lps"%((Q3[i])*1000)
# note : rounding off error.
import math
#Initialization of variables
e = 0.8
output = 400. #kW
H = 150. #m
rho = 1000.
g = 9.81
f = 0.028
l = 1250. #m
#calculations
gam = rho*g
inpu = output/e
Q = inpu*10**3 /(2./3 *gam*H)
hl = 1./3 *H
d5 = f*l*Q**2 /(2*g* math.pi/4 * math.pi/4 *hl)
d = d5**(1./5)
#results
print "Smallest diameter of pen stock = %d cm"%(d*100)
import math
#Initialization of variables
f = 0.04
H = 30. #m
l = 200. #m
d = 0.075 #m
g = 9.81
rho = 1000.
gam = rho*g
#calculations
h = 2/3. *H
vj = math.sqrt(2.*g*h)
hl = 1/3. *H
V = math.sqrt(hl*d*2*g/(f*l))
dj = d*(math.sqrt(V/vj))
Power = 2/3. *gam*math.pi/4. *d**2 *V*H
#results
print "Size of nozzle = %.1f cm"%(dj*100)
print " Max power = %.2f kW"%(Power/1000)