In [11]:

```
import math
# Variables
x_isopropanol = 0.4720
x_water = 0.5280
# From the table A.7 (page 427) reported in the book the Van Laar coefficients for isopropanol-water system at 1atm are given by
A = 1.0728
B = 0.4750
# Calculations
# Van Laar equations are given
# math.log10(Y_a) = A*x_b**(2)/(A/B*x_a+x_b)**(2)
# math.log10(Y_b) = B*x_a**(2)/(B/A*x_b+x_a)**(2)
# We calculate Y_isopropanol and Y_water as
Y_isopropanol = 10**(A*x_water**(2)/(A/B*x_isopropanol+x_water)**(2))
Y_water = 10**(B*x_isopropanol**(2)/(B/A*x_water+x_isopropanol)**(2))
# Results
print " Value of the liquid-phase activity coefficient for isopropanol is %f"%(Y_isopropanol)
print " And value of the liquid-phase activity coefficient for water is %f"%(Y_water)
```

In [23]:

```
import math
# Variables
# Recieving the VLE data from the example 8.2, we have
x_acetone = 0.05
x_water = 0.95
# And the activity coefficient is given by
y_acetone = 7.04
y_water = 1.01
# we hve the relation g_E/RT = summation(x_i*math.log(y_i))
# let C = g_E/RT , so
# Calculations
C = (x_acetone*math.log(y_acetone)+x_water*math.log(y_water))
# Now let M = (g_E/RT )/(x_acetone*x_water)
# So
M = C/(x_acetone*x_water)
# Results
print "The value of g_E/RT for acetone-water solution at 1 atm pressure is %f"%(C)
print "The value of g_E/RT)/x_a*x_b) for acetone-water solution at 1 atm pressure is %f"%(M)
```

In [13]:

```
import math
# Variables
y_acetone_infinity = 10.
y_water_infinty = 5.
Pressure = 1. #[atm]
# Calculations
# From equation 9.L and 9.M (page 224) as reported in the book, we have
# Constants in morgules equation b and c as
b = math.log(y_acetone_infinity)
c = math.log(y_water_infinty)
# Results
print "Values of the consmath.tants in Morgules equation for acetone-water at 1 atm are b = %f"%(b)
print " and c = %f"%(c)
```

In [6]:

```
import math
# Variables
P_1 = 10. #[atm]
x_a_1 = 0.1238 # mole fraction of ethanol at 10 atm pressure
Temp = 273.15+85.3 # [K]
R = 0.08206 #[(L*atm)/(mol*K)]
P_0 = 1. #[atm]
# so
delta_P = (P_1-P_0) #[atm]
# Molecular weight of ethanol and water are respectively
M_ethanol = 46. #[g/mol]
M_water = 18. #[g/mol]
# Calculations
# Now changing the mol fraction of ethanol in the wt fraction
m_a_1 = x_a_1*M_ethanol/(x_a_1*M_ethanol+(1-x_a_1)*M_water)
# From example 8.9(page 188) we know that at this T and 1 atm and x_a_0, activity coefficient for ethanol
y_ethanol_0 = 2.9235
# Now from figure 6.15(page 129), we read that at 20C and m_a_1 mass fraction ethanol ,
v_ethanol_1 = 1.16 #[cm**(3)/g]
# Similarily for mass fraction corresponding to mole fraction x_a_1
v_ethanol_0 = 1.27 #[cm**(3)/]
# Difference of thes etwo values is
v = v_ethanol_1-v_ethanol_0 #[cm**(3)/g]
v = v*46. #[L/g]
# If we assume that this value is more or less independent of temperature, we can use it as the corresponding value at 85.3C, and compute
# From equation 7.31(page 225)
# d(math.log(y_i))/dP = (v_1-v_0)/(R*T) at consmath.tant temperature and mole fraction
# Let d(math.log(y_i))/dP = C, then
C = (v_ethanol_1-v_ethanol_0)/(R*Temp)
# Also we can have
# delta_math.log(y_i) = (d(math.log(y_i))/dP)*delta_P
# or
# delta_math.log(y_i) = C*delta_P
# and delta_math.log(y_i) = math.log(y_ehmath.tanol_1)-math.log(y_ethanol_0)
# So
y_ethanol_1 = math.exp(math.log(y_ethanol_0)+C*delta_P)
# Results
print "The activity coefficient of ethanol in the solution at 10 atm pressure is %f"%(y_ethanol_1)
# Note : Answer is different because of rouding error. Please calculate manually.
```

In [15]:

```
import math
from scipy.integrate import quad
# Variables
x_ethanol = 0.1238
Temp_1 = 273.15+85.3 #[K]
P = 1. #[atm]
Temp_2 = 273.15+70 #[K]
R = 8.314 #[j/(mol*K)]
# From example 8.9, at temperature 85.3C the activity coefficient is
y_ethanol_1 = 2.9235
# From figure 9.5[4] (page 227) as reported in the book, we read the value of (h_i_average-h_i_0) at temperatures 90C and 70C for ethanol.
# which are respectively
delta_h_2 = 0.2 #[kJ/mol]
delta_h_1 = 1.0 #[kJ/mol]
# Calculations
# Taking the average of these two values we have
delta_h_average = (delta_h_1+delta_h_1)/2*1000. #[J/mol]
# From the equation 7.32 (page 225) reported in the book
# d(math.log(y_i))/dT = (h_i_average-h_i_0)/(R*T**(2)) at consmath.tant pressure and mole fraction
# So
# it can be taken approximately as
# So
def f7(T):
return (1/T**(2))
y_ethanol_2 = y_ethanol_1*math.exp((delta_h_average/R)* (quad(f7,Temp_1,Temp_2))[0])
# Results
print "The activity coefficient for ethanol in the solution at 70 deg C and 1 atm is %f"%(y_ethanol_2)
```

In [22]:

```
import math
# Variables
# In this solution we will give the identity to the three species as
# a- Acetone
# b- Methanol
# c- Water
# Given
x_a = 0.1200
x_b = 0.1280
x_c = 0.7520
Temp = 66.70 #[C]
P = 1. #[atm] pressure
# As reported in the book that from [5] we get the following values
# acetone-methanol(a-b)
A_ab = 0.2634
A_ba = 0.2798
# acetone-water(a-c)
A_ac = 0.9709
A_ca = 0.5579
# methanol-water(b-c)
A_bc = 0.3794
A_cb = 0.2211
# Calculations
# Now consider the equation 9.10 (page 228)
# The first term on the right of the equation is
T_1 = round(x_b**(2)*(A_ab+2*x_a*(A_ba-A_ab)),5)
# similarily the second and third terms are given respectively as
T_2 = round(x_c**(2)*(A_ac+2*x_a*(A_ca-A_ac)),3)
T_3 = 0.0550 #x_b*x_c*(0.5*(A_ba+A_ab+A_ac-A_bc-A_cb)+x_a*(A_bc-A_ab+A_ca-A_ac)+(x_b-x_c)*(A_bc-A_cb)-(1-2*x_a)*0.00)
# thus whole term on the right hand side is
T = T_1+T_2+T_3
# So
y_a = 10**(T)
# for this temperature vapour pressure of the acetone is calculated as
p_acetone = 1.417 #[atm]
# So that we estimate
y_acetone = x_a*y_a*p_acetone
# Results
print " yacetone : %.3f"%y_acetone
print "The activity coefficient of acetone in the given mixture is %f"%(y_a)
# The experimental value is y_acetone = 0.698
# Answer is different because of rounding error.
```

In [7]:

```
import math
# Variables
T = 85.3+273.15 #[K] Temperature
P = 1. #[atm] Pressure of the mixture
R = 8.314 #[(Pa*m(3)/(K*mol))]
R_1 = 0.08206 #[(L*atm)/(mol*K)]
y_i = 0.1238 # mole fraction of the ethanol in the vapor phase
y_j = (1-y_i) # mole fraction of the water vapor in the vapor phase
# From the table A.1( table 417), the properties of water and ethanol are given as
# Critical temperatures are
T_c_ii = 513.9 #[K] Critical temperature of the ethanol
T_c_jj = 647.1 #[K] Criatical temperature of water
# Critical pressure are
P_c_ii = 61.48 #[bar] Critical pressure of ethanol
P_c_jj = 220.55 #[bar] Critical pressure of water
# A# Resultsentric factor
w_ii = 0.645 # accentric factor of the ethanol
w_jj = 0.345 # accentric factor of the water
# Compressibility factor are
z_c_ii = 0.24 # compressibility factor of ethanol
z_c_jj = 0.229 # compressibility factor of the water
# Calculations
# Critical volume are given by
V_c_ii = z_c_ii*R*T_c_ii/(P_c_ii*100000)*10**(6) # critical volume the ethanol
V_c_jj = z_c_jj*R*T_c_jj/(P_c_jj*100000)*10**(6) # critical volume the ethanol
# Now
# for k_ij = 0.0
T_c_ij_0 = (T_c_ii*T_c_jj)**(1./2) #[K]
w_ij = (w_ii + w_jj)/2.
z_c_ij = (z_c_ii + z_c_jj)/2.
V_c_ij = ( (V_c_ii**(1./3) + V_c_jj**(1./3))/2.)**(3)
P_c_ij_0 = (z_c_ij*R*T_c_ij_0)/(V_c_ij/10.**(6.))/10.**(5) #[bar]
# again for k_ij = 0.01
T_c_ij_1 = (T_c_ii*T_c_jj)**(1./2.)*(1-0.01) #[K]
P_c_ij_1 = (z_c_ij*R*T_c_ij_1)/(V_c_ij/10.**(6))/10**(5) #[bar]
# Now
T_r_ii = T/T_c_ii
T_r_jj = T/T_c_jj
T_r_ij_0 = T/T_c_ij_0
T_r_ij_1 = T/T_c_ij_1
# and
P_r_ii = P/P_c_ii
P_r_jj = P/P_c_jj
P_r_ij_0 = P/P_c_ij_0
P_r_ij_1 = P/P_c_ij_1
# Now we will calculate f(T_r) for each component and mixture
f_Tr_ii = ( 0.083 - 0.422/T_r_ii**(1.6) ) + w_ii*( 0.139 - 0.172/T_r_ii**(4.2))
f_Tr_jj = ( 0.083 - 0.422/T_r_jj**(1.6) ) + w_jj*( 0.139 - 0.172/T_r_jj**(4.2))
f_Tr_ij0 = ( 0.083 - 0.422/T_r_ij_0**(1.6) ) + w_ij*( 0.139 - 0.172/T_r_ij_0**(4.2))
f_Tr_ij1 = ( 0.083 - 0.422/T_r_ij_1**(1.6) ) + w_ij*( 0.139 - 0.172/T_r_ij_1**(4.2))
# Let us define A = (P_r*f(T_r)/T_r) , so
A_ii = P_r_ii*f_Tr_ii/T_r_ii
A_jj = P_r_jj*f_Tr_jj/T_r_jj
# We are given
v_ii = 0.975
v_jj = 0.986
# Now,
B_ii = ( f_Tr_ii*R*T_c_ii/P_c_ii)*(10.**(3)/10**(5)) #[L/mol]
B_jj = ( f_Tr_jj*R*T_c_jj/P_c_jj)*(10.**(3)/10**(5)) #[L/mol]
B_ij0 = ( f_Tr_ij0*R*T_c_ij_0/P_c_ij_0)*(10.**(3)/10**(5)) #[L/mol]
B_ij1 = ( f_Tr_ij1*R*T_c_ij_1/P_c_ij_1)*(10.**(3)/10**(5)) #[L/mol]
# now we will calculate 'delta'
delta_ij0 = 2*B_ij0 - B_ii - B_jj #[L/mol]
delta_ij1 = 2*B_ij1 - B_ii - B_jj #[L/mol]
# We have
# b_a = B_aa + y_b**(2)*delta and b_b = B_bb + y_a**(2)*delta
# so,
b_ethanol0 = B_ii + y_j**(2)*delta_ij0 #[L/mol]
b_water0 = B_jj + y_i**(2)*delta_ij0 #[L/mol]
b_ethanol1 = B_ii + y_j**(2)*delta_ij1 #[L/mol]
b_water1 = B_jj + y_i**(2)*delta_ij1 #[L/mol]
# Now
# phi_i = exp(b_i*P/(R*T))
# So,
phi_ethanol0 = math.exp((b_ethanol0*P)/(R_1*T))
phi_water0 = math.exp((b_water0*P)/(R_1*T))
phi_ethanol1 = math.exp((b_ethanol1*P)/(R_1*T))
phi_water1 = math.exp((b_water1*P)/(R_1*T))
# and
# Y_i = phi_i/v_i
# So,
Y_ethanol0 = phi_ethanol0/v_ii
Y_water0 = phi_water0/v_jj
Y_ethanol1 = phi_ethanol1/v_ii
Y_water1 = phi_water1/v_jj
# Results
print " The results are summarize in the following table"
print " Property \t\t\t Mix ij Assuming k_ij = 0.0 \t\t\t Mix ij Assuming k_ij = 0.01"
print " phi_ethanol \t\t\t\t %f \t\t\t\t\t %f "%(phi_ethanol0,phi_ethanol1)
print " phi_water \t\t\t\t %f \t\t\t\t\t %f "%(phi_water0,phi_water1)
print " Y_ethanol \t\t\t\t %f \t\t\t\t\t %f "%(Y_ethanol0,Y_ethanol1)
print " Y_water \t\t\t\t %f \t\t\t\t\t %f "%(Y_water0,Y_water1)
print " Value of ''v'' for ethanol is %f"%(v_ii)
print " Value of ''v'' water is %f"%(v_jj)
```

In [17]:

```
import math
# Variables
T = 65+273.15 #[K] Temperature
R = 8.314 #[(m**(3)*Pa)/(mol*K)] Universal gas consmath.tant
# From the table 9.C ( page 239 ) given in the book the molar volumes and solubility of n-hexane and diethylketone at 25 deg C are given as
v_hex = 131.6 #[ml/mol] Molar volume of n-Hexane
v_dketone = 106.4 #[ml/mol] Molar volume of diethylketone
s_hex = 14.9 #[MPa**(0.5)] Solubility of n-Hexane
s_dketone = 18.1 #[MPa**(0.5)] Solubility of diethylketone
# Calculations
# Here we will use these values with the assumption that Y_i,65C = Y_i,25C
# At infinite dilution, the volume fraction of the other species is 1.00, so,
# math.logY_a = v_a*phi_b**(2)*(delta_a - delta_b)**(2)/(R*T)
# so, for n-Hexane
Y_hex = math.exp(v_hex*1**(2)*(s_hex - s_dketone)**(2)/(R*T))
# And that for diethylketone
Y_dketone = math.exp(v_dketone*1**(2)*( s_dketone - s_hex )**(2)/(R*T))
# Results
print " The infinite dilution activity coefficient of n-Hexane is %f"%(Y_hex)
print " The infinite dilution activity coefficient of diethlyketone is %f"%(Y_dketone)
```

In [24]:

```
import math
# Variables
P = 1. #[atm]
T = 25. #[C]
y_i = 1.00 # amount of the oxygen in the vapour
# Umath.sing the consmath.tants for O2 in table A.2
A = 6.69147
B = 319.0117
C = 266.7
# Calculations
# By Antoine equation
# log10(P_i) = A-B/(T+C)
P_i = 10**(A-B/(T+C)) #[mmHg]
P_i = P_i/760. #[atm]
# This is extrapolated vapour pressure of O2 at 25C
# We will take this value as equal to the Henry's law consmath.tant
H_i = P_i
x_i = y_i*P/H_i
# Results
print " Henry's law constant for O2 is %f atm"%(P_i)
print " solubility of O2 is %e"%(x_i)
```

In [20]:

```
import math
# Variables
y_a = 1.00
P = 1.00 #[atm]
x_a = 0.231*10**(-4)
# Using the constants for O2 in table A.2 in the Antoine equation , we find the vapour pressure of the oxygen at 25C viz.
p_a = 521.15 #[atm]
# Thus activity coefficient is calculated by rewriting the equation 8.6 and umath.sing the above values
# Calculations
Y_O2 = (y_a*P)/(x_a*p_a)
# Results
print "The activity coefficient of the oxygen in the water is %f"%(Y_O2)
```

In [ ]:

```
```