#tests on a reciproacating air compressers with water-cooled cylinders show
#that it is practical to cool the air sufficently during compression to
#correspond to a polytropic exponenent n in the vicinity of 1.3. Compare
#the work per pound of air compressed from 15 psia, 80 F to 90 psia, according
#to three processes: reversible adiabatic, reversible isothermal, and reversible
#pv^1.3=c. Find the heat transferred from the air in each case
import math
#initialisation of variables
R= 53.31
T= 80 #F
P2= 90. #psia
P1= 15. #psia
n= 1.4
n1= 1.3
cv= 0.171
#CALCULATIONS
Wk= (n/(n-1))*R*(T+460)*(math.pow((P2/P1),((n-1)/n))-1) #Work in 1
Wn= (n1/(n1-1))*R*(T+460)*(math.pow((P2/P1),((n1-1)/n1))-1) #Work in 2
Wt= R*(T+460)*math.log(P2/P1) #Work in 3
Q= cv*0.778*((n-n1)/(1-n1))*(T+460)*(math.pow((P2/P1),((n-1)/n))-1) #Heat
#RESULTS
print '%s %.2f' %('Heat transfered from the airin each case (Btu/lb) = ',Q)
raw_input('press enter key to exit')
#For the conditions of example 1 find the adiabatic efficiency and the isothermal
#efficiency of the reversible polytropic compressor
import math
#initialisation of variables
R= 53.31
T= 80 #F
P2= 90. #psia
P1= 15. #psia
n= 1.4
n1= 1.3
cv= 0.171
#CALCULATIONS
Wk= (n/(n-1))*R*(T+460)*(math.pow((P2/P1),((n-1)/n))-1) #Work in 1
Wn= (n1/(n1-1))*R*(T+460)*(math.pow((P2/P1),((n1-1)/n1))-1) #Work in 2
Wt= R*(T+460)*math.log(P2/P1) #Work in 3
nc= Wt/Wn #Thermal efficiency
nc1=Wk/Wn #Isothermal effeciency
##RESULTS
print '%s %.2f' %('Thermal effeciency = ',nc)
print '%s %.2f' %(' \n Isothermal effeciency= ',nc1)
raw_input('press enter key to exit')
#For the same initial state and final pressure as in ex.1, a real compressor
#has an efficiency of 95% on the adiabatic basis. The initial and final states
#correspond to a polytropic compression with n=1.3. Find the heat transferred
#per pound of air
import math
#initialisation of variables
R= 53.31
T= 80 #F
P2= 90. #psia
P1= 15. #psia
n= 1.4
cp= 0.240
nc= 0.95
n1= 1.3
#CALCULATIONS
Wk= (n/(n-1))*(R)*(T+460)*(math.pow((P2/P1),((n-1)/n))-1) #Work in 1
Wx= -Wk/nc #Work in 2
dh= cp*(T+460)*(math.pow((P2/P1),((n1-1)/n1))-1) #Enthalpy transferred
Q= dh+(Wx/778.) #Heat
#RESULTS
print '%s %.2f' %('Heat transferred (Btu/lb) = ',Q)
raw_input('press enter key to exit')
#A gas is to be compressed from 5 psia to 83.5 psia. It is known that cooling
#correspondin to the polytropic exponent of 1.25 is practical and the clearance
#of the available compressors is 3%. Compare the volumetric efficencies to be
#anticipated for (a) single-stage compression, and (b)two-stage compression,with
#equal pressure ratios in the stages.
import math
#initialisation of variables
P1= 83.5 #psia
P2= 5. #psia
n= 3. #percent
n1= 1.25
#CALCULATIONS
nv= 1-(n/100.)*(math.pow((P1/P2),(1/n1))-1) #Efficiency of single stage
nv1= 1-(n/100.)*(math.sqrt(math.pow((P1/P2),(1/n1)))-1) #efficiency of two-stage
#RESULTS
print '%s %.3f' %('single-stage compression = ',nv)
print '%s %.3f' %(' \n two-stage compression = ',nv1)
raw_input('press enter key to exit')