Chapter 09: Ideal and Real Solutions

Example Problem 9.2, Page Number 202

In [1]:
from math import log

#Variable Declaration
nb = 5.00      #Number of moles of Benzene, mol
nt = 3.25      #Number of moles of Toluene, mol
T = 298.15     #Temperature, K
P = 1.0        #Pressure, bar
R = 8.314      #Ideal Gas Constant, J/(mol.K)

#Calculations
n = nb + nt
xb = nb/n
xt = 1. - xb
dGmix = n*R*T*(xb*log(xb)+xt*log(xt))
dSmix = -n*R*(xb*log(xb)+xt*log(xt))

#Results
print 'Gibbs energy change of mixing is %4.3e J'%dGmix
print 'Gibbs energy change of mixing is < 0, hence the mixing is spontaneous'
print 'Entropy change of mixing is %4.2f J/K'%dSmix
Gibbs energy change of mixing is -1.371e+04 J
Gibbs energy change of mixing is < 0, hence the mixing is spontaneous
Entropy change of mixing is 45.99 J/K

Example Problem 9.3, Page Number 205

In [12]:
#Variable Declaration
nb = 5.00      #Number of moles of Benzene, mol
nt = 3.25      #Number of moles of Toluene, mol
T = 298.15     #Temperature, K
R = 8.314      #Ideal Gas Constant, J/(mol.K)
P0b = 96.4     #Vapor pressure of Benzene, torr
P0t = 28.9     #Vapor pressure of Toluene, torr

#Calculations
n = nb + nt
xb = nb/n
xt = 1. - xb
P = xb*P0b + xt*P0t
y = (P0b*P - P0t*P0b)/(P*(P0b-P0t))
yt = 1.-yb

#Results
print 'Total pressure of the vapor is %4.1f torr'%P
print 'Benzene fraction in vapor is %4.3f '%yb
print 'Toulene fraction in vapor is %4.3f '%yt
Total pressure of the vapor is 69.8 torr
Benzene fraction in vapor is 0.837 
Toulene fraction in vapor is 0.163 

Example Problem 9.4, Page Number 206

In [1]:
from sympy import symbols, solve
#Variable Declaration
nb = 5.00      #Number of moles of Benzene, mol
nt = 3.25      #Number of moles of Toluene, mol
T = 298.15     #Temperature, K
R = 8.314      #Ideal Gas Constant, J/(mol.K)
P0b = 96.4     #Vapor pressure of Benzene, torr
P0t = 28.9     #Vapor pressure of Toluene, torr
nv = 1.5       #moles vaporized, mol

#Calculations
n = nb + nt
nl = n - nv
zb = nb/n

x,y, P = symbols('x y P')
e1 = nv*(y-zb)-nl*(zb-x)
print 'Mass Balance:', e1
e2 = P - (x*P0b + (1-x)*P0t)
print 'Pressure and x:',e2
e3 = y - (P0b*P - P0t*P0b)/(P*(P0b-P0t))
print 'Pressure and y:', e3
equations = [e1,e2,e3]
sol = solve(equations)

#Results
for i in sol:
    if ((i[x] > 0.0 and i[x] <1.0) and (i[P] > 0.0) and (i[y]>zb and i[y]<1.0)):
        print 'Pressure is %4.1f torr' %i[P]
        print 'Mole fraction of benzene in liquid phase %4.3f' %i[x]
        print 'Mole fraction of benzene in vapor phase %4.3f' %i[y]
Mass Balance: 6.75*x + 1.5*y - 5.0
Pressure and x: P - 67.5*x - 28.9
Pressure and y: y - 0.0148148148148148*(96.4*P - 2785.96)/P
Pressure is 66.8 torr
Mole fraction of benzene in liquid phase 0.561
Mole fraction of benzene in vapor phase 0.810

Example Problem 9.6, Page Number 212

In [69]:
#Variable Declaration
m = 4.50        #Mass of substance dissolved, g
ms = 125.0      #Mass of slovent (CCl4), g
TbE = 0.65      #Boiling point elevation, °C
Kf, Kb = 30.0, 4.95    #Constants for freezing point elevation 
                        # and boiling point depression for CCl4, K kg/mol
Msolvent = 153.8  #Molecualr wt of solvent, g/mol
#Calculations
DTf = -Kf*TbE/Kb
Msolute = Kb*m/(ms*1e-3*TbE)
nsolute = m/Msolute
nsolvent = ms/Msolvent 
x = 1.0 -  nsolute/(nsolute + nsolvent)

#Results
print 'Freezing point depression %5.2f K'%DTf
print 'Molecualr wt of solute %4.1f g/mol'%Msolute
print 'Vapor pressure of solvent is reduced by a factor of %4.3f'%x
Freezing point depression -3.94 K
Molecualr wt of solute 274.2 g/mol
Vapor pressure of solvent is reduced by a factor of 0.980

Example Problem 9.7, Page Number 214

In [70]:
#Variable Declaration
csolute = 0.500 #Concentration of solute, g/L
R = 8.206e-2    #Gas constant L.atm/(mol.K)
T = 298.15      #Temperature of the solution, K

#Calculations
pii = csolute*R*T

#Results
print 'Osmotic pressure %4.2f atm'%pii
Osmotic pressure 12.23 atm

Example Problem 9.8, Page Number 220

In [72]:
#Variable Declaration
xCS2 = 0.3502   #Mol fraction of CS2, g/L
pCS2 = 358.3    #Partial pressure of CS2, torr
p0CS2 = 512.3   #Total pressure, torr

#Calculations
alpha = pCS2/p0CS2
gama = alpha/xCS2

#Results
print 'Activity of CS2 %5.4f atm'%alpha
print 'Activity coefficinet of CS2 %5.4f atm'%gama
Activity of CS2 0.6994 atm
Activity coefficinet of CS2 1.9971 atm

Example Problem 9.9, Page Number 220

In [73]:
#Variable Declaration
xCS2 = 0.3502   #Mol fraction of CS2, g/L
pCS2 = 358.3    #Partial pressure of CS2, torr
kHCS2 = 2010.   #Total pressure, torr

#Calculations
alpha = pCS2/kHCS2
gama = alpha/xCS2

#Results
print 'Activity of CS2 %5.4f atm'%alpha
print 'Activity coefficinet of CS2 %5.4f atm'%gama
Activity of CS2 0.1783 atm
Activity coefficinet of CS2 0.5090 atm

Example Problem 9.10, Page Number 221

In [76]:
#Variable Declaration
rho = 789.9     #Density of acetone, g/L
n = 1.0         #moles of acetone, mol
M = 58.08       #Molecular wt of acetone, g/mol
kHacetone = 1950 #Henrys law constant, torr
#Calculations
H = n*M*kHacetone/rho

#Results
print 'Henrys constant = %5.2f torr'%H
Henrys constant = 143.38 torr

Example Problem 9.11, Page Number 221

In [81]:
#Variable Declaration
m = 0.5         #Mass of water, kg
ms = 24.0       #Mass of solute, g
Ms = 241.0      #Molecular wt of solute, g/mol
Tfd = 0.359     #Freezinf point depression, °C or K
kf = 1.86       #Constants for freezing point depression for water, K kg/mol

#Calculations
msolute = ms/(Ms*m)
gama = Tfd/(kf*msolute)

#Results
print 'Activity coefficient = %4.3f'%gama
Activity coefficient = 0.969

Example Problem 9.12, Page Number 223

In [90]:
#Variable Declaration
m = 70.0        #Mass of human body, kg
V = 5.00        #Volume of blood, L
HN2 = 9.04e4    #Henry law constant for N2 solubility in blood, bar
T = 298.0       #Temperature, K
rho = 1.00      #density of blood, kg/L
Mw = 18.02      #Molecualr wt of water, g/mol
X = 80          #Percent of N2 at sea level
p1, p2 = 1.0, 50.0  #Pressures, bar
R = 8.314e-2       #Ideal Gas constant, L.bar/(mol.K)
#Calculations
nN21  = (V*rho*1e3/Mw)*(p1*X/100)/HN2
nN22  = (V*rho*1e3/Mw)*(p2*X/100)/HN2
V = (nN22-nN21)*R*T/p1
#Results
print 'Number of moles of nitrogen in blood at 1 and 50 bar are %3.2e,%3.3f mol'%(nN21,nN22)
print 'Volume of nitrogen released from blood at reduced pressure %4.3f L'%V
Number of moles of nitrogen in blood at 1 and 50 bar are 2.46e-03,0.123 mol
Volume of nitrogen released from blood at reduced pressure 2.981 L

Example Problem 9.14, Page Number 226

In [2]:
from numpy import arange,array,ones,linalg, divide
from matplotlib import pyplot
%matplotlib inline
#Variable Declaration
cCB = array([1e-6,2e-6,3e-6,5e-6,10e-6])
nu = array([0.006,0.012,0.018,0.028,0.052])
y = nu/cCB
print y
xlim(0.0, 0.06)
ylim(5000,6300)
#Calculations
A = array([ nu, ones(size(nu))])
print A
# linearly generated sequence

w = linalg.lstsq(A.T,y)[0] # obtaining the parameters
print 'slope %8.1f'%w[0]
print 'Intercept %8.1f' %w[1]
# Use w[0] and w[1] for your calculations and give good structure to this ipython notebook
# plotting the line
line = w[0]*nu+w[1] # regression line
  
#Results
plot(nu,line,'r-',nu,y,'o')
xlabel('$ \overline{\upsilon} $')
ylabel('$ \overline{\upsilon}/C_{CB},  M^{-1} $')
#ylabel('$ \dfrac{\overline{\upsilon}}{C_{CB}} $')
show()
[ 6000.  6000.  6000.  5600.  5200.]
[[ 0.006  0.012  0.018  0.028  0.052]
 [ 1.     1.     1.     1.     1.   ]]
slope -19188.2
Intercept   6205.2
In [ ]: