#initialisation of variables
r= 1.5
f= 0.025 # friction factor
#CALCULATIONS
r1= (2/f)*(r**2-1)
#RESULTS
print 'ratio L/D2 = %.f'%(r1)
import math
#initialisation of variables
a= 6. #degrees angle
r= 1.5
l= 100. #ft
f= 0.025
K= 0.15
#CALCULATIONS
R= r**4-1
R1= 1/math.tan(math.radians(a/2))*(1-(1./r))
p1= f*l
p2= 2.5*(l-p1)/l
p3= (1-r**2)**2
p4= K*p3
pt= p4+p2
#RESULTS
print ' lowest ratio = %.2f'%(R)
print ' contribtuion of friction in pipe = %.3f lbf/ft**2'%(p1)
print ' contribtuion of diffuser in pipe = %.3f lbf/ft**2'%(p2)
print ' stagnant pressure drop = %.3f lbf/ft**2'%(p3)
print ' contribtuion of friction in pipe after reduction = %.3f lbf/ft**2'%(pt)
# note : rounding off error
import math
#initialisation of variables
d= 4. #in galvanised iron pipe diameter
q= 0.5 #ft**3/sec flow rate
w= 62.4 #lb/ft**3 density
u= 2.7*10**-5 #lbf sec/ft**2 viscosity
e= 0.0005 #ft
g= 32.1 #ft/sec**2 acceleration
f= 0.0235
lt= 400. #ft long
#CALCULATIONS
V= 4*q/(math.pi*(d/12)**2)
Re= w*V*(d/12)/(u*g)
r= e/(d/12)
dz= (V**2/(2*g))*(1.7+f*lt/(d/12))
#RESULTS
print ' mean flow velocity = %.2f ft/sec'%(V)
print ' Reynolds number = %.2e'%(Re)
print ' Relative roughness = %.4f'%(r)
print ' difference in the levels of water = %.1f ft'%(dz)
import math
#initialisation of variables
d= 4. #in
v= 6.64 #ft/sec
#CALCULATIONS
Q= math.pi*0.25*(d/12)**2*v
#RESULTS
print 'Flow rate= %.3f ft**3/sec'%(Q)
#initialisation of variables
d= 0.366 #ft
i= 12
#CALCULATIONS
pd= d*i
#RESULTS
print 'Required pipe diameter = %.2f in'%(pd)
#initialisation of variables
Ps1= 1050. #lbf/ft**2
fr= 10.7
p= 36.6 #lbf/ft**2
p1= 195. #lbf/ft**2
fr1= 16.
fr2= 1.8
#CALCULATIONS
deltap = (p+957+p1+Ps1)
p2= round(fr*p)
dp= Ps1-p2
lc= round(dp/p)
sp= Ps1+p1-p*(fr1+fr2)
lc1= sp/p
#RESULTS
print ' Pressure = %.f lbf/ft**2'%(round(deltap,-1))
print ' pressure difference = %.f lbf/ft**2'%(dp)
print ' Loss coefficient = %.f '%(lc)
print ' Loss coefficient = %.1f '%(lc1)
import math
#initialisation of variables
p1= 50. #lbf/in**2 pressure
R= 96.3 #ft lbf/lbm R
T= 80. #F temperature
p2= 20. #lbf/in**2 pressure
r= 1.31
u= 2.34*10**-7 #lbf sec/ft**2
e= 0.00005 #ft
m= 5.*10**4 #lbm/sec
d= 1.5 #ft
g= 32.2 #ft/sec**2
f= 0.113
#CALCULATIONS
w1= p1*144/(R*(460+T))
V1= 4*(m/3600)/(math.pi*w1*d**2)
Ma1= V1/(r*R*g*(460+T))**0.5
Re= w1*V1*d/(u*g)
dx= (((1/(r*Ma1**2))*10*(1-(p2/p1)**2))+math.log(p2/p1))*d/f
#RESULTS
print ' density = %.3f lbm/ft**3'%(w1)
print ' mean flow velocity = %.1f ft/sec'%(V1)
print ' Match number = %.4f '%(Ma1)
print ' Reynolds number = %.2e '%(Re)
print ' Length of pipe = %.2e ft'%(dx)
import math
#initialisation of variables
r= 1.4
R= 53.3 #ft lbf/lbm R
g= 32.2 #ft/sec**2
T1= 410. #R temperature
v= 2500. #ft/sec steadility
P1= 628. #lbf/in**2 pressure
#CALCULATIONS
v1= int(math.sqrt(r*g*R*T1))
Ma1= round(v/v1,2)
Ts1= int(T1*(1+0.5*(r-1)*Ma1**2))
Ps1= P1*(1+0.5*(r-1)*Ma1**2)**(r/(r-1))
Ps2= Ps1*((r+1)/(2*r*Ma1**2-r+1))**(1/(r-1))*(0.5*(r+1)*Ma1**2/(1+0.5*(r-1)*Ma1**2))**(r/(r-1))
#RESULTS
print ' acoustic velocity = %.f ft/sec'%(v1)
print ' Match number = %.2f '%(Ma1)
print ' Stagnition temperature = %.f R'%(Ts1)
print ' Stagnition pressure = %.f lbf/ft**2'%(Ps1)
print ' Stagnition pressure = %.f lbf/ft**2'%(Ps2)
# note : answer in book is wrong. Please check manually.
#initialisation of variables
p2= 67.2 #lbf/in**2 pressure
p1= 63. #lbf/in62 pressure
r= 1.4
n= 0.6 # efficiency
T1= 870. #R temperature
ma1= 0.8 #ft/sec mach number
#CALCULATIONS
dt= (p2/p1)**((r-1)/r)-1
dt1= dt/n
T2= T1*(1+dt1)
Ts1= T1*(1+0.5*(r-1)*ma1**2)
ps1= p1*(1+0.5*(r-1)*ma1**2)**(r/(r-1))
ps2= p2*(Ts1/T2)**(r/(r-1))
dp= ps1-ps2
#RESULTS
print ' dT = %.5f '%(dt)
print ' dT1 = %.5f '%(dt1)
print ' Temperature = %.f R'%(T2)
print ' Temperature = %.1f R'%(Ts1)
print ' Pressure = %.1f lbf/in**2'%(ps1)
print ' Pressure = %.1f lbf/in**2'%(ps2)
print ' pressure difference = %.1f lbf/in**2'%(dp)
import math
#initialisation of variables
r= 1.4
ma3= 3. #ft/sec mach number
ps= 80. #lbf/ft**2 pressure
Ts= 840. #R temperature
r1= 53.3 #ft lbm/ft**3
A3= 2. #in**2 flow area
g= 32.2 #ft/sec**2
ma1= 1.6
#CALCULATIONS
R= (1+(r-1)*0.5*ma3**2)**(r/(r-1))
p3= ps/R
R1= 1+0.5*(r-1)*ma3**2
T3= Ts/R1
w3= p3*144/(r1*T3)
V3= ma3*math.sqrt(r*r1*g*T3)
m= w3*V3*A3/144
ra= ((r+1)/(2*r*ma1**2-(r-1)))**(1/(r-1))*(0.5*(r+1)*ma1**2/(1+0.5*(r-1)*ma1**2))**(r/(r-1))
ps2= ps*ra
dp= ps-ps2
#RESULTS
print ' outlet pressure = %.2f lbf/in**2'%(p3)
print ' outlet temperature = %.f R'%(T3)
print ' mass flow rate = %.3f lbm/sec'%(m)
print ' ps2 = %.1f lbf/in**2'%(ps2)
print ' Stagnation pressure loss = %.1f lbf/in**2'%(dp)
# rounding off error