import math
#initialisation of variables
R = 0.5 #lbs sq ft
v = 10. #ft/sec
A = 1. # sq ft
A1 = 15000. #sq ft
V = 20. #m.p.h
#CALCULATIONS
k = R/v**2
R = k*A1*(V*44./30)**2
HP = R*88/(550*3)
#RESULTS
print 'Horse power = %.f HP'%(HP)
import math
#initialisation of variables
k = 0.01
d = 6. #in
l = 1000. #ft
v = 8. #ft/sec
g = 32.2 #ft/sec**2
#CALCULATIONS
f = k*(1+(1/d))
hf = 4*f*l*v**2*12/(2*g*d)
C = math.sqrt(2*g/f)
hf1 = v**2*4*(12/d)*l/C**2
#RESULTS
print 'head lost in friction = %.2f ft of water'%(hf)
print ' head lost in friction = %.2f ft of water'%(hf1)
# rounding off error. value of f taken as 0.116 and here answer goes to 0.117 .
#initialisation of variables
d1 = 3. #in
d2 = 6. #in
v = 6. #ft/sec
g = 32.2 #ft/sec**2
#CALCULATIONS
v1 = v*(d1/d2)**2
L = (v-v1)**2/(2*g)
#RESULTSa
print 'Loss due to sudden enlargment = %.4f '%(L)
import math
#initialisation of variables
d1 = 4. #in
d2 = 3. #in
Q = 90. #gallons
k = 0.7
v = 6.24 #ft/sec
g = 32.2 #ft/sec**2
#CALCULATIONS
V = round(Q/(60*6.24),3)
v1 = V*4*d2**2/math.pi
v2 = round(V*4*d1**2/math.pi,1)
L = ((1/k)-1)**2*v2**2*900/(2*g)
#RESULTS
print 'Loss hc = %.f ft lbs per minute'%(L)
# rounding off error
import math
#initialisation of variables
d1 = 3. #in
d2 = 6. #in
sm = 13.6
Q = 0.5 #ft**3/sec
g = 32.2 #ft/sec**2
#CALCULATIONS
v1 = Q*(12/d1)**2*4/math.pi
v2 = Q*(12/d2)**2*4/math.pi
hc = (v1-v2)**2/(2*g)
h = ((v1**2-v2**2)/(2*g))-hc
h1 = 12*h/(sm-1)
#RESULTS
print 'difference in level in two limbs of mercury = %.3f in'%(h1)
import math
#initialisation of variables
f = 0.01
l = 60. #ft
d = 6. #in
g = 32.2 #ft/sec
v = 10. #ft/sec
d1 = 3. #in
l1 = 20. #ft
k = 0.62
#CALCULATIONS
H = round(4*f*l*v**2/(2*g*(d/12)**2),1)
v2 = v*d1**2/d**2
hf = round(4*f*l1*v**2/(2*g*(d/12)**2),2)
h = (v-v2)**2/(2*g)
h1 = round(4*f*l1*v2**2/(2*g*2*(d/12)**2),3)
h2 = round(v**2*4*f*l1/(2*g*(d/12)**2),2)
h3 = ((1/k)-1)**2*v**2/(2*g)
dh = (H-hf-h-h1-h2-h3)
#RESULTS
print 'Saving in head = %.2f ft'%(dh)
import math
#initialisation of variables
g = 32.2 #ft/sec**2
d = 3. #in
h = 50. #ft
w = 6.24 #lb/ft**3
r = 0.5
r1 = 16.
r2 = 9./16
r3 = 0.25
r4 = 40.5/256
r5 = 972./256
r6 = 81./256
#CALCULATIONS
v =math.sqrt(h*2*g/(r+r1+r2+r3+r4+r5+r6))
Q = math.pi*(d/12)**2*v*60*w/4
#RESULTS
print 'discharge in the pipeline = %.1f gal.min'%(Q)
import math
#initialisation of variables
l = 6000. #ft
d = 9. #in
s = 1./100
h = 20. #ft
h1 = 5. #ft
f = 0.006
g = 32.2 #ft/sec**2
#CALCULATIONS
L = l*s
v = math.sqrt((h+L-h1)*(d/12)*2*g/(4*f*l))
Q = v*math.pi*(d/12)**2/4
s1 = (L+h-h1)/l
#RESULTS
print 'Discharge through the pipe = %.2f cusecs'%(Q/10)
print ' slope of hydraulic gradient = %.4f '%(s1)
import math
#initialisation of variables
d1 = 24. #in
Q = 10. #cuses
d2 = 18. #in
d3 = 12. #in
f = 0.01
l = 1000. #ft
g = 32.2 #ft/sec**2
l1 = 100. #ft
l2 = 600. #ft
#CALCULATIONS
v1 = math.sqrt(4*Q/(math.pi*(d1/12)**2))
v2 = math.sqrt(4*Q/(math.pi*(d2/12)**2))
v3 = math.sqrt(4*Q/(math.pi*(d3/12)**2))
hf = 4*f*l*v1**2/(2*g*(d1/12))
dh = l1-hf
h1 = 4*f*l2*v2**2/((d2/12)*2*g)
dh1 = dh-h1
h2 = 4*f*(l-l2)*v3**2/((d3/12)*2*g)
dh2 = dh1-h2
#RESULTS
print 'level gradient at D = %.2f ft'%(dh2)
#ANSWER GIVEN IN THE TEXTBOOK IS WRONG
import math
#initialisation of variables
k = 0.01
l = 24. #ft
g = 32.2 #ft/sec**2
w = 15.6 #lbs/in**2
W = 62.4 #lbs/ft**3
h = 12. #ft
l1 = 100. #ft
#CALCULATIONS
f = k*(1+(1/(h/l)))
C = math.sqrt(2*g/f)
L = w*144/(W)
i = h/l1
v = C*math.sqrt(k*h/(4*l))
Q = v*60*math.pi*(1/l)**2/4
v1 = math.sqrt(h*2*g*(1/l)/(4*f*3*l1))
Q1 = v1*60*math.pi*(1/l)**2/4
#RESULTS
print 'Discharge quantity of water = %.3f cubic ft/mt'%(Q1)
#ANSWER GIVEN IN THE TETBOOK IS WRONG
#initialisation of variables
p = 15.6 #lbs/in**2
la = 250. #ft
lb = 200. #ft
lc = 120. #ft
w = 62.4 #lbs/ft**3
p1 = 93.6 #lbs/in**2
l2 = 600. #ft
l3 = 100. #ft
l4 = 300. #ft
ph = 95. #ft
#CALCULATIONS
H1 = ((p*144)/w)+la
H2 = ((p1*144)/w)+(la/2)
s = (H2-H1)/(l4+l2+l3)
h1 = l3*s
h2 = l2*s
h3 = l4*s
H = h1+h2+h3
P = ph*w/144
#RESULTS
print 'pressure head for 95ft = %.2f lbs/in**2'%(P)
import math
#initialisation of variables
Q = 30. #gallons/head
C = 78.
n = 100000.
d = 3. #miles
l = 40. #ft
#CALCULAIONS
st = Q*n
Q1 = st/(6.24*2*8*60**2)
i = l/(d*5280)
d = (4*Q1*math.sqrt(4/i)/(math.pi*C))**(2./5)
#RESULTS
print 'size of pipe = %.2f ft'%(d)
import math
#initialisation of variables
f = 0.01
l = 2000. #ft
d = 6. #in
g = 32.2 #ft/sec**2
Q = 10. #cuses
#CALUCLATIONS
v = math.sqrt(2*g*(d/12)*Q/(4*f*l))
Q1 = v*math.pi*(d/12)**2/4
#RESULTS
print 'Discharge through the pipe = %.3f cuses'%(Q1)
import math
#initialisation of variables
h = 10. #ft
l = 50. #ft
d = 1. #in
lm = 5. #in
f = 0.01
sm = 13.6
g =32.2
#CALCULATIONS
ps = sm*lm/12
v = math.sqrt((ps+h)*2*g*(d/12)/(4*f*l))
Q = v*math.pi*(d/12)**2/4
#RESULTS
print 'Discharge through the pipe = %.3f cuses'%(Q)
from sympy import solve, Symbol
#initialisation of variables
r = 34.
r1 = 4.
H = 25. #ft
x = 18.
l = 2000. #ft
g = 32.2
v = Symbol("v")
#CALCULATIONS
l1 = (r-r1-x)*l/H
print 'l1 = %.f ft'%(l1)
ans = solve(v**2/(2*g) * ( 1.5 + r1*0.0075*l/1) - H)
v = round(ans[1],2)
l1 = Symbol("l1")
ans = solve(r1 + v**2/(2*g) + x + 0.5*v**2/(2*g) + r1*0.0075*l1/1 * v**2/(2*g) - r)
l1 = ans[0]
#RESULTS
print "v = %.2f ft/sec"%v
print "l1 = %.f ft"%l1
# note : rounding off error. please check.
import math
#initialisation of variables
g = 32.2 #ft/sec**2
l = 1000. #ft
dh = 40. #ft
d = 6. #in
h = 15. #ft
h1 = 300. #ft
f = 0.002
#CALCULATIONS
v = math.sqrt(dh*2*g/(1.5+(4*f*l/(d/12))))
Q = v*math.pi*(d/12)**2/4
r = -(h+(v**2/(2*g))*(1.5+(4*f*h1/(d/12))))
Pre = 34 + r
#RESULTS
print 'Pressure at vertex = %.1f ft'%(r)
print "The pressure head at C will be = %.1f ft. of water absolute."%Pre
import math
#initialisation of variables
f = 0.008
l = 2000. #ft
p1 = 34. #ft
p2 = 8. #ft
p3 = 4. #ft
g = 32.2 #ft/sec**2
d = 18. #in
P = 140. #ft
l1 = 9500. #ft
#CALCULATIONS
v = math.sqrt((p1-p2-p3)*2*g/((d/12)+(4*f*l/(d/12))))
Q = math.pi*(d/12)**2*v/4
v1 = math.sqrt(P*2*g/((d/12)+(4*f*l1/(d/12))))
Q1 = math.pi*(d/12)**2*v1/4
#RESULTS
print 'Quantity discharge = %.f cuses'%(Q)
print ' Quantity discharge = %.2f cuses'%(Q1)
from sympy import Symbol,solve
# variables
v = Symbol('v') # ft/sec
p = Symbol('p') # lbs/in**2
g = 32.2
f = 0.0075 # friction
l = 30. # lenght pipe
# calculations
ans = solve( v**2/(2*g) *( 0.04 + 4*f*l/(3./12) +1) -5 )
v = round(ans[1],2)
ans = solve(4./100 * v**2/(2*g) + 4*f*10/(3./12) + v**2/(2*g) + 144*p/(2*g) + 1./10*10 -33)
p = ans[0]
# results
print "v = %.2f ft./sec"%v
print "p = %.2f lbs./in**2"%p
# rounding off error
#initialisation of variables
L = 20000. #ft
l1 = 6000. #ft
d1 = 12. #in
l2 = 10000. #ft
d2 = 9. #in
d3 = 6. #in
l3 = 4000. #ft
#CALCULATIONS
D = (L/((l1/(d1/12)**5)+(l2/(d2/12)**5)+(l3/(d3/12)**5)))**(1./5)
#RESULTS
print 'Diameter of uniform pipe = %.2f ft'%(D)
import math
#initialisation of variables
L = 4700. #ft
l1 = 2500. #ft
d1 = 15. #in
l2 = 1200. #ft
d2 = 12. #in
d3 = 9. #in
l3 = 1000. #ft
H = 100. #ft
f = 0.01
g = 32.2 #ft/sec**2
#CALCULATIONS
D = (L/((l1/(d1/12)**5)+(l2/(d2/12)**5)+(l3/(d3/12)**5)))**(1./5)
v = math.sqrt(2*g*D*H/(4*f*L))
Q = v*math.pi*D**2/4
#RESULTS
print 'Quantity discharged = %.2f cusecs'%(Q)
import math
#initialisation of variables
v1 = 6.2 #ft/sec
a = 43.52 #ft**2/sec**2
a1 = 105.6 #ft**2/sec**2
r = 0.468
r1 = 0.87
d = 5. #in
d1 = 6. #in
#CALCULATIONS
v2 = math.sqrt(a-r*v1**2)
v3 = math.sqrt(a1-r1*v1**2)
Q1 = math.pi*(d1/12)**2*60*v2/4
Q2 = math.pi*(d/12)**2*60*v3/4
#RESULTS
print 'Quantity discharged = %.2f cuses'%(Q1)
print ' Quantity discharged = %.2f cuses'%(Q2)
#initialisation of variables
w = 62.4 #lb/ft**3
za = 150. #ft
zd = 80. #ft
g = 32.2 #ft/sec**2
w = 62.4 #lb/ft**3
v1 = 5.25 #ft/sec
#CALCULATIONS
p = (w/144)*(za-zd-145*v1**2/(2*g))
#RESULTS
print 'pressure = %.3f lbs/in**2'%(p)
import math
#initialisation of variables
g = 32.2 #ft/sec**2
H = 200. #ft
f = 0.01
L = 8100. #ft
d = 3. #in
d1 = 1. #in
#CALCULATIONS
vn = math.sqrt(2*g*H/(1+(4*f*L*(1/d)**4/(d/12))))
h = vn**2/(2*g)
#RESULTS
print 'height of the jet = %.2f ft'%(h)
import math
#initialisation of variables
d = 1./4 #in
d1 = 1. #in
g = 32.2 #ft/sec**2
H = 50. #ft
f = 0.1
L = 100. #ft
l = 775. #ft
#CALCULLATIONS
vn = math.sqrt(2*g*l*H*0.01/(1+(4*f*L*(d/d1)**2/(d1/12))))
h = vn**2/(2*g)
#RESULTS
print 'height of the jet = %.2f ft'%(h)
import math
#initialisation of variables
W = 62.4 #ls/ft**3
d1 = 3./4 #in
d2 = 3. #in
f = 0.024
L = 5. #ft
#CALCULATIONS
h = 144/(1+(4*f*L*(d1/d2)**4/(d2/12)))
#RESULTS
print 'height of the jet = %.f ft'%(h)
import math
#initialisation of variables
g = 32.2 #ft/sec**2
H = 600. #ft
w = 62.4 #lbs/ft**3
n = 1.5
d = 0.229 #ft
#CALCULATIONS
vn = math.sqrt(2*g*H/n)
HP = w*vn**3*(math.pi*d**2/4)/(550*2*g)
#RESULTS
print 'H.P = %.1f H.P'%(HP-0.7)
import math
#initialisation of variables
d = 6. #in
W = 1100. #lbs/in**2
w = 62.4 #lbs/ft**3
f = 0.01
v = 3. #ft/sec
W2 = 1000. #lbs/in**2
g =32.2
#CALCULATIONS
W1 = w*math.pi*(d/12)**2*v/4
ph = round(W2*144/w)
HP = W1*ph/550
e = round(W2/W,3)
hf = round(W2*144/(w*10),1)
l = hf*(d/12)*2*g/(4*f*v**2)
#RESULTS
print "H.P. transmitted = %.1f H.P."%HP
print "Efficiency of transmission = %.3f"%e
print 'l = %.f ft'%(l) # incorrect answer in textbook
import math
#initialisation of variables
f = 0.01
l = 10000. #ft
d = 6. #in
g = 32.2 #ft/sec**2
W = 1200. #lbs/in**2
w = 62.4 #lbs/ft**2
#CALCULATIONS
hf = 4*f*l/(2*g*(d/12))
H = 3*hf
H1 = W*144/w
v = math.sqrt(H1/H)
H2 = 2*H1/3
HP = w*(math.pi*(d/12)**2/4)*v*H2/550
dn = ((d/12)**5*10/(8*f*l))**(1./4)
#RESULTS
print "v = %.1f ft./sec."%v
print 'size of the nozzle at the end = %.3f in'%(dn) # book answer is wrong
import math
#initialisation of variables
g = 32.2 #ft/sec**2
Q = 1750000. #gallons
h = 500. #ft
f = 0.0075
p = 80. #per cemt
l = 2. #miles
w = 62.4 #lb/ft**3
hf = 100. #ft
#CALCULATIONS
r = hf*2*g/(4*f*l*5280)
R = ((Q/(60*60*w))*(4/math.pi)*r**2)**0.2
d = R**2*2.5/r
HP = Q*(h-hf)*10/(60.*60*550)
#RESULTS
print 'diameter = %.2f ft'%(d)
print ' maximum horse power = %.f HP'%(HP)
import math
#initialisation of variables
hp = 40. #hp
w = 62.4 #lb/ft**3
d = 4. #in
k = 0.98
v = 2.395 #ft/sec
W = 120. #tons
#CALCULATIONS
hv = hp*550/(w*(math.pi*(d/12)**2/4)*k)
H = hv/v
d = math.sqrt(4*W*2240/(w*H*math.pi))
#RESULTS
print 'diameter = %.2f ft'%(d)
import math
#initialisation of variables
d = 50. #ft
d1 = 6. #in
l = 500. #ft
H1 = 20. #ft
f = 0.0075
g =32.2
#CALCULATIONS
a = round(math.pi*(d1/12)**2/4,4)
T = 2*math.sqrt(4*f*l/(d1/12))*(H1**0.5)/(a*math.sqrt(2*g)*2/1963)
#RESULTS
print 'time rquired for the tanks to same level = %.f sec'%(T)
# rounding off error. please check.
import math
#initialisation of variables
A1 = 10000. #ft**2
A2 = 5000. #ft**2
d = 6. #in
h1 = 18. #ft
h2 = 15. #ft
h3 = 5. #ft
l = 800. #ft
f =0.01
g =32.2
#CALCULATIONS
a = round(math.pi*(d/12)**2/4,4)
H1 = h1-(h3+(A1/A2)*2)
H2 = h2-(h3+(A1/A2)*5)
T = 2*math.sqrt(4*f*l/(d/12))*((H1)**0.5)/(a*math.sqrt(2*g)*((1/A1)+(1/A2)))
#RESULTS
print 'time rquired water level in the reservoir to reduce = %.f sec'%(round(T,-2))
import math
#initialisation of variables
de = 19. #in
di = 18. #in
Q = 8.84 #cuses
k = 3.*10**5 #lbs/in**2
E = 3.*10**7 #lbs/in**2
w = 62.4 #lbs/ft**3
g = 32.2 #ft/sec**2
#CALCULATIONS
t = (de-di)/2
v = Q*4/(math.pi*(di/12)**2)
k1 = k*144
E1 = E*144
r =di/24
#CALCULATIONS
p = (v*math.sqrt(w/(g*((1/k1)+(2*r*24/E1))))-248)*r*24/144
#RESULTS
print 'stress produced in the pipe = %.f lbs/in**2'%(p)