The water–gas shift reaction is
The method used here, minimisation of the Gibbs energy of the reacting mixture with respect to its composition, extends to systems of many simultaneous reactions.
Gibbs energy of the mixture
For a mixture of perfect gases at total pressure \(p\), the Gibbs energy is
where \(n_\mathrm{J}\) is the amount of component \(\mathrm{J}\), \(\Delta_\mathrm{f}G_\mathrm{m,J}^\ominus(T)\) is its standard molar Gibbs energy of formation at temperature \(T\), \(x_\mathrm{J} = n_\mathrm{J}/n\) is its mole fraction in the total amount of gas, \(n\), and \(p^\ominus = 1\;\mathrm{bar}\) is the standard pressure. For a mixture of 1 mol each of \(\mathrm{CO(g)}\) and \(\mathrm{H_2O(g)}\) initially, the composition is given by the extent of reaction, \(\xi\), the amount of \(\mathrm{CO}\) that has reacted: \(n_\mathrm{CO} = n_\mathrm{H_2O} = 1\;\mathrm{mol} - \xi\) and \(n_\mathrm{CO_2} = n_\mathrm{H_2} = \xi\). At equilibrium, \(G\) is a minimum with respect to \(\xi\). The reaction does not change the amount of gas, so \(n = 2\;\mathrm{mol}\) for every composition; the term \(nRT\ln(p/p^\ominus)\) in \(G\) is then independent of \(\xi\), and the equilibrium composition does not depend on the pressure. The calculations below are for \(p = p^\ominus\).
The standard molar Gibbs energies of formation are those of the reactions
and that of \(\mathrm{H_2(g)}\), an element in its reference state, is zero at all temperatures. At the reference temperature, \(T_\mathrm{ref} = 298.15\;\mathrm{K}\), each is calculated from tabulated data as
where \(\Delta_\mathrm{f}H_\mathrm{m,J}^\ominus\) is the standard molar enthalpy of formation of \(\mathrm{J}\) and \(\Delta_\mathrm{f}S_\mathrm{m,J}^\ominus\) is the difference between its standard molar entropy and those of its constituent elements.
Temperature dependence
The temperature dependence of \(\Delta_\mathrm{f}G_\mathrm{m,J}^\ominus\) is given by the Gibbs–Helmholtz equation,
and that of \(\Delta_\mathrm{f}H_\mathrm{m,J}^\ominus\) by Kirchhoff's law,
where the heat capacity of formation, \(\Delta_\mathrm{f}C_{p,\mathrm{m,J}}^\ominus\), is the difference between the heat capacity of \(\mathrm{J}\) and those of its constituent elements in their reference states, e.g. \(\Delta_\mathrm{f}C_{p,\mathrm{m,CO}}^\ominus = C_{p,\mathrm{m,CO}}^\ominus - C_{p,\mathrm{m,C}}^\ominus - \frac{1}{2}C_{p,\mathrm{m,O_2}}^\ominus\). The heat capacity of each species is represented by a cubic polynomial,
whose coefficients are a least-squares fit to the values in the NIST-JANAF Thermochemical Tables between 298.15 and 2000 K. Integrating the Gibbs–Helmholtz equation from \(T_\mathrm{ref}\) to \(T\) gives
where
Show derivationHide derivation
Integrating the Gibbs–Helmholtz equation, and substituting Kirchhoff's law for \(\Delta_\mathrm{f}H_\mathrm{m,J}^\ominus(T')\),
With the cubic heat capacities, and \(\mathrm{d}T' = (1000\;\mathrm{K})\,\mathrm{d}t'\),
where \(\Delta A\), \(\Delta B\), \(\Delta C\) and \(\Delta D\) are the coefficients of \(\Delta_\mathrm{f}C_{p,\mathrm{m,J}}^\ominus\) (those of \(\mathrm{J}\) less those of its constituent elements) and \(t_\mathrm{ref} = T_\mathrm{ref}/(1000\;\mathrm{K})\). The factors of \(1000\;\mathrm{K}\) cancel from \(g\), which is
Implementation
The complete program, which uses NumPy, SciPy and Matplotlib, can be downloaded below; it is listed here in parts.
"""The equilibrium constant of the water-gas shift reaction,
CO(g) + H2O(g) = CO2(g) + H2(g), found by minimising the Gibbs energy of the
reacting mixture.
"""
import matplotlib.pyplot as plt
import numpy as np
from scipy.constants import R
from scipy.optimize import minimize_scalar
from scipy.special import xlogy
Tref = 298.15 # Reference temperature, K
pstd = 1 # Standard pressure, bar
p = 1 # Total pressure, bar
Each compound is an instance of the class Compound, which holds its standard molar enthalpy of formation and standard molar entropy at \(T_\mathrm{ref}\) and the coefficients of its heat capacity, all from the NIST-JANAF tables.
class Compound:
"""
A class representing a chemical compound with defined
formula and phase.
"""
def __init__(self, formula, phase, DfHmo, Smo, Cp_coeffs):
"""
Initialize the Compound object with its formula,
phase, standard molar enthalpy of formation (kJ.mol-1), standard
molar entropy (J.K-1.mol-1) and heat capacity temperature-dependence
coefficients.
"""
self.formula, self.phase = formula, phase
self.DfHmo, self.Smo = DfHmo, Smo
self.Cp_coeffs = dict(zip("ABCD", Cp_coeffs))
def __repr__(self):
"""String representation of the Compound."""
return f"{self.formula}({self.phase})"
# Data from the NIST-JANAF tables: DfHmo and Smo at Tref, and the coefficients
# of least-squares fits of Cp = A + Bt + Ct^2 + Dt^3 (J.K-1.mol-1), where
# t = T / 1000 K, to the heat capacities between 298.15 and 2000 K.
C = Compound('C', 'gr', 0, 5.740, [-3.58404139, 49.8518786, -31.20790025, 6.7641595])
O2 = Compound('O2', 'g', 0, 205.147, [25.15899701, 15.45182265, -7.08291124, 1.24519819])
H2 = Compound('H2', 'g', 0, 130.680, [29.35864238, -2.30374938, 4.0864225, -0.84549361])
H2O = Compound('H2O', 'g', -241.826, 188.834, [31.65695517, 3.84459406, 8.47064074, -2.77385035])
CO = Compound('CO', 'g', -110.527, 197.653, [27.48525388, 4.25879701, 2.50107857, -1.24204472])
CO2 = Compound('CO2', 'g', -393.522, 213.795, [23.04911248, 56.90377511, -31.87688451, 6.4056037])
The class Reaction calculates the standard molar enthalpy, entropy and Gibbs energy of a reaction at \(T_\mathrm{ref}\) from those of its reactants and products. Applied to the formation reactions, it gives \(\Delta_\mathrm{f}H_\mathrm{m,J}^\ominus(T_\mathrm{ref})\) and \(\Delta_\mathrm{f}G_\mathrm{m,J}^\ominus(T_\mathrm{ref})\); the coefficients of \(\Delta_\mathrm{f}C_{p,\mathrm{m,J}}^\ominus\) are combined in the same way.
class Reaction:
"""
A class representing a chemical reaction between
reactant and product Compounds.
"""
def __init__(self, reactants, products):
"""
Initialize the Reaction object with reactants and
products provided as dictionaries of
Compound: stoichiometry key-value pairs.
"""
self.reactants = reactants
self.products = products
# For convenience, create a dictionary of all
# species with positive stoichiometries for products
# and negative stoichiometries for reactants.
self.species = self.products.copy()
for compound, stoich in reactants.items():
self.species[compound] = -stoich
def calc_DrSmo_ref(self):
"""Return the standard molar entropy of reaction in J.K-1.mol-1."""
DrSmo = 0
for compound, stoich in self.species.items():
DrSmo += stoich * compound.Smo
return DrSmo
def calc_DrHmo_ref(self):
"""Return the standard molar enthalpy of reaction in kJ.mol-1."""
DrHmo = 0
for compound, stoich in self.species.items():
DrHmo += stoich * compound.DfHmo
return DrHmo
def calc_DrGmo_ref(self):
"""
Return the standard molar Gibbs energy of reaction in kJ.mol-1 at
the reference temperature, Tref.
"""
return self.calc_DrHmo_ref() - Tref * self.calc_DrSmo_ref() / 1000
# The formation reactions for CO2(g), CO(g), and H2O(g).
CO2_formation = Reaction({C: 1, O2: 1}, {CO2: 1})
CO_formation = Reaction({C: 1, O2: 0.5}, {CO: 1})
H2O_formation = Reaction({H2: 1, O2: 0.5}, {H2O: 1})
formation_reactions = {"CO2(g)": CO2_formation,
"CO(g)": CO_formation,
"H2O(g)": H2O_formation}
# The standard molar enthalpies and Gibbs energies of formation at Tref, in
# kJ.mol-1. They are zero for H2(g), an element in its reference state.
DfHmo_ref = {
"CO(g)": CO_formation.calc_DrHmo_ref(),
"CO2(g)": CO2_formation.calc_DrHmo_ref(),
"H2O(g)": H2O_formation.calc_DrHmo_ref(),
"H2(g)": 0
}
DfGmo_ref = {
"CO(g)": CO_formation.calc_DrGmo_ref(),
"CO2(g)": CO2_formation.calc_DrGmo_ref(),
"H2O(g)": H2O_formation.calc_DrGmo_ref(),
"H2(g)": 0
}
# The coefficients, A, B, C and D, of the heat capacity of formation of each
# species (zero for H2(g)).
DfCp = {formula: dict.fromkeys("ABCD", 0) for formula in DfHmo_ref}
for formula, formation_reaction in formation_reactions.items():
for compound, stoich in formation_reaction.species.items():
for c in "ABCD":
DfCp[formula][c] += stoich * compound.Cp_coeffs[c]
The function g evaluates \(g(T)\), calc_DfGmo evaluates the integrated Gibbs–Helmholtz equation, and calc_G_over_RT returns \(G/RT\) for a given extent of reaction.
def g(T, formula):
"""
Return g(T) in kJ.K-1.mol-1 for the species formula: its heat capacity
of formation integrated twice with respect to temperature.
"""
DA, DB, DC, DD = (DfCp[formula][c] for c in "ABCD")
t, tref = T/1000, Tref/1000
dinv = 1/t - 1/tref
return (DA * (np.log(t / tref) + tref * dinv)
+ DB/2 * (t - tref + tref**2 * dinv)
+ DC/3 * ((t**2 - tref**2) / 2 + tref**3 * dinv)
+ DD/4 * ((t**3 - tref**3) / 3 + tref**4 * dinv)
) / 1000
def calc_DfGmo(T, formula):
"""
Return the standard molar Gibbs energy of formation of the species formula
in kJ.mol-1 at temperature T, from the integrated Gibbs-Helmholtz equation.
"""
DfGmo_over_T = (DfGmo_ref[formula] / Tref
+ DfHmo_ref[formula] * (1/T - 1/Tref)
- g(T, formula)
)
return DfGmo_over_T * T
# Start with 1 mol of CO(g) and 1 mol of H2O(g) only.
nin = {"CO(g)": 1, "H2O(g)": 1, "CO2(g)": 0, "H2(g)": 0}
def calc_G_over_RT(xi, T):
"""
Return G/RT in mol at temperature T and extent of reaction xi (the amount
of CO(g) that has reacted, in mol).
"""
nout = {"CO(g)": nin["CO(g)"] - xi,
"H2O(g)": nin["H2O(g)"] - xi,
"CO2(g)": nin["CO2(g)"] + xi,
"H2(g)": nin["H2(g)"] + xi}
ntot = sum(nout.values())
G_over_RT = 0
for formula, n in nout.items():
DfGmo = calc_DfGmo(T, formula)
x = n / ntot
# xlogy(n, y) is n ln(y), taken to be zero for n = 0, so that G is
# defined at xi = 0 and xi = 1.
G_over_RT += n * DfGmo * 1000 / (R * T) + xlogy(n, x * p / pstd)
return G_over_RT
Equilibrium constant
The minimum of \(G\) with respect to \(\xi\), between 0 and 1 mol, is found by scipy.optimize.minimize_scalar, using Brent's method within these bounds. At equilibrium, the mole fractions of \(\mathrm{CO_2}\) and \(\mathrm{H_2}\) are each \(\xi/(2\;\mathrm{mol})\) and those of \(\mathrm{CO}\) and \(\mathrm{H_2O}\) are each \((1\;\mathrm{mol} - \xi)/(2\;\mathrm{mol})\), so the equilibrium constant is
At the minimum, \((\partial G/\partial\xi)_{T,p} = \Delta_\mathrm{r}G_\mathrm{m}^\ominus + RT\ln K = 0\), where \(\Delta_\mathrm{r}G_\mathrm{m}^\ominus = \Delta_\mathrm{f}G_\mathrm{m,CO_2}^\ominus + \Delta_\mathrm{f}G_\mathrm{m,H_2}^\ominus - \Delta_\mathrm{f}G_\mathrm{m,CO}^\ominus - \Delta_\mathrm{f}G_\mathrm{m,H_2O}^\ominus\) is the standard molar Gibbs energy of reaction. The function get_K_from_DrGmo uses this to check the result, by calculating \(K = \exp(-\Delta_\mathrm{r}G_\mathrm{m}^\ominus/RT)\) directly.
def get_xi_eq(T):
"""Return the extent of reaction at equilibrium, in mol, at temperature T."""
res = minimize_scalar(calc_G_over_RT, bounds=(0, 1), args=(T,),
method="bounded", options={"xatol": 1e-9})
return res.x
def get_K(T):
"""Return the equilibrium constant at temperature T from the composition
that minimises G."""
xi = get_xi_eq(T)
# For the initial composition nin, x(CO2) = x(H2) = xi/2 and
# x(CO) = x(H2O) = (1 - xi)/2.
return xi**2 / (1 - xi)**2
def get_K_from_DrGmo(T):
"""Return the equilibrium constant at temperature T as exp(-DrGmo/RT)."""
DrGmo = (calc_DfGmo(T, "CO2(g)") + calc_DfGmo(T, "H2(g)")
- calc_DfGmo(T, "CO(g)") - calc_DfGmo(T, "H2O(g)"))
return np.exp(-DrGmo * 1000 / (R * T))
Comparison with tabulated values
The results are compared with values of \(K\) calculated from the standard molar Gibbs energies of formation in the NIST-JANAF tables, and with the fit
given by C. A. Callaghan in equation 122 of Kinetics and Catalysis of the Water-Gas-Shift Reaction: A Microkinetic and Graph Theoretic Approach (PhD thesis, Worcester Polytechnic Institute, 2006). The fit was derived from the thermodynamic data in the program HSC, and plotted between 300 and 1500 K.
# The standard molar Gibbs energies of formation of CO2(g), CO(g) and H2O(g),
# in kJ.mol-1, from the NIST-JANAF tables.
DfGmo_JANAF = {500: (-394.939, -155.414, -219.051),
1000: (-395.886, -200.275, -192.590),
1500: (-396.288, -243.740, -164.376),
2000: (-396.333, -286.034, -135.528)}
def get_K_JANAF(T):
"""Return the equilibrium constant at temperature T from the NIST-JANAF
tables."""
DfGmo_CO2, DfGmo_CO, DfGmo_H2O = DfGmo_JANAF[T]
DrGmo = DfGmo_CO2 - DfGmo_CO - DfGmo_H2O
return np.exp(-DrGmo * 1000 / (R * T))
def get_K_Callaghan(T):
"""Return the equilibrium constant at temperature T from Callaghan's fit."""
return 10**(-2.4198 + 0.0003855*T + 2180.6/T)
The main part of the program prints the extent of reaction at equilibrium and the four values of \(K\) at each temperature, and plots \(G/RT\) against \(\xi\):
def plot_G_over_RT(T, ax):
"""
Plot G/RT against the extent of reaction at temperature T on the
Matplotlib Axes ax, and mark its minimum.
"""
xi_grid = np.linspace(0, 1, 201)
ax.plot(xi_grid, [calc_G_over_RT(xi, T) for xi in xi_grid])
xi_eq = get_xi_eq(T)
ax.plot(xi_eq, calc_G_over_RT(xi_eq, T), "o")
ax.set_title(f"{T} K")
if __name__ == "__main__":
temperatures = (500, 1000, 1500, 2000)
print(" T/K xi/mol K(min) K(DrG) K(JANAF) K(Callaghan)")
for T in temperatures:
print(f"{T:4d} {get_xi_eq(T):.4f} {get_K(T):8.4g} "
f"{get_K_from_DrGmo(T):8.4g} {get_K_JANAF(T):8.4g} "
f"{get_K_Callaghan(T):12.4g}")
fig, axes = plt.subplots(nrows=2, ncols=2, sharex=True, layout="constrained")
for T, ax in zip(temperatures, axes.flat):
plot_G_over_RT(T, ax)
fig.supxlabel(r"$\xi$ / mol")
fig.supylabel(r"$G/RT$ / mol")
plt.show()
T/K xi/mol K(min) K(DrG) K(JANAF) K(Callaghan)
500 0.9214 137.4 137.4 137.7 136.2
1000 0.5426 1.407 1.407 1.438 1.401
1500 0.3808 0.3783 0.3783 0.3874 0.4094
2000 0.3162 0.2138 0.2138 0.2193 0.2764
The values of \(K\) from the minimum of \(G\) and from \(\Delta_\mathrm{r}G_\mathrm{m}^\ominus\) agree to four significant figures. \(K\) falls from 137 at 500 K to 0.21 at 2000 K because the reaction is exothermic throughout this range (\(\Delta_\mathrm{r}H_\mathrm{m}^\ominus = -41.2\;\mathrm{kJ\,mol^{-1}}\) at 298.15 K and \(-26.3\;\mathrm{kJ\,mol^{-1}}\) at 2000 K), so that, by the van 't Hoff equation, \(\mathrm{d}\ln K/\mathrm{d}T = \Delta_\mathrm{r}H_\mathrm{m}^\ominus/RT^2 < 0\). The rate of reaction, on the other hand, increases with temperature, which is why industrial shift reactors work in two stages: a high-temperature stage, at 350–600 °C over an iron oxide catalyst, then a low-temperature stage, at 150–300 °C over a copper catalyst, where the equilibrium lies further towards the products (Callaghan, section 2.2).