--- title: "Canonical ensemble" date: 2021-07-10 categories: - Physics - Thermodynamics - Thermodynamic ensembles layout: "concept" --- The **canonical ensemble** or **NVT ensemble** builds on the [microcanonical ensemble](/know/concept/microcanonical-ensemble/), by allowing the system to exchange energy with a very large heat bath, such that its temperature $T$ remains constant, but internal energy $U$ does not. The conserved state functions are the temperature $T$, the volume $V$, and the particle count $N$. We refer to the system of interest as $A$, and the heat bath as $B$. The combination $A\!+\!B$ forms a microcanonical ensemble, i.e. it has a fixed total energy $U$, and eventually reaches an equilibrium with a uniform temperature $T$ in both $A$ and $B$. Assuming that this equilibrium has been reached, we want to know which microstates $A$ prefers in that case. Specifically, if $A$ has energy $U_A$, and $B$ has $U_B$, which $U_A$ does $A$ prefer? Let $c_B(U_B)$ be the number of $B$-microstates with energy $U_B$. Then the probability that $A$ is in a specific microstate $s_A$ is as follows, where $U_A(s_A)$ is the resulting energy: $$\begin{aligned} p(s_A) = \frac{c_B(U - U_A(s_A))}{D} \qquad \quad D \equiv \sum_{s_A} c_B(U - U_A(s_A)) \end{aligned}$$ In other words, we choose an $s_A$, and count the number $c_B$ of compatible $B$-microstates. Since the heat bath is large, let us assume that $U_B \gg U_A$. We thus approximate $\ln{p(s_A)}$ by Taylor-expanding $\ln{c_B(U_B)}$ around $U_B = U$: $$\begin{aligned} \ln{p(s_A)} &= -\ln{D} + \ln\!\big(c_B(U - U_A(s_A))\big) \\ &\approx - \ln{D} + \ln{c_B(U)} - \bigg( \dv{(\ln{c_B})}{U_B} \bigg) \: U_A(s_A) \end{aligned}$$ Here, we use the definition of entropy $S_B \equiv k \ln{c_B}$, and that its $U_B$-derivative is $1/T$: $$\begin{aligned} \ln{p(s_A)} &\approx - \ln{D} + \ln{c_B(U)} - \frac{U_A(s_A)}{k} \Big( \pdv{S_B}{U_B} \Big) \\ &\approx - \ln{D} + \ln{c_B(U)} - \frac{U_A(s_A)}{k T} \end{aligned}$$ We now define the **partition function** or **Zustandssumme** $Z$ as follows, which will act as a normalization factor for the probability: $$\begin{aligned} \boxed{ Z \equiv \sum_{s_A}^{} \exp(- \beta U_A(s_A)) } = \frac{D}{c_B(U)} \end{aligned}$$ Where $\beta \equiv 1/ (k T)$. The probability of finding $A$ in a microstate $s_A$ is thus given by: $$\begin{aligned} \boxed{ p(s_A) = \frac{1}{Z} \exp(- \beta U_A(s_A)) } \end{aligned}$$ This is the **Boltzmann distribution**, which, as it turns out, maximizes the entropy $S_A$ for a fixed value of the average energy $\Expval{U_A}$, i.e. a fixed $T$ and set of microstates $s_A$. Because $A\!+\!B$ is a microcanonical ensemble, we know that its [thermodynamic potential](/know/concept/thermodynamic-potential/) is the entropy $S$. But what about the canonical ensemble, just $A$? The solution is a bit backwards. Note that the partition function $Z$ is not a constant; it depends on $T$ (via $\beta$), $V$ and $N$ (via $s_A$). Using the same logic as for the microcanonical ensemble, we define "equilibrium" as the set of microstates $s_A$ that $A$ is most likely to occupy, which must be the set (as a function of $T,V,N$) that maximizes $Z$. However, $T$, $V$ and $N$ are fixed, so how can we maximize $Z$? Well, as it turns out, the Boltzmann distribution has already done it for us! We will return to this point later. Still, $Z$ does not have a clear physical interpretation. To find one, we start by showing that the ensemble averages of the energy $U_A$, pressure $P_A$ and chemical potential $\mu_A$ can be calculated by differentiating $Z$. As preparation, note that: $$\begin{aligned} \pdv{Z}{\beta} = - \sum_{s_A} U_A \exp(- \beta U_A) \end{aligned}$$ With this, we can find the ensemble averages $\Expval{U_A}$, $\Expval{P_A}$ and $\Expval{\mu_A}$ of the system: $$\begin{aligned} \Expval{U_A} &= \sum_{s_A} p(s_A) \: U_A = \frac{1}{Z} \sum_{s_A} U_A \exp(- \beta U_A) = - \frac{1}{Z} \pdv{Z}{\beta} \\ \Expval{P_A} &= - \sum_{s_A} p(s_A) \pdv{U_A}{V} = - \frac{1}{Z} \sum_{s_A} \exp(- \beta U_A) \pdv{U_A}{V} \\ &= \frac{1}{Z \beta} \pdv{}{V}\sum_{s_A} \exp(- \beta U_A) = \frac{1}{Z \beta} \pdv{Z}{V} \\ \Expval{\mu_A} &= \sum_{s_A} p(s_A) \pdv{U_A}{N} = \frac{1}{Z} \sum_{s_A} \exp(- \beta U_A) \pdv{U_A}{N} \\ &= - \frac{1}{Z \beta} \pdv{}{N}\sum_{s_A} \exp(- \beta U_A) = - \frac{1}{Z \beta} \pdv{Z}{N} \end{aligned}$$ It will turn out more convenient to use derivatives of $\ln{Z}$ instead, in which case: $$\begin{aligned} \Expval{U_A} = - \pdv{\ln{Z}}{\beta} \qquad \quad \Expval{P_A} = \frac{1}{\beta} \pdv{\ln{Z}}{V} \qquad \quad \Expval{\mu_A} = - \frac{1}{\beta} \pdv{\ln{Z}}{N} \end{aligned}$$ Now, to find a physical interpretation for $Z$. Consider the quantity $F$, in units of energy, whose minimum corresponds to a maximum of $Z$: $$\begin{aligned} F \equiv - k T \ln{Z} \end{aligned}$$ We rearrange the equation to $\beta F = - \ln{Z}$ and take its differential element: $$\begin{aligned} \dd{(\beta F)} = - \dd{(\ln{Z})} &= - \pdv{\ln{Z}}{\beta} \dd{\beta} - \pdv{\ln{Z}}{V} \dd{V} - \pdv{\ln{Z}}{N} \dd{N} \\ &= \Expval{U_A} \dd{\beta} - \beta \Expval{P_A} \dd{V} + \beta \Expval{\mu_A} \dd{N} \\ &= \Expval{U_A} \dd{\beta} + \beta \dd{\Expval{U_A}} - \beta \dd{\Expval{U_A}} - \beta \Expval{P_A} \dd{V} + \beta \Expval{\mu_A} \dd{N} \\ &= \dd{(\beta \Expval{U_A})} - \beta \: \big( \dd{\Expval{U_A}} + \Expval{P_A} \dd{V} - \Expval{\mu_A} \dd{N} \big) \end{aligned}$$ Rearranging and substituting the [fundamental thermodynamic relation](/know/concept/fundamental-thermodynamic-relation/) then gives: $$\begin{aligned} \dd{(\beta F - \beta \Expval{U_A})} &= - \beta \: \big( \dd{\Expval{U_A}} + \Expval{P_A} \dd{V} - \Expval{\mu_A} \dd{N} \big) = - \beta T \dd{S_A} \end{aligned}$$ We integrate this and ignore the integration constant, leading us to the desired result: $$\begin{aligned} - \beta T S_A &= \beta F - \beta \Expval{U_A} \quad \implies \quad F = \Expval{U_A} - T S_A \end{aligned}$$ As was already suggested by our notation, $F$ turns out to be the **Helmholtz free energy**: $$\begin{aligned} \boxed{ F \equiv - k T \ln{Z} = \Expval{U_A} - T S_A } \end{aligned}$$ We can therefore reinterpret the partition function $Z$ and the Boltzmann distribution $p(s_A)$ in the following "more physical" way: $$\begin{aligned} Z = \exp(- \beta F) \qquad \quad p(s_A) = \exp\!\Big( \beta \big( F \!-\! U_A(s_A) \big) \Big) \end{aligned}$$ Finally, by rearranging the expressions for $F$, we find the entropy $S_A$ to be: $$\begin{aligned} S_A = k \ln{Z} + \frac{\Expval{U_A}}{T} \end{aligned}$$ This is why $Z$ is already maximized: the Boltzmann distribution maximizes $S_A$ for fixed values of $T$ and $\Expval{U_A}$, leaving $Z$ as the only "variable". ## References 1. H. Gould, J. Tobochnik, *Statistical and thermal physics*, 2nd edition, Princeton.