import math
#initialisation of variables
Q= 0.5 #ft**3/sec
d= 3. #in
d1= 4. #in
d2= 2. #in
h= 12.7 #in
g= 32.2 #ft/sec**2
s= 13.6 #kg/m**3
#CALCULATIONS
k = (s-1)*(h/2.)*2.*g*(math.pi/(Q*d**2*4))**2.+((d1/d)**4.-1)
Cc = (d1/d2)**2./(math.sqrt(k)+1.)
#CALCULATIONS
print ' contraction coefficient= %.3f '%(Cc)
print ' ANSWER GIVEN IN THE TEXTBOOK IS WRONG'
import math
#initialisation of variables
Q= 400. #gallons
d= 4. #in
d1=6. #in
C= 0.66
g= 32.2 #ft/sec**2
w=62.4 #lbf/ft**3
#CALCULATIONS
u1= (Q/60.)*d1**2./(math.pi*6.23)
u2= (d/d1)**2.*u1
h= (u1-u2)**2./(2*g)
w=62.4 #lbf/ft**3
p= (((u1**2-u2**2)/(2*g))-h)*w
h1= ((1/C)-1.)**2*(u1**2/(2*g))
p1= (((u1**2.-u2**2)/(2*g))+h1)*w
p2= (u1**2.-u2**2)
#RESULTS
print ' Loss of head due to the sudden enlargement= %.3f ft'%(h)
print ' difference in pressure = %.1f lbf/ft**2'%(p)
print ' difference in pressure = %.f lbf/ft**2'%round(p1,-1)
print ' difference in pressure = %d lbf/ft**2'%(p2)
# variables
f = .0075
H = 96 # ft
u1 = 25. # ft
g = 64.4
l1 = 5280 # ft
# calculations
d = (4*f*u1*(3*l1+(4*l1)/4))/(H*g)
# results
print "Diameter of Pipe = %.2f ft"%d
import math
#initialisation of variables
l= 9. #ft
g= 32.2 #ft/sec**2
Q= 160.
A= 21.*math.pi
#CALCULATIONS
d= 6./(l*2*g*(A/Q)**2-1.5)
#RESULTS
print 'diameter = %.2f ft'%(d)
#ANSWER GIVEN IN THE TEXTBOOKIS WRONG
import math
#initialisation of variables
a= 2.493
b= 6.8
c= -393./(4*2.493)
d= 0.75 #ft
#CALCULATIONS
u2= (-b+math.sqrt(b**2-4*a*c))/(2*a)
Q= math.pi*d**2*u2/4.
#RESULTS
print ' Rate of flow = %.2f ft**3/sec'%(Q)
import math
#initialisation of variables
g= 32.2 #ft/sec**2
H= 100. #ft
L= 1000. #ft
h1= 0.03
h= 0.05
h2= 0.4
d= 6. #in
le= 1021. #ft
#CALCULATIONS
u1= math.sqrt((2*g*H)/(1+h+h2+(h1*L/0.5)))
Q= math.pi*(d/12.)**2*u1/4.
u2= math.sqrt((H*2*g)/(1+h+(1./16)*(1+h+h2+(h1*L/0.5))))
Q1= math.pi*(d/24)**2*u2/4
r= math.sqrt((d/12)/(2*h1*le))
#RESULTS
print ' rate of discharge without a nozzle= %.2f ft**3/sec'%(Q)
print ' rate of discharge= %.2f ft**3/sec'%(Q1)
print ' diameter of nozzle= %.2f in'%(r)
import math
#initialisation of variables
L= 1730. #ft
l= 104. #ft
hl= 234. #ft
u= 2.3 #ft/sec
g= 32.2 #ft/sec**2
p1 = 750*144.
w = 62.3
#CALCULATIONS
Q = round(3*math.pi/4.*1./4 *u,3) # ft**3/sec
H1 = round(p1/w + (u**2)/(2*g),-1) # ft
Pi = round(w*Q*H1/550) # h.p.
H2= L-l
R= u**2/(2*g)
H1= round(H2+R+hl)
z = H2*100./H1
#RESULTS
print ' efficiency of tramsmission = %.1f per cent'%(z)
import math
#initialisation of variables
g= 32.2 #ft/sec**2
w= 62.3 #lbf/ft**3
p= 40. #lbf/in**2
k= 0.44
d= 2. #in
#CALCULATIONS
Cu = math.sqrt(1/1.44)
Q= (math.pi*(d/2)**2./144.)*math.sqrt(2*g*p*144/(w*0.981))
P= w*Q**3*(144./math.pi)**2/(2*g*550)
#RESULTS
print ' Coefficient of velocity = %.3f'%Cu
print ' discharge rate = %.2f ft**3/min'%(Q)
print ' Power of jet = %.2f h.p'%(P)
import math
#initialisation of variables
u= 80. #ft/sec
d= 1.5 #in
Cu= 0.97
f= 0.007
l= 150. #ft
g= 32.2 #ft/sec**2
n= 70. #percent
Ho= -10. #ft
w= 62.3 #lb/ft**3
#CALCULATIONS
Q=math.pi*d**2*u/(4*144.)
ut= u/Cu
H2= ut**2/(2*g)
H1= 5*H2/4
hf= H1/5
D= ((4/math.pi)**2*4*f*l*Q**2*0.00237/(hf*2*g))**(1/5.)*12*(3.95/1.18)
Ps= w*2*Q*(H1-Ho)*100/(n*550.)
#RESULTS
print ' Diameter = %.2f in'%(D)
print ' shaft power of the pump = %.1f h.p'%(Ps)
#initialisation of variables
v= 10. #ft/sec
g= 32. #ft/sec**2
w= 62.3 #lbf/ft**3
l= 200. #ft
t= 0.5 #sec
#CALCULATIONS
dp= w*l*v/(g*t*144)
#RESULTS
print ' Rise in pressure = %.1f lbf/in**2'%(dp)
# Answer may vary because of rounding error.
import math
#initialisation of variables
w= 62.3 #lb/ft**3
g= 32.2 #ft/se**2
k= 3.*10.**5 #lbf/in**2
u= 10. #ft/sec
#CALCULATIONS
P= u*math.sqrt(w*k/g)/12.
#RESULTS
print ' Rise in pressure = %.f lbf/in**2'%(P)
import math
#initialisation of variables
g= 32.2 #ft/sec**2
w= 62.3 #lb/ft**3
k= 3.*10.**5 #lbf/in**2
#CALCULATIONS
v= math.sqrt(k*g*144/w)
#RESULTS
print ' velocity of sound in the fluid = %.f ft/sec'%(v)
# answer may vary because of rounding error
import math
#initialisation of variables
w= 62.3 #lb/ft**3
d= 6. #in
t= 5./8 #in
k= 3.*10**5 #lbf/in**2
E= 18.*10**6 #lbf/in**2
M= 3. #tonf
#CALCULATIONS
u= math.sqrt(((M*2240)**2/w)*(t*2/d)*32.2*114*((t*2/(d*k))+(2/E)))
Q= (math.pi*(d/2)**2/144)*u
#RESULTS
print ' maximum permissible flow = %.2f ft**3/sec'%(Q)
# answer may vary because of rounding error.