import math
#Initialization of variables
d = 1.26 #specific gravity
d = 24. #in
d2 = 60. #cm
Q = 25. #cfs
Q2 = 700. #L/s
dout = 12. #in
dout2 = 30./100 #m
z = 3. #ft
z2 = 1. #m
P1 = 45. #psi
P2 = 300. #kN/m**2
gamma = 9.81 #kN/m**3
#calculations
V1 = d/math.pi
V2 = d*4/math.pi
pf = (P1*144/(1.26*62.4) + (V1**2)/64.4 - V2**2 /64.4 +z)*1.26*62.4/144
V1 = Q2/1000/(math.pi*dout2**2)
V2 = 4*V1
p2f = ((P2/(1.26*gamma)) + V1**2 /(2*gamma) -V2**2 /(2*gamma) +z2)*1.26*gamma
#Results
print " English units"
print " Pressure at point 2 = %.1f psi "%(pf)
print " \n SI Units"
print " Pressure at point 2 = %.d kN/m**2 "%(p2f)
import math
#Initialization of variables
h = 20. #m
c = 4187. #N m /(kg K)
g = 9.81
#calculations
dT = g*h/c
#Results
print "Increase in temperature of water = %.3f K"%(dT)
#Initialization of variables
sg = 1.26 #specific gravity of liquid
sg2 = 1.26 #
HP = 22.
HP2 = 16.
#calculations
hp = HP*550/(sg*62.4) #divide by Q
Q = 14.2 #cfs
print "In English units, By trial Q = %.1f cfs"%(Q)
hp2 = HP2*1000/(sg2*9.81)
Q2 = 0.42 #m**3/s
print " In SI units, By trial Q = %.2f m**3/s"%(Q2)
#Initialization of variables
g = 9810. #N/m**3
Q = 10 #m**3/s
H = 20 #m
#calculations
Rate = g*Q*H/1000
#Results
print "Rate of energy loss = %d kW"%(Rate-2)
import math
#Initialization of variables
s = 0.86
P2 = 3.8 #pressure - psia
Patm = 26.8 #atmospheric pressure - Hg
SPatm = 29.9 #in of Hg
psi = 14.7 #psia
#calculations
Pa = Patm*psi/SPatm
Pcrit = -(Pa-P2)*144/(s*62.4)
Q = math.sqrt((-Pcrit+ 10*144/(s*62.4))*64.4*math.pi**2 /(-1/2.25**2 + 1/0.25**2 ))
#Results
print "Max. theoretical flow = %.1f cfs"%(Q)
import math
#Initialization of variables
z = 3. #ft
s = 0.82
#calculations
ua = math.sqrt(z*2*32.2)
ub = math.sqrt(2*32.2*(-2*(1-s) +ua**2 /(2*32.2)))
#Results
print "Velocity at B = %.1f fps"%(ub)
import math
#Initialization of variables
d = 3. #in
x1 = 0.5**2
x2 = 0.75**2
z = 80. #ft
z3 = 10. #ft
#calculations
print ("Using Bernoullis theorem")
v3 = 29.7 #fps
Q = math.pi /4 *(d/12)**2 *v3
hls = 5*(x1*v3)**2 /(2*32.2)
hld = 12*(x2*v3)**2 /(2*32.2)
#Results
print "Head loss in suction pipe = %.1f ft"%(hls)
print " Head loss in discharge pipe = %.1f ft"%(hld)
print " Flow rate = %.2f cfs"%(Q)
import math
#Initialization of variables
z1 = 2.
z2 = 0.8
#calculations
print ("From equation of continuity, z1*v1 = z2*v2")
V1 = math.sqrt((z2-z1)*2*9.81/(1-z1**2 /z2**2))
V2 = z1*V1/z2
Q = z1*1*V1
#Results
print "Flow rate = %.2f m**3/s"%(Q)
import math
#Initialization of variables
theta = 30. #degrees
z = 10. #ft
x = 60. #ft
#calculations
V = math.sqrt((0.5*32.2*69.3**2)/((x-math.sin(math.radians(theta)) *69.3)))
#Results
print "velocity = %.0f fps"%(V)
# rounding off error
import math
#Initialization of variables
V = 60. #fps
theta = 15. #degrees
ra = 6/12. #ft
rb = 8/12. #ft
B = 1.5/12 #ft
#calculations
Vra = V*math.sin(math.radians(theta))
Q = 2* math.pi*ra*B*Vra
Vratio = ra/rb
Vb = Vratio*V
flow = (V**2 - Vb**2)/(2*32.2)
#Results
print "Flow rate = %.2f cfs"%(Q)
print " Velocity at b = %d fps"%(Vb)
print " Pressure head = %.1f ft"%(flow)