# Chapter 6 : The Ideal Gas¶

## Example 6.1 Page No : 241¶

In :
#given data
P1 = 100.; 			#Pressure at volume V1 = 100 ft**3 			#Unit:psia
V1 = 100.; 			#Unit:ft**3 			#V1 = Volume at 100 psia
P2 = 30. 			# Reduced Pressure 			#Unit:psia

# Calculations
#Boyle's law,P1*V1 = P2*V2
V2 = (P1*V1)/P2; 			#Volume occupied by the gas 			#ft**3

# Results
print "Volume occupied by the gas  =  %.2f ft**3"%(V2);

Volume occupied by the gas  =  333.33 ft**3


## Example 6.2 Page No : 241¶

In :
# given data
P1 = 10.**6; 			#Pressure at volume V1 = 2 m**3 			#Unit:Pa
V1 = 2.; 			#Unit:m**3 			#V1 = Volume at 10**6 Pa
P2 = 8.*10**6 			# Increased Pressure 			#Unit:Pa

# Calculations
#Boyle's law,P1*V1 = P2*V2
V2 = (P1*V1)/P2; 			#Volume occupied by gas 			#unit:m**3

# Results
print "Volume occupied by gas  =  %.2f m**3"%(V2);

Volume occupied by gas  =  0.25 m**3


## Example 6.3 Page No : 242¶

In :
# Given value
T1 = 32.+460; 			#Temperature at volume V1 = 150 ft**3 			#Unit:R
V1 = 150.; 			#Unit:ft**3 			#V1 = Volume at 32 F
T2 = 100.+460 			# Increased Temperature 			#Unit:R

# Calculations
#Charles's law,V1/V2  =  T1/T2
V2 = (T2*V1)/T1; 			#Volume occupied by gas 			#unit:m**3

# Results
print "Volume occupied by gas  =  %.2f m**3"%(V2);

Volume occupied by gas  =  170.73 m**3


## Example 6.4 Page No : 242¶

In :
#If for this process T2 = 1.25*T1,
# T2/T1  =  1.25
#Therefore,
# p2/p1  =  T2/T1 			#Charles's law(volume constant)
#Thus,
print "The absolute gas pressure increases by 25 percent";

The absolute gas pressure increases by 25 percent


## Example 6.5 Page No : 242¶

In :
#given data
V1 = 4.; 			#m**3 			#initial volume
T2 = 0.+273; 			#celsius converted to kelvin  			#gas is cooled to 0 C 			#final temperature
T1 = 100+273; 			#celsius converted to kelvin 			#initial temperature

# Calculations
V2 = V1*(T2/T1); 			#final volume 			#Charles's law(pressure constant) 			#unit:m**3

# Results
print "The final volume is %.2f m**3"%(V2);

The final volume is 2.93 m**3


## Example 6.6 Page No : 245¶

In :
#Let us first put each of the given variables into a consistent set of units:
p = (200+14.7)*(144); 			#Unit:psfa*(lbf/ft**2) 			#1 ft**2 = 144 in**2 			#pressure
T = (460.+73); 			#Fahrenheit temperature converted to absolute temperature 			#unit:R
V = 120./1728;  			#1 ft**3 = 1728 in**3 			#total volume 			#unit:ft**3
R = 1545./28; 			#Unit:ft*lbf/lbm*R 			#because the molecular weight of nitrogen is 28 			#constant of proportionality
#Applying, p*v = R*T, 			#ideal gas law
v = (R*T)/p; 			#Unit:ft**3/lbm 			#specific volume
print "The specific volume is %.2f ft**3/lbm"%(v);
#The mass of gas is the total volume divided by the specific volume
print "The gas in the container is %.2f lbm"%(V/v);
#The same result is obtained by direct use of eq. p*V = m*R*T
m = (p*V)/(R*T); 			#The gas in the container 			#unit:lbm 			#ideal gas law
print "The gas in the container is %.2f lbm"%(m);

The specific volume is 0.95 ft**3/lbm
The gas in the container is 0.07 lbm
The gas in the container is 0.07 lbm


## Example 6.7 Page No : 245¶

In :
#Applying , (p1*V1)/T1  =  (p2*V2)/T2
#and p2 = p1*(T2/T1) because V1 = V2
p1 = 200+14.7; 			#Unit:psia 			#initial pressure
T2 = 460.+200; 			#final temperature is 200 F 			#Fahrenheit temperature converted to absolute temperature 			#unit:R
T1 = 460+73; 			#Fahrenheit temperature converted to absolute temperature 			#unit:R

# Calculations
p2 = p1*(T2/T1); 			#final pressure 			#Unit:psia 			#Charles's law(volume constant)

# Results
print "The final pressure is %.2f psia"%(p2);

The final pressure is 265.86 psia


## Example 6.8 Page No : 246¶

In :
#For CO2,
R = 8.314/44; 			#Unit:kJ/kg*K 			#constant of proportionality 			#Molecular weight of CO2 = 44
p = 500; 			#Unit:kPa 			#pressure
V = 0.5; 			#Unit:m**3 			#volume
T = (100.+273); 			#Unit:K 			#Celsius converted to kelvin

# Calculations
#Applying p*V = m*R*T ,
m = (p*V)/(R*T); 			#mass 			#kg 			#ideal gas law

# Results
print "The mass of gas in the math.tank is %.2f kg"%(m);

The mass of gas in the math.tank is 3.55 kg


## Example 6.9 Page No : 252¶

In :
# given data
T2 = 500+460;  			#absolute  final temperature  			#unit:R
T1 = 80+460;  			#absolute initial temperature 			#unit:R
#The equation cpbar =  0.338-(1.24*10**2/T)+(4.15*10**4)/T**2 has a form , cbar =  Adash+(Bdash/T)+(Ddash/T**2)
#So,
Bdash = -1.24*10**2; 			#constant
Ddash = 4.15*10**4;  			#constant

# Calculations
cpbar = Adash+((Bdash*math.log(T2/T1))/(T2-T1))+(Ddash/(T2*T1)); 			#The mean specific heat 			#Btu/lbm*R

# Results
print "The mean specific heat at constant pressure between 80F and 500F is %.2f Btu/lbm*R"%(cpbar);

The mean specific heat at constant pressure between 80F and 500F is 0.42 Btu/lbm*R


## Example 6.10 Page No : 252¶

In :
#The table in Appendix 3 does not give us the enthalpy data at 960R and 540R that we need.Interpolating yields
#  T    hbar      T    hbar
# 537  3729.5    900   6268.1
# 540  3750.4    960   6694.0
# 600  4167.9    1000  6977.9
#So,
hbar540 = 3729.5+(3./63)*(4167.9-3729.5); 			#enthalpy 			#unit:Btu/lbm
hbar960 = 6268.1+(60./100)*(6977.9-6268.1);  			#enthalpy 			#unit:Btu/lbm
#Note that hbar is given for a mass of 1 lb mole.To obtain the enthalpy per pound,it is necessary to divide the values og h by the molecular weight,28.
h2 = 6694.0;  			#enthalpy 			#unit:Btu/lbm
h1 = 3750.4;  			#enthalpy 			#unit:Btu/lbm
T2 = 500.+460; 			#absolute  final temperature 			#unit:R
T1 = 80.+460; 			#absolute initial temperature 			#unit:R

# Calculations
cbar = (h2-h1)/(28*(T2-T1)); 			#The mean specific heat at constant pressure  			#unit:Btu/lbm*R

# Results
print "The mean specific heat at constant pressure is %.2f Btu/lbm*R"%(cbar);
#With the more extesive Gas tables,these interpolations are avoided.The Gas Tables provide a relatively easy and accurate method of obtaining average specific heats.Also,these tables have been computerized for ease of application.

The mean specific heat at constant pressure is 0.25 Btu/lbm*R


## Example 6.11 Page No : 253¶

In :
# given data
T2 = 500+460; 			#absolute  final temperature  			#unit:R
T1 = 80+460; 			#absolute initial temperature  			#unit:R
#cp = 0.219 + (3.42*10**-5*T) - (2.93*10**-9*T**2); 			#Unit:Btu/lbm*R
#Comparing with c = A+(B*T)+(D*T**2)
A = 0.219;        			#constant
B = 3.42*10**-5;   			#constant
D = 2.93*10**-9;   			#constant

# Calculations
#Using these values and equation cbar = A+((B/2)(T2+T1))+((D/3)*(T2**2+(T2*T1)+T1**2))
cpbar = A+((B/2)*(T2+T1))+((D/3)*(T2**2+(T2*T1)+T1**2)); 			#The mean specific heat 			#Btu/lbm*R

# Results
print "The mean specific heat at constant pressure for air between 80F and 500F is %.2f Btu/lbm*R"%(cpbar);

The mean specific heat at constant pressure for air between 80F and 500F is 0.25 Btu/lbm*R


## Example 6.12 Page No : 255¶

In :
#The molecular weight of oxygen is 32.Therefore,
R = 1545./32; 			#Unit:ft*lbf/lbm*R 			#constant of proportionality
J = 778.; 			#conversion factor
cp = 0.24; 			#Unit:Btu/lbm*R 			#specific heat at constant pressure

# Calculations
#cp-cv = R/J
cv = cp-(R/J); 			#specific heat at constant volume 			#unit:Btu/lbm*R

# Results
print "Specific heat at constant volume is %.2f Btu/lbm*R"%(cv);

Specific heat at constant volume is 0.18 Btu/lbm*R


## Example 6.13 Page No : 255¶

In :
#From equation,cv = R/(k-1) ,
R = 8.314/32; 			#constant of proportionality 			#kJ/kg*K 			#The molecular weight of oxygen is 32
k = 1.4 			#for oxygen 			#given 			#k = cp/cv
cv = R/(k-1); 			#Specific heat at constant volume 			#unit:kJ/kg*K
print "Specific heat at constant volume is %.2f kJ/kg*K"%(cv);
cp = k*cv; 			#specific heat at constant pressure 			#Unit:kJ/kg*K
print "Specific heat at constant pressure is %.2f kJ/kg*K"%(cp);

Specific heat at constant volume is 0.65 kJ/kg*K
Specific heat at constant pressure is 0.91 kJ/kg*K


## Example 6.14 Page No : 255¶

In :
# given data
R = 60.; 			#Unit:ft*lbf/lbm*R 			#constant of proportionality
deltah = 500.; 			#Btu/lbm 			#change in enthalpy
deltau = 350.; 			#Btu/lbm 			#change in internal energy
J = 778.; 			#conversion factor
#Because deltah-(cp*deltaT) and deltau = cv*deltaT
# deltah/deltau = (cp*deltaT)/(cv*deltaT) = cp/cv = k
k = deltah/deltau; 			#Ratio of specific heats
print "Ratio of specific heats k is %.2f"%(k);
#From equation cv = R/(J*(k-1))
cv = R/(J*(k-1)); 			#specific heat at constant volume 			#Btu/lbm*R
print "Specific heat at constant volume is %.2f Btu/lbm*R"%(cv);
cp = k*cv; 			#Specific heat at constant pressure 			#Btu/lbm*R
print "Specific heat at constant pressure is %.2f Btu/lbm*R"%(cp);

Ratio of specific heats k is 1.43
Specific heat at constant volume is 0.18 Btu/lbm*R
Specific heat at constant pressure is 0.26 Btu/lbm*R


## Example 6.15 Page No : 256¶

In :
#When solving this type of problem,it is necessary to note carefully the information given and to write the correct energy equation for this process.Because the    process is carried out at constant volume,the heat added equals the change in inernal energy.Because the change in internal energy per pound for the ideal gas is      cv*(T2-T1),the total change in internal energy for m pounds must equals the heat added.Thus,
#data given
Q = 0.33; 			#heat
#Initial conditions
V = 60; 			#in**3 			#volume
m = 0.0116; 			#lbs 			#mass
p1 = 90; 			#psia 			#pressure
T1 = 460+40; 			#Fahrenheit temperature converted to absolute temperature
#Final condition = Initial condition + heat
V = 60; 			#in**3 			#volume
m = 0.0116; 			#lbs 			#mass
p2 = 108; 			#psia 			#pressure
T2 = 460+140; 			#Fahrenheit temperature converted to absolute temperature 			#unit:R
#Q = m*(u2-u1) = m*cv*(T2-T1)

# Calculations and Results
cv = Q/(m*(T2-T1)); 			#specific heat at constant volume 			#Btu/lbm*R
print "Specific heat at constant volume is %.2f Btu/lbm*R"%(cv);
#To obtain cp,it is first necessary to obtain R.Enough information was given in the initial conditions of the problem to apply eqn. p*V = m*R*T
R = (144*p1*(V/1728.))/(m*T1); 			#1 ft**2 = 144 in**2 			#1 ft**3 = 1728 in**3 			#Unit:ft*lbf/lbm*R 			#constant of proportionality
print "Consmath.tant of proportionality R is %.2f ft*lbf/lbm*R"%(R);
#cp-cv = (R/J)
J = 778.; 			#conversion factor
cp = cv+(R/J); 			#Specific heat at constant pressure 			#Btu/lbm*R
print "Specific heat at constant pressure is %.2f Btu/lbm*R"%(cp);

Specific heat at constant volume is 0.28 Btu/lbm*R
Consmath.tant of proportionality R is 77.59 ft*lbf/lbm*R
Specific heat at constant pressure is 0.38 Btu/lbm*R


## Example 6.16 Page No : 260¶

In :
import math
#data
cp = 0.24; 			#Specific heat at constant pressure 			#Btu/lbm*R
p2 = 15.; 			#psia 			#final pressure
p1 = 100.; 			#psia 			#initial pressure
T2 = 460.+0;  			#absolute  final temperature 			#unit:R
T1 = 460.+100; 			#absolute initial temperature  			#unit:R
J = 778.; 			#conversion factor
R = 1545./29; 			#moleculer weight = 29 			#Unit:ft*lbf/lbm*R 			#constant of proportionality

# Calculations
#On the basis of the data given,
deltas = (cp*(math.log(T2/T1)))-((R/J)*(math.log(p2/p1))); 			#change in entropy 			#Btu/lbm*R

# Results
print "The change in enthalpy is %.2f Btu/lbm*R"%(deltas);

The change in enthalpy is 0.08 Btu/lbm*R


## Example 6.17 Page No : 261¶

In :
import math

#data of problem6.16
cp = 0.24; 			#Specific heat at constant pressure 			#Btu/lbm*R
p2 = 15.; 			#psia 			#final pressure
p1 = 100.; 			#psia 			#initial pressure
T2 = 460.+0;  			#absolute  final temperature 			#unit:R
T1 = 460.+100; 			#absolute initial temperature 			#unit:R
J = 778.; 			#conversion factor
R = 1545./29; 			#moleculer weight = 29 			#Unit:ft*lbf/lbm*R 			#constant of proportionality
#Because cp and R are given,let us first solve for cv,
#cp = (R*k)/(J*(k-1))
k = (cp*J)/((cp*J)-R); 			#k = cp/cv 			#ratio of specific heats
print "Ratio of specific heats k is %.2f"%(k);
#k = cp/cv
cv = cp/k; 			#Specific heat at constant volume 			#Btu/lbm*R
print "Specific heat at constant volume is %.2f Btu/lbm*R"%(cv);
#Now, deltas = (cv*math.log(p2/p1))+(cp*math.log(v2/v1));
#But, v2/v1 = (T2*p1)/(T1*p2)
v2byv1 = (T2*p1)/(T1*p2); 			# v2/v1 			#unitless
deltas = (cv*math.log(p2/p1))+(cp*math.log(v2byv1)); 			#The change in enthalpy  			#unit:Btu/lbm*R
print "The change in enthalpy is %.2f Btu/lbm*R"%(deltas);
#The agreement is very good.

Ratio of specific heats k is 1.40
Specific heat at constant volume is 0.17 Btu/lbm*R
The change in enthalpy is 0.08 Btu/lbm*R


## Example 6.18 Page No : 261¶

In :
import math

#data,
cp = 0.9093; 			#Specific heat at constant pressure 			#kJ/kg*R
p2 = 150.; 			#kPa 			#final pressure
p1 = 500.; 			#kPa 			#initial pressure
T2 = 273.+0;  			#final temperature 			#Celsius converted to kelvin
T1 = 273.+100; 			#initial temperature 			#Celsius converted to kelvin
#J = 778; 			#conversion factor
R = 8.314/32; 			#moleculer weight of oxygen = 32 			#Unit:ft*lbf/lbm*R 			#constant of proportionality

# Calculations
#Using equation, and dropping J gives,
deltas = (cp*(math.log(T2/T1)))-((R)*(math.log(p2/p1))); 			#change in entropy 			#kJ/kg*K
#For 2 kg,
deltaS = 2*deltas; 			#The change in enthalpy in kJ/K

# Results
print "For 2 kg oxygen, The change in enthalpy is %.2f kJ/K"%(deltaS);

For 2 kg oxygen, The change in enthalpy is 0.06 kJ/K


## Example 6.19 Page No : 262¶

In :
#from the equation, deltas/cv  =  (k*math.log(v2/v1))+ math.log(p2/p1) 			#change in entropy
k = 1.4; 			#k = cp/cv 			#ratio of specific heats
#deltas = (1/4)*cv 			#so,
# 1/4 =  (k*math.log(v2/v1))+ math.log(p2/p1)
v2 = 1./2; 			#Because,v2 = (1/2)*v1  			#initial specific volume
v1 = 1.;   			#final specific volume

# Calculations
p2byp1 = math.exp((1./4)-(k*math.log(v2/v1))); 			#increase in pressure

# Results
print "p2/p1 = %.2f"%(p2byp1);
print "So, increase in pressure is %.2f "%(p2byp1);

p2/p1 = 3.39
So, increase in pressure is 3.39


## Example 6.20 Page No : 264¶

In :
#data
T2 = 460+270; 			#Fahrenheit temperature converted to absolute final temperature 			#unit:R
T1 = 460+70; 			#Fahrenheit temperature converted to absolute initial temperature 			#unit:R
cv = 0.17; 			#specific heat at constant volume 			#Btu/lbm*R

# Calculations
#Now,
deltas = cv*math.log(T2/T1); 			#change in entropy 			#Unit:Btu/lbm*R
#For 1/2 lb,
deltaS = (1./2)*deltas; 			#The change in enthalpy in Btu/R

# Results
print "For 1/2 lb of gas, The change in enthalpy is %.2f Btu/R"%(deltaS);

For 1/2 lb of gas, The change in enthalpy is 0.00 Btu/R


## Example 6.21 Page No : 264¶

In :
#data
T2 = 100.+273; 			#Celsius temperature converted to Kelvin 			#final temperature
T1 = 20+273; 			#Celsius temperature converted to Kelvin 			#initial temperature
cv = 0.7186; 			#specific heat at constant volume 			#kJ/kg*K
#Now,
deltas = cv*math.log(T2/T1); 			#change in entropy 			#Unit:kJ/kg*K
#For 0.2 kg,
deltaS = (0.2)*deltas; 			#The change in enthalpy in kJ/K
print "For 0.2 kg of air, The change in enthalpy is %.2f kJ/K"%(deltaS);

For 0.2 kg of air, The change in enthalpy is 0.03 kJ/K


## Example 6.22 Page No : 264¶

In :
#data
deltas = 0.0743; 			#change in entropy 			#Unit:Btu/lbm*R
T1 = 460+100; 			#Fahrenheit temperature converted to absolute initial temperature
cv = 0.219; 			#specific heat at constant volume 			#Btu/lbm*R
#Now,

# Calculations
#deltas = cv*math.log(T2/T1);
T2 = T1*math.exp(deltas/cv); 			#higher temperature 			#absolute temperature  			#unit:R

# Results
print "The higher temperature is %.2f R"%(T2)

The higher temperature is 786.20 R


## Example 6.23 Page No : 265¶

In :
#data
deltaS = 0.4386; 			#change in entropy 			#Unit:kJ/K
T2 = 273+425; 			#Celsius temperature converted to kelvin 			#initial temperature
cv = 0.8216; 			#specific heat at constant volume 			#kJ/kg*K
m = 1.5; 			#mass 			#kg
#Now,

# Calculations
#deltas = m*cv*math.log(T2/T1);
T1 = T2/(math.exp(deltaS/(m*cv))) 			#initial temperature 			#unit:K

# Results
print "The initial temperature of the process is %.2f K or %.2f C"%(T1,T1-273)

The initial temperature of the process is 488.98 K or 215.98 C


## Example 6.24 Page No : 267¶

In :
#data given
T2 = 460.+400; 			#Fahrenheit temperature converted to absolute final temperature 			#unit:R
T1 = 460.+70; 			#Fahrenheit temperature converted to absolute initial temperature 			#unit:R
cp = 0.24; 			#specific heat at constant pressure 			#Btu/lbm*R
J = 778.; 			#conversion factor
R = 1545./29; 			#moleculer weight = 29 			#Unit:ft*lbf/lbm*R 			#constant of proportionality
#From the energy equation for the constant-pressure process,the heat transferred is deltah.Therefore,
#q = deltah = cp*(T2-T1)
deltah = cp*(T2-T1); 			#heat transferred 			#Btu/lb 			#into system
print "The heat transferred is %.2f Btu/lbinto system)"%(deltah);
deltas = cp*math.log(T2/T1); 			#increase in entropy 			#Btu/lbm*R
print "The increase in entropy is %.2f Btu/lbm*R"%(deltas);
#The flow work change is (p2*v2)/J - (p1*v1)/J  =  (R/J)*(T2-T1)
flowworkchange = (R/J)*(T2-T1); 			#Btu/lbm 			#The flow work change per pound of air
print "The flow work change per pound of air is %.2f Btu/lbm"%(flowworkchange);
#In addition to each of the assumptions made in all the process being considered,it has further been tacitly assumed that these processes are carried out quasi-      statically and without friction.

The heat transferred is 79.20 Btu/lbinto system)
The increase in entropy is 0.12 Btu/lbm*R
The flow work change per pound of air is 22.60 Btu/lbm


## Example 6.25 Page No : 268¶

In :
#data given
T2 = 500.+273; 			#Celsius temperature converted to Kelvin 			#final temperature
T1 = 20+273; 			#Celsius temperature converted to Kelvin 			#initial temperature
cp = 1.0062; 			#specific heat at constant pressure 			#kJ/kg*K
#From the energy equation for the constant-pressure process,the heat transferred is deltah.Therefore,
#q = deltah = cp*(T2-T1)
deltah = cp*(T2-T1); 			#heat transferred 			#kJ/kg 			#into system
print "The heat transferred is per kimath.logram of air %.2f kJ/kg"%(deltah);
deltas = cp*math.log(T2/T1); 			#increase in entropy 			#kJ/kg*K
print "The increase in entropy per kimath.logram of air is %.2f kJ/kg*K"%(deltas);

The heat transferred is per kimath.logram of air 482.98 kJ/kg
The increase in entropy per kimath.logram of air is 0.98 kJ/kg*K


## Example 6.26 Page No : 270¶

In :
#data given
v2 = 2.; 			#Because,v2 = (2)*v1 			#volume increases to its twice its final volume
v1 = 1.; 			#initial volume
T = 460.+200; 			#Fahrenheit temperature converted to absolute temperature
J = 778.; 			#conversion factor
R = 1545./28; 			#moleculer weight of nitrogen = 28 			#Unit:ft*lbf/lbm*R 			#constant of proportionality
#From the equation, w/J = q = T*deltas = ((R*T)/J)*math.log(v2/v1)
q = ((R*T)/J)*math.log(v2/v1); 			#Btu/lbm 			#the heat added to system
#For 0.1 lb,
Q = 0.1*q; 			#Btu 			#the heat added to system
print "The heat added to system is %.2f Btu"%(Q);
#The work out of the system is equal to the heat added;thus,
WbyJ = Q; 			#The work out of the system(out of the system) 			#unit:Btu
print "The work out of the system is %.2f Btuout of the system)"%(WbyJ);

The heat added to system is 3.24 Btu
The work out of the system is 3.24 Btuout of the system)


## Example 6.27 Page No : 270¶

In :
#data given
T = 50+273; 			#Celsius temperature converted to Kelvin 			#final temperature 			#unit:K
v2 = 1./2; 			#Because,v2 = (1/2)*v1 			#volume increases to its half its final volume
v1 = 1.;
R = 8.314/32; 			#moleculer weight of oxygen = 32 			#Unit:kJ/kg*K 			#constant of proportionality
#From the equation, q = ((R*T))*math.log(v2/v1)
q = R*T*math.log(v2/v1); 			#heat added 			#kJ/kg
print "The heat added to system is %.2f kJ/kgheat out of system)"%(q);
#The work out of the system is equal to the heat added;thus,
W = q; 			#The work out of the system  			#unit:kJ/kg
print "The work out of the system is %.2f kJ/kginto system)"%(W);

The heat added to system is -58.17 kJ/kgheat out of system)
The work out of the system is -58.17 kJ/kginto system)


## Example 6.28 Page No : 271¶

In :
#data given in problem 6.27
T = 50+273; 			#Celsius temperature converted to Kelvin 			#final temperature
v2 = 1./2; 			#Because,v2 = (1/2)*v1 			#volume increases to its half its final volume
v1 = 1;
R = 8.314/32; 			#moleculer weight of oxygen = 32 			#Unit:kJ/kg*K 			#constant of proportionality
#From the equation, q = ((R*T))*math.log(v2/v1)
q = R*T*math.log(v2/v1); 			#heat added 			#kJ/kg
print "The heat added to system is %.2f kJ/kgheat out of system)"%(q);
#For a constant temperature,
deltas = q/T; 			#Change in entropy 			#unit:kJ/kg*K
print "The change in entropy is %.2f kJ/kg*K"%(deltas);

The heat added to system is -58.17 kJ/kgheat out of system)
The change in entropy is -0.18 kJ/kg*K


## Example 6.29 Page No : 274¶

In :
#data given
T1 = 1000; 			#absolute initial temperature 			#unit:R
p2 = 1.; 			#unit:atm 			#absolute final pressure
p1 = 5.; 			#unit:atm 			#absolute initial pressure
J = 778.; 			#conversion factor
R = 1545./29; 			#moleculer weight = 29 			#Unit:ft*lbf/lbm*R 			#constant of proportionality
k = 1.4; 			#k = cp/cv 			#ratio of specific heats

# Calculations and Results
#From the equation,
T2 = T1*((p2/p1)**((k-1)/k)); 			#Unit:R 			#The absolute final temperature
print "The absolute final temperature is %.2f R"%(T2);
work = (R*(T2-T1))/(J*(1-k)); 			#Btu/lbm 			#The work done by air(out)
print "The work done by air is %.2f Btu/lbmout)"%(work)

The absolute final temperature is 631.39 R
The work done by air is 63.11 Btu/lbmout)


## Example 6.30 Page No : 274¶

In :
#data given
#mass of 1 kg
T1 = 500+273; 			#Celsius temperature converted to Kelvin 			#final temperature
p2 = 1.; 			#atm 			#absolute final pressure
p1 = 5.; 			#atm 			#absolute initial pressure
J = 778.; 			#conversion factor
R = 8.314/29; 			#moleculer weight = 29 			#Unit:kJ/kg*K 			#constant of proportionality
k = 1.4; 			#k = cp/cv 			#ratio of specific heat
#From the equation,
T2 = T1*((p2/p1)**((k-1)/k)); 			#Unit:Kelvin 			#The absolute final temperature
print "The absolute final temperature is %.2f K or %.2f C"%(T2,T2-273);
work = (R*(T2-T1))/((1-k)); 			#kJ/kg 			#The work done by air(out)
print "The work done by air is %.2f kJ/kgout)"%(work)

The absolute final temperature is 488.06 K or 215.06 C
The work done by air is 204.22 kJ/kgout)


## Example 6.31 Page No : 275¶

In :
from numpy.linalg import inv
import math

#data given
T1 = 800.+273; 			#Celsius temperature converted to Kelvin 			#initial temperature
T2 = 500.+273; 			#Celsius temperature converted to Kelvin 			#final temperature
p2 = 1.; 			#atm 			#absolute final pressure
p1 = 5.; 			#atm 			#absolute initial pressure

# Calculations
#A gas expands isentropically
#From the equation,
#T2/T1 = ((p2/p1)**((k-1)/k));
#rearranging,
k = inv([[1-((math.log(T2/T1)/math.log(p2/p1)))]]); 			#k = cp/cv 			#Ratio of specific heats

# Results
print "Ratio of specific heats k) is %.2f"%(k);

Ratio of specific heats k) is 1.26


## Example 6.32 Page No : 279¶

In :
#data given
n = 1.3; 			#p*v**1.3 = constant
k = 1.4; 			#k = cp/cv Ratio of specific heats
cp = 0.24; 			#specific heat at constant pressure 			#Btu/lbm*R
T2 = 600.; 			#absolute final temperature 			#unit:R
T1 = 1500.; 			#absolute initial temperature 			#unit:R
R = 53.3; 			#Unit:ft*lbf/lbm*R 			#constant of proportionality
J = 778.; 			#conversion factor
cv = cp/k; 			#specific heat at constant volume 			#Btu/lbm*R
#Therefore,
cn = cv*((k-n)/(1-n)); 			#Polytropic specific heat 			#Btu/lbm*R
print "Polytropic specific heatcn, is %.2f Btu/lbm*R"%(cn);
#The negative sign of cn indicates that either the heat transfer for the process comes from the system or there is a negative temperature change while heat is        transferred to the system.
#The heat transferred is cn*(T2-T1).Therefore,
q = cn*(T2-T1); 			#heat transferred 			#Btu/lbm(to the system)
print "The heat transferred is %.2f Btu/lbmto the system"%(q);
#The work done can be found Using equation,
w = (R*(T2-T1))/(J*(1-n)); 			#Btu/lbm 			#the workdone(from the system)
print "The work done is %.2f Btu/lbmfrom the system"%(w);
deltas = cn*math.log(T2/T1) 			#change in entropy 			#Btu/lbm*R
print "The change in enthalpy is %.2f Btu/lbm*R"%(deltas);

Polytropic specific heatcn, is -0.06 Btu/lbm*R
The heat transferred is 51.43 Btu/lbmto the system
The work done is 205.53 Btu/lbmfrom the system
The change in enthalpy is 0.05 Btu/lbm*R


## Example 6.33 Page No : 279¶

In :
#data given in problem 6.32,
n = 1.3; 			#p*v**1.3 = constant
k = 1.4; 			#k = cp/cv 			#ratio of specific heats
cp = 0.24; 			#specific heat at constant pressure 			#Btu/lbm*R
T2 = 600.; 			#absolute final temperature 			#unit:R
T1 = 1500.; 			#absolute initial temperature 			#unir:R
R = 53.3; 			#Unit:ft*lbf/lbm*R 			#constant of proportionality
J = 778.; 			#conversion factor
#Equation,
# T1/T2 = ((p1/p2)**((n-1)/n));
#rearranging,
p1byp2 = math.exp(math.log(T1/T2)/((n-1)/n)); 			#The ratio of inlet to outlet pressure
print "The ratio of inlet to outlet pressure is %.2f"%(p1byp2);

The ratio of inlet to outlet pressure is 53.02


## Example 6.34 Page No : 284¶

In :
#From the table at 1000 R:                     			#From the table at 500 R:
h2 = 240.98;
h1 = 119.48;
#Btu/lbm 			#enthalpy                             			#Btu/lbm 			#enthalpy
u2 = 172.43;
u1 = 85.20;
#Btu/lbm 			#internal energy                      			#Btu/lbm 			#internal energy
fy2 = 0.75042;
fy1 = 0.58233;
#Btu/lbm*R                                      			#Btu/lbm*R

#The change in enthalpy is
deltah = h2-h1; 			#Btu/lbm
#The change in internal energy is
deltau = u2-u1; 			#Btu/lbm
print "The change in enthalpy is %.2f Btu/lbm & the change in internal energy is %.2f Btu/lbm"%(deltah,deltau);
#Because in the constant-pressure process -R*math.log(p2/p1) is zero,
deltas = fy2-fy1; 			#Btu/lbm*R 			#The entropy when air is heated at constant pressure
print "The entropy when air is heated at constant pressure is %.2f Btu/lbm/R"%(deltas);

The change in enthalpy is 121.50 Btu/lbm & the change in internal energy is 87.23 Btu/lbm
The entropy when air is heated at constant pressure is 0.17 Btu/lbm/R


## Example 6.35 Page No : 285¶

In :
#In this problem,the air expands from 5 atm absolute to 1 atm absolute from an initial temperature of 1000R,
pr = 12.298; 			#relative pressure 			#unit:atm
h = 240.98; 			#Btu/lbm 			#enthalpy
pr = 12.298/5; 			#The value of the final relative pressure 			#unit:atm
#Interpolation in the air table yields the following:
#   T     pr
#  620   2.249
#        2.4596
#  640   2.514
T = 620+(((2.4596-2.249)/(2.514-2.249))*20); 			#the final temperature 			#unit:R
print "The absolute final temperature is %.2f R"%(T);
u1 = 172.43; 			#initial internal energy 			#Btu/lbm
u2 = 108.51; 			#final internal energy 			#Btu/lbm
work = u1-u2; 			#Btu/lbm The work done by air in an isentropic nonflow expansion 			#where the value of u2 is obtained by interpolation at T  temperature and the value of u1 is read from the air table at 1000 R.
print "The work done by air in an isentropic nonflow expansion is %.2f Btu/lbmout)"%(work)

The absolute final temperature is 635.89 R
The work done by air in an isentropic nonflow expansion is 63.92 Btu/lbmout)


## Example 6.36 Page No : 288¶

In :
import math

# given data
T = 1000+460; 			#Fahrenheit temperature converted to absolute temperature
#The velocity of sound in air at 1000 F is
Va = 49.0*math.sqrt(T); 			#velocity 			#ft/s
print "The velocity of sound air at 1000 F is %.2f ft/s"%(Va);
#Hydrogen has a specific heat ratio of 1.41 and R = 766.53.Therefore,
khydrogen = 1.41; 			#specific heats ratio for air
kair = 1.40; 			#specific heats ratio for air
Rhydrogen = 766.53; 			#gas constant 			#ft*lbf/lbm*R
Rair = 53.36; 			#gas constant 			#ft*lbf/lbm*R
# Vahydrogen/Vaair  =  math.sqrt((Rhydrogen*khydrogen)/(Rair*kair))
#rearranging,
Vahydrogen = Va*math.sqrt((Rhydrogen*khydrogen)/(Rair*kair)); 			#The velocity of sound in hydrogen at 1000 F 			#unit:ft/s
print "The velocity of sound in hydrogen at 1000 F is %.2f ft/s"%(Vahydrogen);

The velocity of sound air at 1000 F is 1872.29 ft/s
The velocity of sound in hydrogen at 1000 F is 7121.55 ft/s


## Example 6.37 Page No : 288¶

In :
import math

# given data
T = 200+460.; 			#Fahrenheit temperature converted to absolute temperature 			#unit:R
V = 1500; 			#ft/s 			#the local velocity
Va = 49.0*math.sqrt(T); 			#velocity of sound air at 200 F  			#unit:ft/s
print "The velocity of sound air at 200 F is %.2f ft/s"%(Va);
M = V/Va; 			#The Mach number = the local velocity/velocity of sound 			#unitless
print "The Mach number is %.2f"%(M);

The velocity of sound air at 200 F is 1258.83 ft/s
The Mach number is 1.19


## Example 6.38 Page No : 290¶

In :
#data given
V = 1000; 			#ft/s 			#the fluid velocity
gc = 32.17; 			#Unit:(LBm*ft)/(LBf*s**2) 			#gc is constant of proportionality
J = 778; 			#conversion factor
h = 1204.4; 			#Btu/lbm 			#enthalpy of saturated steam
#h0-h = V**2/(2*gc*J)
h0 = h+((V**2)/(2*gc*J));  			#Btu/lbm 			#h0 = stagnation enthalpy
print "The total enthalpy is %.2f Btu/lbm"%(h0);
#It will be noted for this problem that if the initial velocity had been 100ft/s,deltah would have been 0.2 Btu/lbm,and for most practical purpposes,the total      properties and those of the flowing fluid would have been essentially the same.Thus,for low-velocity fluids,the difference in total and steam properties can be      neglected.

The total enthalpy is 1224.38 Btu/lbm


## Example 6.39 Page No : 297¶

In :
import math
from numpy.linalg import inv

# given data
k = 1.4; 			#the specific heats ratio 			#k = cp/cv
M = 1; 			#(table 6.5) 			#The Mach number = the local velocity/velocity of sound
T0 = 800; 			#absolute temperature 			#unit:R
gc = 32.17; 			#Unit:(LBm*ft)/(LBf*s**2) 			#gc is constant of proportionality
R = 53.35; 			#gas constant 			#ft*lbf/lbm*R
p0 = 300; 			#psia 			#pressure

# * or "star" subscripts to conditions in which M = 1;
# "0" subscript refers to isentropic stagnation
#Refer to figure 6.26,
#Tstar/T0 = 0.8333
Tstar = T0*0.8333; 			#temperature when M = 1 			#unit:R
print "If the mach number at the outlet is unity, temperature is %.2f R"%(Tstar);
Vat = math.sqrt(gc*R*Tstar*k); 			#ft/s 			#Vat = V2 			#local velocity of sound
print "If the mach number at the outlet is unity, velocity is %.2f ft/s"%(Vat)

#For A/Astar = 2.035
#The table yields
M1 = 0.3; 			#mach number at inlet
print "At inlet, The mach number is %.2f"%(M1)
#pstar/p0 = 0.52828
pstar = p0*0.52828;  			#pressure when M = 1 			#psia
#also,
#T1/T0 = 0.98232 and p1/p0 = 0.93947
#Therefore,
T1 = T0*0.982332; 			#unit:R 			#T1 = temperature at inlet
print "At inlet, The temperature is %.2f R"%(T1);
p1 = p0*0.93947; 			#psia 			#p1 = pressure at inlet
print "At inlet, The pressure is %.2f psia"%(p1);
#From the inlet conditions derived,
Va1 = math.sqrt(gc*k*R*T1); 			#ft/s 			#V1 = velocity at inlet
V1 = M1*Va1; 			#ft/s 			#velocity
print "At inlet, The velocity is %.2f ft/s"%(V1);
#The specific volume at inlet is found from the equation of state for an ideal gas:
v = (R*T1)/(p1*144); 			#ft**3/lbm 			#1 ft**2 = 144 in**2(for conversion of unit) 			#specific volume
rho = inv([[v]]); 			#inverse of specific volume 			#density
A = 2.035; 			#area 			#ft**2
m = rho*A*V1; 			#mass flow 			#unit:lbm/s
print "At inlet, The mass flow is %.2f lbm/s"%(m);

If the mach number at the outlet is unity, temperature is 666.64 R
If the mach number at the outlet is unity, velocity is 1265.62 ft/s
At inlet, The mach number is 0.30
At inlet, The temperature is 785.87 R
At inlet, The pressure is 281.84 psia
At inlet, The velocity is 412.24 ft/s
At inlet, The mass flow is 812.08 lbm/s


## Example 6.40 Page No : 299¶

In :
# * or "star" subscripts to conditions in which M = 1;
# "0" subscript refers to isentropic stagnation
#This problem will be solved by two methods(A and B)
print "Method A"; 			#By equations:
k = 1.4; 			#the specific heat ratio 			#k = cp/cv
R = 53.3; 			#gas constant 			#ft*lbf/lbm*R
M = 2.5; 			#mach number = the local velocity/velocity of sound
print "Solution for a";
# T/Tstar  =  (k+1)/(2*(1+((1/2)*(k-1)*M**2)))
# Tstar/T0 = 2/(k+1)
#Therefore,
# (Tstar/T0)*(T/Tstar)  =  (T/T0) = 1/(1+((1/2)*(k-1)*M**2))
T0 = 560; 			#absolute temperature or stagnation temperature 			#unit:R
T = T0/(1+((1/2)*(k-1)*M**2)); 			#temperature at M = 2.5
print "The temperature is %.2f R"%(T);
print "Solution for b";
p = 0.5; 			#static pressure 			#unit:psia
# p0/p  =  (T0/T)**(k/(k-1))
p0 = p*14.7*((T0/T)**(k/(k-1))); 			#pressure at M = 2.5 			#unit:psia
print "The pressure is %.2f psia"%(p0);
print "Solution for c";
gc = 32.17; 			#Unit:(LBm*ft)/(LBf*s**2) 			#gc is constant of proportionality
Va = math.sqrt(gc*k*R*T); 			#ft/s 			#local velocity of sound
V = M*Va; 			#valocity at M = 2.5 			#unit:ft/s
print "The velocity is %.2f ft/s"%(V);
print "Solution for d";
v = (R*T)/(p*14.7*144); 			#ft**3/lbm 			#1 ft**2 = 144 in**2 			#specific volume at M = 2.5
print "The specific volume is %.2f ft**3/lbm"%(v);
print "Solution for e";
#Mass velocity is definrd as the mass flow per unit area
# m/A = (A*V)/(v*A) = V/v
print "The mass velocity is %.2f lbm/s*ft**2)"%(V/v); 			#mass velocity at M = 2.5

print "Method B"; 			#By the gas tables: 			#table 6.5 gives
M = 2.5; 			#mach number = the local velocity/velocity of sound
print "Solution for a";
T0 = 560; 			#absolute temperature or stagnation temperature
#T/T0 = 0.44444
T = T0*0.44444; 			#temperature at M = 2.5
print "The temperature is %.2f R"%(T)
print "Solution for b";
p = 0.5; 			#static pressure
#p/p0 = 0.05853
p0 = (p*14.7)/0.05853; 			#pressure at M = 2.5
print "The pressure is %.2f psia"%(p0);
print "Solution for c";
print "As before %.2f ft/s"%(V)
print "Solution for d";
print "As before %.2f ft**3/lbm"%(v)
print "Solution for e";
print "As before %.2f lbm/s*ft**1)"%(V/v)

Method A
Solution for a
The temperature is 560.00 R
Solution for b
The pressure is 7.35 psia
Solution for c
The velocity is 2898.59 ft/s
Solution for d
The specific volume is 28.20 ft**3/lbm
Solution for e
The mass velocity is 102.78 lbm/s*ft**2)
Method B
Solution for a
The temperature is 248.89 R
Solution for b
The pressure is 125.58 psia
Solution for c
As before 2898.59 ft/s
Solution for d
As before 28.20 ft**3/lbm
Solution for e
As before 102.78 lbm/s*ft**1)


## Example 6.41 Page No : 304¶

In :
#For Methane(CH4,MW = 16)
p = 500; 			#evaluate specific volume at p pressure 			#Unit:psia
pc = 674; 			#critical temperature 			#Unit:psia
T = 50+460; 			#evaluate specific volume at T temperature 			#Unit:R
Tc = 343; 			#critical temperature 			#Unit:R
R = 1545./16; 			#gas constant R  =  1545/Molecular Weight 			#ft*lbf/lbm*R
pr = p/pc; 			#reduced pressure 			#unit:psia
Tr = T/Tc; 			#reduced temperature 			#unit:R
#Reading figure 6.28 at these values gives
Z = 0.93; 			#compressibility factor
#Z = (p*v)/(R*T)
v = Z*((R*T)/(p*144)); 			#ft**3/lbm 			#1 ft**2 = 144 in**2(for conversion of unit) 			#specific volume
print "Using the value of Z = 0.93,  the specific volume is %.2f ft**3/lbm"%(v);
#For ideal gas,
v = (R*T)/(p*144); 			#ft**3/lbm 			#1 ft**2 = 144 in**2(for conversion of unit) 			#specific volume
print "For the ideal gas, the specific volume is %.2f ft**3/lbm"%(v);

Using the value of Z = 0.93,  the specific volume is 0.64 ft**3/lbm
For the ideal gas, the specific volume is 0.68 ft**3/lbm