Chapter 7 : Mixtures of Ideal Gases

Example 7.1 Page No : 322

In [2]:
#As the basis of the calculation,assume that we have 1 lbm of mixture.Also,take the molecular weight of oxygen to be 32.00 and nitrogen to be 28.02.(from table7.1)
print "Solution for a";
nO2 = 0.2315/32; 			#no of moles of oxygen = ratio of mass and molecular weight 			#0.2315 lb of oxygen per pound
print "The moles of oxygen is %.2f mole/lbm of mixture"%(nO2);
nN2 = 0.7685/28.02; 			#no of moles of nitrogen = ratio of mass and molecular weight 			#0.7685 lb of nitrogen per pound
print "The moles of nitrogen is %.2f mole/lbm of mixture"%(nN2);
nm = nO2+nN2; 			#Unit:Mole/lbm 			#number of moles of gas mixture is sum of the moles of its constituent gases
print "The total number of moles is %.2f mole/lbm"%(nm); 
xO2 = nO2/nm; 			#mole fraction of oxygen = ratio of no of moles of oxygen and total moles in mixture
xN2 = nN2/nm; 			#mole fraction of nitrogen = ratio of no of moles of oxygen and total moles in mixture
print "The mole fraction of oxygen is %.2f and the mole fraction of nitrogen is %.2f"%(xO2,xN2);
#(Check:xO2+xN2 = 1)
print "xO2+xN2 = %.2f"%(xO2+xN2);

print "Solution for b";
# the air is at 14.7 psia
pO2 = xO2*14.7; 			#the partial pressure of oxygen = pressure of air * the mole fraction of oxygen 			#psia
print "The partial pressure of oxygen is %.2f psia"%(pO2);
pN2 = xN2*14.7; 			#the partial pressure of nitrogen = pressure of air * the mole fraction of nitrogen 			#psia
print "The partial pressure of nitrogen is %.2f psia"%(pN2);

print "Solution for c";
MWm = (xO2*32) + (xN2*28.02); 			#the molecular weight of air = sum of products of mole fraction of each gas component
print "The molecular weight of air is %.2f"%(MWm);

print "Solution for d";
Rm = 1545/MWm; 			#the gas constant of air
print "The gas constant of air is %.2f"%(Rm);
Solution for a
The moles of oxygen is 0.01 mole/lbm of mixture
The moles of nitrogen is 0.03 mole/lbm of mixture
The total number of moles is 0.03 mole/lbm
The mole fraction of oxygen is 0.21 and the mole fraction of nitrogen is 0.79
xO2+xN2 = 1.00
Solution for b
The partial pressure of oxygen is 3.07 psia
The partial pressure of nitrogen is 11.63 psia
Solution for c
The molecular weight of air is 28.85
Solution for d
The gas constant of air is 53.55

Example 7.2 Page No : 323

In [6]:
#For Gaseous Freon-12 (CCl2F2)
#MW of air = 29 & MW of freon-12 = 120.9
#initial pressure in math.tank is atmospheric pressure that is 14.7 psia
#final pressure of math.tank is 1000 psia
#The partial pressure of the Freon-12 is 1000-14.7
print "The partial pressure of the Freon-12 is %.2f"%(1000-14.7)
#the mole fraction of air = the initial pressure / final pressure
print "The mole fraction of air is %.2f"%(14.7/1000)
#the mole fraction of freon = the partial pressure of freon / the final pressure
print "The mole fraction of Freon-12 is %.2f"%((1000-14.7)/1000)
MWm = ((14.7/1000)*29) + (((1000-14.7)/1000)*120.9);			#the molecular weight of mixture = sum of products of mole fraction of each gas component 
print "The molecular weight of the mixture is %.2f"%(MWm);
The partial pressure of the Freon-12 is 985.30
The mole fraction of air is 0.01
The mole fraction of Freon-12 is 0.99
The molecular weight of the mixture is 119.55

Example 7.3 Page No : 323

In [7]:
#Ten pounds of air,1 lb of carbon dioxide,and 5 lb of nitrogen are mixed at constant temperature until the mixture pressure is constant
nair = 10./29; 			#no of moles of air = ratio of mass and molecular weight 			#10 lb of nitrogen per pound 			#molecular weight of air = 29
print "The moles of air is %.2f mole/lbm of mixture"%(nair);
nCO2 = 1./44; 			#no of moles of carbon dioxide = ratio of mass and molecular weight 			#1 lb of per pound 			#molecular weight of CO2 = 44
print "The moles of carbon dioxide is %.2f mole/lbm of mixture"%(nCO2);
nN2 = 5./28; 			#no of moles of nitrogen = ratio of mass and molecular weight 			#5 lb of nitrogen per pound 			#molecular weight of N2 = 28
print "The moles of nitrogen is %.2f mole/lbm of mixture"%(nN2);
nm = nair+nCO2+nN2; 			#Unit:Mole/lbm 			#number of moles of gas mixture is sum of the moles of its constituent gases
print "The total number of moles is %.2f mole/lbm"%(nm); 

xair = nair/nm 			#mole fraction of air = ratio of no of moles of air and total moles in mixture
xCO2 = nCO2/nm; 			#mole fraction of carbon dioxide = ratio of no of moles of carbon dioxide and total moles in mixture
xN2 = nN2/nm; 			#mole fraction of nitrogen = ratio of no of moles of oxygen and total moles in mixture
print "The mole fraction of air is %.2f "%(xair);
print "The mole fraction of carbon dioxide is %.2f"%(xCO2)
print "The mole fraction of nitrogen is %.2f"%(xN2);

#final pressure of is 100 psia
pair = xair*100; 			#the partial pressure of air =  final pressure * the mole fraction of air 			#psia
print "The partial pressure of air is %.2f psia"%(pair);
pCO2 = xCO2*100; 			#the partial pressure of carbon dioxide =  final pressure * the mole fraction of CO2 			#psia
print "The partial pressure of carbon dioxide is %.2f psia"%(pCO2);
pN2 = xN2*100; 			#the partial pressure of nitrogen = final pressure * the mole fraction of nitrogen 			#psia
print "The partial pressure of nitrogen is %.2f psia"%(pN2);

#the molecular weight of mixture = sum of products of mole fraction of each gas component
MWm = (xair*29) + (xCO2*44) + (xN2*28); 			#The molecular weight of air 
print "The molecular weight of air is %.2f"%(MWm);

Rm = 1545/MWm; 			#the gas constant of air
print "The gas constant of air is %.2f"%(Rm);
The moles of air is 0.34 mole/lbm of mixture
The moles of carbon dioxide is 0.02 mole/lbm of mixture
The moles of nitrogen is 0.18 mole/lbm of mixture
The total number of moles is 0.55 mole/lbm
The mole fraction of air is 0.63 
The mole fraction of carbon dioxide is 0.04
The mole fraction of nitrogen is 0.33
The partial pressure of air is 63.14 psia
The partial pressure of carbon dioxide is 4.16 psia
The partial pressure of nitrogen is 32.70 psia
The molecular weight of air is 29.30
The gas constant of air is 52.74

Example 7.4 Page No : 325

In [13]:
#five moles of oxygen and 10 moles of hydrogen are mixed
#The total number of moles is 10+5 = 15.Therefore,mole fraction of each constituent is
xO2 = 5./15; 			#The mole fraction of oxygen 
xH2 = 10./15; 			#The mole fraction of hydrogen
print "The mole fraction of oxygen is %.2f and of hydrogen is %.2f"%(xO2,xH2);
#the molecular weight of mixture = sum of products of mole fraction of each gas component(MW of O2 = 32 and MW of H2 = 2.016)
print "The molecular weight of the final mixture is %.2f"%((((5./15)*32)+10./15)*2.016)
R = 1545./32; 			#the gas constant of oxygen
T = 460.+70; 			#absolute temperature 			#Unit:R
p = 14.7; 			#pressure 			#psia
#The partial volume of the oxygen can be found as follows:per pound of oxygen,
#p*vO2 = R*T;
vO2 = (R*T)/(p*144); 			#ft**3/lbm 			#1 in**2 = 144 ft**2  
#Because there are 5 moles of oxygen,each containing 32 lbm,
VO2 = vO2*5*32; 			#ft**3 			#partial volume of oxygen
print "The partial volume of oxygen is %.2f ft**3"%(VO2);
#For the hydrogen,we can simplify the procedure by noting that the fraction of the total volume occupied by the oxygen is the same as its mole fraction.Therefore,
Vm = 3*VO2; 			#total volume occupied 			#ft**3
print "The mixture volume is %.2f ft**3"%(Vm);
#and the hydrogen volume
VH2 = Vm-VO2; 			#Ft**2 			#partial volume of hydrogen
print "From simplified procedure, The partial volume of hydrogen is %.2f ft**3"%(VH2);

#We could obtain the partial volume of hydrogen by proceeding as we did for the oxygen.Thus,
#p*vH2 = R*T;
R = 1545/2.016; 			#the gas constant of hydrogen
vH2 = (R*T)/(p*144); 			#ft**3/lbm 			#1 in**2 = 144 ft**2  
#Because there are 10 moles of hydrogen,each containing 2.016 lbm,
VH2 = vH2*10*2.016; 			#ft**3 			#partial volume of hydrogen
print "The partial volume of hydrogen is %.2f ft**3"%(VH2);
#Which checks our previous values.


print "From another method"
#As an alternative to the foregoing,we could also use the fact that at 14.7 psia and 32F a mole of any gas occupies a volume of 358 ft**3.
print "At 70F and 14.7 psia, a mole occupies %.2f ft**3"%((((358*460+70.)/460+32))); 
#Therefore, 5 moles of oxygen occupies 
VO2 = 5*358*((460+70.)/(460+32)); 			#The partial volume of oxygen 			#ft**3
print "The partial volume of oxygen is %.2f ft**3"%(VO2);
#and 10 moles of hydrogen occupies
VH2 = 10*358*((460+70.)/(460+32)); 			#The partial volume of hydrogen 			#ft**3
print "The partial volume of hydrogen is %.2f ft**3"%(VH2);
#Both values are in good agreement with the previous calculations.
The mole fraction of oxygen is 0.33 and of hydrogen is 0.67
The molecular weight of the final mixture is 22.85
The partial volume of oxygen is 1934.17 ft**3
The mixture volume is 5802.51 ft**3
From simplified procedure, The partial volume of hydrogen is 3868.34 ft**3
The partial volume of hydrogen is 3868.34 ft**3
From another method
At 70F and 14.7 psia, a mole occupies 390.15 ft**3
The partial volume of oxygen is 1928.25 ft**3
The partial volume of hydrogen is 3856.50 ft**3

Example 7.5 Page No : 326

In [15]:
#Referring to figure 7.3,we have for CO2,
nCO2 = 10./44; 			#mole 			#no of moles of carbon dioxide = ratio of mass and molecular weight 			#10 lb of per pound 			#molecular weight of CO2 = 44
#and for N2,
nN2 = 5/28.02; 			#mole 			#no of moles of nitrogen = ratio of mass and molecular weight 			#5 lb of nitrogen per pound
print "The total number of moles in the mixture is %.2f mole"%(nCO2+nN2);
#Therefore,
xCO2 = nCO2/(nCO2+nN2); 			#mole fraction of carbon dioxide = ratio of no of moles of carbon dioxide and total moles in mixture
xN2 = nN2/(nCO2+nN2); 			#mole fraction of nitrogen = ratio of no of moles of oxygen and total moles in mixture
print "The mole fraction of carbon dioxide is %.2f and the mole fraction of nitrogen is %.2f"%(xCO2,xN2);
#the molecular weight of mixture = sum of products of mole fraction of each gas component
MWm = (xCO2*44) + (xN2*28.02); 			#the molecular weight of mixture
print "The molecular weight of air is %.2f"%(MWm);
#Because the mixture is 15 lbm (10CO2 + 5N2),the volume of the mixture is found from pm*Vm = mm*Rm*Tm
pm = 100.; 			#mixture pressure 			#psia 
Tm = 460.+70; 			#mixture temperature 			#R(absolute temperature)
Rm = 1545/37.0; 			#gas constant of mixture 
mm = 15.; 			#mass of mixture 			#Unit:lb
#So,rearranging the equation,gives
Vm = (mm*Rm*Tm)/(pm*144);  			#mixture volume 			#ft**3 			#1 in**2 =  144 ft**2
print "The mixture volume is %.2f ft**3"%(Vm);
#the partial volume of carbon dioxide is the total volume multiplied by the mole fraction.Thus,
VCO2 = Vm*xCO2; 			#the partial volume of CO2 			#ft**3
print "The partial volume of carbon dioxide is %.2f ft**3"%(VCO2);
VN2 = Vm*xN2; 			#the partial volume of N2 			#ft**3
print "The partial volume of nitrogen is %.2f ft**3"%(VN2);
#The partial pressure of each constituent is proportional to its mole fraction,for these conditions,
pCO2 = pm*xCO2; 			#the partial pressure of carbon dioxide =  final pressure * the mole fraction of CO2 			#psia
print "The partial pressure of carbon dioxide is %.2f psia"%(pCO2);
pN2 = pm*xN2; 			#the partial pressure of nitrogen = final pressure * the mole fraction of nitrogen 			#psia
print "The partial pressure of nitrogen is %.2f psia"%(pN2);
The total number of moles in the mixture is 0.41 mole
The mole fraction of carbon dioxide is 0.56 and the mole fraction of nitrogen is 0.44
The molecular weight of air is 36.97
The mixture volume is 23.05 ft**3
The partial volume of carbon dioxide is 12.91 ft**3
The partial volume of nitrogen is 10.14 ft**3
The partial pressure of carbon dioxide is 56.02 psia
The partial pressure of nitrogen is 43.98 psia

Example 7.6 Page No : 327

In [21]:
#we will assume that we have 100 volumes of gas mixture and set up table 7.2.In first coloumn,we tabulate the gas,and in the second coloumn,we tabulate the given   volume fractions.Because the mole fraction equals to volume fraction,the values in coloumn 3 are the same as those in coloumn 2.
#The molecular weight is obtained from table 7.1.Because the MW of the mixture is the sum of the individual mole fraction multiplied by the respective molecular      weights,the next coloumn tabulates the product of the mole fraction multiplied by molecular weight(3*4).The sum of these entries is the molecular weight of the    mixture,which for this case is 33.4.
print "Basis:100 volumes of gas mixture"
print "gas    Volume       Mole           Molecular                            mass  "
print "       fraction    fraction x      weight MW     xMW                  fraction"
print "CO2    0.40        0.40          44.0           %.2f               %.2f"%(0.40*44.0,(0.40*44.0)/33.4)
print "N2     0.10        0.10          28.02          %.2f                %.2f                "%(28.02*0.10,(28.02*0.10)/33.4)
print "H2     0.10        0.10          2.016          %.2f                %.2f                "%(0.10*2.016,(0.10*2.016)/33.4)
print "O2     0.40        0.40          32.0           %.2f               %.2f                "%(0.40*32.0,(0.40*32.0)/33.4)
print "       1.00        1.00                         33.4 = MWm                =  1.000               "
Basis:100 volumes of gas mixture
gas    Volume       Mole           Molecular                            mass  
       fraction    fraction x      weight MW     xMW                  fraction
CO2    0.40        0.40          44.0           17.60               0.53
N2     0.10        0.10          28.02          2.80                0.08                
H2     0.10        0.10          2.016          0.20                0.01                
O2     0.40        0.40          32.0           12.80               0.38                
       1.00        1.00                         33.4 = MWm                =  1.000               

Example 7.7 Page No : 328

In [22]:
#We will take as a basis 100 lbm of mixture.
#Dividing colomn 2 by 3 gives us mass/molecular weight  or moles of each constituents.The total number of moles in the mixture is the sum of coloumn 4,and the      molecular weight of the mixture is the mass of the mixture(100 lbm) divided by the number of moles
#In coloumn 5,mole fraction is given by moles/total mole

print "Basis:100 pounds of gas mixture"
print "gas    Mass        Molecular      Moles                   Mole         Percent      "
print "        lbm        weight MW                           fraction        Volume        "
print "CO2    52.7          44.0          1.2                   %.2f             %.2f   "%(1.2/3,1.2/3*100)
print "N2      8.4          28.02         0.3                   %.2f             %.2f   "%(0.3/3,0.3/3*100)
print "H2      0.6          2.016         0.3                   %.2f             %.2f   "%(0.3/3,0.3/3*100)
print "O2     38.3          32.0          1.2                   %.2f             %.2f   "%(1.2/3,1.2/3*100)
print "        = 100.0                      = 3.0                  = 1.00                =  100               "
print "                              MWm = 100/3 = 33.3               "
Basis:100 pounds of gas mixture
gas    Mass        Molecular      Moles                   Mole         Percent      
        lbm        weight MW                           fraction        Volume        
CO2    52.7          44.0          1.2                   0.40             40.00   
N2      8.4          28.02         0.3                   0.10             10.00   
H2      0.6          2.016         0.3                   0.10             10.00   
O2     38.3          32.0          1.2                   0.40             40.00   
        = 100.0                      = 3.0                  = 1.00                =  100               
                              MWm = 100/3 = 33.3               

Example 7.8 Page No : 329

In [23]:
#We will take as a basis 100 lbm of mixture.
#Dividing colomn 2 by 3 gives us mass/molecular weight  or moles of each constituents.The total number of moles in the mixture is the sum of coloumn 4,and the      molecular weight of the mixture is the mass of the mixture(100 lbm) divided by the number of moles
#In coloumn 5,mole fraction is given by moles/total mole

print "Basis:100 pounds of gas mixture"
print "gas    Mass        Molecular      Moles                   Mole         Percent      "
print "        lbm        weight MW                           fraction        Volume        "
print "O2     23.18         32.00         0.724                   %.2f             %.2f   "%(0.724/3.45,0.724/3.45*100)
print "N2     75.47         28.02         2.693                   %.2f             %.2f   "%(2.692/3.45,2.692/3.45*100)
print "A       1.30         39.90         0.033                   %.2f             %.2f   "%(0.033/3.45,0.033/3.45*100)
print "CO2     0.05         44.00          -                       -             -  "
print "        = 100.00                      = 3.45                  = 1.00                =  100               "
print "                            MWm = 100/3.45 = 28.99               "
Basis:100 pounds of gas mixture
gas    Mass        Molecular      Moles                   Mole         Percent      
        lbm        weight MW                           fraction        Volume        
O2     23.18         32.00         0.724                   0.21             20.99   
N2     75.47         28.02         2.693                   0.78             78.03   
A       1.30         39.90         0.033                   0.01             0.96   
CO2     0.05         44.00          -                       -             -  
        = 100.00                      = 3.45                  = 1.00                =  100               
                            MWm = 100/3.45 = 28.99               

Example 7.9 Page No : 331

In [29]:
#Given: cp of oxygen is 0.23 Btu/lbm*R.cp of nitrogen is 0.25 Btu/lbm*R. 160 lbm/hr of oxygen and 196 lbm/hr of nitrogen are mixed.oxygen is at 500 F and nitrogen  is at 200 F.

#The energy equation for the steady-flow,adiaatic mixing process gives us the requirement that the enthalpy of the mixture must equal to the enthalpies of the      components,because deltah = q = 0.An alternative statement of this requirement is that the gain in enthalpy of the nitrogen must equal the decrease in enthalpy of the   oxygen.Using the latter statement,that the change in enthalpy of nitrogen,yields
# (160*0.23*(500-tm))  =  (196*0.25*(tm-200)) where tm = mixture temperature
#where m*cp*deltat has been used for deltah. 			#cp = specific heat at constant pressure 			#Unit for cp is Btu/lbm*R
#rearranging the above equation,
tm = ((500.*160*0.23)+(196*0.25*200))/((196*0.25)+(160*0.23)); 			#tm = mixture temperature 			#Unit:fahrenheit
print "The final temperature of the mixture is %.2f F"%(tm);
#Using the requirement that the enthalpy of the mixture must equal to the sum of the enthalpies of the components yields an alternative solution to this problem.Let  us assume that at 0 F,the enthalpy of each gas and of the mixture is zero.The enthalpy of the entering oxygen is (160*0.23*(500-0)),and the enthalpy of the        entering nitrogen is (196*0.25*(200-0)).The enthalpy of the mixture is ((160+196)*cpm*(tm-0))
#Therefore,  (160*0.23*500)+(196*0.25*200)  =  ((160+196)*cpm*tm)
cpm = ((160./(160+196))*0.23)+((196/(160+196))*0.25); 			#specific heat at constant pressure for gas mixture 			#Btu/lbm*R
print "For mixture, Specific heat at constant pressure is %.2f Btu/lbm*R"%(cpm);
#therefore,
tm = ((160*0.23*500)+(196*0.25*200))/(cpm*(160.+196)); 			#tm = mixture temperature 			#Unit:fahrenheit
print "By Using value of cpm, The final temperature of the mixture is %.2f F"%(tm);
#The use of 0 F as a base was arbitrary but convenient.Any base would yield the same results.
#The answer of cpm is wrong in the book.
The final temperature of the mixture is 328.67 F
For mixture, Specific heat at constant pressure is 0.10 Btu/lbm*R
By Using value of cpm, The final temperature of the mixture is 766.30 F

Example 7.10 Page No : 332

In [30]:
#Problem 7.9 is carried out as a nonflow mixing process.
#Given in problem 7.9,: cp of oxygen is 0.23 Btu/lbm*R.cp of nitrogen is 0.25 Btu/lbm*R. 160 lbm/hr of oxygen and 196 lbm/hr of nitrogen are mixed.oxygen is at 500F and nitrogen  is at 200 F. 			#cp = specific heat at constant pressure 
#Given in problem 7.10,: cv of oxygen is 0.164 Btu/lbm*R.cv of nitrogen is 0.178 Btu/lbm*R. 			#cv = specific heat at constant volume

#Because this is a nonflow process,the energy equation for this process requires the internal energy of the mixture to equal to the sum of the internal energy of   its components.
#Alternatively,the decrease in internal energy of the oxygen must equal the increase in internal energy of the nitrogen.Using latter statement gives us,
# (160*0.164*(500-tm))  =  (196*0.178*(tm-200))
#where m*cv*deltat has been used for deltau. 			#Unit for cp & cv is Btu/lbm*R
#rearranging the above equation,
tm = ((500*160*0.164)+(196*0.178*200))/((196*0.178)+(160*0.164)); 			#tm = mixture temperature 			#Unit:fahrenheit

# Results
print "The final temperature of the mixture is %.2f F"%(tm);
The final temperature of the mixture is 328.78 F

Example 7.12 Page No : 334

In [32]:
import math

#The change in entropy of the mixture is the sum of the changes in entropy of each component.
#Given in problem 7.9,: cp of oxygen is 0.23 Btu/lbm*R.cp of nitrogen is 0.25 Btu/lbm*R. 160 lbm/hr of oxygen and 196 lbm/hr of nitrogen are mixed.oxygen is at 500F and nitrogen  is at 200 F. 			#cp = specific heat at constant pressure 
#In 7.9,for the oxygen,the temperature starts at 500F(960 R) and decreases to 328.7 F.For the nitrogen,the temperature starts at 200F(660 R) and increase to 328.7 F.
#deltas  =  (cp*math.log(T2/T1)); 			#Unit:Btu/lbm*R 			#change in entropy

#For the oxygen,
cp = 0.23; 			#specific heat at constant pressure 			#Unit:Btu/lbm*R
T2 = 328.7+460; 			#Unit:R 			#final temperature
T1 = 500+460; 			#Unit:R 			#starting temperature
deltas = (cp*math.log(T2/T1)); 			#Unit:Btu/lbm*R 			#change in entropy for oxygen
DeltaS = 160*deltas; 			#Btu/R 			#The total change in entropy of the oxygen
print "The total change in entropy of the oxygen is %.2f Btu/R"%(DeltaS);

#For the nitrogen,
cp = 0.25; 			#specific heat at constant pressure 			#Unit:Btu/lbm*R
T2 = 328.7+460; 			#Unit:R 			#final temperature
T1 = 200+460; 			#Unit:R 			#starting temperature
deltas = (cp*math.log(T2/T1)); 			#Unit:Btu/lbm*R 			#change in entropy for nitrogen
deltaS = 196*deltas; 			#Btu/R 			#The total change in entropy of the nitrogen
print "The total change in entropy of the nitrogen is %.2f Btu/R"%(deltaS);
deltaS = deltaS+DeltaS; 			#the total change in entropy for the mixture 			#Btu/lbm*R
print "The total change in entropy for the mixture is %.2f Btu/R"%(deltaS);

#Per pound of mixture,
deltasm = deltaS/(196+160); 			#increase in entropy per pound mass of mixture
print "Increase in entropy per pound mass of mixture is %.2f Btu/lbm*R"%(deltasm);


print "An alternative solution:";
#As an alternative solution,assume an arbitrary datum of 0 F(460 R).
cp = 0.23; 			#specific heat at constant pressure 			#Unit:Btu/lbm*R
#For initial entropy of oxygen,
T2 = 500+460; 			#Unit:R 			#final temperature
T1 = 0+460; 			#Unit:R 			#starting temperature
deltas = cp*math.log(T2/T1); 			#the initial change in entropy for oxygen 			# Btu/lbm*R
print "The initial change in entropy for oxygen is %.2f Btu/lbm*R"%(deltas);
#For final entropy of oxygen,
T2 = 328.7+460; 			#Unit:R 			#final temperature
T1 = 0+460; 			#Unit:R 			#starting temperature
Deltas = cp*math.log(T2/T1); 			#the final change in entropy for oxygen 			# Btu/lbm*R
print "The final change in entropy for oxygen is %.2f Btu/lbm*R"%(Deltas);
deltaS = Deltas-deltas; 			#The entropy change of the oxygen 			#Btu/lbm*R
print "The entropy change of the oxygen is %.2f Btu/lbm*R"%(deltaS);

#For nitrogen,
cp = 0.25; 			#specific heat at constant pressure 			#Unit:Btu/lbm*R
#For initial entropy of nitrogen,
T2 = 200.+460; 			#Unit:R 			#final temperature
T1 = 0+460; 			#Unit:R 			#starting temperature
deltas = cp*math.log(T2/T1); 			#the initial change in entropy for nitrogen 			# Btu/lbm*R
print "The initial change in entropy for nitrogen is %.2f Btu/lbm*R"%(deltas);
#For final entropy of nitrogen,
T2 = 328.7+460; 			#Unit:R 			#final temperature
T1 = 0+460; 			#Unit:R 			#starting temperature
Deltas = cp*math.log(T2/T1); 			#the final change in entropy for nitrogen 			# Btu/lbm*R
print "The final change in entropy for nitrogen is %.2f Btu/lbm*R"%(Deltas);
deltaS = Deltas-deltas; 			#The entropy change of the nitrogen 			#Btu/lbm*R
print "The entropy change of the nitrogen is %.2f Btu/lbm*R"%(deltaS);

#The remainder of the problem is as before.The advantage of Using this alternative method is the negative math.logarithms are avoided by choomath.sing a reference          temperature lower than any other temperature in the system
The total change in entropy of the oxygen is -7.23 Btu/R
The total change in entropy of the nitrogen is 8.73 Btu/R
The total change in entropy for the mixture is 1.50 Btu/R
Increase in entropy per pound mass of mixture is 0.00 Btu/lbm*R
An alternative solution:
The initial change in entropy for oxygen is 0.16 Btu/lbm*R
The final change in entropy for oxygen is 0.12 Btu/lbm*R
The entropy change of the oxygen is -0.04 Btu/lbm*R
The initial change in entropy for nitrogen is 0.09 Btu/lbm*R
The final change in entropy for nitrogen is 0.13 Btu/lbm*R
The entropy change of the nitrogen is 0.04 Btu/lbm*R

Example 7.13 Page No : 338

In [33]:
#Referring to figure 7.6,it will be seen that the cooling of an air-water vapor mixture from B to A proceeds at constant pressure until the saturation curve is   reached.
#At 80 F(the mixture temperature),the Steam Tables give us a saturation pressure of a 0.5073 psia,and because the relative humidity is 50%,the vapor pressure of  the water is 0.5*0.5073 = 0.2537 psia.
#Using the steam tables,the saturation temperature corresponding to 0.2537 psia is 60 F.
#So,
print "The dew point temperature of the air is 60 F"
The dew point temperature of the air is 60 F

Example 7.14 Page No : 338

In [36]:
#To solve this probelm,it is necessary to determine the properties of the saturated mixture 90 F.If the air is saturated at 90 F,the partial pressure of the water  vapor is found directly from the Steam Tables as 0.6988 psia,and the specific volume of the water vapor is 467.7 ft**3/lbm of vapor.
print "The partial pressure of the dry air is %.2f psia"%(14.7-0.6988); 			#the mixture is at 14.7 psia
R = 1545/28.966; 			#gas constant of dry air = 1545/Molecular weight
T = 90+460; 			#temperature of dry air 			#Unit:R
pdryair = 14.0; 			#psia 			#pressure of dry air
#Applying the ideal gas equation to the air,
vdryair = (R*T)/(pdryair*144); 			#volume of dry air 			#ft**3/lbm 			#1 in**2 = 144 Ft**2
#the mass of dry air in the 467.7 ft**3 container 
print "The mass of dry air in the 467.7 ft**3 container is %.2f lbm"%(467.7/vdryair);
#To obtain relative humidity(phy),it is necessary to determine the mole fraction of water vapor for both the saturated mixture and the mixture in question.
#The saturated mixture contains 1 lbm of water vapor or 1/18.016 moles  = 0.055 mole of water vapor and (467.7/vdryair)/28.966 = 1.109 moles of dry air.
#For the saturated mixture, the ratio of moles of water vapor to moles of mixture is 0.055/(0.055+1.109) = 0.0477
#For the actual mixture,the moles of water vapor per pound of dry air is 0.005/18.016 = 0.000278 and 1 lbm of dry air is 1/28.966 = 0.0345 mole.So,the mole of water vapor per mole of  mixture at the conditions of the  mixture is 0.000278/(0.0345+0.000278) = 0.00799
#From the defination of relative humidity,
print "The relative humidity of the mixture is %.2f "%((0.00799/0.0477)*100);

#Because the mole ratio is also the ratio of the partial pressures for the ideal gas,phy can be expressed as the ratio of the partial pressure of the water vapor in  the mixture to the partial pressure of the water vapor at saturation.Therefore,
print "The partial pressure of the vapor at saturation is %.2f psia"%((0.00799/0.0477)*0.6988);
print "And the partial pressure of the dry air in the mixture is %.2f psia"%((14.7-0.00799/0.0477)*0.6988); 			#14.7-The partial pressure of the vapor at saturation
#The dew point temperature is the saturation temperature corresponding to the partial pressure of the water vapor in the mixture.So,
print "The dew point temperature corresponding to %.2f psia is 39F"%((0.00799/0.0477)*0.6988);
The partial pressure of the dry air is 14.00 psia
The mass of dry air in the 467.7 ft**3 container is 32.14 lbm
The relative humidity of the mixture is 16.75 
The partial pressure of the vapor at saturation is 0.12 psia
And the partial pressure of the dry air in the mixture is 10.16 psia
The dew point temperature corresponding to 0.12 psia is 39F

Example 7.15 Page No : 343

In [37]:
#Problem 7.14 Using equations, Rm = ((ma/(ma+mv))*Ra)+((mv/(ma+mv))*Rv)   and  phy*pvs = pv
W = 0.005; 			#Humidity ratio
pm = 14.7; 			#mixture is at 14.7 psia
#W = 0.622*(pv/(pm-pv))
#Rearranging,
pv = (W*pm)/(0.622+W); 			#the partial pressure of the water vapor 
print "The partial pressure of the water vapor is %.2f psia"%(pv);
pa = pm-pv; 			#pa = the partial pressure of the dry air in the mixture
print "The partial pressure of dry air is %.2f psia"%(pa);
#It is necessary to obtain pvs from the Steam Tables at 90 F.This is 0.6988 psia.
pvs = 0.6988; 			#saturation pressure of water vapor at the temperature of mixture
print "The partial pressure of the water vapor at saturation is %.2f psia"%(pvs);
#Therefore,
phy = pv/pvs; 			#relative humidity
print "The relative humidity  is %.2f percent"%(phy*100);
#The dew point temperature is the saturation temperature corresponding to 0.117 psia,which is found from the Steam Tables to be 39 F.
print "The dew point temperature of the mixture is 39 F";
#The results of this problem and problem 7.14 are in good agreement
The partial pressure of the water vapor is 0.12 psia
The partial pressure of dry air is 14.58 psia
The partial pressure of the water vapor at saturation is 0.70 psia
The relative humidity  is 16.78 percent
The dew point temperature of the mixture is 39 F

Example 7.16 Page No : 343

In [38]:
pm = 14.7; 			#the barometer is at 14.7 psia 			#mixture is at 14.7 psia
#The amount of water vapor removed (per pound of dry air) is the difference between the humidity ratio (specific humidity) at inlet and outlet of the conditioning    unit.We shall therefore evalute W for both specified conditions.Because phy = pv/pvs,
#At 90F:
phy = 0.7; 			#relative humidity
pvs = 0.6988; 			#psia 			#saturation pressure of water vapor at the temperature of mixture
pv = phy*pvs; 			#psia 			#the partial pressure of the water vapor 
pa = pm-pv; 			#psia 			#pa = the partial pressure of the dry air in the mixture
W = 0.622*(pv/pa); 			#Humidity ratio

#At 80F:
phy = 0.4; 			#relative humidity
pvs = 0.5073; 			#psia 			#saturation pressure of water vapor at the temperature of mixture
pv = phy*pvs; 			#psia 			#the partial pressure of the water vapor 
pa = pm-pv; 			#psia 			#pa = the partial pressure of the dry air in the mixture
w = 0.622*(pv/pa); 			#Humidity ratio

print "The amount of water removed per pound of dry air is %.2f"%(W-w);
The amount of water removed per pound of dry air is 0.01

Example 7.17 Page No : 347

In [39]:
#Problem 7.13 Using the psychrometric chart
#Entering figure 7.11 at a dry-bulb temperature of 80 F,we proceed vertically until we reach 50% humidity curve.At this intersection,we proceed horizontally and    read the dew-point temperature as approximately 60 F.
print "The dew point temperature of air is 60 F";
The dew point temperature of air is 60 F

Example 7.18 Page No : 347

In [40]:
#Problem 7.14 Using the psychrometric chart
#In this problem,we are given the moisture content of the air to be 0.005 lb per pound of dry air.
#This corresponds to 0.005*7000 = 35 grains per pound of dry air.
#Entering the chart at 90F and proceeding verticaly to 35 grains per pound of dry air,we find the dew point to be 39F by proceeding horizontally to the intersection with the saturation curve. 
print "The dew-point temperature of the mixture is 39 F";
print "The relative humidity is approximately 17 percent";
#From the leftmost scale,we read the pressure of water vapor to be 0.12 psia.
print "The partial pressure of the air is %.2f psia"%(14.7-0.12);
#Comparing these results to problem 7.14,indicated good agreement between the results obtained by chart and by calculation
The dew-point temperature of the mixture is 39 F
The relative humidity is approximately 17 percent
The partial pressure of the air is 14.58 psia

Example 7.19 Page No : 348

In [41]:
#Problem 7.16 Using the psychrometric chart
#The initial conditions are 90 F and 70% relative humidity
#Entering the chart at 90 F dry bulb temperature and proceeding vertically to 70% relative humidity,we find the air to have 150 grains water vapor per pound of dry air.At the final condition of 80F and 40% relative humidity,we read 61 grains of water/lb of dry air.
#So,
print "The water removed is %.2f grains per pound of dry air"%(150-61);
print "Or %.2f lb of water per pound of dry air is removed"%((150.-61)/7000);
The water removed is 89.00 grains per pound of dry air
Or 0.01 lb of water per pound of dry air is removed

Example 7.20 Page No : 349

In [42]:
#dry bulb temperature is 50 F
#relative humidity is 50 percent
#We first locate 50 F and 50 percent relative humidity on figure 7.11.At this state,we read 26 grains of water per pound of dry air and a total heat of 16.1 Btu per  pound of a dry air.
#We now proceed horizontally to 80 F at a constant value of 26 grains of water per pound of dry air and read a total heat of 23.4 Btu per pound of dry air.
print "The heat required is %.2f Btu per pound of dry air"%(23.4-16.1)
The heat required is 7.30 Btu per pound of dry air

Example 7.21 Page No : 352

In [43]:
#An evaporative cooling process
#Because the exit air is saturated,we find the exit condition on the curve corresponding to a wet-bulb temperature of 50 F.The process is carried out at constant     total enthalpy,which is along a line of constant wet-bulb temperature.
#Proceeding along the 50 F wet-bulb temperature line of figure 7.11 diagonally to the right until it intersects with the vertical 80 F dry-bulb temperature line    yields a relative humidity of approximately 4 %
print "For An evaporative cooling process,  The relative humidity of the entering air is 4 percent"
For An evaporative cooling process,  The relative humidity of the entering air is 4 percent

Example 7.22 Page No : 356

In [44]:
#As noted from figure 7.27, 1 lb of mixture,4/5 lb of indoor air,and 1/5 lb of outdoor air are mixed per pound of mixture. 
#We now locate the two end states on the psychrometric chart and connect them with a straight line.The line connecting the end states is divided  into 5 equal parts. Using the results of equation, (ha-ha2)/(ha-ha1)  =  (W2-W)/(W-W1)  =  ma1/ma2  =  l1/l2 ,we now proceed from the 75 F indoor air state 1 part toward the 90F outdoor air state.This Locates 
print "The final mixture,  which is found to be a dry-bulb temperature of approximately 78 F, \
a wet-bulb temperature of 66 F and relative humidity of 54 percent"
The final mixture,  which is found to be a dry-bulb temperature of approximately 78 F, a wet-bulb temperature of 66 F and relative humidity of 54 percent

Example 7.23 Page No : 358

In [45]:
#The cooling tower
#From the Steam tables,
#For water:
h100F = 68.05;  			#Btu/lbm 			#enthalpy at 100 F
h70F = 38.09;   			#Btu/lbm  			#enthalpy at 70 F
#For air:
h = 20.4; 			#Unit:Btu/lb 			#at inlet,total heat/lb dry air
w = 38.2; 			#Unit:grains/lb  			#at inlet,moisture pickup/lb dry air (at 60F D.B. and 50% R.H.)
H = 52.1; 			#Unit:Btu/lb 			#at outlet,total heat/lb dry air
W = 194.0; 			#Unit:grains/lb 			#at outlet,moisture pickup/lb dry air (at 90F D.B. and 90% R.H.)

#Per pound of dry air,the heat interchange is H-h Btu per pound of dry air.
#Per pound of dry air,the moisture increase is (W-w)/7000 lb per pound of dry air.
#From the equation, ma*(H-h)  =  200000*h100F - mwout*h70F             			#ma = mass of air  mwout = mass of cooled water 
#and  ma*((W-w)/7000)  =  200000 - mwout
#Solving the latter equation for mwout,we have  mwout = 200000-(ma*((W-w)/7000))
#Substituting this into the heat balance yields,
# ma*(H-h)  =  200000*h100F - 200000*h70F + ma*h70F*((W-w)/7000)
#Solving gives us,
ma = (200000*(h100F-h70F))/((H-h)-(h70F*((W-w)/7000))); 			#The amount of air required per hour 			#Unit:lbm/hr of dry air
print "The amount of air required per hour is %.2f lbm/hr of dry air"%(ma);
print "The amount of water lost per hour due to evaporation is %.2f lbm/hr"%((ma*W-w)/7000)
#note that the water evaporated is slightly over 2% of the incoming water,and this is the makeup that has to be furnished to the tower.
#answer are slightly differ because of value of (W-w)/7000 is given 0.0233 instead of 0.0225
The amount of air required per hour is 194216.14 lbm/hr of dry air
The amount of water lost per hour due to evaporation is 5382.56 lbm/hr