# The canonical ensemble at work

Suppose we have a system whose Hamiltonian is:

${\mathcal {H}}=\sum _{i}{\frac {{\vec {p}}_{i}{}^{2}}{2m}}+\sum _{i}U({\vec {q}}_{i})+{\frac {1}{2}}\sum _{i\neq j}U_{2}({\vec {q}}_{i},{\vec {q}}_{j})$ (for example, $U$ can be the gravitational potential and $U_{2}$ an interaction between the particles). Then the canonical probability density is:
$\rho (\mathbb {Q} ,\mathbb {P} )={\frac {1}{Z}}e^{-\beta \sum _{i}{\frac {{\vec {p}}_{i}{}^{2}}{2m}}-\beta \left[\sum _{i}U({\vec {q}}_{i})+{\frac {1}{2}}\sum _{i\neq j}U_{2}({\vec {q}}_{i},{\vec {q}}_{j})\right]}$ Note that $\mathbb {Q}$ and $\mathbb {P}$ don't "get mixed up"; therefore, when calculating the partition function $Z$ we can separate the kinetic and configurational contributions:
$Z=\int d\Gamma \rho (\mathbb {Q} ,\mathbb {P} )=\prod _{i=1}^{N}\left({\frac {1}{N!h^{3N}}}\int e^{-\beta {\frac {{\vec {p}}_{i}{}^{2}}{2m}}}d{\vec {p}}_{i}\right)\cdot \int e^{-\beta \left[\sum _{i}U({\vec {q}}_{i})+{\frac {1}{2}}\sum _{i\neq j}U_{2}({\vec {q}}_{i},{\vec {q}}_{j})\right]}d\mathbb {Q}$ Now, since:
$\int e^{-\beta {\frac {{\vec {p}}{}^{2}}{2m}}}d{\vec {p}}=\left({\frac {2\pi m}{\beta }}\right)^{3/2}$ we have:
$Z={\frac {1}{N!}}\left({\frac {2\pi m}{h^{2}\beta }}\right)^{3N/2}\int e^{-\beta \left[\sum _{i}U({\vec {q}}_{i})+{\frac {1}{2}}\sum _{i\neq j}U_{2}({\vec {q}}_{i},{\vec {q}}_{j})\right]}d\mathbb {Q}$ In order to simplify this expression, we define the configurational partition function (or configurational sum) as:
$Q_{N}=\int e^{-\beta \left[\sum _{i}U({\vec {q}}_{i})+{\frac {1}{2}}\sum _{i\neq j}U_{2}({\vec {q}}_{i},{\vec {q}}_{j})\right]}d\mathbb {Q}$ and the thermal wavelength as:
$\Lambda ={\sqrt {\frac {h^{2}}{2\pi k_{B}Tm}}}={\sqrt {\frac {2\pi \hbar ^{2}}{k_{B}Tm}}}$ so that, in general:
$Z={\frac {1}{N!\Lambda ^{3N}}}Q_{N}$ If we now consider an ideal gas, namely we set $U=U_{2}=0$ , then:

$Q_{N}=V^{N}\quad \Rightarrow \quad Z={\frac {1}{N!}}\left({\frac {V}{\Lambda ^{3}}}\right)^{N}$ And using Stirling's approximation (see the appendix Stirling's approximation) the free energy $F=-k_{B}T\ln Z$ of the system turns out to be:
$F=k_{B}TN\left[\ln \left({\frac {N}{V}}\Lambda ^{3}\right)-1\right]$ Since from thermodynamics we know that $P=-\partial F/\partial V$ , we get:
$P=-k_{B}TN{\frac {V}{N\Lambda ^{3}}}\left(-{\frac {N}{V^{2}}}\Lambda ^{3}\right)={\frac {k_{B}TN}{V}}\quad \Rightarrow \quad PV=Nk_{B}T$ We have therefore found the state equation of an ideal gas in the canonical ensemble! We are thus really verifying that the canonical and microcanonical ensembles are equivalent. For example, we can also compute the entropy of this ideal gas, and we get:
$S=-{\frac {\partial F}{\partial T}}=Nk_{B}\left[{\frac {5}{2}}-\ln \left({\frac {N}{V}}\Lambda ^{3}\right)\right]$ which is exactly what we have found in the microcanonical ensemble.

## Column of gas in a gravitational potential

Just as another example of the power of the canonical ensemble, we now want to see that in a particular case we can obtain the same results that we can determine from simple kinetic considerations. In particular, we want to see how the density of a gas subjected to a uniform gravitational potential varies with the height from the ground.

We begin with the "kinetic" computation. Consider a column of gas subjected to a constant gravitational potential $mgz$ , where $z$ is the height from the ground. The action of gravity will in some way change the density of the particles (we expect that the gas will be more dense near the ground and become thinner and thinner as $z$ grows) so let us call $\rho (z)$ and $P(z)$ the density and the pressure of the gas at height $z$ . The situation is represented in the following figure:

Let us call $n(z)\Delta z$ is the number of particles that are between the heights $z$ and $z+\Delta z$ , where $n(z)$ is the particle number density at height $z$ ; these will be subjected to the pressures $P(z)$ and $P(z+\Delta z)$ , and if we call $\Sigma$ the cross section of the column then the net force acting on the particles is $P(z)\Sigma -P(z+\Delta z)\Sigma$ . Since the system is in equilibrium, this force must be balanced by the weight of the gas itself:

$P(z)\Sigma -P(z+\Delta z)\Sigma =\rho (z)\Delta z\Sigma g$ Therefore, dividing by $\Sigma$ and $\Delta z$ and taking the limit $\Delta z\to 0$ :
${\frac {\partial P}{\partial z}}=-\rho (z)g$ If we then consider a volume $V$ between $z$ and $z+\Delta z$ we have:
$P(z)V=N(z)k_{B}T\quad \Rightarrow \quad P(z)={\frac {N(z)}{V}}k_{B}T$ and since $\rho (z)=N(z)m/V=n(z)m$ , then:
$P(z)={\frac {\rho (z)}{m}}k_{B}T\quad \Rightarrow \quad \rho (z)={\frac {m}{k_{B}T}}P(z)$ Therefore:
${\frac {\partial P}{\partial z}}=-g\rho (z)=-{\frac {mg}{k_{B}T}}P(z)\quad \Rightarrow \quad P(z)=P(0)e^{-{\frac {mg}{k_{B}T}}z}$ or equivalently:
$n(z)=n(0)e^{-{\frac {mg}{k_{B}T}}z}$ Thus, the density of the gas decreases exponentially with the height.

We now want to show that the tools of the canonical ensemble allow us to obtain the very same result. Let us consider the single-particle canonical partition function:

$Z_{\text{s.p.}}=\int e^{-\beta \left({\frac {{\vec {p}}{}^{2}}{2m}}+mgz\right)}{\frac {d{\vec {p}}d{\vec {q}}}{h^{3}}}$ Since ${\vec {q}}=(x,y,z)$ is such that $(x,y)\in \Sigma$ and $z\in [0,+\infty ]$ , integrating we will have:
$Z_{\text{s.p.}}=\left({\frac {2\pi mk_{B}T}{h^{2}}}\right)^{3/2}{\frac {\Sigma }{\beta mg}}$ The single-particle probability density of having momentum ${\vec {p}}$ and height $z$ is:
$\rho _{\text{s.p.}}({\vec {p}},{\vec {q}})={\frac {1}{Z_{\text{s.p.}}}}e^{-\beta \left({\frac {{\vec {p}}{}^{2}}{2m}}+mgz\right)}$ Therefore we can obtain the spatial probability density integrating over ${\vec {p}}$ , $x$ and $y$ ; in the end we get:
$\rho _{\text{s.p.}}(z)={\frac {mg}{k_{B}T}}e^{-{\frac {mg}{k_{B}T}}z}:=\rho _{\text{s.p.}}(0)e^{-{\frac {mg}{k_{B}T}}z}$ where we have relabelled the proportionality constant. Now, the particle number density at height $z$ will be $n(z)=N\rho _{\text{s.p.}}(z)$ , so in the end we have:
$n(z)=n(0)e^{-{\frac {mg}{k_{B}T}}z}$ which is exactly the result previously found .

1. This "separation" was not possible within the microcanonical ensemble and as we will later see (for example in Statistical mechanics of phase transitions) this will simplify the computations when we will consider non ideal systems, namely if the particles actually interact; in fact since any reasonable interaction does not involve the particles' momenta but only their positions only $Q_{N}$ (see below) will be affected by the presence of the interaction.
2. We use the single-particle partition function because in the end we want to find the single-particle configurational probability density.