#pg 9.18
#calculate the Work required in all cases
#Input data
import math
m=1.;#Mass of air that has to be compressed in kg
P1=1.;#Initial pressure of a single stage reciprocating air compressor in bar
P2=6.;#Final pressure in bar
T1=303.;#Initial temperature of air in K
n=1.2;#Polytropic index of air
R=287.;#Gas constant for air in J/kg K
r=1.4;#Isentropic index
#Calculations
W1=(m*R*T1*math.log(P2/P1))/1000;#Work required for compression in kJ/kg in Isothermal compression process
W2=((n/(n-1))*m*R*T1*((P2/P1)**((n-1)/n)-1))/1000;#Work required for compression in a polytropic compression process in kJ/kg
W3=((r/(r-1))*m*R*T1*((P2/P1)**((r-1)/r)-1))/1000;#Work required for compression in a Isentropic compression process in kJ/kg
#Output
print '(a)Work required in a isothermal compression is (kJ/kg) = ',round(W1,3)
print '(b)Work required in a polytropic compression is (kJ/kg) = ',round(W2,3)
print '(c)Work required in a isentropic compression is (kJ/kg) = ',round(W3,3)
#pg 9.19
#calculate the Length and diameter of the cylinder
#Input data
Pi=60000.;#Indicated power of a double acting air compressor in W
P1=1.;#Initial pressure in bar
T1=293.;#Initial temperature in K
n=1.2;#Polytropic index of the process
P2=8.;#Final pressure in bar
N=120.;#Speed at which the cylinder operates in rpm
S=150.;#Average piston speed in m/min
#Calculations
L=S/(2*N);#Length of the stroke in m
X=(3.14*L)/4;#X=V/D**2 i.e.,Volume of air before compression/square of the diameter in m
Y=((n/(n-1))*P1*10**5*X*(((P2/P1)**((n-1)/n))-1));#Y=W/D**2 Work done by the compressor per cycle in N/m
Nw=2*N;#Number of working strokes per minute since it is a double acting cylinder
D=(((Pi*60)/(Y*Nw))**(0.5))*1000;#Diameter of the cylinder in mm
#Output
print '(a)Length of the cylinder is (m) = ',L
print '(b)Diameter of the cylinder is (mm) = ',round(D,0)
#pg 9.20
#calculate the Indicated power of compressor
#Input data
D=0.15;#Diameter of a cylinder of a single acting reciprocating air compressor in m
L=0.2;#Length of the stroke in m
P1=1.;#The pressure at which compressor sucks air in bar
P2=10.;#Final pressure in bar
T1=298.;#Initial Temperature in K
N=150.;#Operating speed of the compressor in rpm
n=1.3;#Polytropic index of the process
#Calculations
V1=((3.14*D**2*L)/4);#Volume of air before compression in m**3
W=((n/(n-1))*P1*10**5*V1*((P2/P1)**((n-1)/n)-1));#Work done by the compressor for a polytropic compression of air in Nm
Pi=((W*N)/60)/1000;#Indicated power of the compressor in kW
#Output
print 'The indicated power of the compressor is (kW) = ',round(Pi,3)
#pg 9.21
#calculate the mass of air delivered
#Input data
D=0.25;#Diameter of the cylinder of a single acting air compressor in m
L=0.4;#Length of the stroke in m
P1=1.;#Initial Pressure of the compressor in bar
T1=303.;#Initial temperature of the compressor in K
P2=6.;#Pressure during running in bar
N=250.;#Operating speed of the compressor in rpm
R=287.;#Gas constant in J/kg K
#Calculations
V1=(3.14*D**2*L)/4;#Volume of air before compression in m**3
m=(P1*10**5*V1)/(R*T1);#Mass of air delivered by the compressor per stroke in kg/stroke
Nw=N;#Since single acting cylinder number of working stroke is equal to Operating speed of the compressor in rpm
ma=m*Nw;#Mass of air delivered per minute in kg/min
#Output
print 'Mass of air delivered per minute is (kg/min) = ',round(ma,2)
#pg 9.22
#calculate the temperature of air
#Input data
P1=1.;#Initial pressure of a single acting compressor in bar
P2=12.;#Final pressure in bar
N=500.;#Operating speed of the compressor in rpm
T1=308.;#Inlet air temperature in K
n=1.3;#Polytropic index
#Calculations
T2=T1*(P2/P1)**((n-1)/n);#Temperature of air delivered by the compressor in K
#Output
print 'Temperature of air delivered by the compressor is (K) = ',round(T2,1)
#pg 9.22
#calculate the temperature in all cases
#Input data
P1=1.;#Pressure at which air is sucked by a compressor in bar
T1=293.;#Initial temperature in K
P2=9.;#Delivery pressure after compression in bar
r=1.41;#Isentropic index
n=1.3;#Polytropic index
#Calculations
T21=T1*((P2/P1)**((r-1)/r));#Temperature at the end of isentropic compression process in K
T22=T1*((P2/P1)**((n-1)/n));#Temperature at the end of isentropic compression process in K
T23=T1;#Temperature at the end of isotropic compression process in K (Temperature remains constant)
#Output
print '(a)Temperature at the end of isentropic compression is (K) = ',round(T21,2)
print '(b)Temperature at the end of polytropic compression is (K) = ',round(T22,2)
print '(c)Temperature at the end of isotropic compression is (K) = ',T23
#pg 9.23
#calculate the work done in all cases
#Input data
V1=0.07;#Displacement of the piston of a single stage single cylinder air compressor in m**3
P1=1;#Initial pressure in bar
T1=308;#Initial temperature of air in K
P2=8.5;#Pressure after the compression process in bar
r=1.4;#Isentropic compression
#Calculations
V2=V1*((P1/P2)**(1/1.4));#Final volume of the cylinder in m**3
W1=P1*10**5*V1;#Work done by air during suction in Nm (or) J
W2=(P1*10**5*V1*(1-(P2/P1)**((r-1)/r)))/(r-1);#Work done by air during compression in Nm or J
Wa1=P2*10**5*V2;#Work done on air during delivery in Nm or J
Wa2=((-W2)+Wa1-W1)/1000;#Net work done on air during the cycle in kJ
#Output
print '(a)Work done by air during suction is (J) = ',W1
print '(b)Work done on air during compression is (J) = ',round(W2,0)
print '(c)Work done on air during delivery is (J) = ',round(Wa1,0)
print '(d)Net work done on air during the cycle is (kJ) = ',round(Wa2,3)
#pg 9.25
#calculate the work done in all cases
import math
#Input data
V1=0.05;#displacement of a piston of a single cylinder single stage reciprocating compressor in m**3
P1=1.;#pressure of air sucked in the compressor in bar
T1=300.;#Initial Temperature of air in K
P2=7.;#Pressure after the compression process in bar
#Calculations
V2=(P1*V1)/P2;#Volume after the compression in m**3
W1=P1*10**5*V1;#Work done by air during suction in Nm
W2=P1*10**5*V1*math.log(V2/V1);#Work done on sir during isothermal compression in Nm
H=-W2;#Heat transferred to the cylinder walls in Nm or J
W3=P1*10**5*V1;#Work done on air during delivery in Nm
Wn=W1+(-W2)-W3;#Net work done during the cycke in N m
#Output
print '(a)Work done by air during suction is (Nm) = ',W1
print '(b)Work done on air during Isothermal compression is (Nm) = ',round(W2,0)
print '(c)Heat transferred during this process is (J) = ',round(H,0)
print '(d)Work done on air during delivery is (Nm) = ',W3
print '(e)Net work done during the cycle is (Nm) = ',math.floor(Wn)
#pg 9.26
#calculate the Power required
#Input data
m=2.;#Mass of air delivered per second in kg
P1=1.;#Initial pressure of a single stage compressor in bar
T1=293.;#Initial temperature in K
P2=7.;#Final pressure in bar
n=1.4;#Polytropic index
R=287.;#Gas constant in J/kg K
#Calculations
W=((n/(n-1))*m*R*T1*(((P2/P1)**((n-1)/n))-1))/(60*1000);#Work done by compressor in kW
#Output
print 'Power required to compress and deliver 2kg of air per minute is (kW) = ',round(W,3)
#pg 9.27
#calculate the Work done
#Input data
import math
D=0.15;#Diameter of the bore of a single stage single acting reciprocating air compressor in m
L=0.225;#Stroke length in m
P1=1;#Pressure of air received in bar
T1=308.;#Temperature of initial air in K
P2=6.5;#Delivery pressure in bar
n=1.3;#Polytropic index
#Calculations
Vs=(math.pi*D**2*L)/4;#Stroke volume of the compressor in m**3
Vc=0.05*Vs;#Clearance volume in m**3
V1=Vs+Vc;#Initial volume of air in m**3
V4=Vc*(P2/P1)**(1/n);#The air in the clearance volume expands during suction stroke in m**3
V=V1-V4;#Effective swept volume in m**3
W=((n/(n-1))*P1*10**5*(V1-V4)*(((P2/P1)**((n-1)/n))-1));#Work done by the compressor per cycle in Nm
#Output
print 'Work done by the compressor per cycle is (Nm) = ',round(W,0)
#pg 9.28
#calculate the free air delivered
#Input data
D=0.1;#Diameter of the bore of a single acting compressor in m
L=0.1;#Length of the stroke in m
N=400.;#Operating speed of the compressor in in rpm
Vc=0.00008;#Clearance volume in m**3
n=1.2;#Polytropic index
T1=303.;#Initial temperature in K
Tf=293.;#Final temperature in K
P1=0.95;#Initial pressure in bar
P2=8.;#Final pressure in bar
Pf=1.013;#Free air pressure in bar
#Calculations
Vs=(3.14*D**2*L)/4.;#Stroke volume of the compressors in m**3
V1=Vc+Vs;#Initial volume of air is equal to cylinder volume in m**3
V4=Vc*(P2/P1)**(1/n);#Air in the clearance volume expands during suction stroke to V4
Ve=V1-V4;#Effective swept volume in m**3
Vf=(P1*(V1-V4)*Tf)/(T1*Pf);#Free air delivered per cycle can be obtained in m**3
A=Vf*N;#Free air delivered per minute in m**3/min
#Output
print '(a)Free air delivered per cycle is (m^3) = ',round(Vf,6)
print '(b)Free air delivered per minute is (m^3/min) = ',round(A,4)
#pg 9.29
#calculate the Power of the compressor
#Input data
P1=1.;#Pressure of air drawn by a two stage single acting reciprocating air compressor in bar
T1=293.;#Initial temperature in K
P3=60.;#Final pressure after the compression in bar
P2=10.;#Pressure after compression in the LP cylinder in bar
T2=303.;#Temperature after cooling in K
D=0.16;#Diameter of a cylinder in m
L=0.2;#Stroke length of the cylinder in m
n=1.3;#Polytropic index
N=300.;#Operating speed of the compressor in rpm
R=287.;#Gas constant in J/kg K
#Calculations
V1=(3.14*D**2*L)/4;#Volume of the LP cylinder in m**3
V2=(P1*V1*T2)/(T1*P2);#Volume of the HP cylinder in m**3
W=(n/(n-1))*(P1*10**5*V1*(((P2/P1)**((n-1)/n))-1)+(P2*10**5*V2*(((P3/P2)**((n-1)/n))-1)));#Work done by the compressor per working cycle in N m
P=(W*N)/(60.*1000);#Power of the compressor in kW
#Output
print 'Power of the compressor when it runs at 300 rpm is (kW) = ',round(P,3)
#pg 9.30
#calculate the percentage saving
#Input data
P1=1.;#Initial pressure in bar
P3=9.;#Final pressure in bar
n=1.3;#Compression index
#Calculations
W1=(n/(n-1))*(P1*10**5*(((P3/P1)**((n-1)/n))-1));#Work done in compression in a single stage per unit volume per kg of air in N m
P2=(P1*P3)**(0.5);#Intercooler pressure for perfect intercooling in bar
W2=2*(n/(n-1))*(P1*10**5*(((P2/P1)**((n-1)/n))-1));#Work done in compression in a two stage compressor per unit volume per kg of air in N m
Wc=W1-W2;#Saving in work of compression in N m
nw=((W1-W2)/W1)*100;#Percentage saving in work of compression in percentage
#Output
print 'Percentage saving in the work of compression of air in two stages instead of single stage is (percent) = ',round(nw,1)
#pg 9.31
#calculate the Minimum work required
#Input data
m=1.;#Mass of air to be compressed in kg
P1=1.;#Pressure of air before compression in bar
T1=303.;#Initial temperature in K
P3=25.;#Final pressure of air after compression in bar
n=1.3;#Polytropic index
R=287.;#Gas constant in J/kg K
#Calculations
P2=(P1*P3)**(0.5);#Intermediate pressure in the case of perfect intercooling in bar
W=2*(n/(n-1))*(m*R*T1*(((P2/P1)**((n-1)/n))-1));#Work done in compression in a two stage compressor per unit volume per kg of air in N m
#Output data
print 'Minimum work required to compress 1kg of air for given conditions is (Nm) = ',round(W,0)
#pg 9.32
#calculate the minimum power
#Input data
V1=3;#Volume of air sucked in by a two stage compressor in m**3
P1=1.04;#Initial pressure in bar
T1=298;#Initial temperature in K
P2=9;#Delivery pressure in bar
n=1.25;#Polytropic index
#Calculations
P2=(P1*P2)**(0.5);#Intermediate pressure for perfect intercooling and for minimum work of compression in bar
W=2*(n/(n-1))*(P1*10**5*V1*(((P2/P1)**((n-1)/n))-1));#Work done in compression in a two stage compressor per unit volume per kg of air in Nm
P=W/(60*1000);#Power required to drive the compressor in kW
#Output
print 'The minimum power required to drive the compressor is (kW) = ',round(P,3)
#pg 9.32
#calculate the mass of water
#Input data
P1=1.;#Initial pressure of a two stage air compressor in bar
P3=36.;#Final pressure in bar
T1=298.;#Initial temperature in K
n=1.35;#Polytropic index
T3=298.;#Temperature after intercooling in K
Tc=20.;#Permissible temperature rise of the cooling water in K
R=287.;#Gas constant in J/kg K
Cp=1.;#Specific heat of air in kJ/kg K
Cw=4.2;#Specific heat of water in kJ/kg K
ma=1.;#Mass of air in the compressor in kg
#Calculations
P2=(P1*P3)**(0.5);#Intercooler pressure for complete intercooling and for minimum work of compression in bar
T2=T1*(P2/P1)**((n-1)/n);#Temperature after the compression process in K
mw=(ma*Cp*(T2-T3))/(Cw*(Tc));#Mass of water to circulate in the intercooler per kg of air in kg
#Output
print 'Mass of water to circulate in the intercooler for abstracting heat is (kg) = ',round(mw,3)
#pg 9.33
#calculate the volume ratio
#Input data
V1=0.2;#Volume of air flow per second in a two stage single acting reciprocating compressor in m**3
P1=0.1;#Intake pressure of air in MPa
T1=293.;#Initial temperature in K
P3=0.8;#Final pressure after the air is compressed in MPa
N=600.;#Operating speed of the compressor in rpm
#Calculations
P2=(P1*P3)**(0.5);#Intercooler pressure for perfect intercooling and for minimum work of compression in bar
Vl=(V1*60)/600;#Volume of the LP cylinder in m**3
Vh=(P1*Vl)/P2;#Volume of the high pressure cylinder in m**3
R=Vl/Vh;#Ratio of cylinder volumes
#Output
print 'The volume ratio of LP to HP cylinders = ',round(R,2)
#pg 9.34
#calculate the ratio required
#Input data
P1=1.;#Initial pressure of air entering a two stage air compressor with complete intercooling in bar
P3=25.;#Delivery pressure of air toe the mains in bar
T1=303.;#Initial temperature in K
n=1.35;#Compression index
#Calculations
P2=(P1*P3)**(0.5);#Inter cooler pressure for perfect intercooling in bar
R=(P2/P1)**(0.5);#Ratio of cylindrical diameters
#Output
print 'The ratio of cylinder diameters for the efficiency of compression to be maximum = ',round(R,3)
#pg 9.34
#calculate the number of stages and Intermediate pressures
#Input data
import math
P1=1.;#Initial pressure of a multistage compression in bar
Pn1=120.;#Final pressure in bar
r=4;#Permissible pressure ratios per stage
#Calculations
n=math.log(Pn1/P1)/math.log(r)
n1=4;#As n=3.45 say 4 stages
P5=Pn1;#Since number of stages is 4
P4=P5/(Pn1/P1)**(1./n1);#Pressure after the stage 3 in bar
P3=P4/(Pn1/P1)**(1./n1);#Pressure after the stage 2 in bar
P2=P3/(Pn1/P1)**(1./n1);#Pressure after the stage 1 in bar
#Output
print '(a)Number of stages = ',n1
print '(b)Intermediate pressures are, P2 = ',round(P2,2),'bar, P3 = ',round(P3,2),'bar, P4 =',round(P4,2),'bar'
#pg 9.35
#calculate the Power required and Intermediate pressures
#Input data
P1=1.;#Initial pressure of a 3 stage compressor in bar
P4=40.;#Final pressure in bar
T1=293.;#Initial temperature in K
n=1.3;#Polytropic index
V1=15.;#Air delivered per minute in m**3/min
#Calculations
W=((3*n)/(n-1))*P1*10**5*V1*(((P4/P1)**((n-1)/(3*n)))-1);#Work done by the compressor in kJ/min
P=W/(60*1000.);#Power required to deliver 15 m**3/min air in kW
P2=P1*(P4/P1)**(1./3);#Intermediate pressure after stage 1 in bar
P3=P2*(P4/P1)**(1./3);#Intermediate pressure after stage 2 in bar
#Output
print '(a)Power required to deliver 15 m^3/min air at suction condition is (kW) = ',round(P,1)
print '(b)Intermediate pressures are P2 = ',round(P2,2),'bar P3 = ',round(P3,3),'bar'
#pg 9.36
#calculate the Amount of heat rejected
#Input data
P1=1.;#Atmospheric pressure in bar
P4=60.;#Delivery pressure in bar
T1=303.;#Initial temperature in K
n=1.3;#Index of compression
Cp=1.005;#Specific heat of air at constant pressure in kJ/kg K
S=3.;#Number of stages
#Calculations
P2=P1*(P4/P1)**(1./3);#Intermediate pressure in bar
T2=T1*(P2/P1)**((n-1)/n);#Temperature of air entering the intercoolers in K
H=Cp*(T2-T1);#Heat rejected in each intercooler in kJ
#Output
print 'Amount of heat rejected in each intercooler is (kJ) = ',round(H,0)
#pg 9.37
#calculate the compressor delivery pressure and Ratio of cylinder volumes
#Input data
P1=1.;#Pressure at the end of suction stroke in LP cylinder of a 3 stage single acting reciprocating compressor in bar
T1=293.;#Temperature at the end of suction stroke in LP cylinder in K
V=9.;#Free air delivered by the compressor in m**3
P4=65.;#Pressure delivered by the compressor in bar
n=1.25;#Polytropic index
#Calculations
P2=P1*(P4/P1)**(1./3);#Intermediate pressure after stage 1 in bar
P3=P2*(P4/P1)**(1./3);#Intermediate pressure after stage 2 in bar
V3=1;#The volume of cylinder for the third stage in m**3
V2=V3*(P3/P2);#Volume of the cylinder for second stage in m**3
V1=(P2/P1)*V2;#Volume of the cylinder for first stage in m**3
W=(((3*n)/(n-1))*P1*10**5*V*(((P4/P1)**((n-1)/(3*n)))-1))/1000;#Work done by the compressor in kJ/min
Pi=W/60;#Indicated power in kW
#Output
print '(a)L.P. and I.P.compressor delivery pressure is P2 = ',round(P2,3),'bar P3 =',round(P3,2),'bar'
print '(b)Ratio of cylinder volumes is V1:V2:V3 = ',round(V1,2),':',round(V2,3),':',V3
print '(c)Total indicated power is (kW) = ',round(Pi,2)