Skip to content
scipython.com

The heat capacity of a diatomic gas

Posted on

The molar heat capacity of a diatomic gas rises with temperature from 7R/2 towards 9R/2 as its vibrational levels become thermally populated, and beyond 9R/2 because the vibration is anharmonic and interacts with the rotation. This post fits the heat capacities of N₂ and CO from the NIST-JANAF Thermochemical Tables to models of increasing completeness, and shows that the fitted anharmonicity constants agree with the spectroscopic values only when the rotation–vibration interaction is included.

The molar constant-pressure heat capacity, \(C_{p,\mathrm{m}}\), of a diatomic gas rises from about \(\frac{7}{2}R\) near room temperature towards \(\frac{9}{2}R\), and beyond, as the temperature increases. The figure below shows \(C_{p,\mathrm{m}}\) for \(\mathrm{N_2}\), \(\mathrm{CO}\), \(\mathrm{HCl}\) and \(\mathrm{NO^+}\) between 100 and 6000 K, from the NIST-JANAF Thermochemical Tables, which were also the source of the heat capacities in the post on the water–gas shift equilibrium. These values were not measured: they were calculated by statistical mechanics from the energy levels of each molecule, known from spectroscopy. Fitting models to them therefore recovers, at best, the spectroscopic constants from which they were calculated, which makes them a good test of the models.

A graph of molar heat capacity against temperature from 0 to 6000 K for CO, N₂, NO⁺ and HCl. All four curves start at 29.1 J K⁻¹ mol⁻¹, on a horizontal line marked 7/2 R, rise steeply between about 400 and 2000 K, and continue to rise slowly past a second line, marked 9/2 R, at 37.4 J K⁻¹ mol⁻¹. CO rises first, N₂ and NO⁺ almost coincide, and HCl rises last but is the highest of the four above 3000 K, reaching 39.3 J K⁻¹ mol⁻¹ at 6000 K.
The molar constant-pressure heat capacities of four diatomic gases, from the NIST-JANAF Thermochemical Tables, with the classical values \(\frac{7}{2}R\) (translation and rotation) and \(\frac{9}{2}R\) (translation, rotation and vibration).

The order in which the curves rise follows the vibrational wavenumbers of the molecules (\(\omega_\mathrm{e}\), defined below): \(\mathrm{CO}\) (\(2170\;\mathrm{cm^{-1}}\)) first, then \(\mathrm{N_2}\) (\(2359\;\mathrm{cm^{-1}}\)) and \(\mathrm{NO^+}\) (\(2376\;\mathrm{cm^{-1}}\)), whose wavenumbers are so similar that their curves almost coincide, and \(\mathrm{HCl}\) (\(2991\;\mathrm{cm^{-1}}\)) last. Above about 3000 K, however, the heat capacity of \(\mathrm{HCl}\) is the largest of the four, because its anharmonicity and its rotation–vibration interaction, the subjects of the later sections of this post, are about three times those of the other molecules, relative to its vibrational wavenumber and rotational constant.

Equipartition

Near room temperature, the translational and rotational contributions to the heat capacity can be described classically, because the translational and rotational levels are spaced much more closely than \(k_\mathrm{B}T\). A diatomic molecule has three translational degrees of freedom and, being linear, two rotational degrees of freedom. Rotation about the internuclear axis does not contribute: the moment of inertia about this axis is so small (the nuclei lie on it, and the electrons are light) that the corresponding levels are spaced far more widely than \(k_\mathrm{B}T\) (they are, in effect, electronic excitations). By the equipartition theorem, each quadratic term in the energy contributes \(\frac{1}{2}R\) to the molar heat capacity at constant volume, and each translational and rotational degree of freedom has one such term, its kinetic energy. At constant pressure, a perfect gas also does work as it expands, and \(C_{p,\mathrm{m}} = C_{V,\mathrm{m}} + R\), so that

\[C_{p,\mathrm{m}} = \tfrac{3}{2}R + \tfrac{2}{2}R + R = \tfrac{7}{2}R = 29.1\;\mathrm{J\,K^{-1}\,mol^{-1}}.\]

The vibration is a single degree of freedom with two quadratic terms, its kinetic and potential energy, and so contributes \(R\) in the classical limit, for a total of \(\frac{9}{2}R = 37.4\;\mathrm{J\,K^{-1}\,mol^{-1}}\). For strongly bound molecules with high vibrational wavenumbers, however, \(hc\tilde{\nu} \gg k_\mathrm{B}T\) at room temperature, almost all the molecules are in their ground vibrational state (\(v = 0\)), and the vibration contributes almost nothing to the heat capacity. As \(T\) increases, the excited vibrational levels become populated and the heat capacity rises towards \(\frac{9}{2}R\).

Some molecules depart from this pattern for other reasons: unusually widely spaced rotational levels (\(\mathrm{H_2}\)), an open-shell ground state with low-lying electronic states (\(\mathrm{O_2}\), \(\mathrm{NO}\)), or a low dissociation energy (\(\mathrm{I_2}\)). The continued rise above \(\frac{9}{2}R\) in the figure, on the other hand, is common to all four molecules: it is due to the anharmonicity of the vibration and its interaction with the rotation.

Harmonic oscillator model

For a molecule such as \(\mathrm{N_2}\), which has a closed-shell ground state and no excited electronic state within about \(50\,000\;\mathrm{cm^{-1}}\) of it, it should be possible to estimate the vibrational wavenumber, \(\tilde{\nu}\), by fitting a model derived from statistical mechanics to the heat capacity. Within the harmonic approximation, the vibrational energy levels, measured relative to the ground state, are \(E_v = hc\tilde{\nu}v = k_\mathrm{B}\theta_\mathrm{vib}v\) for \(v = 0, 1, 2, \ldots\), where \(\theta_\mathrm{vib} = hc\tilde{\nu}/k_\mathrm{B} = c_2\tilde{\nu}\) is the vibrational temperature and \(c_2 = hc/k_\mathrm{B} = 1.4388\;\mathrm{cm\,K}\) is the second radiation constant. The vibrational partition function is a geometric series,

\[q_\mathrm{vib} = \sum_{v=0}^\infty \exp\left(-\frac{\theta_\mathrm{vib}}{T}v\right) = \frac{1}{1 - \exp(-\theta_\mathrm{vib}/T)},\]

and the molar vibrational energy is

\[U_\mathrm{vib,m}(T) = U_\mathrm{vib,m}(0) + \frac{RT^2}{q_\mathrm{vib}}\frac{\mathrm{d}q_\mathrm{vib}}{\mathrm{d}T} = U_\mathrm{vib,m}(0) + \frac{R\theta_\mathrm{vib}}{\exp(\theta_\mathrm{vib}/T) - 1}.\]

Its derivative with respect to temperature is the vibrational contribution to the heat capacity,

\[C_\mathrm{vib,m} = R\left(\frac{\theta_\mathrm{vib}}{T}\right)^2 \frac{\exp(\theta_\mathrm{vib}/T)}{\left[\exp(\theta_\mathrm{vib}/T) - 1\right]^2},\]

which tends to \(R\) for \(T \gg \theta_\mathrm{vib}\). The function to be fitted to the heat capacity is therefore \(C_{p,\mathrm{m}} = \frac{7}{2}R + C_\mathrm{vib,m}\).

The complete program, which uses NumPy, SciPy and Matplotlib, can be downloaded below with its two data files; it is listed here in parts. The function fit uses scipy.optimize.curve_fit to perform the nonlinear least-squares fit, and returns the fitted parameters, their standard errors (the square roots of the diagonal elements of their covariance matrix) and the root-mean-square residual.

cp_fit.py
The complete program, cp_fit.py
N2_Cp.csv
The molar heat capacity of N₂ from the NIST-JANAF tables, 100–6000 K
CO_Cp.csv
The molar heat capacity of CO from the NIST-JANAF tables, 100–6000 K
python
"""Fit the molar heat capacities of N2 and CO from the NIST-JANAF tables to
models of their vibration and rotation, and compare the fitted vibrational
constants with those from spectroscopy.

N2_Cp.csv and CO_Cp.csv hold the molar constant-pressure heat capacity of each
gas (J K-1 mol-1) as a function of temperature (K).
"""

from functools import partial

import matplotlib.pyplot as plt
import numpy as np
from scipy.constants import R, physical_constants
from scipy.optimize import curve_fit

# The second radiation constant, hc/kB, in cm K.
c2 = physical_constants["second radiation constant"][0] * 100

# The spectroscopic constants we, wexe, Be, alpha_e and De of the ground
# electronic state of each molecule, in cm-1, from K. P. Huber and
# G. Herzberg, Constants of Diatomic Molecules (1979), via the NIST Chemistry
# WebBook.
CONSTANTS = {
    "N2": (2358.57, 14.324, 1.998241, 0.017318, 5.76e-6),
    "CO": (2169.81358, 13.28831, 1.93128087, 0.01750441, 6.12147e-6),
}

JMAX = 400  # the largest rotational quantum number in the sums over levels


def read_Cp(filename):
    """The temperatures (K) and molar heat capacities (J K-1 mol-1) in the CSV
    file filename."""
    return np.genfromtxt(filename, delimiter=",", skip_header=1, unpack=True)


def fit(model, T, Cp, p0):
    """Fit model(T, *params) to the heat capacities Cp, starting from the
    parameters p0; return the fitted parameters, their standard errors and
    the root-mean-square residual."""
    popt, pcov = curve_fit(model, T, Cp, p0=p0)
    rms = np.sqrt(np.mean((Cp - model(T, *popt))**2))
    return popt, np.sqrt(np.diag(pcov)), rms


def Cp_harmonic(T, nu):
    """The molar heat capacity with a harmonic vibration of wavenumber nu
    (cm-1)."""
    x = c2 * nu / T
    return 7 * R / 2 + R * x**2 * np.exp(x) / np.expm1(x)**2

Fitted to all the data, the harmonic model gives \(\tilde{\nu} = 2157 \pm 58\;\mathrm{cm^{-1}}\). It should be compared with the wavenumber of the fundamental transition, \(v = 1 \leftarrow 0\), which is \(2329.9\;\mathrm{cm^{-1}}\): the fitted value is 7% too low. As the figure below shows, the fitted curve rises too early, lying above the data between about 300 and 1850 K, and falls short of them by \(1.0\;\mathrm{J\,K^{-1}\,mol^{-1}}\) at 6000 K. With a single spacing for all its levels, the harmonic model cannot reproduce both the onset of the rise in the heat capacity, which depends on the spacing of the lowest levels, and its continued rise at high temperatures, where many levels are populated and anharmonicity makes their spacing decrease. Fitted to the data up to 1500 K only, where few molecules are excited beyond \(v = 1\), the model gives \(2287\;\mathrm{cm^{-1}}\), closer to the fundamental.

Two panels sharing a temperature axis from 0 to 6000 K. Above, the tabulated heat capacity of N₂, as open circles, rises from 29.1 to 38.3 J K⁻¹ mol⁻¹; the harmonic fit, a solid curve, rises slightly too early and levels off at about 37.2 J K⁻¹ mol⁻¹. Below, the residuals dip to −0.36 J K⁻¹ mol⁻¹ near 900 K, cross zero near 1850 K and rise steadily to 1.04 J K⁻¹ mol⁻¹ at 6000 K.
The molar heat capacity of \(\mathrm{N_2}\) from the NIST-JANAF tables and the fit of the harmonic model, \(\tilde{\nu} = 2157\;\mathrm{cm^{-1}}\). The lower panel shows the residuals (tabulated less fitted values), in \(\mathrm{J\,K^{-1}\,mol^{-1}}\).

Anharmonic oscillator model

The vibrational term values (energies in wavenumbers) of a real diatomic molecule are usually written as a power series in \(v + \frac{1}{2}\),

\[G(v) = \omega_\mathrm{e}\left(v + \tfrac{1}{2}\right) - \omega_\mathrm{e}x_\mathrm{e}\left(v + \tfrac{1}{2}\right)^2 + \omega_\mathrm{e}y_\mathrm{e}\left(v + \tfrac{1}{2}\right)^3 + \cdots,\]

where \(\omega_\mathrm{e}\) is the harmonic wavenumber and \(\omega_\mathrm{e}x_\mathrm{e}\), \(\omega_\mathrm{e}y_\mathrm{e}\), … are the anharmonicity constants. The first two terms are exact for a Morse oscillator, whose levels, relative to \(v = 0\), are

\[\frac{E_v}{hc} = G(v) - G(0) = \omega_\mathrm{e}v - \omega_\mathrm{e}x_\mathrm{e}v(v + 1).\]

Their spacing, \(G(v+1) - G(v) = \omega_\mathrm{e} - 2\omega_\mathrm{e}x_\mathrm{e}(v + 1)\), decreases as \(v\) increases, and \(G(v)\) has its maximum at \(v = \omega_\mathrm{e}/2\omega_\mathrm{e}x_\mathrm{e} - \frac{1}{2}\). The Morse oscillator has a finite number of bound levels, up to this value of \(v\), and the sums below run over these only: beyond the maximum, the energies given by \(G(v)\) fall as \(v\) increases, which is unphysical.

For any set of levels with energies \(E_i\) and degeneracies \(g_i\), the contribution to the molar heat capacity can be written in a compact form:

\[C_\mathrm{m} = R\left(\langle x^2\rangle - \langle x\rangle^2\right), \qquad x = \frac{E}{k_\mathrm{B}T},\]

where the angle brackets denote an average over the Boltzmann distribution of the molecules among the levels, \(\langle f \rangle = \sum_i g_i f_i \exp(-x_i)/q\), and \(q = \sum_i g_i\exp(-x_i)\) is the partition function.

Show derivationHide derivation

Since \(x_i = E_i/k_\mathrm{B}T\), \(\mathrm{d}x_i/\mathrm{d}T = -x_i/T\), and so

\[\frac{\mathrm{d}q}{\mathrm{d}T} = \sum_i g_i \frac{x_i}{T}\exp(-x_i) = \frac{q\langle x\rangle}{T}.\]

The molar energy is then

\[U_\mathrm{m}(T) - U_\mathrm{m}(0) = \frac{RT^2}{q}\frac{\mathrm{d}q}{\mathrm{d}T} = RT\langle x\rangle,\]

and its derivative is

\[C_\mathrm{m} = \frac{\mathrm{d}U_\mathrm{m}}{\mathrm{d}T} = R\langle x\rangle + RT\frac{\mathrm{d}\langle x\rangle}{\mathrm{d}T}.\]

Differentiating \(\langle x\rangle = \sum_i g_i x_i\exp(-x_i)/q\),

\begin{align*} \frac{\mathrm{d}\langle x\rangle}{\mathrm{d}T} &= \frac{1}{q}\sum_i g_i \frac{x_i^2 - x_i}{T}\exp(-x_i) - \frac{\langle x\rangle}{q}\frac{\mathrm{d}q}{\mathrm{d}T}\\ &= \frac{\langle x^2\rangle - \langle x\rangle - \langle x\rangle^2}{T}, \end{align*}

so that \(C_\mathrm{m} = R\left(\langle x^2\rangle - \langle x\rangle^2\right)\).

The heat capacity is therefore proportional to the variance of the energy of the molecules: it is large when the populated levels are spread over a range of energies that is wide compared with \(k_\mathrm{B}T\). For the vibrational levels of the Morse oscillator, \(C_{p,\mathrm{m}} = \frac{7}{2}R + C_\mathrm{vib,m}\), as before. The function heat_capacity evaluates the expression above for all the levels and all the temperatures at once, using NumPy broadcasting: the array x has one row for each level and one column for each temperature.

python
def heat_capacity(E, g, T):
    """The contribution to the molar heat capacity of the levels with energies
    E (cm-1, relative to the lowest) and degeneracies g, at the temperatures
    T: R times the variance of E/kBT."""
    x = c2 * E[:, None] / T
    p = g[:, None] * np.exp(-x)
    p /= p.sum(axis=0)
    mean_x = (p * x).sum(axis=0)
    return R * ((p * x**2).sum(axis=0) - mean_x**2)


def morse_levels(we, wexe):
    """The vibrational quantum numbers of the bound levels of a Morse
    oscillator, and their energies (cm-1) relative to v = 0."""
    vmax = int(we / (2 * wexe) - 0.5)
    v = np.arange(vmax + 1)
    return v, we * v - wexe * v * (v + 1)


def Cp_anharmonic(T, we, wexe):
    """The molar heat capacity with the vibration of a Morse oscillator."""
    v, E = morse_levels(we, wexe)
    return 7 * R / 2 + heat_capacity(E, np.ones_like(E), T)

Fitted to all the data, the anharmonic model gives \(\omega_\mathrm{e} = 2353.9 \pm 2.5\;\mathrm{cm^{-1}}\) and \(\omega_\mathrm{e}x_\mathrm{e} = 27.34 \pm 0.12\;\mathrm{cm^{-1}}\), for which the sums run over the 43 levels \(v = 0\) to 42. It fits the data far better than the harmonic model: the root-mean-square residual is \(0.019\;\mathrm{J\,K^{-1}\,mol^{-1}}\), compared with \(0.50\;\mathrm{J\,K^{-1}\,mol^{-1}}\). The spectroscopic values for the ground state of \(\mathrm{N_2}\) are \(\omega_\mathrm{e} = 2358.57\;\mathrm{cm^{-1}}\) and \(\omega_\mathrm{e}x_\mathrm{e} = 14.324\;\mathrm{cm^{-1}}\) (K. P. Huber and G. Herzberg, Constants of Diatomic Molecules, Van Nostrand Reinhold, 1979, doi:10.1007/978-1-4757-0961-2, as given in the NIST Chemistry WebBook). The fitted \(\omega_\mathrm{e}\) agrees to 0.2%, but \(\omega_\mathrm{e}x_\mathrm{e}\) is almost twice the spectroscopic value, much further from it than its standard error suggests. The residuals, shown below, are systematic rather than random, and so the standard errors, which assume random errors, understate the true uncertainties.

Two panels sharing a temperature axis from 0 to 6000 K. Above, the anharmonic fit passes through all the tabulated heat capacities of N₂. Below, the residuals oscillate smoothly between −0.030 and +0.029 J K⁻¹ mol⁻¹, with minima near 800 and 5600 K and a maximum near 3200 K.
The molar heat capacity of \(\mathrm{N_2}\) from the NIST-JANAF tables and the fit of the anharmonic (Morse oscillator) model, \(\omega_\mathrm{e} = 2353.9\;\mathrm{cm^{-1}}\) and \(\omega_\mathrm{e}x_\mathrm{e} = 27.34\;\mathrm{cm^{-1}}\), with the residuals below, in \(\mathrm{J\,K^{-1}\,mol^{-1}}\). The scale of the residuals is 30 times finer than in the previous figure.

Rotation–vibration interaction

The anharmonic model treats the rotation and vibration as independent, with the rotational contribution to the heat capacity fixed at its classical value, \(R\). In fact the two interact. The rotational term values in vibrational level \(v\) are

\[F_v(J) = B_vJ(J+1) - D_\mathrm{e}J^2(J+1)^2, \qquad B_v = B_\mathrm{e} - \alpha_\mathrm{e}\left(v + \tfrac{1}{2}\right),\]

where \(B_v\) is the rotational constant in level \(v\) and \(D_\mathrm{e}\) is the centrifugal distortion constant (not to be confused with the dissociation energy); the rotational levels themselves are the subject of the post on the most intense line in a rotational spectrum. The rotation–vibration interaction constant, \(\alpha_\mathrm{e}\), is positive because the bond is longer on average in higher vibrational levels, so that the moment of inertia is larger and the rotational levels are closer together. Centrifugal distortion, the stretching of the bond as the molecule rotates faster, lowers the levels of high \(J\). Both effects lower the energies of the levels with large \(v\) and \(J\), which increases the number of levels at high energies, and so the heat capacity at high temperatures. The anharmonic model can reproduce this only by making the vibrational levels converge faster, that is, by increasing \(\omega_\mathrm{e}x_\mathrm{e}\).

The rovibrational model therefore sums over the levels \(E(v, J)/hc = G(v) - G(0) + F_v(J)\), each with degeneracy \(2J+1\), and \(C_{p,\mathrm{m}} = \frac{5}{2}R + C_\mathrm{int,m}\), where \(C_\mathrm{int,m}\), the contribution of the internal (rotational and vibrational) motion, is given by the same expression as before. Spectroscopy determines \(B_\mathrm{e}\), \(\alpha_\mathrm{e}\) and \(D_\mathrm{e}\) far more precisely than the heat capacity could, so they are fixed at their spectroscopic values (\(1.998241\), \(0.017318\) and \(5.76\times10^{-6}\;\mathrm{cm^{-1}}\) for \(\mathrm{N_2}\)), and only \(\omega_\mathrm{e}\) and \(\omega_\mathrm{e}x_\mathrm{e}\) are fitted. For each \(v\), the sum over \(J\) stops at the maximum of \(F_v(J)\), beyond which the polynomial again gives energies that fall as \(J\) increases, or at \(J = 400\), which is ample at 6000 K. The nuclear-spin statistics of \(\mathrm{N_2}\), which give its levels of even and odd \(J\) different weights, make no difference to the heat capacity at these temperatures and are ignored.

python
def Cp_rovib(T, we, wexe, Be, alpha_e, De):
    """The molar heat capacity with the rotational and vibrational levels
    together, including rotation-vibration interaction (alpha_e) and
    centrifugal distortion (De)."""
    v, G = morse_levels(we, wexe)
    Bv = Be - alpha_e * (v[:, None] + 0.5)
    J = np.arange(JMAX + 1)
    JJ = J * (J + 1)
    E = G[:, None] + Bv * JJ - De * JJ**2
    g = np.broadcast_to(2 * J + 1, E.shape)
    # Keep the levels below the maximum of each rotational term-value curve,
    # beyond which the energy falls with J.
    bound = 2 * De * JJ < Bv
    return 5 * R / 2 + heat_capacity(E[bound], g[bound], T)

With \(\alpha_\mathrm{e}\) and \(D_\mathrm{e}\) included, the fit to all the data gives \(\omega_\mathrm{e} = 2362.7 \pm 1.7\;\mathrm{cm^{-1}}\) and \(\omega_\mathrm{e}x_\mathrm{e} = 14.91 \pm 0.10\;\mathrm{cm^{-1}}\), only 4% larger than the spectroscopic value. Both effects are needed: with \(\alpha_\mathrm{e}\) alone, the fit gives \(\omega_\mathrm{e}x_\mathrm{e} = 20.52\;\mathrm{cm^{-1}}\), and with \(D_\mathrm{e}\) alone \(23.39\;\mathrm{cm^{-1}}\). These two fits have smaller root-mean-square residuals (\(0.007\;\mathrm{J\,K^{-1}\,mol^{-1}}\)) than the fit with both effects (\(0.012\;\mathrm{J\,K^{-1}\,mol^{-1}}\)), which shows that a good fit is no guarantee that the fitted parameters mean what the model says they mean.

The fit with both effects is limited by the data at the highest temperatures. According to the documentation of the NIST-JANAF table for \(\mathrm{N_2}\) (M. W. Chase, Jr., NIST-JANAF Thermochemical Tables, 4th edn, J. Phys. Chem. Ref. Data Monograph 9, 1998, p. 1621), its values were calculated in the same way as this model, by direct summation over the rotational and vibrational levels of the ground electronic state, with more terms in the expressions for \(G(v)\) and \(B_v\), together with an approximate correction for three excited electronic states (\(\mathrm{A^3\Sigma_u^+}\), \(\mathrm{B^3\Pi_g}\) and \(\mathrm{W^3\Delta_u}\)), which contributes above about 4800 K. The figure below shows the residuals of the anharmonic and rovibrational fits, and those of the rovibrational model with the spectroscopic values of \(\omega_\mathrm{e}\) and \(\omega_\mathrm{e}x_\mathrm{e}\), without any fitting. Below 4800 K, the unfitted model reproduces the tabulated values to within \(0.003\;\mathrm{J\,K^{-1}\,mol^{-1}}\); above it, the difference is the excited-state correction, \(0.08\;\mathrm{J\,K^{-1}\,mol^{-1}}\) at 6000 K, which the fit to all the data tries to absorb. Fitted only to the 51 values below 4800 K, the rovibrational model gives \(\omega_\mathrm{e} = 2358.62 \pm 0.08\;\mathrm{cm^{-1}}\) and \(\omega_\mathrm{e}x_\mathrm{e} = 14.22 \pm 0.01\;\mathrm{cm^{-1}}\), with a root-mean-square residual of \(0.001\;\mathrm{J\,K^{-1}\,mol^{-1}}\), the precision to which the table gives its values. The remaining difference of 0.7% from the spectroscopic \(\omega_\mathrm{e}x_\mathrm{e}\) reflects small differences between the levels of the model and those of the JANAF calculation.

Residuals in J K⁻¹ mol⁻¹ against temperature from 0 to 6000 K for three models of the heat capacity of N₂. The residuals of the fitted Morse oscillator oscillate between about −0.03 and +0.03. Those of the fitted rovibrational model stay within ±0.016 up to 5000 K, then rise to 0.054 at 6000 K. Those of the unfitted rovibrational model with the spectroscopic constants stay within 0.003 of zero up to 4800 K, marked by a dashed vertical line, then rise to 0.076 at 6000 K.
The residuals (tabulated less model values) of the fits of the anharmonic and rovibrational models to the heat capacity of \(\mathrm{N_2}\), and of the rovibrational model with the spectroscopic constants, unfitted. Above 4800 K (dashed line), the tabulated values include a contribution from excited electronic states, which none of the models includes.

Carbon monoxide

The main part of the program fits each model to the heat capacities of both \(\mathrm{N_2}\) and \(\mathrm{CO}\), prints the results, from which the values for \(\mathrm{N_2}\) above are taken, and plots each fit with its residuals.

python
def report(label, popt, perr, rms):
    """Print the fitted parameters, their standard errors and the
    root-mean-square residual of a fit."""
    params = "".join(f"{p:10.2f} ± {e:<6.2f}" for p, e in zip(popt, perr))
    print(f"{label:28s}{params:38s}{rms:6.3f}")


if __name__ == "__main__":
    for molecule, (we, wexe, Be, alpha_e, De) in CONSTANTS.items():
        T, Cp = read_Cp(f"{molecule}_Cp.csv")
        print(f"{molecule}: we = {we} cm-1, wexe = {wexe} cm-1 and"
              f" we - 2wexe = {we - 2 * wexe:.2f} cm-1 (spectroscopy)")
        print(f"{'Model':28s}{'we / cm-1':>14s}{'wexe / cm-1':>19s}"
              f"{'rms / J K-1 mol-1':>23s}")

        # Each model, with the data it is fitted to and the starting values
        # of its parameters. For the harmonic model, the parameter in the
        # column headed we is the vibrational wavenumber, nu. The
        # rovibrational models take Be, alpha_e and De at their spectroscopic
        # values, or set alpha_e or De to zero. The tabulated values above
        # 4800 K include a contribution from excited electronic states.
        low, ground = T <= 1500, T < 4800
        rovib = partial(Cp_rovib, Be=Be, alpha_e=alpha_e, De=De)
        models = {
            "Harmonic": (Cp_harmonic, T, Cp, [2000]),
            "Harmonic, T <= 1500 K": (Cp_harmonic, T[low], Cp[low], [2000]),
            "Morse oscillator": (Cp_anharmonic, T, Cp, [2000, 10]),
            "Rovibrational, alpha_e only":
                (partial(Cp_rovib, Be=Be, alpha_e=alpha_e, De=0), T, Cp,
                 [2000, 10]),
            "Rovibrational, De only":
                (partial(Cp_rovib, Be=Be, alpha_e=0, De=De), T, Cp,
                 [2000, 10]),
            "Rovibrational": (rovib, T, Cp, [2000, 10]),
            "Rovibrational, T < 4800 K":
                (rovib, T[ground], Cp[ground], [2000, 10]),
        }
        fits = {}
        for label, (model, Tfit, Cpfit, p0) in models.items():
            popt, perr, rms = fit(model, Tfit, Cpfit, p0)
            report(label, popt, perr, rms)
            fits[label] = model(T, *popt)

        # The rovibrational model with the spectroscopic constants, unfitted.
        res = Cp - rovib(T, we, wexe)
        print(f"Spectroscopic constants: largest |residual| below 4800 K"
              f" {np.abs(res[ground]).max():.3f} J K-1 mol-1; residual at"
              f" {T[-1]:.0f} K {res[-1]:.3f} J K-1 mol-1\n")

        # Plot the data and three of the fits, and their residuals.
        fig, (ax1, ax2) = plt.subplots(2, 1, sharex=True,
                                       height_ratios=(3, 1))
        ax1.plot(T, Cp, "+", label="NIST-JANAF")
        for label in ("Harmonic", "Morse oscillator", "Rovibrational"):
            ax1.plot(T, fits[label], label=label)
            ax2.plot(T, Cp - fits[label])
        ax1.set_title(molecule)
        ax1.set_ylabel(r"$C_{p,\mathrm{m}}\;/\;\mathrm{J\,K^{-1}\,mol^{-1}}$")
        ax1.legend()
        ax2.set_xlabel(r"$T\;/\;\mathrm{K}$")
        ax2.set_ylabel("Residual")
        plt.show()
Output
N2: we = 2358.57 cm-1, wexe = 14.324 cm-1 and we - 2wexe = 2329.92 cm-1 (spectroscopy)
Model                            we / cm-1        wexe / cm-1      rms / J K-1 mol-1
Harmonic                       2157.10 ± 57.75                     0.500
Harmonic, T <= 1500 K          2286.93 ± 5.16                      0.035
Morse oscillator               2353.85 ± 2.48       27.34 ± 0.12   0.019
Rovibrational, alpha_e only    2358.07 ± 0.92       20.52 ± 0.05   0.007
Rovibrational, De only         2365.39 ± 0.94       23.39 ± 0.05   0.007
Rovibrational                  2362.70 ± 1.66       14.91 ± 0.10   0.012
Rovibrational, T < 4800 K      2358.62 ± 0.08       14.22 ± 0.01   0.001
Spectroscopic constants: largest |residual| below 4800 K 0.003 J K-1 mol-1; residual at 6000 K 0.076 J K-1 mol-1

CO: we = 2169.81358 cm-1, wexe = 13.28831 cm-1 and we - 2wexe = 2143.24 cm-1 (spectroscopy)
Model                            we / cm-1        wexe / cm-1      rms / J K-1 mol-1
Harmonic                       1966.67 ± 65.02                     0.586
Harmonic, T <= 1500 K          2095.95 ± 6.91                      0.050
Morse oscillator               2155.89 ± 4.88       24.78 ± 0.19   0.040
Rovibrational, alpha_e only    2161.95 ± 2.04       18.49 ± 0.09   0.016
Rovibrational, De only         2168.87 ± 2.10       21.25 ± 0.09   0.017
Rovibrational                  2168.36 ± 0.31       13.37 ± 0.02   0.002
Rovibrational, T < 4800 K      2169.09 ± 0.19       13.49 ± 0.01   0.001
Spectroscopic constants: largest |residual| below 4800 K 0.008 J K-1 mol-1; residual at 6000 K 0.001 J K-1 mol-1

The results for \(\mathrm{CO}\) follow the same pattern. Its spectroscopic constants are \(\omega_\mathrm{e} = 2169.81\;\mathrm{cm^{-1}}\) and \(\omega_\mathrm{e}x_\mathrm{e} = 13.288\;\mathrm{cm^{-1}}\) (Huber and Herzberg). The harmonic model gives \(\tilde{\nu} = 1967 \pm 65\;\mathrm{cm^{-1}}\), 8% below the fundamental, and the anharmonic model gives \(\omega_\mathrm{e}x_\mathrm{e} = 24.78 \pm 0.19\;\mathrm{cm^{-1}}\), almost twice the spectroscopic value. The rovibrational model gives \(13.37 \pm 0.02\;\mathrm{cm^{-1}}\) fitted to all the data and \(13.49 \pm 0.01\;\mathrm{cm^{-1}}\) fitted to the data below 4800 K, within 2% of the spectroscopic value in both cases; with the spectroscopic constants, it reproduces the tabulated heat capacities of \(\mathrm{CO}\) to within \(0.008\;\mathrm{J\,K^{-1}\,mol^{-1}}\) at all temperatures.

Comments

Leave a comment

Optional, and never shown: only the moderator sees it.

Comments are written in Markdown (code between ``` lines) and appear once approved. Your name and comment are published; your email address, if you give one, is seen only by the moderator.