Chapter 8 : Thermodynamic properties of real gases

Example 8.2 Page No : 275

In [1]:
import math 

# Variables
T = 427.85;			 #temperature of n-octane vapour in K
P = 0.215;			 #pressure of n-octane vapour in MPa
a = 3.789;			 #van der Waals constant in Pa (m**3/mol)**2
b = 2.37*10**-4;			 #van der Waals constant in m**3/mol
v = 15.675*10**-3;			 #volume occupied by n-octane vapour taken from Example (3.8) in m**3/mol
R = 8.314;			 #universal gas constant in J/molK

# Calculations
dep_h = (P*10**6*v)-(R*T)-(a/v)
dep_s = R*math.log ((P*10**6*(v-b))/(R*T));	

# Results
print " The enthalpy departure for n-octane vapour  =  %0.2f J/mol"%(dep_h);
print " The entropy departure for n-octane vapour  =  %0.4f J/mol K"%(dep_s);
 The enthalpy departure for n-octane vapour  =  -428.74 J/mol
 The entropy departure for n-octane vapour  =  -0.5757 J/mol K

Example 8.3 Page No : 276

In [10]:
from scipy.optimize import fsolve 
import math 


# Variables
T = 100.    			 #temperature of carbon dioxide in degree celsius
P = 10. 	    		 #pressure of carbon dioxide in MPa
A0 = 0.5073;			 #Beattie-Bridgman constant for carbon dioxide in (Pa m**3)/mol**2
B0 = 104.76*10**-6;			 #Beattie-Bridgman constant for carbon dioxide in m**3/mol
a = 71.32*10**-6;			 #Beattie-Bridgman constant for carbon dioxide in m**3/mol
b = 72.35*10**-6;			 #Beattie-Bridgman constant for carbon dioxide in m**3/mol
C = 660.0;		    	 #Beattie-Bridgman constant for carbon dioxide in (m**3 K**3)/mol
R = 8.314;			     #universal gas constant in J/molK

# Calculations

T = T+273.15
A1 = (R*T)  
A2 = (B0*R*T)-A0-((C*R)/T**2);			 
A3 = (a*A0)-(b*B0*R*T)-((B0*C*R)/T**2);	
A4 = ((b*C*B0*R)/T**2);			 
vguess = 0.01
tolerance = 1e-6

def solver_func(vi):
    return  (P*10**6)-((A1/vi)+(A2/vi**2)+(A3/vi**3)+(A4/vi**4))

v = fsolve(solver_func,vguess)

Z = (P*10**6*v)/(R*T)

dep_h = (((B0*R*T)-(2*A0)-((4*C*R)/(T**2)))*(1./v))+((((3./2)*a*A0)-(b*B0*R*T)-((5*B0*C*R)/(2*(T**2))))*(1./(v**2)))+((2*b*C*B0*R)/((T**2)*(v**3)));

# Results
print " Molar volume of CO2 at %0.f MPa and %0.2f K  =  %.2e m**3/mol "%(P,T,v);
print " The compressibility factor = %.4f "%(Z);
print " The enthalpy departure for carbon dioxide using the Beattie-Bridgman equation of state  =  %.f J/mol"%(dep_h);

# Note: Answer is different because of rounding off error. Please check manually.
 Molar volume of CO2 at 10 MPa and 373.15 K  =  2.33e-04 m**3/mol 
 The compressibility factor = 0.7518 
 The enthalpy departure for carbon dioxide using the Beattie-Bridgman equation of state  =  -3210 J/mol

Example 8.4 Page No : 278

In [4]:
import math

# Variables
T = 353.15    	    		 #temperature of carbon dioxide in degree celsius
P = 10. 	    	    	 #pressure of carbon dioxide in MPa
B0 = 104.76*10**-6;			 #Beattie-Bridgman constant for carbon dioxide in m**3/mol
b = 72.35*10**-6;			 #Beattie-Bridgman constant for carbon dioxide in m**3/mol
C = 660.0;			         #Beattie-Bridgman constant for carbon dioxide in (m**3 K**3)/mol
R = 8.314       			 #universal gas constant in J/molK
v = 0.233*10**-3    		 #volume calculated in Example (8.3) in m**3/mol
Z = 0.751;			         #compressibility factor as calculated in Example (8.3) (no unit)

# Calculations
A1 = ((B0*R)+((2*C*R)/(T**3)))
dep_s = (R*math.log (Z))-(A1*(1./v))+(((b*B0*R)-((2*C*B0*R)/(T**3)))*(1./(2*(v**2))))+((2*b*C*B0*R)/(3*(T**3)*(v**3)));

# Results
print " The entropy departure for carbon dioxide using the Beattie-\
Bridgman equation of state  =  %.f J/mol K"%(dep_s);

# Note: Answer is varies because of rounding off error. Please check manually.
 The entropy departure for carbon dioxide using the Beattie-Bridgman equation of state  =  -7 J/mol K

Example 8.5 Page No : 281

In [5]:
import math
# Variables
T = 427.85;			 #temperature of n-octane vapour in K
P = 0.215;			 #pressure of n-octane vapour in MPa
a = 4.426;			 #Redlich-Kwong constant taken from Example(3.9) in (m**6 Pa mol**-2)
b = 164.3*10**-6;			 #Redlich-Kwong constant taken from Example(3.9) in m**3/mol
Z = 0.9308;			 #compressibility factor taken from Example(3.9) (no unit)
B = 9.9306*10**-3;			 #value of B, used in the Cardan's method in Example (3.9)
R = 8.314;			 #universal gas constant in J/molK

# Calculations
dep_h = (R*T*(Z-1))-(((3*a)/(2*b))*math.log ((Z+B)/Z))
dep_s = (R*math.log(Z-B))-((a/(2*b*T))*math.log((Z+B)/Z))

# Results
print " The enthalpy departure for n-octane vapour using the generalized Redlich\
-Kwong equation of state  =  %0.2f J/mol"%(dep_h);
print " The entropy departure for n-octane vapour using the generalized Redlich\
-Kwong equation of state  =  %0.4f J/mol K"%(dep_s);
 The enthalpy departure for n-octane vapour using the generalized Redlich-Kwong equation of state  =  -674.98 J/mol
 The entropy departure for n-octane vapour using the generalized Redlich-Kwong equation of state  =  -1.0195 J/mol K

Example 8.6 Page No : 281

In [6]:
import math
# Variables
T = 427.85			 #temperature of n-octane vapour in K
P = 0.215			 #pressure of n-octane vapour in MPa
S = 1.0786			 #constant used in the SRK equation of state,from Example(3.15)
alpha = 1.3079		 #constant used in the SRK equation of state,from Example(3.15)
a = 5.0180			 #constant used in the SRK equation of state,from Example(3.15) in (m**6 Pa mol**-2)
b = 1.6426*10**-4			 #constant used in the SRK equation of state,from Example(3.15) in m**3/mol
B = 9.9282*10**-3			 #factor used in the Cardan's method for solving the SRK equation of state,from Example(3.15) (no unit)
Z = 0.9191;			 #compressibility factor taken from Example (3.15) (no unit)
R = 8.314;			 #universal gas constant in J/molK
Tc = 569.4;			 #critical temperature of n-octane in K

# Calculations
da_dT = (-a*S)/(math.sqrt (alpha*T*Tc))
dep_h = (R*T*(Z-1))+((((T*da_dT)-a)/b)*math.log ((Z+B)/Z));			 
dep_s = (R*math.log (Z-B))+((1./b)*(da_dT)*math.log ((Z+B)/Z));		

# Results
print " The enthalpy departure for n-octane vapour using the SRK equation of state  =  %f J/mol"%(dep_h);
print " The entropy departure for n-octane vapour using the SRK equation of state  =  %0.4f J/mol K"%(dep_s);
 The enthalpy departure for n-octane vapour using the SRK equation of state  =  -884.335509 J/mol
 The entropy departure for n-octane vapour using the SRK equation of state  =  -1.4188 J/mol K

Example 8.7 Page No : 282

In [7]:
import math
# Variables
T = 427.85			 #temperature of n-octane vapour in K
P = 0.215			 #pressure of n-octane vapour in MPa
S = 0.9457			 #constant used in the Peng-Robinson equation of state,from Example(3.16)
alpha = 1.2677		 #constant used in the Peng-Robinson equation of state,from Example(3.16)
a = 5.2024			 #constant used in the Peng-Robinson equation of state,from Example(3.16) in (m**6 Pa mol**-2)
b = 1.4750*10**-4	 #constant used in the Peng-Robinson equation of state,from Example(3.16) in m**3/mol
B = 8.9151*10**-3	 #factor used in the Cardan's method for solving the Peng-Robinson equation of state,from Example(3.16) (no unit)
Z = 0.9151			 #compressibility factor taken from Example (3.16) (no unit)
R = 8.314			 #universal gas constant in J/molK
Tc = 569.4			 #critical temperature of n-octane in K

# Calculations
da_dT = (-a*S)/(math.sqrt (alpha*T*Tc))

dep_h = (R*T*(Z-1))+(((((T*da_dT)-a)/(2*math.sqrt(2)*b)))*(math.log ((Z+(B*(1+math.sqrt (2))))/(Z+(B*(1-math.sqrt (2)))))));
dep_s = (R*math.log (Z-B))+((1./(2*math.sqrt (2)*b))*(da_dT)*(math.log ((Z+(B*(1+math.sqrt (2))))/(Z+(B*(1-math.sqrt (2)))))));		

# Results
print " The enthalpy departure for n-octane vapour using the Peng-Robinson \
 equation of state  =  %0.1f J/mol"%(dep_h);
print " The entropy departure for n-octane vapour using the Peng-Robinson\
 equation of state  =  %0.3f J/mol K"%(dep_s);
 The enthalpy departure for n-octane vapour using the Peng-Robinson  equation of state  =  -890.1 J/mol
 The entropy departure for n-octane vapour using the Peng-Robinson equation of state  =  -1.398 J/mol K

Example 8.8 Page No : 284

In [8]:
# Variables
T = 339.7			 #temperature of ethylene in K
P = 30.7			 #pressure of ethylene in bar
Tc = 283.1			 #critical temperature of ethylene in K
Pc = 51.17			 #critical pressure of ethylene in bar
w = 0.089			 #acentric factor (no unit)
R = 8.314			 #universal gas constant in J/molK

# Calculations
Pr = P/Pc
Tr = T/Tc
del_h0 = 0.45
del_h1 = 0.18
del_s0 = 0.26
del_s1 = 0.20
dep_h = ((del_h0)+(w*del_h1))*R*Tc
dep_s = ((del_s0)+(w*del_s1))*R;	

# Results
print " The enthalpy departure for ethylene using the Edmister charts  =  %0.3f J/mol"%(dep_h);
print " The entropy departure for ethylene using the Edmister charts  =  %0.4f J/mol K"%(dep_s);
 The enthalpy departure for ethylene using the Edmister charts  =  1096.868 J/mol
 The entropy departure for ethylene using the Edmister charts  =  2.3096 J/mol K

Example 8.9 Page No : 297

In [9]:
# Variables
T = 339.7;			 #temperature of ethylene in K
P = 30.7;			 #pressure of ethylene in bar
Tc = 283.1;			 #critical temperature of ethylene in K
Pc = 51.17;			 #critical pressure of ethylene in bar
w = 0.089;			 #acentric factor (no unit)
R = 8.314;			 #universal gas constant in J/molK

# Calculations
Pr = P/Pc
Tr = T/Tc
del_h0 = 0.474
del_h1 = 0.232
del_s0 = 0.277
del_s1 = 0.220
dep_h = ((del_h0)+(w*del_h1))*R*Tc
dep_s = ((del_s0)+(w*del_s1))*R

# Results
print " The enthalpy departure for ethylene using the Lee-Kesler data  =  %f J/mol"%(dep_h);
print " The entropy departure for ethylene using the Lee-Kesler data  =  %f J/mol K"%(dep_s);
 The enthalpy departure for ethylene using the Lee-Kesler data  =  1164.249733 J/mol
 The entropy departure for ethylene using the Lee-Kesler data  =  2.465766 J/mol K

Example 8.10 Page No : 299

In [10]:
# Variables
T = 339.7;			 #temperature of ethylene in K
P = 1.  			 #pressure of ethylene in bar
Tc = 283.1;			 #critical temperature of ethylene in K
Pc = 51.17;			 #critical pressure of ethylene in bar
w = 0.089;			 #acentric factor (no unit)
R = 8.314;			 #universal gas constant in J/molK

# Calculations
Pr = P/Pc
Tr = T/Tc
dep_h = R*Tc*Pr*((0.083-(1.097/(Tr**1.6)))+(w*(0.139-(0.894/(Tr**4.2)))))
dep_s = -Pr*R*((0.675/(Tr**2.6))+(w*(0.722/(Tr**5.2))));			 

# Results
print " The enthalpy departure for ethylene using the generalized virial coefficient \
correlation  =  %f J/mol"%(dep_h);
print " The entropy departure for ethylene using the generalized virial coefficient \
correlation  =  %e J/mol K"%(dep_s);
 The enthalpy departure for ethylene using the generalized virial coefficient correlation  =  -35.011078 J/mol
 The entropy departure for ethylene using the generalized virial coefficient correlation  =  -7.232682e-02 J/mol K

Example 8.11 Page No : 299

In [20]:
import math
import cmath

# Variables
T = 427.85			 #temperature of n-octane vapour in K
P = 0.215			 #pressure of n-octane vapour in MPa
T_ref = 0.			 #reference state saturated liquid temperature in degree celsius
h0 = 0. 			 #enthalpy of saturated liquid in J/mol (reference state)
s0 = 0. 			 #entropy of saturated liquid in J/molK (reference state)
Tc = 569.4;			 #critical temperature of n-octane in K
Pc = 24.97;			 #critical pressure of n-octane in bar
w = 0.398;			 #acentric factor (no unit)
NBP = 398.8;			 #normal boiling point of n-octane (saturated liquid)
Cp = [6.907,741.770*10**-3,-397.204*10**-6,82.629*10**-9,0]			 #coefficients to compute the isobaric molar heat capacity, where Cp = a+bT+cT**2+dT**3+eT**-2,in J/molK
S = 0.9457;			 #value of S taken from Example (3.16)
b = 1.4750*10**-4;			 #value of the Peng-Robinson constant in m**3/mol from Example (3.16)
v = 15.14*10**-3;			 #volume of saturated vapour in m**3/mol from Example (3.16)
R = 8.314;			 #universal gas constant in J/molK
P_amb = 101.325;			 #pressure at which the normal boiling point is computed in kPa

# Calculations

#Step a: Vaporization of n-octane at T_ref
T_ref = T_ref+273.15

del_hv = ((R*math.log ((Pc*10**5)/(P_amb*10**3)))/((1./NBP)-(1./Tc)))*10**-3;
P2 = P_amb* math.exp (((del_hv*10**3)/(R))*((1./NBP)-(1./T_ref)))
Tbr = NBP/Tc
			
del_hvn = (1.093*R*Tc*(Tbr*(((math.log (Pc))-1.013)/(0.930-Tbr))))*10**-3;
Tr2 = T_ref/Tc

del_ha = ((del_hvn*10**3)*(((1-Tr2)/(1-Tbr))**(0.38)))*10**-3;
del_sa = (del_ha*10**3)/T_ref

alpha = (1+(S*(1-math.sqrt (Tr2))))**2
a = (0.45724*(R**2)*(Tc**2)*alpha)/(Pc*10**5)

A = (a*P2*10**3)/(R*T_ref)**2
B = (b*P2*10**3)/(R*T_ref);	
alpha = -1+B;			 
beeta = A-(2*B)-(3*B**2);
gaamma = -(A*B)+(B**2)+(B**3);			 
p = beeta-(alpha**2)/3;			 
q = ((2*alpha**3)/27)-((alpha*beeta)/3)+gaamma
D = (((q)**2)/4)+(((p)**3)/27);			

if D>0:
    Z = ((-q/2)+(math.sqrt(D)))**(1./3)+((-q/2)-(math.sqrt(D)))**(1./3)-(alpha/3)
elif D == 0:
    Z1 = ((-2*(q/2))**(1./3))-(alpha/3)
    Z2 = ((q/2)**(1./3))-(alpha/3);
    Z3 = ((q/2)**(1./3))-(alpha/3);
    Za = [Z1 ,Z2, Z3];
    Z = max(Za);
else:
    theta = math.cos((-(q)/2)*(math.sqrt((-27)/(((p)**3)))))
    r = math.sqrt((-(p**3)/27));			 
    Z1 = (2*(r**(1./3))*math.cos(theta/3))-(alpha/3);
    Z2 = (2*(r**(1./3))*math.cos(((2*math.pi)+theta)/3))-(alpha/3)
    Z3 = (2*(r**(1./3))*math.cos(((4*math.pi)+theta)/3))-(alpha/3)
    Za = [Z1, Z2, Z3];
    Z = max(Za);
da_dT = (-a*S)/(cmath.sqrt(alpha*T_ref*Tc));			 

dep_h = (R*T_ref*(Z-1))+(((((T_ref*da_dT)-a)/(2*math.sqrt(2)*b)))*(math.log ((Z+(B*(1+math.sqrt (2))))/(Z+(B*(1-math.sqrt (2)))))));
dep_s = (R*math.log (Z-B))+((1./(2*math.sqrt (2)*b))*(da_dT)*(math.log ((Z+(B*(1+math.sqrt (2))))/(Z+(B*(1-math.sqrt (2)))))));
del_hb = -dep_h
del_sb = -dep_s

del_hc = ((Cp[0]*(T-T_ref))+(((Cp[1])/2)*((T**2)-(T_ref**2)))+(((Cp[2])/3)*((T**3)-(T_ref**3)))+(((Cp[3])/4)*((T**4)-(T_ref**4)))-((Cp[4])*((1./T)-(1./T_ref))))*10**-3;
del_sc = ((Cp[0])*math.log (T/T_ref))+((Cp[1])*(T-T_ref))+(((Cp[2])/2)*((T**2)-(T_ref**2)))+(((Cp[3])/3)*((T**3)-(T_ref**3)))-(((Cp[4])/2)*((1./(T**2))-(1./(T_ref**2))))-(R*math.log((P*10**6)/(P2*10**3)))			 

Z = 0.9151
da_dT = (-a*S)/(cmath.sqrt (alpha*T*Tc));			 

del_hd = (R*T*(Z-1))+((((T*da_dT)-a)/(2*math.sqrt(2)*b))*math.log ((Z+(B*(1+math.sqrt (2))))/(Z+(B*(1-math.sqrt (2))))));

del_sd = (R*math.log (Z-B))+((1./(2*math.sqrt(2)*b))*(da_dT)*(math.log ((Z+(B*(1+math.sqrt (2))))/(Z+(B*(1-math.sqrt (2)))))));

h = h0+del_ha+(del_hb*10**-3)+del_hc+(del_hd*10**-3)
s = s0+del_sa+del_sb+del_sc+del_sd;			 

# Results
print " The enthalpy of n-octane vapour at 427.85K and 0.215MPa using the Peng-Robinson equation\
 of state  =",h, "kJ/mol"
print " The entropy of n-octane vapour at 427.85K and 0.215MPa using the Peng-Robinson\
 equation of state  = ",s," J/mol K"
print " The volume of n-octane vapour at 427.85K and 0.215MPa using the Peng-Robinson\
 equation of state  =",v," m**3/mol"


#THE VOLUME OF n-OCTANE VAPOUR AS COMPUTED IN EXAMPLE 3.16 IS 15.14*10**-3 m**3/mol AND NOT 
#15.41*10**-3 m**3/mol AS PRINTED IN THIS EXAMPLE IN THE TEXTBOOK.
# So ANSWER WOULD BE DIFFERENT
 The enthalpy of n-octane vapour at 427.85K and 0.215MPa using the Peng-Robinson equation of state  = (76.8343786515+0.000518888144511j) kJ/mol
 The entropy of n-octane vapour at 427.85K and 0.215MPa using the Peng-Robinson equation of state  =  (207.222784016-0.000740500199878j)  J/mol K
 The volume of n-octane vapour at 427.85K and 0.215MPa using the Peng-Robinson equation of state  = 0.01514  m**3/mol