# Chapter 10 : Vapor Liquid Equilibrium VLE at High Pressures¶

### Example 10.1 Page: 260¶

In [33]:
import math

# Variables
P = 100.                #[psia] Bubble point pressure
x_ethane = 0.10         # Mole fraction of ethane in liquid phase
x_hepmath_tane = (1-x_ethane)

# a) From figure 10.7( page 260 ) given in the book
# We read the chart to get the bubble-point temperature
# The dew point curve for 100 psia crosses the 10 mol% ethane line at about temperature
T1 = 165.               #[C]
# Now, we horizontally from that intersection point to the dew-point curve, finding the vapor phase composition of ethane
y1_e = 0.92
y1_h = (1- y1_e)

# b) By Raoult's law, we use a trial and error procedureon the temperature
# Antoine equation consmath.tants for ethanol are given
A_e = 6.80267
B_e = 656.4028
C_e = 255.99

# and that for n-hepmath_tane are
A_h = 6.9024
B_h = 1268.115
C_h = 216.9

# Antoine equation is given by
# (math.log10p) = (A - B/(T+C))
T = 50.                     #[C]
err = 1.

# Calculations
while err > 10**(-4):
p1_e = (10**(A_e - B_e/(C_e + T)))*(14.7/760)
p1_h = (10**(A_h - B_h/(C_h + T)))*(14.7/760)
y2_e = p1_e*x_ethane/P
y2_h = p1_h*x_hepmath_tane/P
err = abs((y2_e + y2_h) - 1)
T = T + 0.0001

# Changing the temperature in deg F
T2 = T*9./5 + 32            #[F] Bubble-point temperature

# c) In this method, we use L-R rule, instead of simple Raoult's law
# So,
# y_i = (x_i*p_i)/(v_i*P)
# Where calculated values of v_i from EOS are given in the table 10.A and are
v_e = 0.950                     # For ethane
v_h = 0.459                     # For n-hepmath_tane

# We again use trial and error on the temperature
# Let us assume the initial temperature
Ti = 50.                       #[C]
err = 1

while err > 10**(-4):
p2_e = (10**(A_e - B_e/(C_e + Ti)))*(14.7/760)
p2_h = (10**(A_h - B_h/(C_h + Ti)))*(14.7/760)
y3_e = p2_e*x_ethane/(P*v_e)
y3_h = p2_h*x_hepmath_tane/(P*v_h)
err = abs((y3_e + y3_h) - 1)
Ti = Ti + 0.0001

# Changing the temperature in deg F
T3 = Ti*9./5 + 32               #[F] Bubble-point temperature

# Results
print " The results are summarized in the following table:"
print " Variable \t Values calculated from\t Values calculated from \t Values calculated  "
print "               \t from figure 10.7  \t Raoult''s law \t\t\t from L-R rule"
print " Tdeg F) \t %f \t\t %f \t\t\t    %f"%(T1,T2,T3)
print " y_ethane \t %f \t\t %f \t\t\t    %f"%(y1_e,y2_e,y3_e)
print " y_heptane \t %f \t\t %f \t\t\t    %f"%(y1_h,y2_h,y3_h)
print "\nWhere T is boiling point temperature"

 The results are summarized in the following table:
Variable 	 Values calculated from	 Values calculated from 	 Values calculated
from figure 10.7  	 Raoult''s law 			 from L-R rule
Tdeg F) 	 165.000000 		 133.014380 			    124.179620
y_ethane 	 0.920000 		 0.968397 			    0.943469
y_heptane 	 0.080000 		 0.031504 			    0.056431

Where T is boiling point temperature


### Example 10.2 Page: 262¶

In [23]:

import math

# Variables
P = 800.            #[psia] Bubble point pressure
x_ethane = 0.60     # Mole fraction of ethane in liquid phase
x_hepmath_tane = (1-x_ethane)

# a) From figure 10.7( page 260 ) given in the book
# We read the chart to get the bubble-point temperature
# The dew point curve for 800 psia crosses the 60 mol% ethane line at about temperature
# T1 = 165
# Now, we horizontally from that intersection point to the dew-point curve, finding the vapor phase composition of ethane
# y1_e = 0.95
# But, by linear interpolation in the experimental data on which Figure 10.7 is based we make a slightly more reliable estimate and get
T1 = 209.           #[F]
y1_e = 0.945
y1_h = (1- y1_e)

# b) By Raoult's law, we use a trial and error procedureon the temperature
# Antoine equation consmath.tants for ethanol are given
A_e = 6.80267
B_e = 656.4028
C_e = 255.99

# and that for n-hepmath_tane are
A_h = 6.9024
B_h = 1268.115
C_h = 216.9

# Antoine equation is given by
# (math.log10p) = (A - B/(T+C))
T = 50.             #[C]
err = 1.

# Calculations
while err > 10**(-4):
p1_e = (10**(A_e - B_e/(C_e + T)))*(14.7/760)
p1_h = (10**(A_h - B_h/(C_h + T)))*(14.7/760)
y2_e = p1_e*x_ethane/P
y2_h = p1_h*x_hepmath_tane/P
err = abs((y2_e + y2_h) - 1)
T = T + 0.0001

# Changing the temperature in deg F
T2 = T*9./5 + 32            #[F] Bubble-point temperature

# c) In this method, we use L-R rule, instead of simple Raoult's law
# So,
# y_i = (x_i*p_i)/(v_i*P)
# Where calculated values of v_i from EOS are given
v_e = 0.6290642             # For ethane
v_h = 0.0010113             # For n-hepmath_tane

# We again use trial and error on the temperature
# Let us assume the initial temperature
Ti = 10.                    #[C]
err = 1.

while err > 10**(-4):
p2_e = (10**(A_e - B_e/(C_e + Ti)))*(14.7/760)
p2_h = (10**(A_h - B_h/(C_h + Ti)))*(14.7/760)
y3_e = p2_e*x_ethane/(P*v_e)
y3_h = p2_h*x_hepmath_tane/(P*v_h)
err = abs((y3_e + y3_h) - 1)
Ti = Ti + 0.0001

# Changing the temperature in deg F
T3 = Ti*9./5 + 32           #[F] Bubble-point temperature

# Results
print " The results are summarized in the following table:"
print " \t   Variable \t\t Values calculated from\t Values calculated from Values calculated"
print " \t\t\t\t from figure 10.7 \t Raoult''s law \t\t from L-R rule"
print " \n\t  Tdeg F \t\t %f \t\t %f \t\t    %f"%(T1,T2,T3)
print " \t  y_ethane \t\t %f \t\t %f \t\t    %f"%(y1_e,y2_e,y3_e)
print " \t  y_heptane \t\t %f \t\t %f \t\t    %f"%(y1_h,y2_h,y3_h)
print "\nWhere T is boiling point temperature"

 The results are summarized in the following table:
Variable 		 Values calculated from	 Values calculated from Values calculated
from figure 10.7 	 Raoult''s law 		 from L-R rule

Tdeg F 		 209.000000 		 172.210640 		    70.854980
y_ethane 		 0.945000 		 0.996044 		    0.632080
y_heptane 		 0.055000 		 0.003856 		    0.367822

Where T is boiling point temperature


### Example 10.3 Page: 262¶

In [1]:


from scipy.optimize import fsolve
import math

# Variables
# The initial data for this example is same as that of example 10.2, i.e.
P = 800.             #[psia] Bubble point pressure
x_e = 0.60           # Mole fraction of ethane in liquid phase
x_h = (1-x_e)        # Mole fraction of n-hepmath.tane in the liquid phase
R = 0.08314         #( L*bar/(mol*K)) Universal gas consmath.tant

# Changing the pressure in bar
Pb = (800/14.7)*(1.01325)           #[bar]

# In this problem we will denote ethane by 'e' and that to n-hepmath.tane by 'h'
# From table A.1 ( page 417 ) given in the book, critical temperatures of ethane and hepmath.tane are
T_c_e = 305.3           #[K]
T_c_h = 540.2           #[K]

# and critical pressures are
P_c_e = 48.72           #[bar]
P_c_h = 27.40           #[bar]

# also the accentric facors are
w_e = 0.1
w_h = 0.35

# Thus we have
P_r_e = Pb/P_c_e
P_r_h = Pb/P_c_h

# Now from equations (F.13) and (F.14) ( page 459 ) given in the book we have
# A_e = 0.42747 + ( 1 + (0.480 + 1.574*w_e - 0.17*w_e**(2))*( 1 - T_r_e**(0.5)))**(2)*(P_r_e/T_r_e**(2))
# A_h = 0.42747 + ( 1 + (0.480 + 1.574*w_h - 0.17*w_h**(2))*( 1 - T_r_h**(0.5)))**(2)*(P_r_h/T_r_h**(2))
# and
# B_e = 0.08664*(P_r_e/T_r_e)
# B_h = 0.08664*(P_r_h/T_r_h)

# We will take the help trial and error method both on Temperature and the vapor phase composition of ethane
# Let us assume the starting temperature 200 deg F. Changing this temperature in K
T = (200-32)*5./9 + 273.15           #[K]
err = 1

# Calculations
while err > 10**(-4):
T_r_e = T/T_c_e
T_r_h = T/T_c_h
A_e = 0.42747*( 1 + (0.480 + 1.574*w_e - 0.17*w_e**(2))*( 1 - T_r_e**(0.5)))**(2)*(P_r_e/T_r_e**(2))
A_h = 0.42747*( 1 + (0.480 + 1.574*w_h - 0.17*w_h**(2))*( 1 - T_r_h**(0.5)))**(2)*(P_r_h/T_r_h**(2))

B_e = 0.08664*(P_r_e/T_r_e)
B_h = 0.08664*(P_r_h/T_r_h)

# Now we will take the starting value of vapor phase composition of ethane as
y_e = 0.9
err1 = 1

while err1 > 10**(-6):
# Now value of A_mix and B_mix for both liquid and vapor phase are calculated as

A_mix_l = (x_e*math.sqrt(A_e) + x_h*math.sqrt(A_h))**(2)        # For liquid phase
A_mix_v = (y_e*math.sqrt(A_e) + (1 - y_e)*math.sqrt(A_h))**(2)  # For vapor phase
B_mix_l = (x_e*B_e + x_h*B_h)                                   # For liquid
B_mix_v = (y_e*B_e + (1 - y_e)*B_h)                             # For liquid

def f(z1):
return  z1**(3) - z1**(2) + z1*(A_mix_l - B_mix_l - B_mix_l**(2)) - A_mix_l*B_mix_l
z_l = fsolve(f,0.2)
# and
def g(z2):
return  z2**(3) - z2**(2) + z2*(A_mix_v - B_mix_v - B_mix_v**(2)) - A_mix_v*B_mix_v
z_v = fsolve(g,0.3)
# Now
phi_el = B_e/B_mix_l*( z_l - 1) - math.log(z_l - B_mix_l) - (A_mix_l/B_mix_l)*(2*math.sqrt(A_e/A_mix_l)-B_e/B_mix_l)*math.log(1-B_mix_l/z_l)
phi_hl = B_h/B_mix_l*( z_l - 1) - math.log(z_l - B_mix_l) - (A_mix_l/B_mix_l)*(2*math.sqrt(A_h/A_mix_l)-B_h/B_mix_l)*math.log(1-B_mix_l/z_l)
phi_ev = B_e/B_mix_v*( z_v - 1) - math.log(z_v - B_mix_v) - (A_mix_v/B_mix_v)*(2*math.sqrt(A_e/A_mix_v)-B_e/B_mix_v)*math.log(1-B_mix_v/z_v)
phi_hv = B_h/B_mix_v*( z_v - 1) - math.log(z_v - B_mix_v) - (A_mix_v/B_mix_v)*(2*math.sqrt(A_h/A_mix_v)-B_h/B_mix_v)*math.log(1-B_mix_v/z_v)
K_e = phi_el/phi_ev
K_h = phi_hl/phi_hv
y_e1 = K_e*x_e
y_h1 = K_h*x_h
err1 =abs((y_e1 - y_e))
y_e = y_e1

err = abs((y_e1 + y_h1) -1)
T = T + 0.1

# Changing the temperature in deg F, we have
Tf = ( T - 273.15)*9./5 + 32         #[F]

# Results
print " Bubble point of the given ethanol and n-hepmath.tane mixture at 800 psia is %f deg F"%(Tf)
print " Amount of ethanol in the vapour phase of the mixture at the given condition is %f "%(y_e1)
print " Amount of n-heptane in the vapour phase of the mixture at the given condition is %f "%(y_h1)

# Answers may vary because of rounding error.

 Bubble point of the given ethanol and n-hepmath.tane mixture at 800 psia is 200.180000 deg F
Amount of ethanol in the vapour phase of the mixture at the given condition is 0.599997
Amount of n-heptane in the vapour phase of the mixture at the given condition is 0.399997

/usr/lib/python2.7/dist-packages/scipy/optimize/minpack.py:227: RuntimeWarning: The iteration is not making good progress, as measured by the
improvement from the last five Jacobian evaluations.
warnings.warn(msg, RuntimeWarning)
/usr/lib/python2.7/dist-packages/scipy/optimize/minpack.py:227: RuntimeWarning: The iteration is not making good progress, as measured by the
improvement from the last ten iterations.
warnings.warn(msg, RuntimeWarning)

In [ ]: