Skip to content
LumenaryAcademy
Quantum 80 min

Statistical thermodynamics

From energy levels to entropies, heat capacities and equilibrium constants — the Boltzmann distribution, partition functions computed for real molecules, and how thermochemical tables are made.

Code tested · 6AI-draftedAwaiting review by a chemist

Your guides: Chloe · The Chemist, Margaret · The Analyst, Gideon · The Sceptic

MotivationH

From energy levels to tables

Look up the standard entropy of carbon monoxide gas in the NIST Chemistry WebBook and you will find 197.660 ± 0.004 J mol⁻¹ K⁻¹, quoted to six figures. Nobody measured that number by warming solid carbon monoxide from near absolute zero, and nobody could: the crystal freezes in with some molecules pointing the wrong way, as Entropy and free energy explained. It was computed, from the mass of the molecule, the spacing of its rotational lines and the wavenumber of its vibration, all measured by the methods of Spectroscopy.

The bridge from those molecular facts to the thermodynamic quantities of Thermochemistry and Chemical equilibrium is statistical thermodynamics. Quantum mechanics tells us which energies a molecule may have; statistics tells us how a mole of molecules shares out its energy among those levels; and from that sharing follow the entropy, the heat capacity, the Gibbs energy and the equilibrium constant. This lesson builds the bridge and walks across it with real molecules, checking every number against the tables.

IntuitionH

The Boltzmann distribution

Take one molecule in a gas at temperature TT. It collides constantly with the others, which act as a huge reservoir of energy, and it hops from one quantum state to another. Which states does it spend its time in? Low-energy states are favoured, but not exclusively: the reservoir can lend energy, and a state's chance falls off exponentially with the energy it costs.

Definition— Boltzmann distribution

In thermal equilibrium at temperature TT, the probability that a molecule is in a particular state ii of energy εi\varepsilon_i is proportional to e−εi/kBTe^{-\varepsilon_i/k_\mathrm{B}T}. For an energy level with gig_i states of the same energy (its degeneracy),

pi=gi e−εi/kBTq,q=∑jgj e−εj/kBT.p_i = \frac{g_i\, e^{-\varepsilon_i/k_\mathrm{B}T}}{q}, \qquad q = \sum_j g_j\, e^{-\varepsilon_j/k_\mathrm{B}T}.

The yardstick is kBTk_\mathrm{B}T. Levels much less than kBTk_\mathrm{B}T above the lowest are almost as populated as it; levels many times kBTk_\mathrm{B}T above are almost empty. Chemists keep kBTk_\mathrm{B}T in several units at once, and the program below starts by printing them.

0ε2ε3ε4ε5ε0ε2ε3ε4ε5ε86%12%1.6%0.2%39%24%14%8.8%5.3%3.2%cold: kT = ε/2hot: kT = 2ε
The Boltzmann distribution over six equally spaced levels (spacing ε), at two temperatures. When kT is half the spacing, 86% of molecules sit in the lowest level. When kT is twice the spacing, the populations fall off gently and every level shown is occupied. In both cases each level holds fewer molecules than the one below it.

Two real cases show the range. Rotational levels of a small molecule are spaced by a few cm⁻¹, far below kBTk_\mathrm{B}T, so dozens of them are occupied at room temperature; their degeneracy 2J+12J + 1 grows while the exponential falls, so the most populated level is not the lowest. Vibrational quanta are usually hundreds or thousands of cm⁻¹, so most molecules sit in v=0v = 0. The program computes both.

python
import numpy as np

h, c, kB, NA = 6.62607015e-34, 2.99792458e10, 1.380649e-23, 6.02214076e23   # c in cm/s
T = 298.15
print(f"kT at {T} K = {kB * T * NA / 1e3:.3f} kJ/mol = {kB * T / (h * c):.1f} cm^-1 = {kB * T / 1.602176634e-19 * 1e3:.1f} meV\n")

# Rotational levels of CO: E_J = hcB J(J+1), degeneracy 2J + 1
B = 1.9225                                   # cm^-1
J = np.arange(0, 60)
weights = (2 * J + 1) * np.exp(-h * c * B * J * (J + 1) / (kB * T))
p = weights / weights.sum()                  # the Boltzmann distribution
print("CO at 25 C: fraction of molecules in each rotational level")
for j in range(0, 25, 2):
    print(f"  J = {j:2d}  {p[j]:.4f}  " + "#" * int(round(400 * p[j])))
print(f"most populated level: J = {np.argmax(p)};  levels holding 99% of molecules: J = 0 to {np.searchsorted(np.cumsum(p), 0.99)}")

# Vibrations: for a harmonic oscillator the fraction NOT in v = 0 is 1 - (1 - e^-x) = e^-x, x = hc nu / kT
print("\nfraction of molecules vibrationally excited (v >= 1)")
print("molecule   wavenumber/cm^-1     298 K       1000 K")
for name, nu in [("H2", 4161), ("N2", 2330), ("CO", 2143), ("Cl2", 554), ("I2", 213)]:
    f = [np.exp(-h * c * nu / (kB * TT)) for TT in (298.15, 1000)]
    print(f"{name:8s} {nu:12d} {f[0]:14.2e} {f[1]:11.3f}")
Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.
DefinitionsH

The partition function

Why the exponential? It follows from the one assumption behind Entropy and free energy: an isolated system is equally likely to be in any of its microstates.

Theorem— The Boltzmann distribution

A system in thermal contact with a much larger reservoir at temperature TT is found in a particular state ii of energy εi\varepsilon_i with probability pi=e−εi/kBT/qp_i = e^{-\varepsilon_i/k_\mathrm{B}T}/q, where q=∑je−εj/kBTq = \sum_j e^{-\varepsilon_j/k_\mathrm{B}T} is summed over states.

Proof

Let the system and reservoir together be isolated, with total energy EE. When the system is in state ii, the reservoir has energy E−εiE - \varepsilon_i and can be in any of WR(E−εi)W_\mathrm{R}(E - \varepsilon_i) microstates. All microstates of the whole are equally likely, so pi∝WR(E−εi)=exp⁡[SR(E−εi)/kB]p_i \propto W_\mathrm{R}(E - \varepsilon_i) = \exp[S_\mathrm{R}(E - \varepsilon_i)/k_\mathrm{B}], using S=kBln⁡WS = k_\mathrm{B}\ln W. Because εi≪E\varepsilon_i \ll E, expand to first order: SR(E−εi)≈SR(E)−εi ∂SR/∂E=SR(E)−εi/TS_\mathrm{R}(E - \varepsilon_i) \approx S_\mathrm{R}(E) - \varepsilon_i\, \partial S_\mathrm{R}/\partial E = S_\mathrm{R}(E) - \varepsilon_i/T, by the statistical definition of temperature, 1/T=∂S/∂E1/T = \partial S/\partial E. Hence pi∝e−εi/kBTp_i \propto e^{-\varepsilon_i/k_\mathrm{B}T}, and requiring ∑ipi=1\sum_i p_i = 1 fixes the constant as 1/q1/q. The neglected second-order term is proportional to εi2/CR\varepsilon_i^2/C_\mathrm{R}, where CRC_\mathrm{R} is the reservoir's heat capacity, and vanishes for a large reservoir.

∎

Definition— molecular partition function

The molecular partition function is q=∑levelsgie−εi/kBTq = \sum_\text{levels} g_i e^{-\varepsilon_i/k_\mathrm{B}T}, with energies measured from the molecule's lowest state. It is a pure number, roughly the number of states thermally accessible to the molecule: close to 1 at very low temperature (only the ground state), and growing without limit as TT rises.

The partition function holds all the thermodynamics. For NN molecules of an ideal gas, which are independent and indistinguishable, the total partition function is Q=qN/N!Q = q^N/N!, and differentiating gives (per mole, with U(0)U(0) the energy when every molecule is in its lowest state):

U−U(0)=RT2(∂ln⁡q∂T)V,CV=(∂U∂T)V,S=U−U(0)T+R(ln⁡qNA+1),U - U(0) = RT^2\left(\frac{\partial \ln q}{\partial T}\right)_V, \qquad C_V = \left(\frac{\partial U}{\partial T}\right)_V, \qquad S = \frac{U - U(0)}{T} + R\left(\ln\frac{q}{N_\mathrm A} + 1\right),H−H(0)=U−U(0)+RT,G−G(0)=−RTln⁡qNA.H - H(0) = U - U(0) + RT, \qquad G - G(0) = -RT\ln\frac{q}{N_\mathrm A}.

The "+1" and the NAN_\mathrm A come from the N!N!, that is, from the indistinguishability of identical molecules. A useful equivalent, which the programs below use, is to write the average energy and its fluctuations directly: U−U(0)=NA⟨ε⟩U - U(0) = N_\mathrm A\langle\varepsilon\rangle and CV=NA(⟨ε2⟩−⟨ε⟩2)/kBT2C_V = N_\mathrm A(\langle\varepsilon^2\rangle - \langle\varepsilon\rangle^2)/k_\mathrm{B}T^2. A large heat capacity means large energy fluctuations. Mathematically, qq as a function of β=1/kBT\beta = 1/k_\mathrm{B}T is a generating function: −∂ln⁡q/∂β-\partial\ln q/\partial\beta is the mean energy and the second derivative its variance, as with a moment-generating function in probability theory; and β\beta is the Lagrange multiplier that appears when ln⁡W\ln W is maximised at fixed total energy (optimisation).

If a molecule's energy is a sum of independent parts, ε=εtrans+εrot+εvib+εel\varepsilon = \varepsilon_\text{trans} + \varepsilon_\text{rot} + \varepsilon_\text{vib} + \varepsilon_\text{el}, the exponential of a sum is a product and the partition function factorises: q=qtrans qrot qvib qelq = q_\text{trans}\,q_\text{rot}\,q_\text{vib}\,q_\text{el}. Then ln⁡q\ln q, and every thermodynamic function, is a sum of contributions, one per kind of motion.

Worked examplesH

Translation, rotation, vibration and electrons

Each factor comes from a quantum model of Quantum mechanics for chemists or Spectroscopy, summed over its levels.

Translation. A molecule of mass mm in a container of volume VV is a particle in a three-dimensional box. Its levels are so close together that the sum becomes an integral:

qtrans=VΛ3,Λ=h2πmkBT.q_\text{trans} = \frac{V}{\Lambda^3}, \qquad \Lambda = \frac{h}{\sqrt{2\pi m k_\mathrm{B} T}}.

The thermal wavelength Λ\Lambda is about the de Broglie wavelength of a molecule at temperature TT: 19 pm for CO at room temperature. qtransq_\text{trans} counts how many boxes of size Λ3\Lambda^3 fit in VV: an astronomically large number, which is why translation dominates the entropy of a gas.

Rotation. A linear molecule has levels hcBJ(J+1)hcBJ(J+1) with degeneracy 2J+12J + 1, where BB is the rotational constant in cm⁻¹. When TT is much larger than the rotational temperature Θrot=hcB/kB\Theta_\text{rot} = hcB/k_\mathrm{B}, the sum is close to an integral:

qrot≈Tσ Θrot=kBTσhcB.q_\text{rot} \approx \frac{T}{\sigma\,\Theta_\text{rot}} = \frac{k_\mathrm{B}T}{\sigma hcB}.

The symmetry number σ\sigma is 1 for an unsymmetrical linear molecule (CO, HCl) and 2 for a symmetrical one (N₂, CO₂, I₂). A non-linear molecule has three rotational constants and qrot=(π/σ) (kBT/hc)3/2/ABCq_\text{rot} = (\sqrt{\pi}/\sigma)\,(k_\mathrm{B}T/hc)^{3/2}/\sqrt{ABC}, with σ=2\sigma = 2 for water and 12 for methane.

Vibration. Each normal mode is, to a good approximation, a harmonic oscillator with levels hcν~ vhc\tilde\nu\,v above its zero-point level. The sum is a geometric series:

qvib=11−e−Θvib/T,Θvib=hcν~kB.q_\text{vib} = \frac{1}{1 - e^{-\Theta_\text{vib}/T}}, \qquad \Theta_\text{vib} = \frac{hc\tilde\nu}{k_\mathrm{B}}.

A non-linear molecule of nn atoms has 3n−63n - 6 modes and multiplies their factors; a linear one has 3n−53n - 5.

Electrons. Excited electronic states usually lie so high that qelq_\text{el} is just the degeneracy of the ground state: 1 for most closed-shell molecules, 3 for O₂ (a triplet), and 4 for an iodine atom, whose ground state ²P₃/₂ has four states.

ComputationC

Carbon monoxide from its spectrum

Now the real calculation. Carbon monoxide's spectroscopic constants, from the NIST WebBook, are a rotational constant B0=1.9225B_0 = 1.9225 cm⁻¹ and a fundamental vibrational wavenumber of 2143.27 cm⁻¹; its molar mass is 28.010 g/mol. Translation uses the formula, at the standard pressure of 1 bar; rotation and vibration are summed level by level with a single function that returns qq, UU, CVC_V and SS from any list of levels.

python
import numpy as np

h, c, kB, NA = 6.62607015e-34, 2.99792458e10, 1.380649e-23, 6.02214076e23   # SI; c in cm/s
R, p0 = kB * NA, 1e5                                                          # J/(mol K), Pa

def from_levels(energies_K, degeneracies, T):
    """q, and U, Cv, S per mole divided by R, from a list of levels (energies in kelvin, E/k)."""
    e, g = np.asarray(energies_K, float), np.asarray(degeneracies, float)
    w = g * np.exp(-e / T)                 # Boltzmann weights
    q = w.sum()
    mean = (w * e).sum() / q               # <E>/k
    mean2 = (w * e**2).sum() / q
    return q, mean / T, (mean2 - mean**2) / T**2, np.log(q) + mean / T   # q, U/RT, Cv/R, S/R

# Carbon monoxide, from spectroscopy (NIST Chemistry WebBook)
M = 28.010e-3           # kg/mol (natural isotopic mixture)
B = 1.9225              # rotational constant of the v = 0 level, cm^-1
nu = 2143.27            # wavenumber of the fundamental vibration, cm^-1
T = 298.15
theta_rot, theta_vib = h * c * B / kB, h * c * nu / kB

# Translation: particle in a box of the molar volume at 1 bar (Sackur-Tetrode)
Lam = h / np.sqrt(2 * np.pi * (M / NA) * kB * T)
q_tr = (R * T / p0) / Lam**3
S_tr, Cp_tr, H_tr = R * (np.log(q_tr / NA) + 2.5), 2.5 * R, 2.5 * R * T

# Rotation: sum over J levels, energy J(J+1) theta_rot, degeneracy 2J+1 (symmetry number 1)
J = np.arange(0, 300)
q_rot, U_rot, Cv_rot, S_rot = from_levels(J * (J + 1) * theta_rot, 2 * J + 1, T)
# Vibration: harmonic levels v * theta_vib, measured from the zero-point level
v = np.arange(0, 40)
q_vib, U_vib, Cv_vib, S_vib = from_levels(v * theta_vib, np.ones_like(v), T)

print(f"theta_rot = {theta_rot:.3f} K   theta_vib = {theta_vib:.0f} K   thermal wavelength = {Lam * 1e12:.2f} pm")
print(f"q_trans = {q_tr:.3e} (in 1 molar volume)   q_rot = {q_rot:.2f} (high-T formula T/theta: {T / theta_rot:.2f})"
      f"   q_vib = {q_vib:.6f}")
print(f"\n            translation   rotation   vibration     total     tables")
S = [S_tr, R * S_rot, R * S_vib]
Cp = [Cp_tr, R * Cv_rot, R * Cv_vib]
H = [H_tr / 1e3, R * T * U_rot / 1e3, R * T * U_vib / 1e3]
print(f"S°  J/(mol K) {S[0]:10.2f} {S[1]:10.2f} {S[2]:11.4f} {sum(S):9.2f}    197.66")
print(f"Cp° J/(mol K) {Cp[0]:10.2f} {Cp[1]:10.2f} {Cp[2]:11.4f} {sum(Cp):9.2f}     29.14")
print(f"H-H(0) kJ/mol {H[0]:10.3f} {H[1]:10.3f} {H[2]:11.5f} {sum(H):9.3f}     8.671")
print(f"(with the high-temperature formula q_rot = T/theta_rot instead of the sum: H - H(0) = "
      f"{(3.5 * R * T + R * T * U_vib) / 1e3:.3f} kJ/mol)")
Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.

Three molecular numbers and the Planck, Boltzmann and Avogadro constants reproduce the table to within 0.01 J mol⁻¹ K⁻¹ for the entropy and 0.001 kJ/mol for the enthalpy. The breakdown is instructive. Translation provides three-quarters of the entropy, 150.42 J mol⁻¹ K⁻¹; rotation provides 47.23, because about a hundred rotational states are accessible; vibration provides 0.003, because CO hardly vibrates at room temperature. The explicit sum over rotational levels gives qrot=108.12q_\text{rot} = 108.12, slightly more than the high-temperature formula's 107.79. That small difference, 13\tfrac13 to a very good approximation, is what brings H−H(0)H - H(0) to 8.670 kJ/mol instead of 8.677.

This is how standard entropies of gases are known so precisely. When the calorimetric third-law entropy of CO came out about 4.6 J mol⁻¹ K⁻¹ below this statistical value, the difference was not an error in either: it is the residual entropy of the disordered crystal, close to Rln⁡2R\ln 2.

ComputationC

Equilibrium constants from molecular properties

Because G−G(0)=−RTln⁡(q/NA)G - G(0) = -RT\ln(q/N_\mathrm A) for each gas, and ΔrG∘=−RTln⁡K\Delta_\mathrm{r}G^\circ = -RT\ln K, an equilibrium constant can be written entirely in terms of partition functions:

K=∏J(qJ∘NA)νJe−ΔrE0/RT,K = \prod_J \left(\frac{q^\circ_{J}}{N_\mathrm A}\right)^{\nu_J} e^{-\Delta_\mathrm{r}E_0/RT},

where qJ∘q^\circ_J is the partition function of species JJ in the molar volume at the standard pressure, νJ\nu_J its stoichiometric number (positive for products), and ΔrE0\Delta_\mathrm{r}E_0 the difference between the lowest energies of products and reactants, per mole. The two factors pull in opposite directions: ΔrE0\Delta_\mathrm{r}E_0 is an energy, and the product of partition functions counts how many states each side can spread over.

Take the dissociation of iodine vapour, I₂(g) ⇌ 2 I(g). The energy is the dissociation energy measured from the molecule's lowest vibrational level, D0=12 440D_0 = 12\,440 cm⁻¹ (148.8 kJ/mol); the molecule's constants are B0=0.03731B_0 = 0.03731 cm⁻¹, ν~=214.5\tilde\nu = 214.5 cm⁻¹ and σ=2\sigma = 2; the atoms have only translation and their electronic degeneracy of 4. The program compares the result with the equilibrium constant calculated from tabulated enthalpies of formation and entropies.

python
import numpy as np

h, c, kB, NA = 6.62607015e-34, 2.99792458e10, 1.380649e-23, 6.02214076e23   # c in cm/s
R, p0 = kB * NA, 1e5
cm_to_K = h * c / kB                     # 1 cm^-1 corresponds to 1.4388 K

def ln_q_std(M, T, B=None, sigma=1, nus=(), g_el=1):
    """ln(q°/N_A) for an ideal gas at 1 bar: translation, rigid linear rotor (B, sigma),
    harmonic vibrations (wavenumbers nus, from the zero-point level) and electronic degeneracy."""
    Lam = h / np.sqrt(2 * np.pi * (M * 1e-3 / NA) * kB * T)
    lnq = np.log(kB * T / p0 / Lam**3) + np.log(g_el)
    if B is not None:
        lnq += np.log(T / (sigma * B * cm_to_K))
    for nu in nus:
        lnq -= np.log(1 - np.exp(-nu * cm_to_K / T))
    return lnq

D0 = 12440.0     # cm^-1: energy to split I2 from its lowest level into two ground-state atoms (148.8 kJ/mol)

def K_iodine(T):
    """K° for I2(g) <=> 2 I(g) from molecular data alone."""
    ln_I = ln_q_std(126.904, T, g_el=4)                         # I atom: 2P3/2 ground state, 4 states
    ln_I2 = ln_q_std(253.809, T, B=0.03731, sigma=2, nus=[214.5])
    return np.exp(2 * ln_I - ln_I2 - D0 * cm_to_K / T)

# The same K from thermochemical tables (CODATA values on the NIST WebBook) at 298.15 K
dH = 2 * 106.76 - 62.42             # kJ/mol: 2 x DfH°(I, g) - DfH°(I2, g)
dS = 2 * 180.787 - 260.687          # J/(mol K): 2 x S°(I, g) - S°(I2, g)
K_tables = np.exp(-(dH * 1e3 - 298.15 * dS) / (R * 298.15))
print(f"298.15 K: K from molecular data = {K_iodine(298.15):.3e}   from tables = {K_tables:.3e}")
print(f"1000 K:   K from molecular data = {K_iodine(1000):.3e}   from NIST-JANAF tables = 3.08e-03\n")

# Where does K pass 1 (Delta G° = 0)? Bisection on ln K.
lo, hi = 800.0, 2000.0
for _ in range(60):
    mid = (lo + hi) / 2
    lo, hi = (mid, hi) if K_iodine(mid) < 1 else (lo, mid)
print(f"K = 1 at T = {lo:.0f} K")

# ln K splits into a "number of states" term and an energy term
for T in (298.15, 1000.0, 1446.0):
    states = 2 * ln_q_std(126.904, T, g_el=4) - ln_q_std(253.809, T, B=0.03731, sigma=2, nus=[214.5])
    energy = D0 * cm_to_K / T
    print(f"{T:7.2f} K: ln K = {states:6.2f} (states) - {energy:6.2f} (bond energy) = {states - energy:7.2f}")
Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.

Molecular data alone give K=6.35×10−22K = 6.35 \times 10^{-22} at 298.15 K; the thermochemical tables give 6.28×10−226.28 \times 10^{-22}, a difference of 1% in a number twenty-one orders of magnitude below one. At 1000 K the two agree within 4%, and most of the gap comes from treating the soft I₂ vibration as harmonic. The last lines show the competition. Two free atoms have far more states available than one molecule, worth about 12 in ln⁡K\ln K at every temperature; the bond costs D0/kBTD_0/k_\mathrm{B}T, which is 60 at room temperature but falls as 1/T1/T. The two balance at about 1450 K, above which iodine vapour is mostly atoms at standard pressure. Every dissociation shares this pattern: high temperature favours the side with more particles, because entropy is weighted by TT in ΔG=ΔH−TΔS\Delta G = \Delta H - T\Delta S.

ComputationC

Heat capacities

Classical physics has a simple rule, equipartition: every quadratic term in a molecule's energy contributes 12R\tfrac12 R to the molar heat capacity CVC_V. Translation has three (32R\tfrac32 R), a linear rotor two (RR), and each vibration two, kinetic and potential (RR). So a diatomic gas should have CV=72RC_V = \tfrac72 R, and Cp=CV+R=92RC_p = C_V + R = \tfrac92 R, at every temperature. At room temperature it does not: CO has Cp=3.5RC_p = 3.5R. Explaining this was one of the first triumphs of quantum theory.

The rule holds only for motions whose level spacing is much smaller than kBTk_\mathrm{B}T. A motion with widely spaced levels is frozen: almost every molecule is in its ground level, and adding a little heat cannot excite it. For one harmonic vibration the heat capacity is Einstein's function, from his 1907 paper on solids,

CV,vibR=x2ex(ex−1)2,x=ΘvibT,\frac{C_{V,\text{vib}}}{R} = \frac{x^2 e^{x}}{(e^{x} - 1)^2}, \qquad x = \frac{\Theta_\text{vib}}{T},

which is 0 at low temperature and rises to 1, the classical value, when T≫ΘvibT \gg \Theta_\text{vib}.

3/25/27/2110100100010 000T / K (logarithmic)Cv/RΘrotΘvibtranslation+ rotation+ vibration
Heat capacity of an idealised diatomic gas, calculated for a rotational temperature of 10 K and a vibrational temperature of 3000 K, on a logarithmic temperature axis. Each kind of motion switches on near its characteristic temperature, raising Cv/R from 3/2 (translation) to 5/2 (with rotation) and towards 7/2 (with vibration). The small overshoot as rotation switches on is real for a heteronuclear molecule. A real gas would condense before the lowest temperatures shown.

For carbon monoxide, with Θvib\Theta_\text{vib} = 3084 K, the program follows CpC_p from 100 K to 5000 K and compares it with the NIST-JANAF tables.

python
import numpy as np

h, c, kB, R = 6.62607015e-34, 2.99792458e10, 1.380649e-23, 8.314462618
theta_vib = h * c * 2143.27 / kB          # CO, in K

def einstein(T, theta):
    """Heat capacity of one harmonic vibration, in units of R."""
    x = theta / T
    return x**2 * np.exp(x) / np.expm1(x)**2

def cp_over_R(T):
    return 2.5 + 1.0 + einstein(T, theta_vib)   # translation (with pV), rotation, vibration

nist = {298.15: 29.14, 500: 29.82, 1000: 33.18, 2000: 36.22}   # NIST-JANAF (Shomate fits), J/(mol K)
print("   T/K     Cp/R   Cp J/(mol K)  NIST-JANAF   vibrational part")
for T in [100, 298.15, 500, 750, 1000, 1500, 2000, 3000, 5000]:
    cp = cp_over_R(T)
    ref = f"{nist[T]:8.2f}" if T in nist else " " * 8
    print(f"{T:8.2f}  {cp:6.3f}  {cp * R:9.2f}    {ref}     " + "#" * int(round(20 * (cp - 3.5))))

lo, hi = 100.0, 5000.0                    # where is the vibration "half switched on"?
for _ in range(60):
    mid = (lo + hi) / 2
    lo, hi = (mid, hi) if einstein(mid, theta_vib) < 0.5 else (lo, mid)
print(f"\nC(vib) reaches R/2 at {lo:.0f} K = theta_vib / {theta_vib / lo:.2f}")
Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.

The rigid-rotor, harmonic-oscillator model stays within 1% of the tables up to 2000 K. The vibration is half switched on near 1030 K, about a third of Θvib\Theta_\text{vib}, and the heat capacity approaches the classical 92R\tfrac92 R only above several thousand kelvin. The remaining differences at high temperature come from anharmonicity and from the stretching of the rotating molecule, which the model leaves out. The same Einstein function, applied to the vibrations of atoms in a crystal, explains why the heat capacities of solids fall towards zero at low temperature.

Further reading

Statistical thermodynamics at work

Statistical thermodynamics runs quietly underneath much of chemistry and engineering:

  • Thermochemical tables. The NIST-JANAF tables and similar compilations used to design combustion engines, rockets and chemical reactors give CpC_p, SS and GG for gases up to 6000 K. Above a few hundred kelvin almost all of those numbers are computed from spectroscopic constants, with corrections for anharmonicity, rotation–vibration coupling and excited electronic states, exactly as in this lesson but with more terms.
  • Quantum chemistry output. Every frequency calculation in a program such as those of Computational chemistry ends with a table of translational, rotational, vibrational and electronic contributions to HH, SS and GG, computed with the rigid-rotor, harmonic-oscillator model. Chemists then correct the low-frequency modes, which the harmonic model treats worst (they are often hindered internal rotations), because those modes carry most of the error in computed entropies. The CCCBDB at NIST compares such calculations with experiment for hundreds of molecules.
  • Rates. Eyring's transition-state theory, met in Chemical kinetics, is this lesson's equilibrium formula applied to an equilibrium between reactants and the transition state: k=(kBT/h)K‡k = (k_\mathrm{B}T/h)K^\ddagger, with K‡K^\ddagger built from partition functions. Kinetic isotope effects follow from the change in vibrational partition functions when hydrogen is replaced by deuterium (Reaction mechanisms).
  • Liquids and proteins. When molecules interact strongly the partition function cannot be factorised, and it is sampled instead: Metropolis Monte Carlo (1953) and molecular dynamics generate configurations with Boltzmann probabilities, and free-energy methods compute differences in ln⁡Q\ln Q, for example between a drug bound to a protein and free in water (see atomistic simulation in Lumenary Materials).
Common misconceptionsH

Common misconceptions

Misconception

"At equilibrium every molecule has the average energy." The Boltzmann distribution is a distribution. At room temperature some CO molecules are in J=0J = 0 and some in J=20J = 20; a few in a hundred thousand are vibrationally excited. Chemical reactions often depend on the rare, energetic tail.

Misconception

"The highest level is always the least populated, so the lowest level is always the most populated." Each state is less likely the higher its energy, but a level with many states can hold more molecules than a level below it. CO's most populated rotational level at 25 °C is J=7J = 7, not J=0J = 0.

Misconception

"Equipartition gives the heat capacity of any gas." Only for motions whose level spacing is small compared with kBTk_\mathrm{B}T. Vibrations of light, stiffly bonded molecules are frozen at room temperature, and so are rotations of hydrogen at low temperature.

Misconception

"The partition function is just the normalising constant of the Boltzmann distribution." It is that, and also everything else: its logarithm and derivatives give UU, SS, HH, GG, CVC_V and KK. Normalising constants rarely know so much.

Exercises

Exercises

1. Statistical thermodynamics

Warm-upHuman

At 25 °C, kBTk_\mathrm{B}T corresponds to about 207 cm⁻¹. Nitrogen, N₂, has a rotational constant of 2.0 cm⁻¹ and a vibrational wavenumber of 2330 cm⁻¹. Which of its motions is essentially frozen (almost every molecule in the lowest level) at 25 °C?

Choose one

2. Statistical thermodynamics

CoreComputational

Hydrogen chloride has rotational constant B=10.44B = 10.44 cm⁻¹. Which rotational level JJ is the most populated at 298.15 K? (Level JJ has energy hcBJ(J+1)hcBJ(J+1) and degeneracy 2J+12J + 1; kBT/hck_\mathrm{B}T/hc = 207.2 cm⁻¹.)

3. Statistical thermodynamics

CoreHuman

N₂ and CO have the same molar mass (28 g/mol), almost the same rotational constant (about 2 cm⁻¹) and vibrations too stiff to matter at 298 K. Their tabulated standard entropies at 298.15 K are 191.61 and 197.66 J mol⁻¹ K⁻¹. Why is CO's larger?

Choose one

4. Statistical thermodynamics

CoreHuman

For I₂(g) ⇌ 2 I(g), the lesson split ln⁡K\ln K into a "states" term of about +12 and an energy term −D0/kBT-D_0/k_\mathrm{B}T. Which statement explains why dissociation wins at high temperature?

Choose one

5. Statistical thermodynamics

StretchHuman

By the classical equipartition theorem, what would the molar heat capacity CV/RC_V/R of water vapour be, if every motion behaved classically? (Water is a non-linear molecule of three atoms.)

6. Statistical thermodynamics

CoreComputational

Compute the standard molar entropy of water vapour at 298.15 K from molecular data, as the lesson did for CO, and compare it with the CODATA value, 188.835 J mol⁻¹ K⁻¹. The translational part is written for you. Water is a non-linear (asymmetric-top) rotor, with

qrot=πσ(kBThc)3/21ABC,Srot=R(ln⁡qrot+32),q_\text{rot} = \frac{\sqrt{\pi}}{\sigma}\left(\frac{k_\mathrm{B}T}{hc}\right)^{3/2}\frac{1}{\sqrt{ABC}}, \qquad S_\text{rot} = R\left(\ln q_\text{rot} + \tfrac32\right),

and three vibrations, each contributing Svib=R [x/(ex−1)−ln⁡(1−e−x)]S_\text{vib} = R\,[x/(e^x - 1) - \ln(1 - e^{-x})] with x=hcν~/kBTx = hc\tilde\nu/k_\mathrm{B}T. Complete water_entropy(T).

Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.

7. Statistical thermodynamics

StretchComputational

In a mixture of H₂ and D₂ with a catalyst, the isotopes scramble: H₂ + D₂ ⇌ 2 HD. If the atoms paired up at random, KK would be 4. Compute KK from molecular properties. All three molecules share one potential energy curve, so their constants follow from H₂'s and the masses: the reduced mass μ\mu fixes ω=ωH2μH2/μ\omega = \omega_{\mathrm{H_2}}\sqrt{\mu_{\mathrm{H_2}}/\mu}, ωx=(ωx)H2 μH2/μ\omega x = (\omega x)_{\mathrm{H_2}}\,\mu_{\mathrm{H_2}}/\mu, the zero-point energy ω/2−ωx/4\omega/2 - \omega x/4, and the rotational constant ∝1/μ\propto 1/\mu. Because two molecules appear on each side, every constant factor cancels, and each species needs only

ln⁡q=32ln⁡M+ln⁡(μ/σ)−ZPE⋅hc/kBT,\ln q = \tfrac32\ln M + \ln(\mu/\sigma) - \text{ZPE}\cdot hc/k_\mathrm{B}T,

with MM and μ\mu in u and σ\sigma = 2 for H₂ and D₂, 1 for HD. Ignore vibrational excitation above v=0v = 0. Complete k_exchange(T).

Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.

Further reading and resources