import math
#Given
V1 = 2.7;#flow rate of CO2 in cubic meter/min
T1 = 273-51;#temperature in K
P1 = 1.0;#initial pressure in Kgf/sq cm
P2 = 10.0;#final pressure in Kgf/sq cm
y = 1.3;#gamma
v1 = 0.41;#specific volume in cubic meter/Kg
H1 = 158.7;# initial enthalpy in Kcal/Kg
H2 = 188.7;#final enthalpy in Kcal/Kg
#process is isentropic
#To calculate the horsepower required
#(i)Assuming ideal gas behaviour
#From equation 10.3 (page no 189)
W = (y/(y-1))*(P1*1.03*10**4*V1)*(1-(P2/P1)**((y-1)/y));#work in m Kgf/min
W1 = W/4500.0;
print "i)The horsepower required is %f hp"%(W1);
#(ii)Umath.sing the given data for CO2
#From equation 10.2 (page no 189)
W = -(H2 - H1);#work in Kcal/Kg
M = V1/v1;#Mass rate of gas in Kg/min
W1 = W*M*(427/4500.0);
print " ii)Compressor work is %f hp"%(W1);
#end
#Given
P1 = 1.0;#Initial pressure in atm
P2 = 29.0;#Final pressure in atm
C = 0.05;#Clearance
y = 1.4;#gamma of air
#To calculate the volumetric efficiency and the maximum possible pressure that can be attained in a math.single stage
#(i)Calulation of volumetric efficiency
#From equation 10.11 (page no 194)
V_E = 1+C-C*(P2/P1)**(1/y);
print "i)Volumetric efficiency is %f percent"%(V_E*100);
#(ii)Calculation of maximum pressure
V_E = 0;#Minimum efficiency
P2 = P1*(((1+C-V_E)/C)**y);
print " ii)The maximum possible pressure attained is %f atm"%(P2);
#end
#Given
V_d = 5.15;#print lacement volume in cubic meter/min
P1 = 1.0;#initial pressure in Kgf/sq cm
P2 = 8.5;#final pressure in Kgf/sq cm
C = 0.06;#Clearance
M_E = 0.8;#Mechenical efficiency
y = 1.31;#gamma
#To calculate the capacity and the actual horse power of the compressor
v1 = V_d*(1+C-(C*((P2/P1)**(1/y))));
print "The capacity of the copressor is %f cubic meter/min"%(v1);
#From equation 10.6 (page no 192)
W = (y/(y-1))*(P1*1*10**4*v1)*(1-(P2/P1)**((y-1)/y));#work in Kgf/min
W1 = W/4500.0;#work in hp
W2 = W1/M_E;
print " The actual horse power of the compressor is %f hp"%(W2);
#end
#Given
P1 = 1.0;#Initial pressure in Kgf/sq cm
Pn = 13.0;#Final pressure in Kgf/sq cm
V1 =27.0;#flow rate of gas in cubic meter/min
y = 1.6;#gamma of the gas
n = [1.0,2.0,3.0,4.0,7.0,10.0];#number of stages
print "No of stages Horse power in hp";
#To Calculate the theoretical horse power required
W = []
for i in range(0,6):
W.append(n[i]*(y/(y-1))*((P1*10**4)/4500)*V1*(1-(Pn/P1)**((y-1)/(n[i]*y))));
print " %d"%(n[i]),
print " %f"%(-1*W[i])
#end
#Given
P1 = 1.0;#Initial pressure in Kgf/sq cm
P4 = 200.0;#Final pressure in Kgf/sq cm
n = 4.0;#no of stages
#To find out the presure between stages
r = (P4/P1)**(1/n);#Compression ratio
P2 = r*P1;
print "The pressure after 1st stage is %f Kgf/sq cm"%(P2);
P3 = r*P2;
print " The pressure after 2nd stage is %f Kgf/sq cm"%(P3);
P4 = r*P3;
print " The pressure after 3rd stage is %f Kgf/sq cm"%(P4);
#end