import math
from numpy import *
#Initialization of variables
z2 = 500. #ft
z1 = 300. #ft
D = array([1, 1.5, 2 ,2.5, 3, 4, 6])
g = 32.2
gam = 62.4
#calculations
Dj = D/12
Vj = sqrt((z2-z1)*2*g/(1.04 + 640.*Dj**4))
Aj = math.pi/4 *Dj**2
Q = Aj*Vj
Pjet = gam*Q*Vj**2 /(2*g) /550
Pj = max(Pjet)
for i in range(0,len(Pjet)):
if(Pjet[i] == Pj):
break
diameter = D[i]
#Results
print "Dj,in Dj,ft Vj,fps Aj,ft**2 Q=AjVj,cfs Pjet,hp"
for i in range(len(D)):
print "%5.1f %5.3f %5.f %7.4f %5.2f %5.1f"%(D[i],Dj[i],Vj[i],Aj[i],Q[i],Pjet[i])
print "Thus a pipe of %d in will be the optimum"%(diameter)
# answer are slightly different because of rounding off error
import math
from sympy.functions.elementary.trigonometric import acot
#Initialization of variables
phi = 0.46
g = 32.2
k = 0.44
cv = 0.98
d = 10. #in
A = 0.545 #ft**2
beta = 160. #degrees
#calculations
u = phi*math.sqrt(2*g)
V1 = cv*math.sqrt(2*g)
gQ = 62.4*A*V1
T = d/2 *gQ/g *(1 - math.cos(math.radians(beta)) /math.sqrt(1+k) )*math.sqrt(2*g)*(cv-phi)
Power = T*2*u/d
#Results
print "Torque required = %d ft lb"%(T)
print " Power transferred = %d ft lb/s"%(Power)
Pi = gQ
He = Power/Pi
print " Hydraulic efficiency = %.2f"%(He)
v1 = V1-u
v2 = v1/(math.sqrt(1+k))
hl = k*v2**2 /(2*g)
print "Head loss in bucket friction = %.1f %%"%(hl*100)
Hn = (1/cv**2 -1)*V1**2 /(2*g)
print " Head loss in nozzle = %.4f"%(Hn*100)
V2cos = u+v2*math.cos(math.radians(beta))
V2sin = v2*math.sin(math.radians(beta))
#alpha = math.degrees(1/math.atan(V2cos/V2sin))
alpha = math.degrees(acot(V2cos/V2sin))
V2 = V2sin/math.sin(math.radians(alpha))
Hd = V2**2/(2*g)
print " Head loss at discharge = %.1f %%"%(Hd*100)
Htotal = Hd+Hn+hl
print " Total head loss = %.2f %%"%(Htotal*100)
# rounding off error
import math
#Initialization of variables
cv = 0.98
g = 32.2
h = 1320. #ft
A = 0.196 #ft**2
eta = 0.85
ne = 400.
phi = 0.45
#calculations
V = cv*math.sqrt(2*g*h)
Q = A*V
bhp = eta*62.4*Q*h/550
ns = ne*math.sqrt(bhp) /h**(5./4)
u = phi*math.sqrt(2*g*h)
D = u*60/math.pi/ne
#Results
print "Pitch diameter = %.2f ft"%(D)
# part b
#Initialization of variables
cv = 0.98
g = 32.2
h = 1320. #ft
A = 0.196 #ft**2
eta = 0.85
ne = 400.
phi = 0.45
#calculations
V = cv*math.sqrt(2*g*h)
Q = A*V/3
bhp = eta*62.4*Q*h/550
ne2 = 600.
ns1 = ne2*math.sqrt(bhp) /h**(5./4)
D = 2500./ne2
Dj = math.sqrt(Q*4/V/math.pi)
#Results
print " Jet diameter = %.3f ft"%(Dj)
print " Specific speed = %.2f "%(ns1)
print " Pitch Diameter = %.2f ft"%(D)
print " Operating speed = %d rpm"%(ne2)
# rounding off error