Chapter 10 - Vapour liquid equillibrium

Example: 10.1 Page: 390

In [1]:
print "Example: 10.1 - Page: 390\n\n"

# Mathematics is involved in proving but just that no numerical computations are involved.
# For prove refer to this example 10.1 on page number 390 of the book.

print " Mathematics is involved in proving but just that no numerical computations are involved.\n\n"
print " For prove refer to this example 10.1 on page 390 of the book."
Example: 10.1 - Page: 390


 Mathematics is involved in proving but just that no numerical computations are involved.


 For prove refer to this example 10.1 on page 390 of the book.

Example: 10.2 Page: 399

In [2]:
print "Example: 10.2 - Page: 399\n\n"

# Mathematics is involved in proving but just that no numerical computations are involved.
# For prove refer to this example 10.2 on page number 399 of the book.

print " Mathematics is involved in proving but just that no numerical computations are involved.\n\n"
print " For prove refer to this example 10.2 on page 399 of the book."
Example: 10.2 - Page: 399


 Mathematics is involved in proving but just that no numerical computations are involved.


 For prove refer to this example 10.2 on page 399 of the book.

Example: 10.3 Page: 400

In [3]:
from __future__ import division
print "Example: 10.3 - Page: 400\n\n"

# Solution

#*****Data******#
x1 = 0.6## [mole fraction of ethylene]
x2 = 0.4## [mole fraction of propylene]
T = 423## [K]
P1_sat = 15.2## [vapour pressure of ethylene, atm]
P2_sat = 9.8## [vapour pressure of propylene, atm]
#**************#

P = x1*P1_sat + x2*P2_sat## [atm]
print "The total pressure is %.2f atm\n"%(P)#
# In vapour phase:
y1 = x1*P1_sat/P## [mole fraction of ethylene]
y2 = x2*P2_sat/P## [mole fraction of propylene]
print "Mole fraction of ethylene in vapour phase is %.1f\n"%(y1)#
print "Mole fraction of propylene in the vapour phase is %.1f\n"%(y2)#
Example: 10.3 - Page: 400


The total pressure is 13.04 atm

Mole fraction of ethylene in vapour phase is 0.7

Mole fraction of propylene in the vapour phase is 0.3

Example: 10.4 Page: 400

In [1]:
from __future__ import division
from scipy.optimize import fsolve
from math import exp
print "Example: 10.4 - Page: 400\n\n"

# Solution

#*****Data******#
Temp = 77## [OC]
P = 75## [kPa]
#deff('[P1] = f1(T)','P1 = exp(14.35 - 2942/(T + 220))')#
#deff('[P2] = f2(T)','P2 = exp(14.25 - 2960/(T + 210))')#
def f1(T):
    P1 = exp(14.35 - 2942/(T + 220))
    return P1

def f2(T):
    P2 = exp(14.25 - 2960/(T + 210))
    return P2


#*************#

P1sat = f1(Temp)## [kPa]
P2sat = f2(Temp)## [kPa]
#deff('[y] = f3(x1)','y = P - (x1*P1sat) - (1 - x1)*P2sat')#
def f3(x1):
    y = P - (x1*P1sat) - (1 - x1)*P2sat
    return y
x1 = fsolve(f3,7)#
x2 = 1 - x1#
print "In Liquid phase\n"
print "The mole fraction of X is %.3f\n"%(x1)#
print "The mole fraction of Y is %.3f\n"%(x2)#

y1 = x1*P1sat/P#
y2 = 1 - y1#
print "In Vapour phase\n"
print "The mole fraction of X is %.3f\n"%(y1)#
print "The mole fraction of Y is %.3f\n"%(y2)#
Example: 10.4 - Page: 400


In Liquid phase

The mole fraction of X is 0.701

The mole fraction of Y is 0.299

In Vapour phase

The mole fraction of X is 0.796

The mole fraction of Y is 0.204

Example: 10.5 Page: 401

In [2]:
from __future__ import division
from math import exp
print "Example: 10.5 - Page: 401\n\n"

# Solution

#*****Data******#
#deff('[P1] = f1(T)','P1 = exp(14.3916 - 2795/(T + 230))')#
def f1(T):
    P1 = exp(14.3916 - 2795/(T + 230))
    return P1

#deff('[P2] = f2(T)','P2 = exp(14.2724 - 2945.47/(T + 224))')#
def f2(T):
    P2 = exp(14.2724 - 2945.47/(T + 224))
    return P2
#deff('[P3] = f3(T)','P3 = exp(14.2043 - 2972.64/(T + 209))')#
def f3(T):
    P3 = exp(14.2043 - 2972.64/(T + 209))
    return P3

#*************#

# Solution (i)

#*****Data******#
Temp = 75## [OC]
P = 75## [kPa]
x1 = 0.30#
x2 = 0.40#
#*************#

x3 = 1 - (x1 + x2)#
P1sat = f1(Temp)## [kPa]
P2sat = f2(Temp)## [kPa]
P3sat = f3(Temp)## [kPa]
P = x1*P1sat + x2*P2sat + x3*P3sat## [kPa]
y1 = x1*P1sat/P#
y2 = x2*P2sat/P#
y3 = x3*P3sat/P#
print "Solution (i)\n"
print "The mole fraction of acetone is %.3f\n"%(y1)#
print "The mole fraction of acetonitrile is %.3f\n"%(y2)#
print "The mole fraction of nitromethane is %.3f\n"%(y3)#

# Solution (ii)

#*****Data*****#
Temp = 80## [OC]
y1 = 0.45#
y2 = 0.35#
#**************#

y3 = 1 - (y1 + y2)#
P1sat = f1(Temp)## [kPa]
P2sat = f2(Temp)## [kPa]
P3sat = f3(Temp)## [kPa]
P = 1/((y1/P1sat) + (y2/P2sat) + (y3/P3sat))## [kPa]
x1 = y1*P/P1sat#
x2 = y2*P/P2sat#
x3 = y3*P/P3sat#
print "Solution (ii)\n"
print "The mole fraction of acetone is %.3f\n"%(x1)#
print "The mole fraction of acetonitrile is %.3f\n"%(x2)#
print "The mole fraction of nitromethane is %.3f\n"%(x3)#
Example: 10.5 - Page: 401


Solution (i)

The mole fraction of acetone is 0.549

The mole fraction of acetonitrile is 0.327

The mole fraction of nitromethane is 0.124

Solution (ii)

The mole fraction of acetone is 0.216

The mole fraction of acetonitrile is 0.371

The mole fraction of nitromethane is 0.413

Example: 10.6 Page: 403

In [9]:
from __future__ import division
from math import exp
print "Example: 10.6 - Page: 403\n\n"

# Solution

#*****Data******#
#deff('[P1] = f1(T)','P1 = exp(16.5915 - 3643.31/(T - 33.424))')#
def f1(T):
    P1 = exp(16.5915 - 3643.31/(T - 33.424))
    return P1
#deff('[P2] = f2(T)','P2 = exp(14.2532 - 2665.54/(T - 53.424))')#
def f2(T):
    P2 = exp(14.2532 - 2665.54/(T - 53.424))
    return P2
#deff('[A] = f3(T)','A = 2.771 - 0.00523*T')#
def f3(T):
    A = 2.771 - 0.00523*T
    return A

Temp = 318.15## [K]
x1 = 0.25#
#**************#

P1sat = f1(Temp)## [kPa]
P2sat = f2(Temp)## [kPa]
A = f3(Temp)#
x2 = 1 - x1#
gama1 = exp(A*x2**2)#
gama2 = exp(A*x1**2)#
P = x1*gama1*P1sat + x2*gama2*P2sat#
y1 = x1*gama1*P1sat/P#
y2 = x2*gama2*P2sat/P#
print "In Vapour phase\n"
print "The mole fraction of methanol is %.3f\n"%(y1)#
print "The mole fraction of methyl acetate is %.3f\n"%(y2)#
Example: 10.6 - Page: 403


In Vapour phase

The mole fraction of methanol is 0.282

The mole fraction of methyl acetate is 0.718

Example: 10.7 Page: 408

In [10]:
from __future__ import division
from math import exp,log
print "Example: 10.7 - Page: 408\n\n"

# Solution

#*****Data******#
Temp = 30## [OC]
A = 0.625#
#**************#

P1sat = exp(13.71 - 3800/Temp)## [kPa]
P2sat = exp(14.01 - 3800/Temp)## [kPa]
# At azeotropic point:
# P = gama1*P1sat + gama2*P2sat
# gama1/gama2 = P2sat/P1sat
# log(gama1) - log(gama2) = log(P2sat) - log(P1sat)
# Val = log(gama1) - gama2
Val = log(P2sat) - log(P1sat)#
# log(gama1) = (A*x2**2)
# log(gama2) = (A*x1**2)
# A(x2**2 - x1**2) = 0.625*(x2**2 - x1**2)..................... (1)
# x1 + x2 = 1............................................. (2)
# On simplifying, we get:
# A*(1 - (2*x1)) = Val
x1 = (1/2)*(1 - Val/A)#
x2 = 1 - x1#
print "Azeotropic Composition\n"
print "The mole fraction of component 1 is %.3f\n"%(x1)#
print "The mole fraction of component 2 is %.3f\n"%(x2)#
Example: 10.7 - Page: 408


Azeotropic Composition

The mole fraction of component 1 is 0.260

The mole fraction of component 2 is 0.740

Example: 10.8 Page: 410

In [11]:
print "Example: 10.8 - Page: 410\n\n"

# This problem involves proving a relation in which no mathematics and no calculations are involved.
# For prove refer to this example 10.8 on page number 410 of the book.

print " This problem involves proving a relation in which no mathematics and no calculations are involved.\n\n"
print " For prove refer to this example 10.8 on page 410 of the book."
Example: 10.8 - Page: 410


 This problem involves proving a relation in which no mathematics and no calculations are involved.


 For prove refer to this example 10.8 on page 410 of the book.

Example: 10.9 Page: 412

In [3]:
from __future__ import division
from math import exp,log

print "Example: 10.9 - Page: 412\n\n"

# Solution

#*****Data******#
x1 = 0.42#
x2 = 0.58#
P = 760## [mm of Hg]
P1sat = 786## [mm of Hg]
P2sat = 551## [mm of Hg]
#***************#

gama1 = P/P1sat#
gama2 = P/P2sat#
A = log(gama1)*(1 + (x2*log(gama2))/(x1*log(gama1)))**2#
B = log(gama2)*(1 + (x1*log(gama1))/(x2*log(gama2)))**2#
print "Van Laar Constants\n"
print "A = %.3f\n"%(A)#
print "B = %.3f\n"%(B)#
Example: 10.9 - Page: 412


Van Laar Constants

A = -5.008

B = 0.275

Example: 10.10 Page: 412

In [4]:
from __future__ import division
from math import exp,log
print "Example: 10.10 - Page: 412\n\n"

# Solution

#*****Data******#
P = 101.3## [kPa]
P1sat = 100.59## [kPa]
P2sat = 99.27## [kPa]
x1 = 0.532#
#****************#

x2 = 1 - x1#
gama1 = P/P1sat#
gama2 = P/P2sat#
A = log(gama1)*(1 + (x2*log(gama2))/(x1*log(gama1)))**2#
B = log(gama2)*(1 + (x1*log(gama1))/(x2*log(gama2)))**2#

# For solution containing 10 mol percent benzene:
x1 = 0.10#
x2 = 1 - x1#
gama1 = exp(A/(1 + (A*x1/(B*x2))**2))#
gama2 = exp(B/(1 + (B*x2/(A*x1))**2))#
print "Activity Coeffecient\n"
print "gama1 = %.3f\n"%(gama1)#
print "gama2 = %.3f\n"%(gama2)#
Example: 10.10 - Page: 412


Activity Coeffecient

gama1 = 1.086

gama2 = 1.002

Example: 10.11 Page: 413

In [5]:
from __future__ import division
from math import exp,log
print "Example: 10.11 - Page: 413\n\n"

# Solution

#*****Data******#
P = 760## [mm of Hg]
P1sat = 995## [mm of Hg]
P2sat = 885## [mm of Hg]
x1 = 0.335#
T = 64.6## [OC]
#****************#

x2 = 1 - x1#
gama1 = P/P1sat#
gama2 = P/P2sat#
A = log(gama1)*(1 + (x2*log(gama2))/(x1*log(gama1)))**2#
B = log(gama2)*(1 + (x1*log(gama1))/(x2*log(gama2)))**2#

# For solution containing 11.1 mol percent acetone:
x1 = 0.111#
x2 = 1 - x1#
gama1 = exp((A*x2**2)/(x2 + (A*x1/(B))**2))#
gama2 = exp((B*x1**2)/(x1 + (B*x2/(A))**2))#
y1 = 1/(1 + (gama2*x2*P2sat/(gama1*x1*P1sat)))#
y2 = 1 - y1#
print "Equilibrium Composition\n"
print "Acetone Composition = %.2f %%\n"%(y1*100)#
print "Chloform composition = %.2f %%\n"%(y2*100)#
Example: 10.11 - Page: 413


Equilibrium Composition

Acetone Composition = 4.98 %

Chloform composition = 95.02 %

Example: 10.12 Page: 414

In [15]:
print "Example: 10.12 - Page: 414\n\n"

# Mathematics is involved in proving but just that no numerical computations are involved.
# For prove refer to this example 10.12 on page number 414 of the book.

print " Mathematics is involved in proving but just that no numerical computations are involved.\n\n"
print " For prove refer to this example 10.12 on page 414 of the book."
Example: 10.12 - Page: 414


 Mathematics is involved in proving but just that no numerical computations are involved.


 For prove refer to this example 10.12 on page 414 of the book.

Example: 10.13 Page: 418

In [6]:
from __future__ import division
from math import exp,log
print "Example: 10.13 - Page: 418\n\n"

# Solution

#*****Data******#
# 1: iso - butanol
# 2: iso - propanol
T = 50 + 273## [K]
x1 = 0.3#
V1 = 65.2## [cubic cm/mol]
V2 = 15.34## [cubic cm/mol]
# For Wilson equation:
a12 = 300.55## [cal/mol]
a21 = 1520.32## [cal/mol]
# For NTRL equation:
b12 = 685.21## [cal/mol]
b21 = 1210.21## [cal/mol]
alpha = 0.552#
R = 2## [cal/mol K]
#******************#

x2 = 1 - x1#
# A: Estimation of activity coeffecient using Wilson equation:
# From Eqn. 10.65:
A12 = (V2/V1)*exp(-a12/(R*T))#
# From Eqn. 10.66:
A21 = (V1/V2)*exp(-a21/(R*T))#
# From Eqn. 10.67:
gama1 = exp(-log(x1 + A12*x2) + x2*((A12/(x1 + A12*x2)) - (A21/(A21*x1 + x2))))#
# From Eqn. 10.68:
gama2 = exp(-log(x2 + A21*x1) - x1*((A12/(x1 + A12*x2)) - (A21/(A21*x1 + x2))))#
print "Wilson equation\n"
print "Activity Coeffecient of iso - butanol is %.3f\n"%(gama1)#
print "Activity Coeffecient of iso - propanol is %.3f\n"%(gama2)#
print "\n"

# A: Estimation of activity coeffecient using NTRL equation:
t12 = b12/(R*T)#
t21 = b21/(R*T)#
G12 = exp(-alpha*t12)#
G21 = exp(-alpha*t21)#
# From Eqn. 10.70:
gama1 = exp((x2**2)*(t21*(G21/(x1 + x2*G21))**2 + (t12*G12/(x2 + x1*G12)**2)))#
# From Eqn. 10.71:
gama2 = exp((x1**2)*(t12*(G12/(x2 + x1*G12))**2 + (t21*G21/(x1 + x2*G21)**2)))#
print "NTRL equation\n"
print "Activity Coeffecient of iso - butanol is %.3f\n"%(gama1)#
print "Activity Coeffecient of iso - propanol is %.3f\n"%(gama2)#
Example: 10.13 - Page: 418


Wilson equation

Activity Coeffecient of iso - butanol is 2.270

Activity Coeffecient of iso - propanol is 1.265



NTRL equation

Activity Coeffecient of iso - butanol is 2.160

Activity Coeffecient of iso - propanol is 1.269

Example: 10.14 Page: 426

In [7]:
print "Example: 10.14 - Page: 426\n\n"

# Solution

#*****Data******#
x1 = 0.4## [mole fraction of ethane in vapour phase]
x2 = 0.6## [mole fraction of propane in vapour phase]
P = 1.5## [MPa]
#***************#

# Assume T = 10 OC
T = 10## [OC]
# From Fig. 10.14 (Pg 426):
K1 = 1.8#
K2 = 0.5#
# From Eqn. 10.83:
y1 = K1*x1#
y2 = K2*x2#
# Since y1 + y2 > 1, so we assume another value of T = 9 OC.
T = 9## [OC]
# From Fig. 10.14 (Pg 426):
K1 = 1.75#
K2 = 0.5#
# From Eqn. 10.83:
y1 = K1*x1#
y2 = K2*x2#
# Since y1 + y2 = 1. Therefore:
print "Bubble Temperature is %d OC\n"%(T)#
print "Composition of the vapour bubble:\n y1 = %.2f\n y2 = %.2f"%(y1,y2)#
Example: 10.14 - Page: 426


Bubble Temperature is 9 OC

Composition of the vapour bubble:
 y1 = 0.70
 y2 = 0.30

Example: 10.15 Page: 428

In [18]:
print "Example: 10.15 - Page: 428\n\n"

# Solution

#*****Data******#
y1 = 0.20## [mole fraction of methane in vapour phase]
y2 = 0.30## [mole fraction of ethane in vapour phase]
y3 = 0.50## [mole fraction of propane in vapour phase]
T = 30## [OC]
#*************#

# Assume P = 2.0 MPa
P = 2.0## [MPa]
# From Fig. 10.14 (Pg 426):
K1 = 8.5#
K2 = 2.0#
K3 = 0.68#
# From Eqn. 10.83:
x1 = y1/K1#
x2 = y2/K2#
x3 = y3/K3#
# Since x1 + x2 +x3 < 1, so we assume another value of P = 2.15 MPa at 30 OC.
P = 2.15## [MPa]
# From Fig. 10.14 (Pg 426):
K1 = 8.1#
K2 = 1.82#
K3 = 0.62#
# From Eqn. 10.83:
x1 = y1/K1#
x2 = y2/K2#
x3 = y3/K3#
# Since x1 + x2 +x3 = 1. Therefore:
print "Dew Pressure is %.2f MPa\n"%(P)#
print "Composition of the liquid drop:\n x1 = %.4f\n x2 = %.4f\n x3 = %.4f"%(x1,x2,x3)#
Example: 10.15 - Page: 428


Dew Pressure is 2.15 MPa

Composition of the liquid drop:
 x1 = 0.0247
 x2 = 0.1648
 x3 = 0.8065

Example: 10.16 Page: 429

In [19]:
print "Example: 10.16 - Page: 429\n\n"

# Solution

# Dew point Pressure
#*****Data******#
y1 = 0.10## [mole fraction of methane in vapour phase]
y2 = 0.20## [mole fraction of ethane in vapour phase]
y3 = 0.70## [mole fraction of propane in vapour phase]
T = 10## [OC]
#*************#

# Assume P = 690 kPa
P = 690## [kPa]
# From Fig. 10.14 (Pg 426):
K1 = 20.0#
K2 = 3.25#
K3 = 0.92#
# From Eqn. 10.83:
x1 = y1/K1#
x2 = y2/K2#
x3 = y3/K3#
# Since x1 + x2 +x3 < 1, so we assume another value of P = 10135 kPa at 10 OC.
P = 10135## [kPa]
# From Fig. 10.14 (Pg 426):
K1 = 13.20#
K2 = 2.25#
K3 = 0.65#
# From Eqn. 10.83:
x1 = y1/K1#
x2 = y2/K2#
x3 = y3/K3#
# Since x1 + x2 +x3 > 1, so we assume another value of P = 870 kPa at 10 OC.
P = 870## [kPa]
# From Fig. 10.14 (Pg 426):
K1 = 16.0#
K2 = 2.65#
K3 = 0.762#
# From Eqn. 10.83:
x1 = y1/K1#
x2 = y2/K2#
x3 = y3/K3#
# Since x1 + x2 +x3 = 1. Therefore:
print "Dew Pressure is %d kPa\n"%(P)#
print "Composition of the liquid drop:\n x1 = %.4f\n x2 = %.4f\n x3 = %.4f\n"%(x1,x2,x3)#
print "\n"

# Bubble point Pressure
#*****Data******#
x1 = 0.10## [mole fraction of methane in vapour phase]
x2 = 0.20## [mole fraction of ethane in vapour phase]
x3 = 0.70## [mole fraction of propane in vapour phase]
T = 10## [OC]
#*************#

# Assume P = 2622 kPa
P = 2622## [kPa]
# From Fig. 10.14 (Pg 426):
K1 = 5.60#
K2 = 1.11#
K3 = 0.335#
# From Eqn. 10.83:
y1 = K1*x1#
y2 = K2*x2#
y3 = K3*x3#
# Since x1 + x2 +x3 > 1, so we assume another value of P = 2760 kPa at 10 OC.
P = 2760## [kPa]
# From Fig. 10.14 (Pg 426):
K1 = 5.25#
K2 = 1.07#
K3 = 0.32#
# From Eqn. 10.83:
y1 = K1*x1#
y2 = K2*x2#
y3 = K3*x3#
# Since x1 + x2 +x3 < 1, so we assume another value of P = 2656 kPa at 10 OC.
P = 2656## [kPa]
# From Fig. 10.14 (Pg 426):
K1 = 5.49#
K2 = 1.10#
K3 = 0.33#
# From Eqn. 10.83:
y1 = K1*x1#
y2 = K2*x2#
y3 = K3*x3#
# Since x1 + x2 +x3 = 1. Therefore:
print "Bubble Pressure is %d kPa\n"%(P)#
print "Composition of the vapour bubble:\n y1 = %.4f\n y2 = %.4f\n y3 = %.4f"%(y1,y2,y3)#
Example: 10.16 - Page: 429


Dew Pressure is 870 kPa

Composition of the liquid drop:
 x1 = 0.0063
 x2 = 0.0755
 x3 = 0.9186



Bubble Pressure is 2656 kPa

Composition of the vapour bubble:
 y1 = 0.5490
 y2 = 0.2200
 y3 = 0.2310

Example: 10.17 Page: 432

In [8]:
from __future__ import division
from scipy.optimize import fsolve
from math import exp,log
print "Example: 10.17 - Page: 432\n\n"

# Solution

#*****Data******#
# 1: acetone 2: acetonitrile 3: nitromethane
z1 = 0.45#
z2 = 0.35#
z3 = 0.20#
P1sat = 195.75## [kPa]
P2sat = 97.84## [kPa]
P3sat = 50.32## [kPa]
#***************#

# Bubble Point Calculation:
Pbubble = z1*+P1sat + z2*P2sat +z3*P3sat## [kPa]

# Dew Point Calculation:
Pdew = 1/((z1/P1sat) + (z2/P2sat) + (z3/P3sat))## [kPa]
K1 = P1sat/Pdew#
K2 = P2sat/Pdew#
K3 = P3sat/Pdew#
# Overall Material balance:
# For 1 mol of the feed.
# L + V = 1......................................... (1)
# F*zi = L*xi + V*yi ............................... (2)
# zi = (1 - V)*xi + V*yi ........................... (3)
# Substituting xi = yi/K in eqn. (3)
# yi = zi*Ki/(1 + V*(Ki - 1))
# Since, Sum(yi) = 1.
#deff('[y] = f(V)','y = (z1*K1/(1 + V*(K1 - 1))) + (z2*K2/(1 + V*(K2 - 1))) + (z3*K3/(1 + V*(K3 - 1))) - 1')#
def f(V):
    y = (z1*K1/(1 + V*(K1 - 1))) + (z2*K2/(1 + V*(K2 - 1))) + (z3*K3/(1 + V*(K3 - 1))) - 1
    return y

V = fsolve(f,0.8)#
L = 1 - V#
y1 = z1*K1/(1 + V*(K1 - 1))#
y2 = z2*K2/(1 + V*(K2 - 1))#
y3 = z3*K3/(1 + V*(K3 - 1))#
# From Eqn. 10.83:
x1 = y1/K1#
x2 = y2/K2#
x3 = y3/K3#
print " L = %e mol\n"%(L)#
print " V = %e mol\n"%(V)#
print " y1 = %.4f\n y2 = %.4f\n y3 = %.4f\n"%(y1,y2,y3)#
print " x1 = %.4f\n x2 = %.4f\n x3 = %.4f\n"%(x1,x2,x3)#
Example: 10.17 - Page: 432


 L = 3.154304e-08 mol

 V = 1.000000e+00 mol

 y1 = 0.4500
 y2 = 0.3500
 y3 = 0.2000

 x1 = 0.2334
 x2 = 0.3631
 x3 = 0.4035

Example: 10.18 Page: 433

In [10]:
from __future__ import division
from scipy.optimize import fsolve
from math import exp
print "Example: 10.18 - Page: 433\n\n"

# Solution

#*****Data******#
# 1: Benzene 2: Toulene
z1 = 0.81#
Temp = 60## [OC]
P = 70## [kPa]
# Antonine Constants:
A1 = 14.2321#
B1 = 2773.61#
C1 = 220.13#
A2 = 15.0198#
B2 = 3102.64#
C2 = 220.02#
#******************#

#deff('[P1] = f1(T)','P1 = exp(A1 - B1/(T + C1))')#
def f1(T):
    P1 = exp(A1 - B1/(T + C1))
    return P1

P1sat = f1(Temp)## [kPa]
#deff('[P2] = f2(T)','P2 = exp(A2 - B2/(T + C2))')#
def f2(T):
    P2 = exp(A2 - B2/(T + C2))
    return P2

P2sat = f2(Temp)## [kPa]
# P = x1*P1sat + x2*P2sat#
# x2 = 1 - x1#
#deff('[y] = f3(x1)','[y] = P - (x1*P1sat + (1 - x1)*P2sat)')#
def f3(x1):
    y= P - (x1*P1sat + (1 - x1)*P2sat)
    return y

x1 = fsolve(f3,7)#
y1 = x1*P1sat/P#
x2 = 1 - x1#
y2 = 1 - y1#

# Basis: 1 mol of feed stream.
F = 1## [mol]
# F*zi = L*xi + V*yi = L*xi + (1 - L)*yi
#deff('[y] = f4(L)','[y] = F*z1 - (L*x1 + (1 - L)*y1)')#
def f4(L):
    y = F*z1 - (L*x1 + (1 - L)*y1)
    return y

L = fsolve(f4,7)## [mol]
V = 1 - L## [mol]
print " L = %.4f mol\n"%(L)#
print " V = %.4f mol\n"%(V)#
print " y1 = %.4f\n y2 = %.4f\n"%(y1,y2)#
print " x1 = %.4f\n x2 = %.4f\n"%(x1,x2)#
Example: 10.18 - Page: 433


 L = 0.1615 mol

 V = 0.8385 mol

 y1 = 0.8205
 y2 = 0.1795

 x1 = 0.7555
 x2 = 0.2445

Example: 10.19 Page: 413

In [11]:
from math import exp, log
from numpy import nditer, shape, zeros,mat    
%matplotlib inline
from matplotlib.pyplot import plot, xlabel, ylabel, show, grid

print "Example: 10.19 - Page: 436\n\n"

# Solution

#*****Data******#
# (1): acetone (2): carbon tetrachloride
T = 45## [OC]
# Data = [P (torr), x1, y1]

Data = mat([[315.32, 0.0556, 0.2165],[339.70, 0.0903, 0.2910],[397.77, 0.2152, 0.4495],[422.46, 0.2929, 0.5137],[448.88, 0.3970, 0.5832],[463.92, 0.4769, 0.6309],[472.84, 0.5300, 0.6621],[485.16, 0.6047, 0.7081],[498.07, 0.7128, 0.7718],[513.20, 0.9636, 0.9636]])
#*************#

# From the standard data (Pg 531):
# For Acetone:
A1 = 14.2342#
B1 = 2691.46#
C1 = 230.00#
# For carbon tetrachloride:
A2 = 13.6816#
B2 = 2355.82#
C2 = 220.58#
P1sat = exp(A1 - B1/(T + C1))## [kPa]
P2sat = exp(A2 - B2/(T + C2))## [kPa]
P1sat = P1sat*760/101.325## [torr]
P2sat = P2sat*760/101.325## [torr]
P = Data[:,0]#
x1 = Data[:,1]#
y1 = Data[:,2]#
x2 = 1 - x1#
y2 = 1 - y1#

gama1 = zeros(x1.shape)
i=0
for a,b,c in nditer([y1,P,x1]):
    gama1[i]=(a*b/c)
    i+=1

    
gama2 = zeros(x2.shape)
i=0
for a,b,c in nditer([y2,P,x2]):
    gama2[i]=(a*b/c)
    i+=1

Value = zeros(gama1.shape)
i=0    
for x,y in nditer([gama1, gama2]):
    Value[i]=(log(x/y))
    i+=1
plot(x1,Value)
grid()#
xlabel("x1")
ylabel("ln(y1/y2)")
# Since the whole area is above X - axis:
print "The data is not consistent thermodynamically\n"
Example: 10.19 - Page: 436


The data is not consistent thermodynamically