## Degrees of freedom: mechanical vs. thermal

One of the most important principles of thermodynamics is the equipartition theorem:

A system in thermodynamic equilibrium will have an internal thermal energy of $$\frac{1}{2}k_BT$$ in each degree of freedom.

But there’s a subtlety here: what exactly are degrees of freedom? There are (at least) two slightly different kinds:

• A mechanical degree of freedom is any way in which a system can freely change its spatial configuration
• A thermodynamic degree of freedom is any way in which a system can freely increase its stored energy

The degrees of freedom the equipartition theorem mentions are the thermodynamic variety. It’s important to know this because the equipartition theorem predicts the heat capacity for many substances in the high-temperature limit, and if if you count the wrong kind of degrees of freedom, you’ll get the wrong answer.

# Diatomic molecules

One simple example of this is a diatomic molecule. If you want to figure out how many mechanical degrees of freedom this molecule has, you just count up all the various distances that you need to completely specify the molecule’s spatial configuration. They break down like this:

• Three positions $$x$$, $$y$$, $$z$$ to specify the center of mass of the molecule
• Two angles $$\theta$$, $$\phi$$ to specify the orientation of the molecule (there is a third angle which only becomes relevant at high energies, but I’ll ignore it for now)
• One distance $$d$$ to specify the separation between the atoms (the length of the chemical bond)

for a total of six mechanical degrees of freedom: three translation, two rotation, one vibration.

Alternatively, you could think of the molecule as two independent atoms, each with three position coordinates. That gives you six degrees of freedom, but you then have to subtract off the number of rigid constraints. For a diatomic molecule, there are none, but for a more complex molecule, you might have some constraints to deal with.

Especially given this latter interpretation, you might be surprised to find out that the internal energy of a diatomic gas is actually $$\frac{7}{2}k_BT$$, which means there are actually 7 degrees of freedom. How is that possible, when the individual atoms only allow for 6?

As you might expect, the explanation for this “paradox” is that there are only 6 mechanical degrees of freedom, but that doesn’t limit the number of thermodynamic degrees of freedom. The two kinds are completely different. You can’t count thermodynamic degrees of freedom by just examining how the particles can move; instead, you need to look at the Hamiltonian and count up the quadratic terms.

The Hamiltonian for a diatomic molecule can be written in terms of the individual particle coordinates as

$$H = \frac{p_{1x}^2}{2m} + \frac{p_{1y}^2}{2m} + \frac{p_{1z}^2}{2m} + \frac{p_{2x}^2}{2m} + \frac{p_{2y}^2}{2m} + \frac{p_{2z}^2}{2m} + \frac{k}{2}\Bigl(\sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2 + (z_2 - z_1)^2} - l\Bigr)^2$$

where $$l$$ is the equilibrium separation between the atoms. Alternatively, you can write it as

$$H = \frac{p_{\text{cm},x}}{2\mu} + \frac{p_{\text{cm},y}}{2\mu} + \frac{p_{\text{cm},z}}{2\mu} + \frac{L_{\phi}}{2I} + \frac{L_{\theta}}{2I} + \frac{p_r^2}{2\mu} + \frac{k}{2}(r - l)^2$$

which clearly shows the difference between the translational energies (the first three terms), the rotational energies (the next two), and the vibrational energies (the last two, kinetic and potential respectively). There are seven terms in here, and according to the equipartition theorem, each of them represents an energy of $$\frac{1}{2}k_BT$$.

# Directly calculating the energy

Even without counting terms, there is a way to see that this Hamiltonian corresponds to a system with seven thermodynamic degrees of freedom — or more precisely, to see that it stores $$\frac{7}{2}k_BT$$ on average. You just compute the expectation value of the energy stored in the system, over all possible thermodynamic states.

$$E = \expect{H} = \frac{\sum_j w_jH_j}{\sum_j w_j}$$

Here $$H_j$$ is the Hamiltonian for the state $$j$$, and $$w_j$$ is a factor indicating the relative probability of state $$j$$, which is the Boltzmann factor, $$w_j = e^{-H_j/k_BT} = e^{-\beta H_j}$$. The method I’m about to describe comes from An Introduction to Thermal Physics by Daniel Schroeder.

Suppose we’re using the first version of the Hamiltonian from above, where the variables are the individual positions and momenta of the two atoms. In this case, each state is identified by those variables, $$\vec{x}_1, \vec{x}_2, \vec{p}_1, \vec{p}_2$$. Since these are continuous variables, I’ll multiply both the top and bottom of $$\expect{H}$$ by a product of very small increments, $$\Delta x_1\Delta y_1\Delta z_1\Delta x_2\Delta y_2\Delta z_2\Delta p_{1x}\Delta p_{1y}\Delta p_{1z}\Delta p_{2x}\Delta p_{2y}\Delta p_{2z}$$, and take the limit as all these increments go to zero:

$$\expect{H} = \lim_{\Delta(\cdot)\to 0}\frac{\sum_j e^{-\beta H_j} H_j \Delta x_1\Delta y_1\Delta z_1\Delta x_2\Delta y_2\Delta z_2\Delta p_{1x}\Delta p_{1y}\Delta p_{1z}\Delta p_{2x}\Delta p_{2y}\Delta p_{2z}}{\sum_j e^{-\beta H_j} \Delta x_1\Delta y_1\Delta z_1\Delta x_2\Delta y_2\Delta z_2\Delta p_{1x}\Delta p_{1y}\Delta p_{1z}\Delta p_{2x}\Delta p_{2y}\Delta p_{2z}} = \frac{\idotsint e^{-\beta H} H \udc^{12}\mathcal{P}.\mathcal{S}.}{\idotsint e^{-\beta H} \udc^{12}\mathcal{P}.\mathcal{S}.}$$

$$\udc^{12}\mathcal{P}.\mathcal{S}.$$ is just a space-saving abbreviation for $$\udc x_1\udc y_1\udc z_1\udc x_2\udc y_2\udc z_2\udc p_{1x}\udc p_{1y}\udc p_{1z}\udc p_{2x}\udc p_{2y}\udc p_{2z}$$.

So how does one go about calculating this integral?

## Calculation of the partition function

Let’s start with the denominator for simplicity. If you’re not familiar with thermodynamics, take note that the denominator is the sum of the Boltzmann factor (the probability weight) over all possible states, and it is called the partition function. It’s the first thing you calculate when solving any thermodynamic problem; you’ll see why at the end of this post.

Because the Hamiltonian is a sum of terms, $$H = H_1 + H_2 + \cdots$$ (I’ll get to what $$H_1$$ and $$H_2$$ etc. are momentarily), we can break down the Boltzmann factor into a product of the corresponding individual Boltzmann factors, $$e^{-\beta H} = e^{-\beta H_1}e^{-\beta H_2}\cdots$$. And if each of those terms depends on different variables, that means the integral over all twelve variables breaks down into a product of some number of independent integrals, one for each piece of the Hamiltonian. Specifically, we can treat each of the momentum terms of the Hamiltonian as a separate “piece”: $$H_1 = \frac{p_{1x}^2}{2m}$$ and so on.

\begin{align}\idotsint e^{-\beta H}\udc^{12}\mathcal{P}.\mathcal{S}. &= \Biggl(\int e^{-\beta p_{1x}^2/2m}\udc p_{1x}\Biggr)\Biggl(\int e^{-\beta p_{1y}^2/2m}\udc p_{1y}\Biggr)\Biggl(\int e^{-\beta p_{1z}^2/2m}\udc p_{1z}\Biggr)\\ &\quad\times\Biggl(\int e^{-\beta p_{2x}^2/2m}\udc p_{2x}\Biggr)\Biggl(\int e^{-\beta p_{2y}^2/2m}\udc p_{2y}\Biggr)\Biggl(\int e^{-\beta p_{2z}^2/2m}\udc p_{2z}\Biggr)\\ &\quad\times\idotsint e^{-\beta H_r}\udc^3\vec{r}_1 \udc^3\vec{r}_2\end{align}

Each of the momentum integrals is a Gaussian integral, so each factor in parentheses works out to $$\sqrt{\frac{2m\pi}{\beta}}$$.

That takes care of the momentum-dependent pieces of the Hamiltonian, but what about the coordinate-dependent piece, the potential energy term? That one’s trickier because you can’t break it up into individual terms, each of which depends on only one coordinate. So we’ll have to handle that integral some other way.

Fortunately, it’s not that hard. In the other form of the Hamiltonian, the one which was broken up into translational, rotational, and vibrational terms, the potential energy term took a very simple form, $$\frac{k}{2}(r - l)^2$$, where $$r$$ is the distance between the atoms. That suggests that we should use a change of variables, where one of the new variables is this distance $$r$$. For the other five new variables, I’ll use the three coordinates of the center of mass position and two angles specifying the orientation of the molecule, $$x_\text{cm},y_\text{cm},z_\text{cm},\phi,\theta$$, though as I’ll show shortly, it doesn’t even matter what those other variables are!

In order to do the integral in these coordinates, I’ll need to calculate the Jacobian determinant for this change of variables.

\begin{align}\udc r\udc x_\text{cm}\udc y_\text{cm}\udc z_\text{cm}\udc\phi\udc\theta &= \begin{vmatrix}\pd{r}{x_1} & \pd{r}{y_1} & \pd{r}{z_1} & \pd{r}{x_2} & \pd{r}{y_2} & \pd{r}{z_2} \\ & \vdots & & & \vdots & \end{vmatrix}\udc x_1\udc y_1\udc z_1\udc x_2\udc y_2\udc z_2 \\ &= \mathcal{J}\udc x_1\udc y_1\udc z_1\udc x_2\udc y_2\udc z_2\end{align}

You could calculate the value of that determinant using the definition

$$r = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2 + (z_2 - z_1)^2}$$

but it’s not going to matter (and it’d be an ugly formula), so let’s skip the calculation and just represent the (unknown) value as $$\mathcal{J}$$.

With the new coordinates, now I can break the position-space integral into factors depending on different variables:

$$\mathcal{J}^{-1}\biggl(\int_0^\infty e^{-\beta k(r - l)^2/2}\udc r\biggr)\biggl(\int \udc x_\text{cm}\biggr)\biggl(\int \udc y_\text{cm}\biggr)\biggl(\int \udc z_\text{cm}\biggr)\biggl(\int \udc \phi\biggr)\biggl(\int \udc \theta\biggr)$$

The first of those factors is just another Gaussian integral (half-Gaussian, really), with a value of $$\sqrt{\frac{\pi}{k\beta}}$$. The rest of them… well, they’re technically infinite, but again, it’s not going to matter! I’ll just conveniently ignore it for now, and just lump all those infinite integrals along with the factor $$\mathcal{J}^{-1}$$ into one constant $$C$$. Putting it all together, that gives the following expression for the partition function:

$$Z = \frac{2^{\frac{5}{2}}Cm^3\pi^{\frac{7}{2}}}{k^{\frac{1}{2}}\beta^{\frac{7}{2}}}$$

## Using the partition function

The reason the partition function is so useful is that you can get all sorts of useful thermodynamic quantities out of it by taking derivatives. For example, look at the following neat trick:

$$-\pd{Z}{\beta} = -\pd{}{\beta}\sum_j e^{-\beta H_j} = -\sum_j\pd{}{\beta} e^{-\beta H_j} = -\sum_j (-H_j) e^{-\beta H_j}$$

This last expression is exactly the numerator of the fraction we’re trying to calculate! That means we can find the expectation value of the energy as

$$\expect{H} = -\frac{1}{Z}\pd{Z}{\beta}$$

Putting in the expression for $$Z$$, you get

$$\expect{H} = \frac{k^{\frac{1}{2}}}{2^{\frac{5}{2}}Cm^3\pi^{\frac{7}{2}}}\beta^{\frac{7}{2}}\times \frac{2^{\frac{5}{2}}Cm^3\pi^{\frac{7}{2}}}{k^{\frac{1}{2}}}\times\frac{7}{2}\beta^{-\frac{9}{2}} = \frac{7}{2}\beta^{-1} = \frac{7}{2}k_BT$$

Now, the most important thing to notice about this is that all the constants cancel out. That’s why it didn’t matter what the Jacobian determinant was, and why it didn’t matter that there were a bunch of infinite integrals involved in computing the constant $$C$$, and in turn why it didn’t matter what those other five position variables were. (If the infinite-ness of the integrals really bothers you, consider that they are really improper integrals, $$\int_{-\infty}^{\infty} = \lim_{a\to\infty}\int_{-a}^a$$, and just defer taking the limit until after you calculate the ratio $$\frac{1}{Z}\pd{Z}{\beta}$$; this keeps the integrals finite until all the unbounded factors have canceled out.) Because we were able to treat the Hamiltonian as a sum of quadratic terms, and to split the partition function into a separate factor for each quadratic term, we wound up with just a sum of a constant value, namely $$\frac{1}{2}k_BT$$, for each of those terms.

The formula

$$\expect{H} = -\frac{1}{Z}\pd{Z}{\beta}$$

can be used for any sort of Hamiltonian, by the way. For example, if you put in a Hamiltonian with a linear term, like $$H = bp$$, you’ll find that that term contributes $$k_BT$$ to the energy, not $$\frac{1}{2}k_BT$$. Or you could put in some other Hamiltonian with a more complicated form, and in principle, as long as you can do the integral (or at least take its derivative with respect to $$\beta$$, which may not even require doing the integral at all in some cases), you can determine its specific heat. In these more complicated cases, you have to get more creative as to how you define “thermodynamic degrees of freedom,” because you can’t split the Hamiltonian into terms each of which contributes $$\frac{1}{2}k_BT$$ to the energy — so the equipartition theorem, at least as stated at the top of this post, doesn’t hold true anymore. But that’s okay, because degrees of freedom aren’t a physically measurable quantity. You can always calculate the relationship between the quantities you can actually measure, the energy and the temperature.