%matplotlib inline
import math
from numpy import *
from matplotlib.pyplot import *
# Variables
T = 60. #temperature of the system in degree celsius
P = [237.60,265.20,317.50,333.00,368.70,387.20]; #Pressure data in Torr (from Danneil et al.)
x1 = [0.0870,0.1800,0.4040,0.4790,0.7130,0.9070]; #mole fraction of benzene in the liquid phase corresponding to the given pressure (no unit) (from Danneil et al.)
y1 = [0.1870,0.3400,0.5780,0.6420,0.7960,0.9220]; #mole fraction of benzene in the vapour phase corresponding to the given pressure (no unit) (from Danneil et al.)
antoine_const_benzene = [6.87987,1196.760,219.161]; #Antoine's constants for Benzene from Table A.7
antoine_const_heptane = [6.89386,1264.370,216.640]; #Antoine's constants for heptane from Table A.7
# Calculations
P1_s = 10**(antoine_const_benzene[0]-(antoine_const_benzene[1]/(T+antoine_const_benzene[2])));
P2_s = 10**(antoine_const_heptane[0]-(antoine_const_heptane[1]/(T+antoine_const_heptane[2])));
l = len(P); #iteration parameter
i = 0; #iteration parameter
gaamma1 = zeros(l)
gaamma2 = zeros(l)
ln_gaamma1_expt = zeros(l)
ln_gaamma2_expt = zeros(l)
gE_RTx1x2 = zeros(l)
while i<l:
gaamma1[i] = (y1[i]*P[i])/(x1[i]*P1_s);
gaamma2[i] = ((1-y1[i])*P[i])/((1-x1[i])*P2_s);
ln_gaamma1_expt[i] = math.log(gaamma1[i]);
ln_gaamma2_expt[i] = math.log(gaamma2[i]);
gE_RTx1x2[i] = ((x1[i]*ln_gaamma1_expt[i])+((1-x1[i])*ln_gaamma2_expt[i]))/(x1[i]*(1-x1[i])); # Calculations of gE/RT using Eq.(11.36) (no unit)
i = i+1;
plot(x1,gE_RTx1x2,'o');
suptitle('Plot of gE/RTx1x2 vs x1')
xlabel('x1')
ylabel('gE/RTx1x2');
A21 = 0.555
A12 = 0.315
j = 0
ln_gaamma1 = zeros(l)
ln_gaamma2 = zeros(l)
P_calc = zeros(l)
y1_calc = zeros(l)
gaamma1 = zeros(l)
gaamma2 = zeros(l)
while j<l:
ln_gaamma1[j] = ((1-x1[j])**2)*(A12+(2*(A21-A12)*x1[j]));
ln_gaamma2[j] = (x1[j]**2)*(A21+(2*(A12-A21)*(1-x1[j])));
gaamma1[j] = math.exp(ln_gaamma1[j])
gaamma2[j] = math.exp(ln_gaamma2[j])
P_calc[j] = (gaamma1[j]*x1[j]*P1_s)+(gaamma2[j]*(1-x1[j])*P2_s)
y1_calc[j] = (gaamma1[j]*x1[j]*P1_s)/P[j];
j = j+1;
# Results
print 'Data for the plot of gE/RTx1x2 vs x1: ';
for i in range(l):
print 'P = %f Torr\t x1 = %f\t y1 = %f \t lngamma1) = %f\t\t lngamma2) =\
%f\t\t gE/RTx1x2 = %f'%(P[i],x1[i],y1[i],ln_gaamma1_expt[i],ln_gaamma2_expt[i],gE_RTx1x2[i]);
print 'Results: ';
for i in range(l):
print 'x1 = %f \t gamma1 = %f \t gamma2 = %f \t P_Exptl. = %f \
Torr\t P_Calc = %f Torr\t y1_Exptl = %f \t y1_calc = %f '%(x1[i],gaamma1[i],gaamma2[i],P[i],P_calc[i],y1[i],y1_calc[i]);
from numpy import *
# Variables
T = 25. #temperature of the system in degree celsius
A12 = 2.0522; #three suffix Margules parameters for the system (no unit)
A21 = 1.7201; #three suffix Margules parameters for the system (no unit)
P = [118.05,207.70,246.35,259.40,261.50,262.00,261.90,258.70,252.00]; #Pressure data in Torr (from Tasic et al.)
x1 = [0.0115,0.1125,0.3090,0.5760,0.6920,0.7390,0.7575,0.8605,0.9250];
y1 = [0.1810,0.5670,0.6550,0.7050,0.7250,0.7390,0.7460,0.8030,0.8580];
antoine_const_acetone = [7.11714,1210.595,229.664]; #Antoine's constants for acetone from Table A.7
antoine_const_chexane = [6.85146,1206.470,223.136]; #Antoine's constants for cyclohexane from Table A.7
# Calculations
P1_s = 10**(antoine_const_acetone[0]-(antoine_const_acetone[1]/(T+antoine_const_acetone[2])));
P2_s = 10**(antoine_const_chexane[0]-(antoine_const_chexane[1]/(T+antoine_const_chexane[2])));
l = len(P)
ln_gaamma1 = zeros(l)
ln_gaamma2 = zeros(l)
gaamma1 = zeros(l)
gaamma2 = zeros(l)
P = zeros(l)
y1_calc = zeros(l)
j = 0;
while j<l:
ln_gaamma1[j] = ((1-x1[j])**2)*(A12+(2*(A21-A12)*x1[j]));
ln_gaamma2[j] = (x1[j]**2)*(A21+(2*(A12-A21)*(1-x1[j])));
gaamma1[j] = math.exp(ln_gaamma1[j]);
gaamma2[j] = math.exp(ln_gaamma2[j]);
P[j] = (gaamma1[j]*x1[j]*P1_s)+(gaamma2[j]*(1-x1[j])*P2_s)
y1_calc[j] = (gaamma1[j]*x1[j]*P1_s)/P[j];
j = j+1;
# Results
print 'P-x-y data: ';
print 'x1 \t gamma1\t gamma2 \t P Torr \t y1 ';
for i in range(l):
print '%0.4f \t %f \t %f \t %f \t %f '%(x1[i],gaamma1[i],gaamma2[i],P[i],y1_calc[i])
# Variables
T = 25. #temperature of the system in degree celsius
A = 2.0684; #the van Laar parameters for the system (no unit)
B = 1.7174; #the van Laar parameters for the system (no unit)
P = [118.05,207.70,246.35,259.40,261.50,262.00,261.90,258.70,252.00]; #Pressure data in Torr (from Tasic et al.)
x1 = [0.0115,0.1125,0.3090,0.5760,0.6920,0.7390,0.7575,0.8605,0.9250];
y1 = [0.1810,0.5670,0.6550,0.7050,0.7250,0.7390,0.7460,0.8030,0.8580];
antoine_const_acetone = [7.11714,1210.595,229.664]; #Antoine's constants for acetone from Table A.7
antoine_const_chexane = [6.85146,1206.470,223.136]; #Antoine's constants for cyclohexane from Table A.7
# Calculations
P1_s = 10**(antoine_const_acetone[0]-(antoine_const_acetone[1]/(T+antoine_const_acetone[2])))
P2_s = 10**(antoine_const_chexane[0]-(antoine_const_chexane[1]/(T+antoine_const_chexane[2])));
l = len(P)
j = 0
while j<l:
ln_gaamma1[j] = A/(1+((A*x1[j])/(B*(1-x1[j]))))**2
ln_gaamma2[j] = B/(1+((B*(1-x1[j]))/(A*x1[j])))**2
gaamma1[j] = math.exp(ln_gaamma1[j]);
gaamma2[j] = math.exp(ln_gaamma2[j]);
P[j] = (gaamma1[j]*x1[j]*P1_s)+(gaamma2[j]*(1-x1[j])*P2_s)
y1_calc[j] = (gaamma1[j]*x1[j]*P1_s)/P[j];
j = j+1;
# Results
print 'P-x-y data: ';
i = 0;
print 'x1 \t gamma1 \t gamma2 \t PTorr \t y1 ';
for i in range(l):
print '%0.4f \t %f \t %f \t %f \t %f '%(x1[i],gaamma1[i],gaamma2[i],P[i],y1_calc[i]);
import math
from numpy import *
from matplotlib.pyplot import *
# Variables
P = 760. #pressure in Torr at which chloroform and methanol form an azeotrope
T = 53.5 #temperature in degree celsius at which chloroform and methanol form an azeotrope
x1 = 0.65 #mole fraction of chloroform in the liquid phase (no unit) (corresponding to azeotropic composition)
antoine_const_chloroform = [6.95465,1170.966,226.232]; #Antoine's constants for acetone from Table A.7
antoine_const_methanol = [8.08097,1582.271,239.726]; #Antoine's constants for acetone from Table A.7
# Calculations
x2 = 1-x1
P1_s = 10**(antoine_const_chloroform[0]-(antoine_const_chloroform[1]/(T+antoine_const_chloroform[2])));
P2_s = 10**(antoine_const_methanol[0]-(antoine_const_methanol[1]/(T+antoine_const_methanol[2])));
gaamma1 = P/P1_s
gaamma2 = P/P2_s
A = math.log(gaamma1)*(1+((x2*math.log(gaamma2))/(x1*math.log(gaamma1))))**2
B = math.log(gaamma2)*(1+((x1*math.log(gaamma1))/(x2*math.log(gaamma2))))**2
x1 = linspace(0.1,0.9,9)
l = len(x1)
gaamma1 = zeros(l)
gaamma2 = zeros(l)
P = zeros(l)
y1 = zeros(l)
j = 0
while j<l:
ln_gaamma1[j] = A/(1+((A*x1[j])/(B*(1-x1[j]))))**2
ln_gaamma2[j] = B/(1+((B*(1-x1[j]))/(A*x1[j])))**2
gaamma1[j] = math.exp(ln_gaamma1[j]);
gaamma2[j] = math.exp(ln_gaamma2[j]);
P[j] = (gaamma1[j]*x1[j]*P1_s)+(gaamma2[j]*(1-x1[j])*P2_s)
y1[j] = (gaamma1[j]*x1[j]*P1_s)/P[j];
j = j+1;
# Results
print 'VLE data: ';
print 'x1 \tgamma1 \t\t gamma2 \t P Torr \t y1 ';
for i in range(l):
print '%0.1f \t %f \t %f \t %f \t %f '%(x1[i],gaamma1[i],gaamma2[i],P[i],y1[i]);
# Variables
y1 = 0.3; #mole fraction of ethane in the vapour phase (no unit)
T = 30. #temperature in degree celsius
# Calculations
y2 = 1-y1
P_guess = 1
K1 = 3.4
K2 = 1.1
x1_calc = y1/K1
x2_calc = y2/K2;
tot = x1_calc+x2_calc
if tot == 1:
P = P_guess
x1 = x1_calc
x2 = x2_calc
else:
P = 1.5
K1 = 2.4
K2 = 0.8
x1 = y1/K1
x2 = y2/K2
# Results
print 'The Dew pressure and the liquid composition of a binary vapour mixture of\
ethane and propane was found to be P = %0.2f MPa\t x1 = %0.3f\t x2 = %0.3f \t'%(P,x1,x2);
# Variables
x1 = 0.4; #mole fraction of ethane in the liquid phase (no unit)
P = 1.5; #pressure in MPa
# Calculations
x2 = 1-x1
t_guess = 10.
K1 = 1.8;
K2 = 0.5;
y1_calc = K1*x1
y2_calc = K2*x2
tot = y1_calc+y2_calc
if tot == 1:
t = t_guess
y1 = y1_calc
y2 = y2_calc
else:
t = 9.
K1 = 1.75
K2 = 0.5;
y1 = K1*x1
y2 = K2*x2
# Results
print 'The bubble temperature and the vapour composition of a binary vapour mixture\
of ethane and propane was found to be t = %d degree celsius y1 = %f\t y2 = %f\t'%(t,y1,y2);
from numpy import *
from matplotlib.pyplot import *
%matplotlib inline
# Variables
P = [350.00,446.00,518.00,574.50,609.00,632.50,665.00,681.50,691.50]
x1 = [0.0550,0.1290,0.2120,0.3130,0.4300,0.5200,0.6380,0.7490,0.8720]
y1 = [0.3500,0.5110,0.5990,0.6500,0.6970,0.7260,0.7590,0.8130,0.8830]
antoine_const_propanol = [8.37895,1788.020,227.438];
antoine_const_cbenzene = [7.17294,1549.200,229.260];
T = 95. #temperature of the system in degree celsius
# Calculations
P1_s = 10**(antoine_const_propanol[0]-(antoine_const_propanol[1]/(T+antoine_const_propanol[2])));
P2_s = 10**(antoine_const_cbenzene[0]-(antoine_const_cbenzene[1]/(T+antoine_const_cbenzene[2])));
l = len(P)
lngamma1_gamma2 = zeros(l)
gaamma1 = zeros(l)
gaamma2 = zeros(l)
i = 0
while i<l:
gaamma1[i] = (y1[i]*P[i])/(x1[i]*P1_s)
gaamma2[i] = ((1-y1[i])*P[i])/((1-x1[i])*P2_s)
lngamma1_gamma2[i] = math.log(gaamma1[i]/gaamma2[i])
i = i+1;
plot(x1,lngamma1_gamma2);
suptitle('Plot of ln(gamma1/gamma2) vs x1')
xlabel('x1')
ylabel('ln(gamma1/gamma2)');
area_above = 1515.
area_below = 1540.
consistency_parameter = abs((area_above-area_below)/(area_above+area_below));
# Results
print 'Values of lngamma1./gamma2: ';
print 'x1 \t gamma1 \t gamma2 \t lngamma1./gamma2';
for i in range(l):
print '%0.4f \t %f \t %f \t %f '%(x1[i],gaamma1[i],gaamma2[i],lngamma1_gamma2[i]);
print 'The value of the consistency parameter = %f'%(consistency_parameter);
if consistency_parameter<0.02 or consistency_parameter == 0.02:
print 'The VLE data is thermodynamically consistent';
else:
print 'The VLE data is not thermodynamically consistent';
from numpy import *
from matplotlib.pyplot import *
%matplotlib inline
# Variables
P = 760. #pressure of the system in Torr
antoine_const_benzene = [6.87987,1196.760,219.161]; #Antoine's constants for Benzene from Table A.7
t = linspace(60,100,9); #temperature range in degree celsius
P2_s = [149.40,187.58,233.71,289.13,355.21,433.51,525.84,634.00,760.00];
x1 = linspace(0,1,6)
# Calculations
l = len(t)
i = 0
P1_s = zeros(l)
P_tot = zeros(l)
while i<l:
P1_s[i] = 10**(antoine_const_benzene[0]-(antoine_const_benzene[1]/(t[i]+antoine_const_benzene[2])));
P_tot[i] = P1_s[i]+P2_s[i];
i = i+1;
T = (((t[2]-t[1])*(760-P_tot[1]))/(P_tot[2]-P_tot[1]))+t[1]
P1_s_three_phase = 10**(antoine_const_benzene[0]-(antoine_const_benzene[1]/(T+antoine_const_benzene[2])));
P2_s_three_phase = 760-P1_s_three_phase;
y1_three_phase = P1_s_three_phase/760
trange1 = linspace(T,T+11,11)
n = len(trange1)
i = 0
y1 = zeros(n)
P1_s_calc = zeros(n)
while i<n:
if i == 1:
y1[i] = y1_three_phase
else:
P1_s_calc[i] = 10**(antoine_const_benzene[0]-(antoine_const_benzene[1]/(trange1[i]+antoine_const_benzene[2])));
y1[i] = (P1_s_calc[i])/P
i = i+1;
trange2 = [70,75,80,85,90,95,100]
P2_s_range = [233.71,289.13,355.21,433.51,525.84,634.00,760.00]
p = len(trange2);
i = 0
y_one = zeros(p)
# Calculations of the vapour composition of benzene in the two phase region (L2+V) using Eq.(12.61) (no unit)
y_one[i] = y1_three_phase;
trange2[i] = T;
i = i+1;
while i<p:
y_one[i] = (P-P2_s_range[i])/P;
i = i+1;
k=len(x1)
t_3phase = zeros(k)
i = 0
k = len(x1)
while i<k:
t_3phase[i] = T
i = i+1;
# Results
plot(y1,trange1);
plot(y_one,trange2);
plot(x1,t_3phase);
suptitle('t-x-y diagram for benzene-water sytem at 760 Torr')
xlabel('x1,y1')
ylabel('t (degree celsius)');
q = len(t)
i = 1;
print ' Calculationss performed for determining the three phase equilibrium temperature';
print 'tdegree celsius \t P1_s Torr \t P2_s Torr \t P1_s+P2_s Torr ';
for i in range(q):
print '%d \t \t \t %.2f \t %0.2f \t %.2f '%(t[i],P1_s[i],P2_s[i],P_tot[i]);
print 'The three phase equilibrium temperature = %0.2f degree celsius '%(T);
print 'The vapour phase composition of benzene at the three phase equilibrium point = %0.4f '%(y1_three_phase);
# Note: answer are slightly different because of rounding off error.