# Chapter 06: Chemical Equilibrium¶

## Example Problem 6.1, Page Number 117¶

In :
#Variable Declaration
dHcCH4 = -891.0        #Std. heat of combustion for CH4, kJ/mol
dHcC8H18 = -5471.0     #Std. heat of combustion for C8H18, kJ/mol

T = 298.15
SmCO2, SmCH4, SmH2O, SmO2, SmC8H18 = 213.8,186.3,70.0,205.2, 316.1
dnCH4 = -2.
dnC8H18 = 4.5
R = 8.314
#Calculations
dACH4 = dHcCH4*1e3 - dnCH4*R*T - T*(SmCO2 + 2*SmH2O - SmCH4 - 2*SmO2)
dAC8H18 = dHcC8H18*1e3 - dnC8H18*R*T - T*(8*SmCO2 + 9*SmH2O - SmC8H18 - 25.*SmO2/2)
#Results
print 'Maximum Available work through combustion of CH4 %4.1f kJ/mol'%(dACH4/1000)
print 'Maximum Available work through combustion of C8H18 %4.1f kJ/mol'%(dAC8H18/1000)

Maximum Available work through combustion of CH4 -813.6 kJ/mol
Maximum Available work through combustion of C8H18 -5320.9 kJ/mol


## Example Problem 6.2, Page Number 118¶

In :
#Variable Declaration
dHcCH4 = -891.0        #Std. heat of combustion for CH4, kJ/mol
dHcC8H18 = -5471.0     #Std. heat of combustion for C8H18, kJ/mol

T = 298.15
SmCO2, SmCH4, SmH2O, SmO2, SmC8H18 = 213.8,186.3,70.0,205.2, 316.1
dnCH4 = -2.
dnC8H18 = 4.5
R = 8.314
#Calculations
dGCH4 = dHcCH4*1e3  - T*(SmCO2 + 2*SmH2O - SmCH4 - 2*SmO2)
dGC8H18 = dHcC8H18*1e3 - T*(8*SmCO2 + 9*SmH2O - SmC8H18 - 25.*SmO2/2)
#Results
print 'Maximum nonexapnasion work through combustion of CH4 %4.1f kJ/mol'%(dGCH4/1000)
print 'Maximum nonexapnasion work through combustion of C8H18 %4.1f kJ/mol'%(dGC8H18/1000)

Maximum nonexapnasion work through combustion of CH4 -818.6 kJ/mol
Maximum nonexapnasion work through combustion of C8H18 -5309.8 kJ/mol


## Example Problem 6.4, Page Number 123¶

In :
#Variable Declaration
dGf298 = 370.7     #Std. free energy of formation for Fe (g), kJ/mol
dHf298 = 416.3     #Std. Enthalpy of formation for Fe (g), kJ/mol
T0 = 298.15        #Temperature in K
T = 400.           #Temperature in K
R = 8.314

#Calculations

dGf = T*(dGf298*1e3/T0 + dHf298*1e3*(1./T - 1./T0))

#Results
print 'Std. free energy of formation for Fe(g) at 400 K is %4.1f kJ/mol'%(dGf/1000)

Std. free energy of formation for Fe(g) at 400 K is 355.1 kJ/mol


## Example Problem 6.5, Page Number 127¶

In :
from math import log

#Variable Declaration
nHe = 1.0          #Number of moles of He
nNe = 3.0          #Number of moles of Ne
nAr = 2.0          #Number of moles of Ar
nXe = 2.5          #Number of moles of Xe
T = 298.15         #Temperature in K
P = 1.0            #Pressure, bar
R = 8.314

#Calculations
n = nHe + nNe + nAr + nXe
dGmix = n*R*T*((nHe/n)*log(nHe/n) + (nNe/n)*log(nNe/n) +(nAr/n)*log(nAr/n) + (nXe/n)*log(nXe/n))
dSmix = n*R*((nHe/n)*log(nHe/n) + (nNe/n)*log(nNe/n) +(nAr/n)*log(nAr/n) + (nXe/n)*log(nXe/n))

#Results
print 'Std. free energy Change on mixing is %3.1e J'%(dGmix)
print 'Std. entropy Change on mixing is %4.1f J'%(dSmix)

Std. free energy Change on mixing is -2.8e+04 J
Std. entropy Change on mixing is -93.3 J


## Example Problem 6.6, Page Number 128¶

In :
#Variable Declaration
dGfFe  = 0.0       #Std. Gibbs energy of formation for Fe (S), kJ/mol
dGfH2O = -237.1     #Std. Gibbs energy of formation for Water (g), kJ/mol
dGfFe2O3 = -1015.4  #Std. Gibbs energy of formation for Fe2O3 (s), kJ/mol
dGfH2 = 0.0        #Std. Gibbs energy of formation for Hydrogen (g), kJ/mol
T0 = 298.15        #Temperature in K
R = 8.314
nFe, nH2, nFe2O3, nH2O = 3,-4,-1,4

#Calculations
dGR = nFe*dGfFe + nH2O*dGfH2O + nFe2O3*dGfFe2O3 + nH2*dGfH2

#Results
print 'Std. Gibbs energy change for reaction is %4.2f kJ/mol'%(dGR)

Std. Gibbs energy change for reaction is 67.00 kJ/mol


## Example Problem 6.7, Page Number 128¶

In :
#Variable Declaration
dGR  = 67.0        #Std. Gibbs energy of formation for reaction, kJ, from previous problem
dHfFe  = 0.0       #Enthalpy of formation for Fe (S), kJ/mol
dHfH2O = -285.8    #Enthalpy of formation for Water (g), kJ/mol
dHfFe2O3 = -1118.4 #Enthalpy of formation for Fe2O3 (s), kJ/mol
dHfH2 = 0.0        #Enthalpy of formation for Hydrogen (g), kJ/mol
T0 = 298.15        #Temperature in K
T = 525.           #Temperature in K
R = 8.314
nFe, nH2, nFe2O3, nH2O = 3,-4,-1,4

#Calculations
dHR = nFe*dHfFe + nH2O*dHfH2O + nFe2O3*dHfFe2O3 + nH2*dHfH2
dGR2 = T*(dGR*1e3/T0 + dHR*1e3*(1./T - 1./T0))

#Results
print 'Std. Enthalpy change for reactionat %4.1f is %4.2f kJ/mol'%(T, dHR)
print 'Std. Gibbs energy change for reactionat %4.1f is %4.0f kJ/mol'%(T, dGR2/1e3)

Std. Enthalpy change for reactionat 525.0 is -24.80 kJ/mol
Std. Gibbs energy change for reactionat 525.0 is  137 kJ/mol


## Example Problem 6.8, Page Number 130¶

In :
from math import log

#Variable Declaration
dGfNO2  = 51.3     #Std. Gibbs energy of formation for NO2 (g), kJ/mol
dGfN2O4 = 99.8     #Std. Gibbs energy of formation for N2O4 (g), kJ/mol
T0 = 298.15        #Temperature in K
pNO2 = 0.350       #Partial pressure of NO2, bar
pN2O4 = 0.650      #Partial pressure of N2O4, bar
R = 8.314
nNO2, nN2O4 = -2, 1 #Stoichiomentric coeff of NO2 and N2O4 respectively in reaction

#Calculations
dGR = nN2O4*dGfN2O4*1e3 + nNO2*dGfNO2*1e3 + R*T0*log(pN2O4/(pNO2)**2)

#Results
print 'Std. Gibbs energy change for reaction is %5.3f kJ/mol'%(dGR/1e3)

Std. Gibbs energy change for reaction is 1.337 kJ/mol


## Example Problem 6.9, Page Number 131¶

In :
from math import exp

#Variable Declaration
dGfCO2  = -394.4   #Std. Gibbs energy of formation for CO2 (g), kJ/mol
dGfH2 = 0.0        #Std. Gibbs energy of formation for H2 (g), kJ/mol
dGfCO = 237.1      #Std. Gibbs energy of formation for CO (g), kJ/mol
dGfH2O = 137.2     #Std. Gibbs energy of formation for H24 (l), kJ/mol
T0 = 298.15        #Temperature in K
R = 8.314
nCO2, nH2, nCO, nH2O = 1,1,1,1 #Stoichiomentric coeff of CO2,H2,CO,H2O respectively in reaction

#Calculations
dGR = nCO2*dGfCO2 + nH2*dGfH2 + nCO*dGfCO + nH2O*dGfH2O
Kp = exp(-dGR*1e3/(R*T0))

#Results
print 'Std. Gibbs energy change for reaction is %5.3f kJ/mol'%(dGR/1e3)
print 'Equilibrium constant for reaction is %5.3f '%(Kp)
if Kp > 1: print 'Kp >> 1. hence, mixture will consists of product CO2 and H2'

Std. Gibbs energy change for reaction is -0.020 kJ/mol
Equilibrium constant for reaction is 3323.254
Kp >> 1. hence, mixture will consists of product CO2 and H2


## Example Problem 6.11, Page Number 133¶

In :
from math import exp, sqrt

#Variable Declaration
dGfCl2  = 0.0     #Std. Gibbs energy of formation for CO2 (g), kJ/mol
dGfCl = 105.7     #Std. Gibbs energy of formation for H2 (g), kJ/mol
dHfCl2 = 0.0      #Std. Gibbs energy of formation for CO (g), kJ/mol
dHfCl = 121.3     #Std. Gibbs energy of formation for H24 (l), kJ/mol
T0 = 298.15       #Temperature in K
R = 8.314
nCl2, nCl= -1,2 #Stoichiomentric coeff of Cl2,Cl respectively in reaction
PbyP0 = 0.01
#Calculations
dGR = nCl*dGfCl + nCl2*dGfCl2
dHR = nCl*dHfCl + nCl2*dHfCl2
func = lambda T: exp(-dGR*1e3/(R*T0) - dHR*1e3*(1./T - 1./T0)/R)
Kp8 = func(800)
Kp15 = func(1500)
Kp20 = func(2000)
DDiss = lambda K: sqrt(K/(K+4*PbyP0))
alp8 = DDiss(Kp8)
alp15 = DDiss(Kp15)
alp20 = DDiss(Kp20)

#Results
print 'Part A'
print 'Std. Gibbs energy change for reaction is %5.3f kJ/mol'%(dGR)
print 'Std. Enthalpy change for reaction is %5.3f kJ/mol'%(dHR)
print 'Equilibrium constants at 800, 1500, and 2000 K are %4.3e, %4.3e, and %4.3e'%(Kp8,Kp15,Kp20)

print 'Part B'
print 'Degree of dissociation at 800, 1500, and 2000 K are %4.3e, %4.3e, and %4.3e'%(alp8,alp15,alp20)

Part A
Std. Gibbs energy change for reaction is 211.400 kJ/mol
Std. Enthalpy change for reaction is 242.600 kJ/mol
Equilibrium constants at 800, 1500, and 2000 K are 4.223e-11, 1.042e-03, and 1.349e-01
Part B
Degree of dissociation at 800, 1500, and 2000 K are 3.249e-05, 1.593e-01, and 8.782e-01


## Example Problem 6.12, Page Number 134¶

In :
from math import exp

#Variable Declaration
dGfCaCO3  = -1128.8     #Std. Gibbs energy of formation for CaCO3 (s), kJ/mol
dGfCaO = -603.3         #Std. Gibbs energy of formation for CaO (s), kJ/mol
dGfCO2 = -394.4         #Std. Gibbs energy of formation for O2 (g), kJ/mol
dHfCaCO3 = -1206.9      #Std. Enthalpy Change of formation for CaCO3 (s), kJ/mol
dHfCaO = -634.9         #Std. Enthalpy Change of formation for CaO (s), kJ/mol
dHfCO2 = -393.5         #Std. Enthalpy Change of formation for O2 (g), kJ/mol
T0 = 298.15             #Temperature in K
R = 8.314
nCaCO3, nCaO, nO2 = -1,1,1 #Stoichiomentric coeff of CaCO3, CaO, O2 respectively in reaction

#Calculations
dGR = nCaO*dGfCaO + nO2*dGfCO2 + nCaCO3*dGfCaCO3
dHR = nCaO*dHfCaO + nO2*dHfCO2 + nCaCO3*dHfCaCO3

func = lambda T: exp(-dGR*1e3/(R*T0) - dHR*1e3*(1./T - 1./T0)/R)

Kp10 = func(1000)
Kp11 = func(1100)
Kp12 = func(1200)

#Results
print 'Std. Gibbs energy change for reaction is %4.1f kJ/mol'%(dGR)
print 'Std. Enthalpy change for reaction is %4.1f kJ/mol'%(dHR)
print 'Equilibrium constants at 1000, 1100, and 1200 K are %4.4f, %4.3fe, and %4.3f'%(Kp10,Kp11,Kp12)

Std. Gibbs energy change for reaction is 131.1 kJ/mol
Std. Enthalpy change for reaction is 178.5 kJ/mol
Equilibrium constants at 1000, 1100, and 1200 K are 0.0956, 0.673e, and 3.423


## Example Problem 6.13, Page Number 135¶

In :
from math import exp

#Variable Declaration
dGfCG  = 0.0            #Std. Gibbs energy of formation for CaCO3 (s), kJ/mol
dGfCD = 2.90            #Std. Gibbs energy of formation for CaO (s), kJ/mol
rhoG = 2.25e3           #Density of Graphite, kg/m3
rhoD = 3.52e3           #Density of dimond, kg/m3
T0 = 298.15             #Std. Temperature, K
R = 8.314               #Ideal gas constant, J/(mol.K)
P0 = 1.0                #Pressure, bar
M = 12.01               #Molceular wt of Carbon
#Calculations
P = P0*1e5 + dGfCD*1e3/((1./rhoG-1./rhoD)*M*1e-3)

#Results
print 'Pressure at which graphite and dimond will be in equilibrium is %4.2e bar'%(P/1e5)

Pressure at which graphite and dimond will be in equilibrium is 1.51e+04 bar


## Example Problem 6.14, Page Number 143¶

In :
from math import exp

#Variable Declaration
beta = 2.04e-4          #Thermal exapansion coefficient, /K
kapa = 45.9e-6          #Isothermal compressibility, /bar
T = 298.15              #Std. Temperature, K
R = 8.206e-2            #Ideal gas constant, atm.L/(mol.K)
T1 = 320.0              #Temperature, K
Pi = 1.0                #Initial Pressure, bar
V = 1.00                #Volume, m3
a = 1.35                #van der Waals constant a for nitrogen, atm.L2/mol2

#Calculations
dUbydV = Pf = (beta*T1-kapa*P0)/kapa
dVT = V*kapa*(Pf-Pi)
dVbyV = dVT*100/V
Vm = Pi/(R*T1)
dUbydVm = a/(Vm**2)

#Results
print 'dUbydV = %4.2e bar'%(dUbydV)
print 'dVbyV = %4.3f percent'%(dVbyV)
print 'dUbydVm = %4.0e atm'%(dUbydVm)

dUbydV = 1.42e+03 bar
dVbyV = 6.519 percent
dUbydVm = 9e+02 atm


## Example Problem 6.15, Page Number 144¶

In :
from math import exp, log

#Variable Declaration
m = 1000.0                #mass of mercury, g
Pi, Ti  = 1.00, 300.0     #Intial pressure and temperature, bar, K
Pf, Tf  = 300., 600.0     #Final pressure and temperature, bar, K
rho = 13534.              #Density of mercury, kg/m3
beta = 18.1e-4            #Thermal exapansion coefficient for Hg, /K
kapa = 3.91e-6            #Isothermal compressibility for Hg, /Pa
Cpm = 27.98               #Molar Specific heat at constant pressure, J/(mol.K)
M = 200.59                #Molecular wt of Hg, g/mol

#Calculations
Vi = m*1e-3/rho
Vf = Vi*exp(-kapa*(Pf-Pi))
Ut = m*Cpm*(Tf-Ti)/M
Up =  (beta*Ti/kapa-Pi)*1e5*(Vf-Vi) + (Vi-Vf+Vf*log(Vf/Vi))*1e5/kapa
dU = Ut + Up
Ht = m*Cpm*(Tf-Ti)/M
Hp = ((1 + beta*(Tf-Ti))*Vi*exp(-kapa*Pi)/kapa)*(exp(-kapa*Pi)-exp(-kapa*Pf))
dH =  Ht + Hp
#Results
print 'Internal energy change is %6.2e J/mol in which \ncontribution of temeprature dependent term %6.4f percent'%(dU,Ut*100/dH)
print 'Enthalpy change is %4.3e J/mol in which \ncontribution of temeprature dependent term %4.1f percent'%(dH,Ht*100/dH)

Internal energy change is 4.06e+04 J/mol in which
contribution of temeprature dependent term 99.9999 percent
Enthalpy change is 4.185e+04 J/mol in which
contribution of temeprature dependent term 100.0 percent


## Example Problem 6.16, Page Number 145¶

In :
#Variable Declaration
T = 300.0                   #Temperature of Hg, K
beta = 18.1e-4              #Thermal exapansion coefficient for Hg, /K
kapa = 3.91e-6              #Isothermal compressibility for Hg, /Pa
M = 0.20059                 #Molecular wt of Hg, kg/mol
rho = 13534                 #Density of mercury, kg/m3
Cpm = 27.98                 #Experimental Molar specif heat at const pressure for mercury, J/(mol.K)

#Calculations
Vm = M/rho
DCpmCv = T*Vm*beta**2/kapa
Cvm = Cpm - DCpmCv
#Results
print 'Difference in molar specific heats \nat constant volume and constant pressure %4.2e J/(mol.K)'%DCpmCv
print 'Molar Specific heat of Hg at const. volume is %4.2f J/(mol.K)'%Cvm

Difference in molar specific heats
at constant volume and constant pressure 3.73e-03 J/(mol.K)
Molar Specific heat of Hg at const. volume is 27.98 J/(mol.K)


## Example Problem 6.17, Page Number 147¶

In :
#Variable Declaration
T = 298.15                  #Std. Temperature, K
P = 1.0                     #Initial Pressure, bar
Hm0, Sm0 = 0.0,154.8        #Std. molar enthalpy and entropy of Ar(g), kJ, mol, K units
Sm0H2, Sm0O2 = 130.7,205.2  #Std. molar entropy of O2 and H2 (g), kJ/(mol.K)
dGfH2O = -237.1         #Gibbs energy of formation for H2O(l), kJ/mol
nH2, nO2 = 1, 1./2       #Stoichiomentric coefficients for H2 and O2 in water formation reaction

#Calculations
Gm0 = Hm0 - T*Sm0
dGmH2O = dGfH2O*1000 - T*(nH2*Sm0H2 + nO2*Sm0O2)
#Results
print 'Molar Gibbs energy of Ar %4.3f kJ/mol'%(Gm0/1e3)
print 'Molar Gibbs energy of Water %4.3f kJ/mol'%(dGmH2O/1e3)

Molar Gibbs energy of Ar -46.154 kJ/mol
Molar Gibbs energy of Water -306.658 kJ/mol