Appendix C

Example 1

In [1]:
# -*- coding: utf8 -*-
from __future__ import division
from math import exp
#Example: 14.1
'''Determine the sublimation pressure of water vapor at −60◦C using data available in the
steam tables.
Control mass: Water.'''

#Variable Declaration: 
#from table in appendix B.1.5
T1 = 213.2			#K, Temperature at state 1
P2 = 0.0129			#kPa, pressure at state 2
T2 = 233.2			#K, Temperature at state 2
hig = 2838.9		#kJ/kg, enthalpy of sublimation 
R = .46152			#Gas constant 

#Calculations:
P1 = P2*exp(-hig/R*(1/T1-1/T2)) #using relation log(P2/P1) = (hig/R)*(1/T1-1/T2) 

#Results:
print 'Sublimation Pressure: ',round(P1,5),'KPa'
Sublimation Pressure:  0.00109 KPa

Example 4

In [2]:
# -*- coding: utf8 -*-
from __future__ import division
#Example: 14.4
'''The pressure on a block of copper having a mass of 1 kg is increased in a reversible process
from 0.1 to 100 MPa while the temperature is held constant at 15◦C. Determine the work
done on the copper during this process, the change in entropy per kilogram of copper, the
heat transfer, and the change of internal energy per kilogram.
Over the range of pressure and temperature in this problem, the following data can
be used:
Volume expansivity = αP = 5.0 × 10−5 K−1
Isothermal compressibility = βT = 8.6 × 10−12 m2/N
Specific volume = 0.000 114 m3/kg'''

#Variable Declaration: 
#known data
ap = 5*10**-5				#K**-1 Volume expansivity
bt = 8.6*10**-12			#m**2/N, Isothermal compressibility
v = 0.000114				#m**3/kg, specific volume
P2 = 100*10**6				#pressure at state 2 in kPa
P1 = 100					#pressure at state 1 in kPa
T = 288.2					#Temperature in K

#Calculations:
w = -v*bt*(P2**2-P1**2)/2	#work done in J/kg
q = -T*v*ap*(P2-P1)			#heat in J/kg
du = q-w					#change in internal energy in J/kg

#Results:
print 'Change in internal energy: ',round(du,1),'J/Kg'
 
Change in internal energy:  -159.4 J/Kg

Example 5

In [3]:
# -*- coding: utf8 -*-
from __future__ import division
#Example: 14.5
'''Nitrogen is throttled from 20 MPa, −70◦C, to 2 MPa in an adiabatic, steady-state, steadyflow
process. Determine the final temperature of the nitrogen.
Control volume:
Inlet state:
Exit state:
Process:
Diagram:
Model:
Throttling valve.
P1, T1 known; state fixed.
P2 known.
Steady-state, throttling process.
Figure 14.8.
Generalized charts, Fig. D.2.'''

#Variable Declaration: 
#from table A.2
P1 = 20		#pressure at state 1 in MPa
P2 = 2		#pressure at state 2 in MPa
T1 = 203.2		#Temperature at state 1 in K
Pr1 = P1/3.39		#Reduced pressure at state 1
Pr2 = P2/3.39		#Reduced pressure at state 2
Tr1 = T1/126.2		#Reduced temperature
#from compressibility chart h1*-h1 = 2.1*R*Tc
#from zero pressure specific heat data h1*-h2* = Cp*(T1a-T2a)
#h2*-h2 = 0.5*R*Tc
#this gives dh = h1-h2 = -2.1*R*Tc+Cp*(T1a-T2a)+0.5*R*Tc
R = 0.2968		#gas constant for given substance
Tc = 126.2		#K, Constant temperature
Cp = 1.0416		#heat enthalpy at constant pressure in kJ/kg
T2 = 146		#temperature at state 2

#Calculations:
dh = 0.5*R*Tc#

#Results:
print 'Enthalpy change: ',round(dh,2),'KJ/Kg'
print 'Temperature :',round(T2,2),'K' 
Enthalpy change:  18.73 KJ/Kg
Temperature : 146.0 K

Example 6

In [5]:
# -*- coding: utf8 -*-
from __future__ import division
from math import log

#Example: 14.6
'''Nitrogen at 8 MPa, 150 K, is throttled to 0.5 MPa. After the gas passes through a short
length of pipe, its temperature is measured and found to be 125 K. Determine the heat
transfer and the change of entropy using the generalized charts. Compare these results
with those obtained by using the nitrogen tables.
Control volume:
Inlet state:
Exit state:
Process:
Diagram:
Model:
Throttle and pipe.
P1, T1 known; state fixed.
P2, T2 known; state fixed.
Steady state.
Figure 14.10.
Generalized charts, results to be compared with those
obtained with nitrogen tables.'''

#Variable Declaration: 
#from table A.2
P1 = 8					#pressure at state 1 in MPa
P2 = 0.5				#pressure at state 2 in MPa
T1 = 150				#Temperature at state 1 in K
Pr1 = P1/3.39			#Reduced pressure at state 1
Pr2 = P2/3.39			#Reduced pressure at state 2
Tr1 = T1/126.2			#Reduced temperature
T2 = 125				#Temperature at state 2
R = 0.2968				#gas constant for given substance
Tc = 126.2				#K, Constant temperature
Cp = 1.0416				#Heat enthalpy at constant pressure in kJ/kg

#Calculations:
dh = (2.35)*R*Tc+Cp*(T2-T1)		#
ds = 1.6*R-0.1*R+Cp*log(T2/T1)-R*log(P2/P1)

#Results:
print 'Enthalpy change: ',round(dh,2),'kJ/kg'
print 'Entropy Change: ',round(ds,4),'kJ/kg.K'
Enthalpy change:  61.98 kJ/kg
Entropy Change:  1.0782 kJ/kg.K

Example 7

In [6]:
# -*- coding: utf8 -*-
from __future__ import division
from math import sqrt
#Example: 14.7
'''A mixture of 80% CO2 and 20% CH4 (mass basis) is maintained at 310.94 K, 86.19 bar,
at which condition the specific volume has been measured as 0.006757 m3/kg. Calculate
the percent deviation if the specific volume had been calculated by (a) Kay’s rule and (b)
van der Waals’ equation of state.
Control mass:
State:
Model:
Gas mixture.
P, v, T known.
(a) Kay’s rule. (b) van der Waals’ equation.'''
#Keys:
#a-denotes C02
#b-denotes CH4
#c-denotes critical conditions

#Variable Declaration: 
T = 310.94				#Temperature of mixture K
P = 86.19				#Pressure of mixture in MPa
Tca = 304.1				#K
Tcb = 190.4				#K
Pca = 7.38				#MPa
Pcb = 4.60				#MPa
Ra = 0.1889				#gas constant for a in kJ/kg.K
Rb = 0.5183				#gas constant for b in kJ/kg.K
xa = 0.8				#fraction of CO2
xb = 0.2				#fraction of CH4
Ma = 44.01				#molecular mass of a
Mb = 16.043				#molecular mass of b
Zm = 0.7				#Compressiblity from generalised compressibility chart
ve = 0.0006757			#experimental specific volume in m**3/kg

#Calculations:
Rm = xa*Ra+xb*Rb		#mean gas constant in kJ/kg.K
ya = xa/Ma/(xa/Ma+xb/Mb)#mole fraction of a
yb = xb/Mb/(xa/Ma+xb/Mb)#mole fraction of b
Tcm = ya*Tca+yb*Tcb		#mean critical temp in K
Pcm = ya*Pca+yb*Tcb		#mean critical pressure n MPa
Trm = T/Tcm
Prm = P/Pcm
vc = Zm*Rm*T/P/1000		#specific volume calculated in m**3/kg
pd1 = (ve-vc)/ve*100	#percent deviation
Aa = 27*Ra**2*Tca**2/(64*Pca*1000)
Ba = Ra*Tca/(8*Pca*1000)
Ab = 27*Rb**2*Tcb**2/(64*Pcb*1000)
Bb = Rb*Tcb/(8*Pcb*1000)
Am = (xa*sqrt(Aa)+xb*sqrt(Ab))**2
Bm = (xa*Ba+xb*Bb)
vc = 0.0006326			#calculated specific volume in m**3/kg
pd2 = (ve-vc)/ve*100

#Results:
print 'Percentage deviation in specific volume using Kays rule: ',round(pd1,1),'%'
print 'Percentage deviation in specific volume using vander waals eqn: ',round(pd2,1),'%' 
Percentage deviation in specific volume using Kays rule:  4.8 %
Percentage deviation in specific volume using vander waals eqn:  6.4 %