In [4]:

```
from __future__ import division
print "Example: 9.1 - Page: 338\n\n"
# Solution
#*****Data******#
V1_bar = 52.37*10**(-6)## [partial molar volume of ethanol, cubic m/mol]
y1 = 0.5## [mole fraction of ethanol]
Density = 800.21## [kg/cubic m]
M1 = 46*10**(-3)## #[Molecular wt. of ethanol,kg/mol]
M2 = 18*10**(-3)## [Molecular wt. of water,kg/cmol]
#*************#
y2 = 1 - y1## [mole fraction of water]
M = y1*M1 + y2*M2## [Molecular wt. of mixture, kg/mol]
V = M/Density## [Volume of mixture, cubic m/mol]
# From Eqn. 9.9:
V2_bar = (V - y1*V1_bar)/y2## [partial molar volume of water, cubic m/mol]
print "Partial molar volume of water is %.2e cubic m/mol\n"%(V2_bar)#
```

In [5]:

```
from __future__ import division
print "Example: 9.2 - Page: 338\n\n"
# Solution
#*****Data******#
Vol = 2## [Volume of the mixture, cubic m/mol]
y1 = 0.4## [mole fraction of alcohol, cubic m/mol]
V1_bar = 38.3*10**(-6)## [partial molar volume of alcohol, cubic m/mol]
V2_bar = 17.2*10**(-6)## [partial molar volume of water, cubic m/mol]
V1 = 39.21*10**(-6)## [molar volume of alcohol, cubic m/mol]
V2 = 18*10**(-6)## [molar volume of water, cubic m/mol]
#*************#
# From Eqn. 9.9:
V = y1*V1_bar + (1 - y1)*V2_bar## [molar volume of the solution]
n = Vol/V## [number of moles of solution]
n1 = y1*n## [number of moles of alcohol required]
n2 = (1 - y1)*n## [number of moles of water required]
V_alcohol = V1*n1## [Volume of alcohol required, cubic m]
V_water = V2*n2## [Volume of water required, cubic m]
print "Volume of alcohol required is %.3f cubic m while volume of water required is %.3f cubic m\n"%(V_alcohol,V_water)#
```

In [6]:

```
from __future__ import division
print "Example: 9.3 - Page: 339\n\n"
# Solution
#*****Data******#
Vol = 2000## [cubic cm]
y1_1 = 0.96## [mass fraction of ethanol in laboratory alcohol]
y2_1 = 0.04## [mass fraction of water in laboratory alcohol]
y1_2 = 0.56## [mass fracion of ethanol in vodka]
y2_2 = 0.44## [mass fraction of water in vodka]
Vbar_water1 = 0.816## [cubic cm/g]
Vbar_ethanol1 = 1.273## [cubic cm/g]
Vbar_water2 = 0.953## [cubic cm/g]
Vbar_ethanol2 = 1.243## [cubic cm/g]
Density_water = 0.997## [cubic cm/g]
#***************#
# Solution (i)
# From Eqn 9.9
Va = y1_1*Vbar_ethanol1 + y2_1*Vbar_water1## [Volume of laboratory alcohol, cubic cm/g]
mass = Vol/Va## [g]
# Let Mw be the mass of water added in laboratory alcohol.
# Material balance on ethanol:
Mw = mass*y1_1/y1_2 - mass## [g]
Vw = Mw/Density_water## [Volume of water added, cubic cm]
print "Mass of water added is %d g\n"%(Mw)#
# Solution (ii)
Mv = mass + Mw## [Mass of vodka, g]
Vv = y1_2*Vbar_ethanol2 + y2_2*Vbar_water2## [Volume of ethanol, cubic cm/g]
V_vodka = Vv*Mv## [Volume of vodka obtained after conversion, cubic cm]
print "The volume of vodka obtained after conversion is %.d cubic cm\n"%(V_vodka)#
```

In [7]:

```
print "Example: 9.4 - Page: 339\n\n"
# Mathematics is involved in proving but just that no numerical computations are involved.
# For prove refer to this example 9.4 on page number 339 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 9.4 on page 339 of the book."
```

In [8]:

```
print "Example: 9.5 - Page: 340\n\n"
# Mathematics is involved in proving but just that no numerical computations are involved.
# For prove refer to this example 9.5 on page number 340 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 9.5 on page 340 of the book."
```

In [9]:

```
from __future__ import division
print "Example - 9.6 and Page number - 341\n\n"
#Given
T = 25+273.15## [K]
P = 1## [atm]
# Component 1 = water
# Component 2 = methanol
a = -3.2## [cubic cm/mol] A constant
V2 = 40.7## [cubic cm/mol] Molar volume of pure component 2 (methanol)
# V1_bar = 18.1 + a*x_2**(2)
# From Gibbs-Duhem equation at constant temperature and pressure we have
# x_1*dV1_bar + x_2*dV2_bar = 0
# dV2_bar = -(x_1/x_2)*dV1_bar = -(x_1/x_2)*a*2*x_2*dx_2 = -2*a*x_1*dx_2 = 2*a*x_1*dx_1
# At x_1 = 0: x_2 = 1 and thus V2_bar = V2
# Integrating the above equation from x_1 = 0 to x_1 in the RHS, and from V2_bar = V2 to V2 in the LHS, we get
# V2_bar = V2 + a*x_1**(2) - Molar volume of component 2(methanol) in the mixture
print "The expression for the partial molar volume of methanol(2) is\nV2_bar = V2 + a*x_1**(2) [cubic cm/mol]\n\n"
# At infinite dilution, x_2 approach 0 and thus x_1 approach 1, therefore
x_1 = 1## Mole fraction of component 1(water) at infinite dilution
V2_bar_infinite = V2 + a*(x_1**(2))##[cubic cm/mol]
print "The partial molar volume of methanol at infinite dilution is %.1f cubic cm/mol"%(V2_bar_infinite)#
```

In [10]:

```
from __future__ import division
from numpy import mat
%matplotlib inline
from matplotlib.pyplot import plot, title, xlabel, ylabel, show, grid
print "Example: 9.7 - Page: 342\n\n"
# Solution
#*****Data******#
# Data = [X1 V*10**6(cubic m/mol)]#
Data = mat([[0, 20],[0.2, 21.5],[0.4, 24.0],[0.6, 27.4],[0.8, 32.0],[1, 40]])
#************#
plot(Data[:,0],Data[:,1])
title("Example 9.7")
xlabel("Mole fraction")
ylabel("Molar Volume*10**(6)")
grid()#
show()
# Solution (i)
print "For X1 = 0.5\n"
# A tangent is drawn to the curve at X1 = 0.5.
# The intercept at X2 = 0 or X1 = 1, gives V1_bar.
V1_bar1 = 33.8*10**(-6)## [cubic m/mol]
# The intercept at X2 = 1 or X1 = 0, gives V2_bar.
V2_bar1 = 17*10**(-6)## [cubic m/mol]
print "Partial molar volume of component 1 is %.2e cubic m/mol\n"%(V1_bar1)#
print "Partial molar volume of component 2 is %.2e cubic m/mol\n"%(V2_bar1)#
print "\n"
# Solution (ii)
print "For X2 = 0.75\n"
# A tangent is drawn to the curve at X1 = 0.75.
# The intercept at X2 = 0 or X1 = 1, gives V1_bar.
V1_bar2 = 36.6*10**(-6)## [cubic m/mol]
# The intercept at X2 = 1 or X1 = 0, gives V2_bar.
V2_bar2 = 12.4*10**(-6)## [cubic m/mol]
point1 = mat([[0, V1_bar1],[ 1 ,V2_bar1]])
point2 = mat([[0, V1_bar2],[1, V2_bar2]])
plot(point1[:,0],point1[:,1],point2[:,0],point2[:,1])
#legend("X1 = 0.5"%("X1 = 0.75"
xlabel("Mole fraction")
ylabel("Molar Volume")
print "Partial molar volume of component 1 is %.2e cubic m/mol\n"%(V1_bar2)
print "Partial molar volume of component 2 is %.2e cubic m/mol\n"%(V2_bar2)
```

In [11]:

```
print "Example: 9.8 - Page: 352\n\n"
# Mathematics is involved in proving but just that no numerical computations are involved.
# For prove refer to this example 9.8 on page number 352 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 9.8 on page 352 of the book."
```

In [12]:

```
print "Example: 9.9 - Page: 352\n\n"
# Mathematics is involved in proving but just that no numerical computations are involved.
# For prove refer to this example 9.9 on page number 352 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 9.9 on page 352 of the book."
```

In [13]:

```
from __future__ import division
from math import exp, log
print "Example: 9.10 - Page: 354\n\n"
# Solution
#*****Data******#
x1 = 0.3## [mole fraction of component 1 in the mixture]
x2 = 0.7## [mole fraction of component 2 in the mixture]
phi1 = 0.7## [fugacity coeffecient of component 1 in the mixture]
phi2 = 0.85## [fugacity coeffecient of component 2 in the mixture]
P = 50## [bar]
T = 273 + 100## [K]
#*************#
phi = exp(x1*log(phi1) + x2*log(phi2))## [fugacity coeffecient of the mixture]
f = phi*P## [bar]
print "Fugacity of the gaseous mixture is %.3f bar"%(f)#
```

In [14]:

```
from __future__ import division
from math import exp, log
print "Example: 9.11 - Page: 354\n\n"
# Solution
#*****Data******#
x1 = 0.3## [mole fraction of hydrogen in the mixture]
x2 = 0.25## [mole fraction of nitrogen in the mixture]
x3 = 0.45## [mole fraction of oxygen in the mixture]
phi1 = 0.7## [fugacity coeffecient of oxygen in the mixture]
phi2 = 0.85## [fugacity coeffecient of nitrogen in the mixture]
phi3 = 0.75## [fugacity coeffecient of oxygen in the mixture]
P = 60## [bar]
T = 273 + 150## [K]
#***********#
phi = exp(x1*log(phi1) + x2*log(phi2) + x3*log(phi3))## [fugacity coeffecient of the mixture]
f = phi*P## [bar]
print "Fugacity of the gaseous mixture is %.3f bar"%(f)#
```

In [15]:

```
from __future__ import division
from math import exp, log
print "Example: 9.12 - Page: 356\n\n"
# Solution
#*****Data******#
T = 372.12## [K]
Psat = 100## [kPa]
P = 300# #[kPa]
Vspecific = 1.043*10**(-3)##[cubic m/kg]
M = 18*10**(-3)## [molecular weight of water, kg/mol]
R = 8.314## [J/mol K]
#***************#
Psat = Psat/100## [bar]
P = P/100## [bar]
Vl = Vspecific*M## [cubic m/mol]
# Vapour is assumed to be like an ideal gas.
phi = 1#
fsat = Psat*phi## [bar]
fl = fsat*exp(Vl*(P - Psat)*10**5/(R*T))## [bar]
print "Fugacity of liquid water is %.4f bar"%(fl)#
```

In [16]:

```
from __future__ import division
from math import exp, log
print "Example: 9.13 - Page: 357\n\n"
# Solution
#*****Data******#
Vl = 90.45*10**(-6)## [molar volume of liquid butadiene, cubic m/mol]
fsat = 4.12## [bar]
P = 10## [bar]
Psat = 4.12## [bar]
T = 313## [K]
R = 8.314## [J/mol K]
#************#
fl = fsat*exp(Vl*(P - Psat)*10**5/(R*T))## [bar]
print "The fugacity of the liquid water is %.4f bar"%(fl)#
```

In [17]:

```
from __future__ import division
from math import exp, log
from sympy.mpmath import quad
print "Example: 9.14 - Page: 357\n\n"
# Solution
#*****Data******#
b = 0.0391## [cubic dm/mol]
P1 = 1000## [atm]
T = 1000 + 273## [K]
R = 0.0892## [L bar/K mol]
#deff('[Vreal] = f1(P)','Vreal = R*T/P + b')#
#deff('[Videal] = f2(P)','Videal = R*T/P')#
def f1(P):
Vreal = R*T/P + b
return Vreal
def f2(P):
Videal = R*T/P
return Videal
def f(P):
f12 = f1(P)-f2(P)
return f12
#**************#
# We know that:
# RTlog(f/P) = integral('Vreal - Videal',P,0,P)
f = P1*exp((1/(R*T))*quad(f,[0,P1]))## [atm]
phi = f/P1#
print "The fugacity of the gas is %d atm \n"%(f)#
print "The fugacity coeffecient of the gas is %.3f atm"%(phi)#
```

In [18]:

```
from __future__ import division
from math import exp, log
print "Example: 9.15 - Page: 359\n\n"
# Solution
#*****Data******#
Vl = 73*10**(-6)## [cubic m/mol]
P = 275## [bar]
Psat = 4.360## [bar]
T = 110 + 273## [K]
R = 8.314## [J/mol K]
#**************#
# Acetone vapour is assumed to behave like ideal gas.
phi = 1#
fsat = Psat## [bar]
fl = fsat*exp(Vl*(P - Psat)*10**5/(R*T))## [bar]
print "Fugacity of liquid butadiene at 313 K & 10 bar is %.3f bar"%(fl)#
```

In [19]:

```
from __future__ import division
from math import exp, log
print "Example: 9.16 - Page: 362\n\n"
# Solution
#*****Data******#
V1 = 2.8## [Volume of Oxygen, L]
V2 = 19.6## [Volume of hydrogen, L]
R = 1.987## [cal/K mol]
#**************#
n1 = V1/22.4## [moles of Oxygen]
n2 = V2/22.4## [moles of Hydrogen]
n = n1 + n2## [total number of moles]
x1 = n1/n## [mole fraction of Oxygen]
x2 = n2/n## [mole fraction of Hydrogen]
# From Eqn. 9.88:
deltaS_mix = - (R*(x1*log(x1) + x2*log(x2)))## [cal/K mol]
print "The entropy change of mixiong is %.3f cal/K mol"%(deltaS_mix)
```

In [20]:

```
print "Example: 9.17 - Page: 363\n\n"
# Mathematics is involved in proving but just that no numerical computations are involved.
# For prove refer to this example 9.17 on page number 363 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 9.17 on page 363 of the book."
```

In [21]:

```
from __future__ import division
from math import exp, log
print "Example: 9.18 - Page: 364\n\n"
# Solution
#*****Data******#
n1 = 0.7## [moles of helium]
n2 = 0.3## [moles of argon]
R = 8.314## [J/mol K]
T = 273 + 25## [K]
#******************#
n = n1 + n2## [total moles]
x1 = n1/n## [mole fraction of helium]
x2 = n2/n## [mole fraction of argon]
deltaG_mix = n*R*T*(x1*log(x1) + x2*log(x2))## [J]
print "The free energy change of mixing is %.2f J\n"%(deltaG_mix)#
# Since the gases are ideal:
deltaH_mix = 0## [J]
print "The enthalpy change of mixing is %d J\n"%(deltaH_mix)#
```

In [22]:

```
from __future__ import division
from math import exp, log
print "Example: 9.19 - Page: 364\n\n"
# Solution
#*****Data******#
V = 20## [Volume of vessel, L]
V1 = 12## [Volume of Hydrogen, L]
V2 = 10## [Volume of Nitrogen, L]
P = 1## [atm]
T = 298## [K]
P1 = 1## [atm]
P2 = 1## [atm]
R = 0.082## [L atm/K mol]
#************#
n1 = P1*V1/(R*T)## [number of moles of Hydrogen]
n2 = P2*V2/(R*T)## [number of moles of Nitrogen]
n = n1 + n2## [total number of moles]
Pfinal = n*R*T/V## [atm]
p1 = Pfinal*n1## [partial pressure of Hydrogen, atm]
p2 = Pfinal*n2## [partial pressure of Nitrogen, atm]
deltaG_mix = R*T*(n1*log(p1/P1) + n2*log(p2/P2))## [J]
print "Free Energy change of mixing is %.2f J\n"%(deltaG_mix)#
# Since mixing is ideal:
deltaH_mix = 0## [J]
print "Enthalpy change in mixing is %.2f J\n"%(deltaH_mix)#
deltaS_mix = - (deltaG_mix/T)## [J/K]
print "Entropy Change in mixing is %.3f J/K\n"%(deltaS_mix)#
```

In [23]:

```
print "Example: 9.20 - Page: 367\n\n"
# Mathematics is involved in proving but just that no numerical computations are involved.
# For prove refer to this example 9.20 on page number 367 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 9.20 on page 367 of the book."
```

In [24]:

```
print "Example: 9.21 - Page: 373\n\n"
# Mathematics is involved in proving but just that no numerical computations are involved.
# For prove refer to this example 9.21 on page number 373 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 9.21 on page 373 of the book."
```