Chapter 9 : Ideal Gas and Ideal Gas Mixtures

Example 9.1 Page No : 253

In [1]:
			
# Variables
m = 6. 			#kg 			#mass of nitrogen
M = 28. 			#kg/kmol 			#molar mass of nitrogen
R = 8314.3 			#kg/kmol
p = 1e5 			#Pa 			#pressure
T = 27.+273 			#K 			#temperature
			
# Calculations and Results
V = m*R*T/(p*M)
print "Volume occupied by nitrogen = %.3f m**3"%(V)
Volume occupied by nitrogen = 5.345 m**3

Example 9.2 Page No : 253

In [2]:
			
# Variables
p1 = 10. 			#bar 			#inital pressure
T1 = 273.+227 			#K 			#inital temperature
v1 = 0.01 			#m**3 			#initial volume
p2 = 1. 			#bar 			#final pressure
T2 = 273.+27 			#K 			#final temperature
			
# Calculations and Results
v2 = (p1/p2)*(T2/T1)*v1 			#m**3 			#final volume
print "Final volume = %.2f m**3"%(v2)
Final volume = 0.06 m**3

Example 9.3 Page No : 255

In [3]:
			
# Variables
p = 1. 			#bar 			#pressure
T = 50.+273 			#°C 			#temperature
h = 324.6 			#kJ/kg 			#enthalpy
R = 8.3143 			#kJ/kmolK
M = 28.97 			#kg/kmol

#Part (a)
print "Part a";
u = h - (R/M)*T 			#kJ/kg 			#internal energy
print "Internal energy = %.1f kJ/kg"%(u)

#Part (b)
print "Part b:i";
u = h - (R/M)*T 			#kJ/kg 			#internal energy
print "Enthalpy = %.1f kJ/kg"%(h)
print "Internal energy = %.1f kJ/kg"%(u)
print "Part b:ii";
u = h - (R/M)*T 			#kJ/kg 			#internal energy
print "Enthalpy = %.1f kJ/kg"%(h)
print "Internal energy = %.1f kJ/kg"%(u)
Part a
Internal energy = 231.9 kJ/kg
Part b:i
Enthalpy = 324.6 kJ/kg
Internal energy = 231.9 kJ/kg
Part b:ii
Enthalpy = 324.6 kJ/kg
Internal energy = 231.9 kJ/kg

Example 9.4 Page No : 256

In [1]:
			
# Variables
Cv = 718 			#J/kgK 			#specific at constant volume
M = 28.97 			#kg/kmol 			#molar mass of air
R = 8314.3 			#J/kmolK
			
# Calculations and Results
Cp = (R/M)+Cv 			#J/kgK 			#specific heat at constant pressure
print "Specific heat at constant pressure = %.0f J/kg K"%(Cp)
Specific heat at constant pressure = 1005 J/kg K

Example 9.5 Page No : 258

In [5]:
import math 
from scipy.integrate import quad 
			
# Variables
p1 = 1. 			#bar 			#initial pressure
T1 = 27.+273 			#K 			#initial temperature
p2 = 10. 			#bar 			#final pressure
T2 = 327.+273 			#K 			#final temperature
			
# Calculations and Results
#Part(a)
print "Part a";

def f2(T): 
	 return 1.4-18.3*(T/100)**(-1.5)+38.3*(T/100)**(-2)-29.3*(T/100)**(-3)

delta_h =  quad(f2,T1,T2)[0]

print "Increase in specific enthalpy = %.2f kJ/kg"%(delta_h)

#Part(b)
print "Part b";

def f3(T): 
	 return 1.042

delta_h =  quad(f3,T1,T2)[0]

print "Increase in specific enthalpy at Cp = 1.042 kJ/kgK) = %.2f kJ/kg"%(delta_h)
Part a
Increase in specific enthalpy = 317.34 kJ/kg
Part b
Increase in specific enthalpy at Cp = 1.042 kJ/kgK) = 312.60 kJ/kg

Example 9.6 Page No : 268

In [1]:
%matplotlib inline

from numpy import *
from matplotlib.pyplot import *
import math 
			
# Variables
Cp = 1005. 			#J/kgK 			#specific heat at constant pressure
Cv = 718. 			#J/kgK 			#specific heat at constant volume
m = 1. 			#kg 			#mass of air
T1 = (27.+273) 			#K 			#initial temperature
p1 = 1e5 			#Pa 			#initial pressure
p2 = p1/2. 			#Pa 			#final pressure

			
# Calculations and Results
#Part(a)
print "Parta";
R = Cp-Cv 			#J/kgK
V1_a = m*R*T1/p1 			#m**3 			#initial volume
V2_a = V1_a 			#m**3 			#final volume
T2 = p2*V2_a/(m*R) 			#K 			#final temperature
print "Final temperature,T2 = %.1f K"%(T2)

#Part(b)
print "Partb";
V1_b = m*R*T1/p1 			#m**3 			#initial volume
V2_b = V1_b*(p1/p2) 			#m**3 			#final volume
#Isothermal process => T1 = T2
print "Final temperature,T2 = %.1f K"%(T1)

#Part(c)
print "Partc";
R = Cp-Cv 			#J/kgK
y = Cp/Cv
V1_c = m*R*T1/p1 			#m**3 			#initial volume
V2_c = V1_c*(p1/p2)**(1/y) 			#m**3 			#final volume
T2 = p2*V2_c/(m*R) 			#K 			#final temperature
print "Final temperature,T2 = %.0f K"%(T2)

#P-V diagram
P = [p1*1e-5, p2*1e-5]
V = [V1_a ,V1_a]
plot(V,P,'b')       			#plot for part(a)

V = linspace(V1_b,V2_b,100)
P = (p1*1e-5*V1_b)/V
plot(V,P,'g')      			#plot for part(b)

V = linspace(V1_c,V2_c,100)
P = (p1*1e-5*V1_c**y)/V**y
plot(V,P,'r')     			#plot for part(c)
xlabel('Volume in m**3')
ylabel('Pressure in bar')
suptitle('p-V diagram sought in example 9.6')
#legends(['Part (a)';'Part (b)';'Part (c)'],[2 3 5],opt=1)
Parta
Final temperature,T2 = 150.0 K
Partb
Final temperature,T2 = 300.0 K
Partc
Final temperature,T2 = 246 K
Out[1]:
<matplotlib.text.Text at 0x1100b2a90>

Example 9.7 Page No : 270

In [10]:
import math 
from numpy.linalg import solve
			
# Variables
p1 = 10e6 			#N/m**2 			#initial pressure
T1 = 273.+27 			#K 			#inital temperature
V1 = 50.e-3 			#m**3 			#inital volume
M = 28. 			#g/mol 			#molecular mass
R = 8314.3/M 			#J/kgK
y = 1.4 			#gamma

			
# Calculations and Results
#Part(a)
print 'Parta';
m = (p1*V1)/(R*T1)
print "Mass of nitrogen stored in bottle = %.3f kg"%(m)

#Part(b):(i)
print 'Partb:i';
p2 = 15e6 			#N/m**2 			#final pressure
V2 = V1 			#m**3 			#final volume
T2 = (p2*V2)/(m*R)
print "Temperature of nitrogen at maximum permitted temperature = %.1f K"%(T2)

#Part(b):(ii)
print 'Partb:ii';
C = solve([[1, -1.4],[1, -1]],[[0],[R]]) 			#J/kgK 			#C = [Cp;Cv]
delta_U = m*C[1]*(T2-T1)*.001 			#kJ 			#Change in internal energy
print "Change in internal energy = %.1f kJ"%(delta_U)

#Part(b):(iii)
print 'Partb:iii';
delta_H = m*C[0]*(T2-T1)*.001 			#kJ 			#Change in enthalpy
print "Change in enthalpy = %.1f kJ"%(delta_H)

#Part(b):(iv)
print 'Partb:iv';
delta_S = m*(C[1]*math.log(T2/T1)+R*math.log(V2/V1))*.001 			#kJ/K 			#Change in entropy
print "Change in entropy = %.4f kJ/K"%(delta_S)
Parta
Mass of nitrogen stored in bottle = 5.613 kg
Partb:i
Temperature of nitrogen at maximum permitted temperature = 450.0 K
Partb:ii
Change in internal energy = 625.0 kJ
Partb:iii
Change in enthalpy = 875.0 kJ
Partb:iv
Change in entropy = 1.6894 kJ/K

Example 9.8 Page No : 271

In [11]:
import math 

			
# Variables
T1 = 800. 			#K 			#initial temperature
p1 = 1.5e6 			#N/m**2 			#initial pressure
T2 = 540. 			#K 			#final temperature
T2s = 485. 			#K 			#final temperature for reversible process
Q = 0. 			#adiabatic process
y = 1.4
Cv = 718. 			#J/kgK 			#specific heat at constant volume

			
# Calculations and Results
delta_U = Cv*(T2-T1) 			#kJ/kg 			#change in internal energy
W = (Q-delta_U)*.001 			#kJ/kg 			#work done per kilogram
print "Work done per kilogram = %.1f kJ/kg"%(W);

p2 = p1*(T2s/T1)**(y/(y-1)) 			#N/m**2 			#final pressure
delta_S = (y*Cv)*math.log(T2/T1)-(y*Cv-Cv)*math.log(p2/p1)
print "Change in entropy = %.3f kJ/kgK"%(delta_S*.001)
Work done per kilogram = 186.7 kJ/kg
Change in entropy = 0.108 kJ/kgK

Example 9.9 Page No : 279

In [12]:
import math 
			
# Variables
xCO2 = 0.1 			#mole fraction of CO2
xO2 = .09 			#mole fraction of O2
xCO = 0.01 			#mole fraction of CO
xN2 = 0.8 			#mole fraction of N2

			
# Calculations and Results
M = xCO2*44 + xO2*32 + xCO*28 + xN2*28 			#kg/kmol 			#avg. molar mass
R = 8314.3/M 			#J/kgK 			#gas constant
yCO2 = xCO2*(44/M) 			#mass fraction of CO2
yO2 = xO2*(32/M) 			#mass fraction of O2
yCO = xCO*(28/M) 			#mass fraction of CO
yN2 = xN2*(28/M) 			#mass fraction of N2

print "Molar Mass = %.2f kg/kmol"%(M);
print "Gas constant = %.1f J/kgK"%(R);
print "Mass fraction of CO2 = %.4f "%(yCO2);
print "Mass fraction of O2 = %.4f "%(yO2);
print "Mass fraction of CO = %.4f "%(yCO);
print "Mass fraction of N2 = %.4f "%(yN2);
Molar Mass = 29.96 kg/kmol
Gas constant = 277.5 J/kgK
Mass fraction of CO2 = 0.1469 
Mass fraction of O2 = 0.0961 
Mass fraction of CO = 0.0093 
Mass fraction of N2 = 0.7477 

Example 9.10 Page No : 280

In [2]:
import math 

# variables
m = 1.9 			#kg
T = 273.+20 			#K
p = 150.e3 			#Pa
yO2 = 0.1 			#mass fraction of O2
yN2 = 0.75 			#mass fraction of N2
yCO2 = 0.12 			#mass fraction of CO2
yCO = 0.03 			#mass fraction of CO

			
# Calculations and Results
#Part(a)
print "Parta";
M = 1/((yO2/32)+(yN2/28)+(yCO/28)+(yCO2/44)) 			#kg/kmol 			#molar mass
print "Molar mass = %.2f kg/kmol "%(M)
R = 8314.3/M 			#J/kgK 			#Gas constant
print "Gas constant = %.2f J/kgK "%(R)
V = m*R*T/p 			#m**3 			#Volume

#Part(b)
print "Partb"
xO2 = yO2*(M/32) 			#mole fraction O2
print "Mole fraction of O2 = %.3f"%(xO2)
pO2 = xO2*p 			#partial pressure O2
print "Partial pressure of O2 = %.2f kPa"%(pO2*.001)
VO2 = xO2*V 			#partial volume of O2
print "Partial volume of O2 = %.4f m**3"%(VO2)


xN2 = yN2*(M/28) 			#mole fraction N2
print "Mole fraction of N2 = %.3f"%(xN2)
pN2 = xN2*p 			#partial pressure N2
print "Partial pressure of N2 = %.2f kPa"%(pN2*.001)
VN2 = xN2*V 			#partial volume of N2
print "Partial volume of N2 = %.4f m**3"%(VN2)


xCO2 = yCO2*(M/44) 			#mole fraction CO2
print "Mole fraction of CO2 = %.3f"%(xCO2)
pCO2 = xCO2*p 			#partial pressure CO2
print "Partial pressure of CO2 = %.2f kPa"%(pCO2*.001)
VCO2 = xCO2*V 			#partial volume of CO2
print "Partial volume of CO2 = %.4f m**3"%(VCO2)


xCO = yCO*(M/28) 			#mole fraction CO
print "Mole fraction of CO = %.3f"%(xCO)
pCO = xCO*p 			#partial pressure CO
print "Partial pressure of CO = %.2f kPa"%(pCO*.001)
VCO = xCO*V 			#partial volume of CO
print "Partial volume of CO = %.4f m**3"%(VCO)

# note : rounding off error
Parta
Molar mass = 29.67 kg/kmol 
Gas constant = 280.27 J/kgK 
Partb
Mole fraction of O2 = 0.093
Partial pressure of O2 = 13.91 kPa
Partial volume of O2 = 0.0964 m**3
Mole fraction of N2 = 0.795
Partial pressure of N2 = 119.19 kPa
Partial volume of N2 = 0.8265 m**3
Mole fraction of CO2 = 0.081
Partial pressure of CO2 = 12.14 kPa
Partial volume of CO2 = 0.0842 m**3
Mole fraction of CO = 0.032
Partial pressure of CO = 4.77 kPa
Partial volume of CO = 0.0331 m**3

Example 9.11 Page No : 283

In [10]:
import math 
from numpy.linalg import solve
			
# Variables
R = 1841. 			#J/kgK 			#Gas constant
Cp = 6310. 			#J/kgK 			#specific heat at constant pressure
MN = 28. 			#kg/kmol 			#molar mass N2
MH = 2. 			#kg/kmol 			#molar mass H2
CpN = 1042. 			#J/kgK 			#specific heat of N2
CpH = 14210. 			#J/kgK 			#specific heat of H2

			
# Calculations and Results
Y = solve([[8314.3/MN, 8314.3/MH],[CpN, CpH]],[[R],[ Cp]])
YN = round(Y[0],1) 			#mass fraction of N2
YH = round(Y[1],1) 			#mass fraction of H2
XN = YN*(8314.3/(R*MN)) 			#volume fraction of N2
XH = YH*(8314.3/(R*MH)) 			#volume fraction of H2
print "Mass fraction of N2 = %.1f "%(YN)
print "Mass fraction of H2 = %.1f "%(YH)
print "Volume fraction of N2 = %.4f "%(XN)
print "Volume fraction of H2 = %.4f "%(XH)

# note : rounding off error
Mass fraction of N2 = 0.6 
Mass fraction of H2 = 0.4 
Volume fraction of N2 = 0.0968 
Volume fraction of H2 = 0.9032 

Example 9.12 Page No : 284

In [15]:
import math 
			
# Variables
m = 1.9 			#kg
T = 273.+20 			#K
p = 150. 			#kPa
pdat = 100. 			#kPa 			#datum pressure
Tdat = 273. 			#K 			#datum temperature
yO2 = 0.1 			#mass fraction of O2
yN2 = 0.75 			#mass fraction of N2
yCO2 = 0.12 			#mass fraction of CO2
yCO = 0.03 			#mass fraction of CO
xO2 = 0.093 			#mole fraction of O2
xN2 = 0.795 			#mole fraction of N2
xCO2 = 0.081 			#mole fraction of CO2
xCO = 0.031 			#mole fraction of CO
R = 280.22 			#J/kgK
M = 29.67 			#kg/kmol 			#mixture molar mass
CpO2=0.922 			#kJ/kgK
CpN2=1.042 			#kJ/kgK
CpCO2=0.842 			#kJ/kgK
CpCO=1.041 			#kJ/kgK

#Part(a)
print "Parta";
Cp = yN2*CpN2 + yO2*CpO2 + yCO2*CpCO2 + yCO*CpCO 			#kJ/kgK 			# specific heat of mixture at constant pressure
Cv = Cp - R*.001 			#specific heat of mixture at constant volume
print "Cp = %.3f kJ/kgK"%(Cp)
print "Cv = %.4f kJ/kgK"%(Cv) 

#Part(b)
print "Partb";
U = m*(Cv*(T-Tdat)) 			#kJ 			#internal energy
print "Internal energy = %.2f kJ"%(U)

#Part(c)
print "Partc"
H = U + m*R*T*.001 			#kJ 			#enthalpy
print "Enthalpy = %.1f kJ"%(H)

#Part(d)
print "Partd"
SO2 = CpO2*math.log(T/Tdat)-(8.3143/32)*math.log(xO2*(p/pdat)) 			#kJ/kgK 			#entropy of O2
SN2 = CpN2*math.log(T/Tdat)-(8.3143/28)*math.log(xN2*(p/pdat)) 			#kJ/kgK 			#entropy of N2
SCO2 = CpCO2*math.log(T/Tdat)-(8.3143/44)*math.log(xCO2*(p/pdat)) 			#kJ/kgK 			#entropy of CO2
SCO = CpCO*math.log(T/Tdat)-(8.3143/28)*math.log(xCO*(p/pdat)) 			#kJ/kgK 			#entropy of CO

S = m*(yO2*SO2+yN2*SN2+yCO2*SCO2+yCO*SCO) 			#kJ/K 			#entropy
print "Entropy = %.4f kJ/K"%(S)
Parta
Cp = 1.006 kJ/kgK
Cv = 0.7258 kJ/kgK
Partb
Internal energy = 27.58 kJ
Partc
Enthalpy = 183.6 kJ
Partd
Entropy = 0.3006 kJ/K

Example 9.13 Page No : 288

In [16]:
import math 
			
# Variables
V_He = 0.3 			#m**3 			#volume of Helium
p_He = 20e5 			#Pa 			#pressure of Helium
T_He = 273.+30 			#K 			#Temperature of Helium
V_O2 = 0.7 			#m**3 			#volume of O2
p_O2 = 6e5 			#Pa 			#pressure of O2
T_O2 = 273.+2 			#K Temperature of O2
R_He = 2077. 			#J/kgK
R_O2 = 260. 			#J/kgK
Cv_He = 3116. 			#J/kgK
Cv_O2 = 662. 			#J/kgK
			
# Calculations and Results
m_He = (p_He*V_He)/(R_He*T_He) 			#kg 			#mass of Helium
m_O2 = (p_O2*V_O2)/(R_O2*T_O2) 			#kg 			#mass of O2
T_ad = (m_He*Cv_He*T_He+m_O2*Cv_O2*T_O2)/(m_He*Cv_He+m_O2*Cv_O2) 			#K 			#Temperature after mixing
T_final = 300 			#K 			#final temperature
Q = (Cv_He*m_He+Cv_O2*m_O2)*(T_final-T_ad) 			#J 			#Magnitude of heat transfer
print "Magnitude of heat transfer = %.2f kJ"%(Q*.001)
Magnitude of heat transfer = 88.30 kJ

Example 9.14 Page No : 289

In [11]:
import math 
			
# Variables
T_E = (273.+20) 			#K 			#temperature of ethane
p_E = 200. 			#kPa 			#pressure of ethane
T_M = 273.+45 			#K 			#temperature of methane
p_M = 200. 			#kPa 			#pressure of methane
m_E = 9. 			#kg/s 			#mass rate of ethane
m_M = 4.5 			#kg/s 			#mass rate of methane
Cp_E = 1766. 			#J/kgK 			#specific heat of ethane
Cp_M = 2254. 			#J/kgK 			#specific heat of methane

			
# Calculations and Results
#Part(a)
print "Parta";
T = (m_E*Cp_E*T_E+m_M*Cp_M*T_M)/(m_E*Cp_E+m_M*Cp_M) 			#K 			#mixture temperature
print "Mixture temperature = %.1f K"%(T)

#Part(b)
print "Partb";
R_E = 8314.3/30 			#J/kgK 			#gas constant for ethane
R_M = 8314.3/16 			#J/kgK 			#gas constant for methane
R = (m_E/(m_E+m_M))*R_E+(m_M/(m_E+m_M))*R_M 			#J/kgK 			#gas constant of mixture
M = 8314.3/R 			#kg/kmol 			#mixture molar mass
x_E = (m_E/(m_E+m_M))*(M/30) 			#mole fraction of ethane
x_M = (m_M/(m_E+m_M))*(M/16) 			#mole fraction of methane

delta_S_E = Cp_E*math.log(T/T_E) - R_E*math.log(x_E) 			#J/kgK 			#change in entropy of ethane
delta_S_M = Cp_M*math.log(T/T_M) - R_M*math.log(x_M) 			#J/kgK 			#change in entropy of methane

print "Rate of entropy production = %.4f kJ/sK"%((m_E*delta_S_E+m_M*delta_S_M)*.001)

# note : rounding off error
Parta
Mixture temperature = 302.7 K
Partb
Rate of entropy production = 3.3681 kJ/sK