In [1]:

```
# Given:-
m = 4.00 # mass of carbon monoxide in kg
T = 223.00 # temperature of carbon monoxide in kelvin
D = 0.2 # inner diameter of cylinder in meter
L = 1.00 # length of the cylinder in meter
pi=3.14
# Analysis
M = 28.00 # molar mass in kg/kmol
# Calculations
V = (pi*D**2.00/4.00)*L # volume occupied by the gas in m^3
vbar = M*(V/m) # The molar specific volume in m^3/kmol
# Part(a)
# From Table A-1 for CO
Tc = 133 # in kelvin
Pc = 35 # in bar
Tr = T/Tc # reduced temperature
Rbar = 8314 # universal gas constant in N.m/kmol.K
Z = 0.9
# Calculations
vrdash = (vbar*Pc*10**5)/(Rbar*Tc) # pseudoreduced specific volume
p = (Z*Rbar*T/vbar)*10**-5 # in bar
# Result
print '-> part(a)the pressure in bar is: '
print round(p,2)
# Part(b)
# The ideal gas equation of state gives
# Calculations
p = (Rbar*T/vbar)/10**5 # in bar
# Result
print '-> Part(b)the pressure in bar is: '
print round(p,2)
# Part(c)
# For carbon monoxide, the van der Waals constants a and b can be read directly from Table A-24
a = 1.474 # in (m^3/kmol)^2
b = 0.0395 # in m^3/kmol
# Calculations
p = (Rbar*T/(vbar-b))/10**5 - a/vbar**2
# Result
print '-> Part(c)the pressure in bars is: '
print round(p,2)
# Part(d)
# For carbon monoxide, the Redlich–Kwong constants can be read directly from Table A-24
a = 17.22 # in m^6*K^.5/kmol^2
b = 0.02737 # in m^3/kmol
# Calculations
p = (Rbar*T/(vbar-b))/10**5 - a/(vbar*(vbar+b)*T**.5)
# Result
print '-> Part(d)the pressure in bar is: '
print round(p,2)
```

In [2]:

```
%matplotlib inline
```

In [3]:

```
# Given:-
# Part(a)
v = 0.4646 # specific volume in in m^3/kg
M = 18.02 # molar mass of water in kg/kmol
# At the specified state, the temperature is 513 K and the specific volume on a molar basis is
vbar = v*M # in m^3/kmol
# From Table A-24
a = 142.59 # (m^3/kmol)^2 * K^.5
b = 0.0211 # in m^3/kmol
Rbar = 8314.0 # universal gas constant in N.m/kmol.K
T = 513.0 # in kelvin
delpbydelT = (Rbar/(vbar-b) + a/(2*vbar*(vbar+b)*T**1.5)*10**5)/10**3 # in kj/(m^3*K)
# By The Maxwell relation
delsbydelv = delpbydelT
# Result
print '-> The value of delpbydelT in kj/(m^3*K) is: ',delpbydelT
# Part(b)
from pylab import *
# A value for (dels/delv)T can be estimated using a graphical approach with steam table data, as follows: At 240C, Table A-4 provides the values for specific entropy s and specific volume v tabulated below
T = 240.0 # in degree celcius
# At p =1, 1.5, 3, 5, 7, 10 bar respectively
y = [7.994, 7.805, 7.477, 7.230, 7.064, 6.882] # in kj/kg.k # in kj/kg.k
x = [2.359, 1.570, 0.781, 0.4646, 0.3292, 0.2275] # in m^3/kg # in m^3/kg
plot(x,y)
xlabel("Specific volume")
ylabel("Specific entropy")
show()
# The pressure at the desired state is 5 bar.The corresponding slope is
delsbydelv = 1 # in kj/m^3.K
print '-> From the data of the table,delsbydelv = ',delsbydelv
```

In [4]:

```
# Given:-
# Analysis
# For comparison, Table A-2 gives at 100C,
hgf =2257.00 # in kj/kg
ugf = 2087.6 # in kj/kg
sgf = 6.048 # in kj/kg.K
# Values
print '-> From table, hg-hf = ',hgf
print '-> From table, ug-uf = ',ugf
print '-> From table, sg-sf = ',sgf
# Part(a)
T = 373.15 # in kelvin
# If we plot a graph between temperature and saturation pressure using saturation pressure–temperature data from the steam tables, the desired slope is:
delpbydelT = 3570.00 # in N/(m^2.K)
vg = 1.673 # in m^3/kg
vf = 1.0435e-3 # in m^3/kg
# Calculations
# From the Clapeyron equation
hgf = T*(vg-vf)*delpbydelT*10**-3 # in kj/kg
# Result
print '-> Part(a)using Clapeyron equation, hg-hf = ', round(hgf,2)
# Part(b)
psat = 1.014e5 # in N/m^2
hgf = 2256.00 # can be obtained using IT software in kj/kg
# Calculations
ugf = hgf - psat*(vg-vf)/10**3 # in kj/kg
# Result
print '-> Part(b)ug-uf = ', round(ugf,2)
# Part(c)
# Calculation
sgf =hgf/T # in kj/kg.K
# Result
print '-> Part(c)sg-sf = ', round(sgf,2)
```

In [5]:

```
# Given:-
# Part(a)
v = 1.00/998.21 # specific volume of water in m^3/kg
T = 293.00 # given temperature in kelvin
beta = 206.6e-6 # volume expansivity in /K
k = 45.90e-6 # isothermal compressibility in /bar
# Interpolating in Table A-19
cp = 4.188 # in kj/kg.k
# Calculations
cpv = (v*T*beta**2.00/k)*10**2 # in kj/kg.k
cv = cp-cpv # in kj/kg.k
errorPercentage = 100*(cp-cv)/cv
# Result
print '-> The percentage error is: ',round(errorPercentage,2)
# Part(b)
# Calculations
K = cp/cv # specific heat ratio
c = ((K*v/k)*10**5)**0.5 # velocity of sound in m/s
# Result
print '-> The velocity of sound is: ',round(c,2),'m/s'
```

In [6]:

```
# Given:-
p1 = 100.00 # in bar
T1 = 300.00 # in kelvin
p2 = 40.00 # in bar
T2 = 245.00 # in kelvin
# From table A-23
h1starbar = 8723.00 # in kj/kmol
h2starbar = 7121.00 # in kj/kmol
# From Tables A-1
Tc = 126.00 # critical temperature in kelvin
pc = 33.9 # critical pressure in bar
M = 28.00 # molar mass in kg/kmol
Rbar = 8.314 # universal gas constant in kj/(kmol.K)
Term1 = 0.5
Term2 = 0.31
# Calculations
TR1 = T1/Tc # reduced temperature at the inlet
PR1 = p1/pc # reduced pressure at the inlet
TR2 = T2/Tc # reduced temperature at the exit
PR2 = p2/pc # reduced pressure at the exit
wcvdot = (1.00/M)*(h1starbar-h2starbar-Rbar*Tc*(Term1-Term2)) # in kj/kg
# Result
print '-> The work developed, in kJ per kg of nitrogen flowing is : '
print round(wcvdot,2)
```

In [7]:

```
# Given:-
# Part(a)
# With values from Table A-23
sT2bar = 185.775 # in kj/(kmol.K)
sT1bar = 191.682 # in kj/(kmol.K)
Rbar = 8.314 # universal gas constant
M = 28.00 # molar mass in kg/kmol
p2 = 40.00 # in bar
p1 = 100.00 # in bar
Term1 = 0.21
Term2 = 0.14
# Calculations
import math
S2StarBarMinusS1StarBar = sT2bar-sT1bar-Rbar*math.log(p2/p1) # The change in specific entropy in kj/(kmol.K)
sigmacvdot = (1.00/M)*(S2StarBarMinusS1StarBar-Rbar*(Term2-Term1))
# Result
print '-> the rate of entropy production in kj/kg.K is: '
print round(sigmacvdot,2)
# Part(b)
# From Table A-23,
h2starbar = 6654.00 # in kj/kmol
h1starbar = 8723.00 # in kj/kmol
Tc = 126.00 # critical temperature in kelvin
Term2 = 0.36
Term1 = 0.5
wcvdot = 50.1 # from example 11.8
# Calculations
wcvdots = (1.00/M)*(h1starbar-h2starbar-Rbar*Tc*(Term1-Term2)) # isentropic work in kj/kg
etat = wcvdot/wcvdots # turbine efficiency
# Result
print '-> The isentropic turbine efficiency is: '
print round(etat,2)
```

In [8]:

```
# Given:-
# Analysis
V = 0.241 # volume of the mixture in m^3
T = 511.00 # temperature of the mixture in kelvin
n1 = 0.18 # number of moles of methane in kmol
n2 = 0.274 # number of moles of butane in kmol
Rbar = 8314 # universal gas constant in (N.m)/(kmol.K)
# Calculations
n = n1 + n2 # The total number of moles of mixture
y1 = n1/n # mole fraction of methane
y2 = n2/n # mole fraction of butane
vbar = V/(n) # The specific volume of the mixture on a molar basis in m^3/kmol
# Part(a)
p = (Rbar*T/vbar)*10**-5 # in bar
# Result
print '-> The pressure in bar obtained using ideal gas equation is: '
print round(p,2)
# Part(b)
# From table A-1
Tc1 = 191.00 # critical temperature for methane in kelvin
Pc1 = 46.4 # critical pressure for methane in bar
Tc2 = 425.00 # critical temperature for butane in kelvin
Pc2 = 38.00 # critical pressure for butane in bar
Z = 0.88
# Calculations
Tc = y1*Tc1 + y2*Tc2 # critical temperature in kelvin
Pc = y1*Pc1 + y2*Pc2 # critical pressure in bar
TR = T/Tc # reduced temperature of the mixture
vRdash= vbar*Pc/(Rbar*Tc)
p = ((Z*Rbar*T)/vbar)*10**-5 # mixture pressure in bar
# Result
print '-> Pressure obtained using Kay’s rule together with the generalized compressibility chart, is: '
print round(p,2)
# Part(c)
# Table A-24 gives the following van der Waals constants values for methane
a1 = 2.293 # in (m^3/kmol)^2
b1 = 0.0428 # in m^3/kmol
# Table A-24 gives the following van der Waals constants values for butane
a2 = 13.86 # in (m^3/kmol)^2
b2 = 0.1162 # in m^3/kmol
a = (y1*a1**.5 + y2*a2**.5)**2 # in bar*(m^3/kmol)^2
b = y1*b1+y2*b2 # in m^3/kmol
# From van der Waals equation
p = ((Rbar*T)/(vbar-b))*10**-5 - a/(vbar**2)
print '-> The pressure in bar from van der Waals equation is: '
print round(p,2)
# Part(d)
# For methane
TR1 = T/Tc1
vR1dash = (.241/.18)*10**5*Pc1/(Rbar*Tc1)
Z1 = 1.00
# For butane
TR2 = T/Tc2
vR2dash = (.88*10**5*Pc2)/(Rbar*Tc2)
Z2 = 0.8
Z = y1*Z1 + y2*Z2
# Accordingly, the same value for pressure as determined in part (b) using Kay’s rule results:
p = 70.4
# Result
print '-> The pressure in bar obtained using the rule of additive pressures employing the generalized compressibility chart is: '
print round(p,2)
```