Chapter 10: Properties of gases and gas mixture

Ex10.1:pg-366

In [3]:
import math
Pa = 1.5 # Pressure in vessel A in MPa
Ta = 50  # Temperature in vessel A in K
ca = 0.5 # Content in vessel A in kg mol
Pb = 0.6 # Pressure in vessel B in MPa
Tb = 20 # Temperature in vessel B in K
mb = 2.5 # Content in vessel B in kg mol
R = 8.3143 # Universal gas constant
Va = (ca*R*(Ta+273))/(Pa*1e03) # volume of vessel A
ma = ca*28 # mass of gas in vessel A
Rn = R/28 # Gas content to of nitrogen
Vb = (mb*Rn*(Tb+273))/(Pb*1e03) # volume of vessel B
V = Va + Vb  # Total volume
m = ma + mb # Total mass
Tf = 27 # Equilibrium temperature in degree Celsius
P = (m*Rn*(Tf+273))/V # Equilibrium pressure 
g = 1.4 # Heat capacity ratio
cv  = Rn/(g-1) # Heat capacity at constant volume
U1 = cv*(ma*Ta+mb*Tb) # Initial internal energy 
U2 = m*cv*Tf# Final internal energy 
Q = U2-U1 # heat transferred

print "\n Example 10.1"
print "\n\n The final equilibrium pressure is ",P/1e3 ," MPa"
print "\n The amount of heat transferred to the surrounding is ",Q ," kJ"
#The answers vary due to round off error

T_ = (ma*Ta+mb*Tb)/m  # final temperature
P_ = (m*Rn*(T_+273))/V # final pressure
print " \n\n If the vessel is perfectly insulated"
print "\n The final temperature is ",T_ ," degree Celsius"
print "\n The final pressure is ",P_/1e3 ," MPa"
 Example 10.1


 The final equilibrium pressure is  1.16869318853  MPa

 The amount of heat transferred to the surrounding is  -226.04503125  kJ
 

 If the vessel is perfectly insulated

 The final temperature is  45.4545454545  degree Celsius

 The final pressure is  1.24058552709  MPa

Ex10.2:pg-368

In [4]:
import math
cp = 1.968 # Heat capacity in kJ/kg
cv = 1.507 # Heat capacity in kJ/kg
R_ = 8.314 # Gas constant
V = 0.3 # Volume of chamber in m**3
m = 2 # mass of gas in kg
T1 = 5.0# Initial gas temperature in degree Celsius
T2 = 100.0 # Final gas temperature in degree Celsius
R = cp-cv # Universal gas constant
mu = R_/R # molecular weight
Q12 = m*cv*(T2-T1) # The heat transfer at constant volume
W12 = 0 # work done
U21 = Q12 # change in internal energy
H21= m*cp*(T2-T1) # change in  enthalpy
S21 = m*cv*math.log((T2+273)/(T1+273)) #change in  entropy 

print "\n Example 10.2"
print "\n\n Gas constant of the gas is ",R ," kJ/kg K "
print "\n Molecular weight the gas is ",mu ," kg/kg mol"
print "\n The heat transfer at constant volume is ",Q12 ," kJ"
print "\n Work done is ",0 ," kJ"
print "\n The change in internal energy is ",U21 ," kJ"
print "\n The change in  enthalpy is ",H21 ," kJ"
print "\n The change in  entropy is ",S21 ," kJ/k"
#The answers vary due to round off error
 Example 10.2


 Gas constant of the gas is  0.461  kJ/kg K 

 Molecular weight the gas is  18.0347071584  kg/kg mol

 The heat transfer at constant volume is  286.33  kJ

 Work done is  0  kJ

 The change in internal energy is  286.33  kJ

 The change in  enthalpy is  373.92  kJ

 The change in  entropy is  0.885987320143  kJ/k

Ex10.3:pg-369

In [5]:
import math
from scipy import integrate
m = 1.5 # Mass of gas in kg
P1 = 5.6 # Initial pressure of gas in MPa
V1 = 0.06 # Initial volume of gas in m**3
T2_ = 240 # Final temperature of gas in degree Celsius
a = 0.946 # Constant
b = 0.662 # Constant
k = 1e-4 # Constant
# Part (b)
R = a-b # constant
T2 = T2_+273 # Final temperature of gas in KK
T1 = (P1*1e03*V1)/(m*R) # Initial temperature
W12,er =integrate.quad(lambda T:m*(b+k*T),T1,T2) # Work done

print "\n Example 10.3"
print "\n The work done in the expansion is ",-W12 ," kJ"
#The answers vary due to round off error
 Example 10.3

 The work done in the expansion is  300.72200185  kJ

Ex10.5:pg-371

In [6]:
import math
m = 0.5 # mass of air in kg
P1 = 80 # Initial pressure kPa
T1 = 60 # Initial temperature in degree Celsius
P2 = 0.4 # Final pressure in MPa
R = 0.287 # Gas constant
V1 = (m*R*(T1+273))/(P1) # Volume of air at state 1
g = 1.4 # Heat capacity ratio
T2 = (T1+273)*(P2*1e3/P1)**((g-1)/g)# Final temperature
W12 = (m*R*(T1+273-T2))/(g-1) # Work done in 
V2 = V1*((P1/(P2*1e3))**(1/g)) # Final volume
W23 = P2*(V1-V2)*1e3 # # Work done
W = W12+W23 # Net work done
V3 = V1 # constant volume
T3 = (T2)*(V3/V2) # Temperature at state 3
cp = 1.005 # Heat capacity at constant volume in kJ/kgK
Q = m*cp*(T3-T2)# Heat transfer
print "\n Example 10.5"
print "\n The work transfer for the whole path is ",W ," kJ"
#The answers vary due to round off error
print "\n The heat transfer for the whole path ",Q ," kJ"
#The answer provided in the textbook is wrong
 Example 10.5

 The work transfer for the whole path is  93.4986082985  kJ

 The heat transfer for the whole path  571.638005316  kJ

Ex10.6:pg-372

In [7]:
import math
P1 = 700 # Initial pressure of gas in kPa
T1 = 260 # Initial temperature of gas in degree Celcius 
T3 = T1 # Temperature at state 3
V1 = 0.028 # Initial volume of gas in m**3
V2 = 0.084 # Final volume of gas in m**3
R = 0.287 # Gas constant
m = (P1*V1)/(R*(T1+273)) # mass of gas  
P2 = P1 # Pressure at state 2
T2 = (T1+273)*((P2*V2)/(P1*V1)) # Temperature at state 2
n  = 1.5 # polytropic index 
P3 = P2*(((T3+273)/(T2))**(n/(n-1))) # Pressure at state 3
cp = 1.005 # COnstant pressure heat capacity in kJ/kgK
cv = 0.718 # COnstant volume heat capacity in kJ/kgK
Q12 = m*cp*(T2-T1-273) # HEat transfer
Q23 = m*cv*(T3+273-T2) + (m*R*(T2-T3-273))/(n-1) # Heat transfer
Q31 = m*R*(T1+273)*math.log(P3/P2) # Heat transfer
Q1 = Q12 # Heat equivalance
Q2 = -(Q23+Q31) # Net heat transfer
e = 1-(Q2/Q1) # First law efficiency

print "\n Example 10.6"
print "\n The heat received in the cycle is ",Q1 ," kJ"
print "\n The heat rejected in the cycle ",Q2 ," kJ"
print "\n The efficiency of the cycle is ",math. ceil(e*100) ," percent"
#The answers vary due to round off error
 Example 10.6

 The heat received in the cycle is  137.268292683  kJ

 The heat rejected in the cycle  84.2666952566  kJ

 The efficiency of the cycle is  39.0  percent

Ex10.7:pg-374

In [8]:
import math
P1 = 300 # Initial gas pressure in kPa
V1 = 0.07 # Initial volume of gas in m**3
m = 0.25 # Mass of gas in kg
T1 = 80 # Initial temperature of gas in degree Celsius
R = (P1*V1)/(m*(T1+273)) # constant
P2 = P1 # process condition
V2 = 0.1 # Final volume in m**3
T2 = (P2*V2)/(m*R) # Final temperature in K
W = -25 #Work done in kJ
cv = -W/(m*(T2-T1-273)) # Constant volume heat capacity in kJ/kg
cp = R+cv #Constant pressure heat capacity in kJ/kg
S21 = m*cp*math.log(V2/V1) # Entropy change
print "\n Example 10.7"
print "\n Cv of the gas is ",cv ," kJ/kg K"
print "\n Cp of the gas is ",cp ," kJ/kg K"
print "\n Increase in the entropy of the gas is ",S21 ," kJ/kg K"
#The answers vary due to round off error
 Example 10.7

 Cv of the gas is  0.661000944287  kJ/kg K

 Cp of the gas is  0.89896128423  kJ/kg K

 Increase in the entropy of the gas is  0.080159241414  kJ/kg K

Ex10.8:pg-374

In [15]:
import math
mn = 3.0 # Mass of nitrogen in kg
mc = 5.0 # mass of CO2 in kg
an = 28.0 # Atomic weight of nitrogen
ac = 44.0 # Atomic weight of CO2
# Part (a)
xn = (mn/an)/((mn/an)+(mc/ac)) # mole fraction of nitrogen
xc = (mc/ac)/((mn/an)+(mc/ac)) # mole fraction of carbon

print "\n Example 10.8"
print "\n\n Mole fraction of N2 is ",xn 
print "\n Mole fraction of CO2  is ",xc
#The answers vary due to round off error

# Part (b)
M = xn*an+xc*ac # Equivalent molecular weight
print "\n Equivalent molecular weight of mixture is ",M ,"kg/kg mol" 

# Part (c)
R = 8.314 # Gas constant
Req = ((mn*R/an)+(mc*R/ac))/(mn+mc)
print "\n\n The equivalent gas constant of the mixture is ",Req ," kJ/kg K" 

# Part (d)
P = 300.0 # Initial pressure in kPa
T = 20.0 # Initial temperature in degree Celsius
Pn = xn*P # Partial pressure of Nitrogen
Pc = xc*P # Partial pressure of CO2 
Vn = (mn*R*(T+273))/(P*an) # Volume of nitrogen
Vc = (mc*R*(T+273))/(P*ac) # Volume of CO2
print "\n\n Partial pressures of nitrogen and CO2 are \n ",Pn ," kPa and ",Pc ," kPa respectively"
print "\n Partial volume of nitrogen and CO2 are \n ",Vn ," kPa and ",Vc ," kPa respectively"
# Part (e)
V = (mn+mc)*Req*(T+273)/P # Total volume
rho = (mn+mc)/V # mass density
print "\n\n Total volume of mixture is ",V ," m**3" 
print "\n Density of mixture is ",rho ," kg/m**3" 

# Part (f)
gn = 1.4 # Heat capacity ratio for nitrogen
gc = 1.286 # Heat capacity ratio for carbon dioxide 
cvn = R/((gn-1)*an) # cp and cv of N2
cpn = gn*cvn  # Constant pressure heat capacity of nitrogen
cvc = R/((gc-1)*ac) # cp and cv of CO2
cpc = gc*cvc# COnstant pressure heat capacity of carbon dioxide 
cp = (mn*cpn+mc*cpc)/(mn+mc)  # Constant pressure heat capacity ratio of mixture
cv = (mn*cvn+mc*cvc)/(mn+mc) # Constant volume Heat capacity ratio of mixture
print "\n\n Cp and Cv of mixture are \n ",cp ,"kJ/kg K and ",cv ,"kJ/kg K respectively" 
T1 = T 
T2 = 40 
U21 = (mn+mc)*cv*(T2-T1)
H21 = (mn+mc)*cp*(T2-T1)
S21v = (mn+mc)*cv*math.log((T2+273)/(T1+273)) # If heated at constant volume
S21p = (mn+mc)*cp*math.log((T2+273)/(T1+273)) # If heated at constant Pressure

print "\n\n Change in internal energy of the system heated at constant volume  is ",U21 ,"kJ" 
print "\n Change in enthalpy of the system heated at constant volume  is ",H21 ,"kJ" 
print "\n Change in entropy of the system heated at constant volume  is ",S21v ," kJ/kg K"
print "\n\n Change in entropy of the system heated at constant Pressure  is ",S21p ,"kJ/kgK" 

#The answers vary due to round off error
 Example 10.8


 Mole fraction of N2 is  0.485294117647

 Mole fraction of CO2  is  0.514705882353

 Equivalent molecular weight of mixture is  36.2352941176 kg/kg mol


 The equivalent gas constant of the mixture is  0.229444805195  kJ/kg K


 Partial pressures of nitrogen and CO2 are 
  145.588235294  kPa and  154.411764706  kPa respectively

 Partial volume of nitrogen and CO2 are 
  0.870000714286  kPa and  0.922728030303  kPa respectively


 Total volume of mixture is  1.79272874459  m**3

 Density of mixture is  4.46247098126  kg/m**3


 Cp and Cv of mixture are 
  0.920740483948 kJ/kg K and  0.691295678753 kJ/kg K respectively


 Change in internal energy of the system heated at constant volume  is  110.6073086 kJ

 Change in enthalpy of the system heated at constant volume  is  147.318477432 kJ

 Change in entropy of the system heated at constant volume  is  0.36517324538  kJ/kg K


 Change in entropy of the system heated at constant Pressure  is  0.486376236695 kJ/kgK

Ex10.9:pg-375

In [16]:
import math
mo = 2.0 # mass of oxygen in kg
mn = 6.0 # mass of nitrogen in kg
muo = 32.0 # molecular mass of oxygen
mun = 28.0 # molecular mass of nitrogen
o = mo/muo # mass fraction of oxygen
n = mn/mun # mass fraction of nitrogen
xo = o/(n+o) # mole fraction of oxygen
xn = n/(n+o) # mole fraction of nitrogen
R = 8.314 # Universal gas constant
Ro = R/muo # Gas constant for oxygen
Rn = R/mun # Gas constant for nitrogen
dS = -mo*Ro*math.log(xo)-mn*Rn*math.log(xn) # Increase in entropy 

print "\n Example 10.9"
print "\n Increase in entropy is ",dS ," kJ/kg K"
#The answers vary due to round off error
 Example 10.9

 Increase in entropy is  1.22920562691  kJ/kg K

Ex10.10:pg-376

In [9]:
import math
an = 20.183 # molecular weight of neon
Pc = 2.73 # Critical pressure
Tc = 44.5 # Critical tmperature in Kelvin
Vc = 0.0416 # volume of gas in m**3
Pr = 2 # Reduced Pressure
Tr = 1.3 # Reduced temperature
Z = 0.7 # Compressibility factor
P = Pr*Pc # Corresponding Pressure 
T = Tr*Tc # Corresponding temperature
R = 8.314 # Gas constant
v = (Z*R*T)/(P*an) # Corresponding volume
vr = (v*an)/(Vc*1e3)  # reduced volume

print "\n Example 10.10"
print "\n Specific volume is ",v ," *10**-3 m3/kg"
print "\n Specific temperature is ",T ," K"
print "\n Specific pressure is ",P ," MPa"
print "\n Reduced volume is ",vr ," m3/kg"
#The answers vary due to round off error
 Example 10.10

 Specific volume is  3.05515367719  *10**-3 m3/kg

 Specific temperature is  57.85  K

 Specific pressure is  5.46  MPa

 Reduced volume is  1.48226362179  m3/kg