%matplotlib inline
from matplotlib.pyplot import *
import math
#initialisation of variables
d= 0.0764 #lbm/ft**3
u= 3.74*10**-7 #lbf sec/ft**2
D= 15. #in
g= 32.2 #ft/sec**2
p= 14.7 #lb/in**2
r1= [0.02, 0.04, 0.06, 0.08, 0.1, 1.15]
r2= [0.0338, 0.0267, 0.0199, 0.0159, 0.0132, 0.0100]
r3= [0.46, 0.92, 1.38, 1.84, 2.3, 2.64]
r4= [2.97, 2.35, 1.75, 1.4, 1.16, 0.88]
r5= [0.0206, 0.0163, 0.0121, 0.0097, 0.0081, 0.0061]
#CALCULATIONS
re= (d/u)*(p*100*2*math.pi/60)*(D/12)**2/g
#RESULTS
print 'Reynolds Number = %.2e '%(re)
print "m/qwD**3 g0deltaPe/QW**2D**2 m(lbm/sec) deltap(lbf/ft**2) deltap(lbf/in**2)"
for i in range(len(r1)):
print "%7.2f %8.4f %7.2f %7.2f %8.4f"%(r1[i],r2[i],r3[i],r4[i],r5[i])
plot(r3,r5)
xlabel("m lbm/sec")
ylabel( "dPs lbf/ft**2")
suptitle("Actual perfomance curve")
import math
#initialisation of variables
psif= 10.2 #lbf/in**2 pressure
usit= 3.8*10**-7 #lbf sec/ft**2 viscosity
usif= 3.52*10**-7 #lbf sec/ft**2 viscosity
Tsit= 530. #R temperature
Tsif= 480. #R temperature
wf= 15000. #rev/min speed
#CALCULATIONS
Psit= psif*usit*math.sqrt(Tsit/Tsif)/usif
wt= wf*math.sqrt(Tsit/Tsif)
#RESULTS
print 'Pressure in the test cell = %.1f lbf/in**2'%(Psit)
print ' Compressor speed = %.f rev.min'%(wt)
# book answer is wrong.
import math
#initialisation of variables
w= 62.3 #lbf/ft**3 weight
d= 0.375 #in diameter
ro= 0.75 #ft radius
l= 1.25 #ft length
b= 120. #degrees angle
do= 0.25 #in diameter
p= 750. #lbf/in**2
g= 32.1 #ft/sec**2
f= 0.03 # friction factor
f1= 0.9
f2= 0.3
w1= 60. #rad/sec
#CALCULATIONS
Q= math.sqrt(((p/w)+((60*ro)**2/(2*g))+do)*math.pi**2*g*(d/12)**4/((d/do)**4-1+(l*f/(d/12))+f1+f2))*0.353
Vwo= w1*ro+(4*Q/(math.pi*(do/12)**2))*math.cos(math.radians(b))
C= w*Q*Vwo*ro/g
#RESULTS
print ' Flow Rate = %.4f ft**3/sec'%(Q)
print ' Vwo = %.2f ft/sec'%(Vwo)
print ' Driving Torque = %.3f lbf ft'%(C)
#initialisation of variables
W= 38. #rev/sec speed
w= 62.4 #lbf/ft**3 density
m= 2000. #lbm/sec flow rate
g= 32.2 #ft/sec**2
ps= 5000. #lbf/ft**2 pressure rise
S3= 4.6
e= 0.91
#CALCULATIONS
S1= W*(w*m**2/(g*ps)**3)**0.25
D= S3*(m**2/(w*g*ps))**0.25
#RESULTS
print ' S1 = %.3f'%(S1)
print ' Diameter = %.2f ft'%(D)
print ' efficiency = %.2f '%(e)
import math
#initialisation of variables
d= 6. #in diameter
f= 0.25
l= 1200. #ft long
p= 55. #lbm/ft**3
w= 740. #rev/min
g= 32.2 #ft/sec**2
n= 0.87 # efficiency
d1= 1.78 #ft
#CALCULATIONS
D= (0.13*math.pi**2*(d/12)**5/(8*f*l*0.012**2))**0.25*d1
m= 0.012*p*(w*2*math.pi/60)*D**3
dps= 0.13*p*(w*2*math.pi*D/60)**2/g
P= m*10*dps/(p*n)
#RESULTS
print ' Diameter = %.2f ft'%(D)
print ' Mass flow rate = %.1f lbm/sec'%(m)
print ' pressure rise = %.1f lbf/ft**2'%(round(dps,-1))
print ' shaft power = %.2e ft lbf/sec'%(P)
# rounding off error