---
title: The Grand Canonical Ensemble
module: Grand Canonical Ensemble
moduleNumber: 6
lessonNumber: 1
order: 601
summary: >
  When a system exchanges both energy and particles with a reservoir, the
  reservoir fixes its temperature and its chemical potential. Expanding the
  reservoir entropy to first order in the exchanged energy and particle number
  gives the Gibbs factor $e^{-\beta(E-\mu N)}$, and summing it over every
  microstate of every particle number gives the grand partition function $\Xi$.
  The grand potential $\Phi = -k_BT\ln\Xi = -PV$ generates the mean particle
  number, energy, entropy, and pressure by differentiation.
topics: [Grand Canonical Ensemble]
sources:
  - book: Schroeder
    ref: "Ch. 7 — Quantum Statistics; §7.1 The Gibbs Factor"
  - book: Reif
    ref: "Ch. 9 — Quantum Statistics of Ideal Gases; §9.1–9.3"
  - book: Kardar (Statistical Physics of Particles)
    ref: "Ch. 4 — Classical Statistical Mechanics; §4.9 The Grand Canonical Ensemble"
  - book: Pathria & Beale
    ref: "Ch. 4 — The Grand Canonical Ensemble; §4.1–4.4"
draft: false
---

The canonical ensemble fixes the particle number and lets the energy fluctuate.
Many systems fix neither. A region of a gas open to the rest of the container,
a metal surface adsorbing molecules from a vapor, a single quantum mode that any
number of bosons may occupy — each exchanges particles as freely as energy with
its surroundings. The grand canonical ensemble describes a system in contact
with a reservoir that fixes the temperature and the chemical potential while
both the energy and the particle number of the system fluctuate. Its central
object is the grand partition function, from which the whole thermodynamics
follows exactly as the canonical thermodynamics follows from $Z$.

## A system open to a particle reservoir

Consider a small system $\mathcal S$ in contact with a large reservoir
$\mathcal R$, the two together forming an isolated compound with fixed total
energy $E_{\rm tot}$ and fixed total particle number $N_{\rm tot}$. The wall
between them passes both energy and particles. A microstate of $\mathcal S$ is
now labeled by two quantities: its energy $E_s$ and its particle number $N_s$.
When $\mathcal S$ is in a definite microstate $s$, the reservoir holds the
remainder $E_{\rm tot}-E_s$ and $N_{\rm tot}-N_s$, and it does so in
$\Omega_{\mathcal R}(E_{\rm tot}-E_s,\,N_{\rm tot}-N_s)$ ways.

By the postulate of equal a priori probabilities applied to the isolated
compound, the probability of the system microstate $s$ is proportional to the
number of reservoir microstates consistent with it,

$$
P(s)\;\propto\;\Omega_{\mathcal R}(E_{\rm tot}-E_s,\,N_{\rm tot}-N_s).
$$

The system energies and particle numbers are tiny against the reservoir totals,
so expand the reservoir entropy $S_{\mathcal R}=k_B\ln\Omega_{\mathcal R}$ to
first order in both $E_s$ and $N_s$:

$$
\ln\Omega_{\mathcal R}(E_{\rm tot}-E_s,\,N_{\rm tot}-N_s)
\approx \ln\Omega_{\mathcal R}(E_{\rm tot},N_{\rm tot})
-\frac{1}{k_B}\frac{\partial S_{\mathcal R}}{\partial E}\,E_s
-\frac{1}{k_B}\frac{\partial S_{\mathcal R}}{\partial N}\,N_s.
$$

These two reservoir derivatives coincide with the statistical definitions of
temperature and chemical potential established for the microcanonical
ensemble,[^micro]

$$
\frac{\partial S_{\mathcal R}}{\partial E}=\frac1T,
\qquad
\frac{\partial S_{\mathcal R}}{\partial N}=-\frac{\mu}{T}.
$$

Both are properties of the reservoir alone, hence constants that the reservoir
imposes on the system. Writing $\beta=1/k_BT$, the reservoir count reduces to a
weight on the system microstate,

$$
P(s)\;\propto\;\exp\!\big[-\beta(E_s-\mu N_s)\big].
$$

$$
% caption: A rigid wall permeable to both energy and particles couples the system to a reservoir that fixes $T$ and $\mu$; the reservoir is large enough that finite exchanges leave its temperature and chemical potential unchanged.
\begin{tikzpicture}[>=Latex,font=\footnotesize,scale=1.0]
\definecolor{acc}{HTML}{4A6FA5}
\fill[acc!10] (0,0) rectangle (2.6,2.6);
\draw[acc,thick] (0,0) rectangle (2.6,2.6);
\node[acc] at (1.3,2.2) {system};
\node at (1.3,1.3) {$E_s,\,N_s$};
\fill[black] (3.3,-0.5) rectangle (7.9,3.1);
\draw[black,thick] (3.3,-0.5) rectangle (7.9,3.1);
\node[black!70] at (5.6,2.6) {reservoir};
\node[align=center] at (5.6,1.3) {holds $T$ and\\chemical potential};
\draw[black,thick] (2.6,0.15)--(3.3,0.15)--(3.3,2.85)--(2.6,2.85);
\draw[<->,acc,thick] (2.75,1.9)--(3.15,1.9);
\node[black!70,above,font=\scriptsize] at (2.95,1.95) {energy};
\draw[<->,black,thick] (2.75,0.9)--(3.15,0.9);
\node[black!70,below,font=\scriptsize] at (2.95,0.85) {particles};
\end{tikzpicture}
$$

## The Gibbs factor

The exponential weight is the two-variable analogue of the Boltzmann factor.

> **Definition (Gibbs factor).** For a system that exchanges energy and
> particles with a reservoir at temperature $T$ and chemical potential $\mu$, the
> unnormalized probability of a microstate $s$ with energy $E_s$ and particle
> number $N_s$ is the **Gibbs factor**
> $$\exp\!\big[-\beta(E_s-\mu N_s)\big]=e^{-\beta E_s}\,e^{\beta\mu N_s}.$$

The Gibbs factor differs from the Boltzmann factor $e^{-\beta E_s}$ by the extra
weight $e^{\beta\mu N_s}$. Raising $\mu$ multiplies the weight of every
particle-carrying state, favoring microstates with more particles; lowering it
favors emptier states. The chemical potential is the reservoir's control knob on
the system's population, precisely as the temperature is its knob on the energy.
For a fixed particle number the Gibbs factor collapses to the Boltzmann factor,
so the canonical ensemble is the $N_s$-fixed section of the grand ensemble.

$$
% caption: At fixed particle number the Gibbs weight decays with energy like the Boltzmann factor; raising the particle number multiplies the whole curve by $e^{\beta\mu N}$, which for $\mu<0$ suppresses the higher-$N$ curves.
\begin{tikzpicture}[>=Latex,font=\footnotesize,scale=1.0]
\definecolor{acc}{HTML}{4A6FA5}
\draw[->,black] (0,0)--(7.2,0) node[right,black]{$E$};
\draw[->,black] (0,0)--(0,4.0) node[above,black]{Gibbs weight};
\draw[black,very thick,dashed] plot[domain=0:6.8,samples=70] (\x,{3.6*exp(-0.5*\x)});
\draw[acc,very thick] plot[domain=0:6.8,samples=70] (\x,{2.3*exp(-0.5*\x)});
\draw[black,very thick,densely dotted] plot[domain=0:6.8,samples=70] (\x,{1.4*exp(-0.5*\x)});
\node[black,right] at (2.5,{3.6*exp(-0.5*2.5)+0.3}) {$N=1$};
\node[acc,right] at (3.0,{2.3*exp(-0.5*3.0)+0.28}) {$N=2$};
\node[black,right] at (3.6,{1.4*exp(-0.5*3.6)+0.26}) {$N=3$};
\end{tikzpicture}
$$

## The grand partition function

Normalizing the Gibbs factor requires summing it over every microstate the
system can occupy — over all particle numbers, and for each particle number over
all microstates of that many particles.

> **Definition (Grand partition function).** The normalizing sum of the Gibbs
> factor over all microstates is
> $$
> \Xi(T,V,\mu)=\sum_{s}e^{-\beta(E_s-\mu N_s)}
> =\sum_{N=0}^{\infty}e^{\beta\mu N}\sum_{s(N)}e^{-\beta E_{s(N)}},
> $$
> where the inner sum runs over the microstates $s(N)$ of exactly $N$ particles.
> The probability of microstate $s$ is $P(s)=\Xi^{-1}e^{-\beta(E_s-\mu N_s)}$.

The double sum factorizes the counting cleanly. The inner sum over the
$N$-particle microstates is the canonical partition function $Z(N,V,T)$ studied
in the previous module,[^canon] so the grand partition function is a
$\mu$-weighted sum of canonical partition functions,

$$
\Xi(T,V,\mu)=\sum_{N=0}^{\infty}e^{\beta\mu N}\,Z(N,V,T).
$$

This makes $\Xi$ a generating function: it packages the canonical partition
functions of every particle number into one object, with $e^{\beta\mu}$ marking
the particle number as a bookkeeping variable. Fixing $\mu$ selects a
distribution over $N$ rather than a single value, which is the whole point of
opening the system to particle exchange.

$$
% caption: The grand sum is organized by particle number: each block $N$ contributes its canonical partition function $Z(N,V,T)$ weighted by the fugacity power $z^N=e^{\beta\mu N}$, and the blocks are summed over all $N$.
\begin{tikzpicture}[>=Latex,font=\footnotesize,scale=1.0]
\definecolor{acc}{HTML}{4A6FA5}
\foreach \i/\lab in {0/{N=0},1/{N=1},2/{N=2},3/{N=3}}{
  \draw[acc,thick,fill=acc!8] (\i*1.8,0) rectangle (\i*1.8+1.4,1.5);
  \node[acc] at (\i*1.8+0.7,1.2) {\lab};
  \node at (\i*1.8+0.7,0.55) {$Z(\i)$};
}
\node[black!70] at (0.7,-0.55) {$1$};
\node[black!70] at (2.5,-0.55) {$z$};
\node[black!70] at (4.3,-0.55) {$z^2$};
\node[black!70] at (6.1,-0.55) {$z^3$};
\node[black!70] at (7.8,0.75) {$+\ \cdots$};
\node[black!70,align=center,font=\scriptsize] at (3.4,-1.3) {weight $z^N$ per block};
\end{tikzpicture}
$$

## Fugacity

The weight $e^{\beta\mu}$ appears once per particle, so it is convenient to name
it.

> **Definition (Fugacity).** The **fugacity** (or absolute activity) is
> $z=e^{\beta\mu}$. In terms of it the grand partition function is a power series
> in the particle number,
> $$\Xi(T,V,z)=\sum_{N=0}^{\infty}z^{N}\,Z(N,V,T).$$

Written this way $\Xi$ is a polynomial (or power series) in $z$ whose coefficient
of $z^N$ is the $N$-particle canonical partition function. The fugacity runs from
$0$ (the empty limit $\mu\to-\infty$, where only the $N=0$ term survives) upward;
$z=1$ marks $\mu=0$. For the classical gases of the next lesson $z$ stays small,
and the low-order terms of the series dominate; for the quantum gases of the
following module $z$ is the natural expansion variable in which the Bose and
Fermi occupation functions are written. The fugacity is the same control knob as
$\mu$, rescaled to enter as a simple multiplicative activity per particle.

## The grand potential

The bridge to thermodynamics is the logarithm of the grand partition function,
exactly as $F=-k_BT\ln Z$ bridges the canonical ensemble.

> **Definition (Grand potential).** The **grand potential** is
> $$\Phi(T,V,\mu)=-k_BT\ln\Xi(T,V,\mu).$$
> It is the thermodynamic potential natural to the variables $T$, $V$, and
> $\mu$.

To connect $\Phi$ to the potentials already in hand, start from the Helmholtz
free energy $F=U-TS$ and subtract the particle term. The grand potential is the
double Legendre transform of the energy that trades $S$ for $T$ and $N$ for
$\mu$,

$$
\Phi=U-TS-\mu N=F-\mu N.
$$

Its differential follows from the fundamental relation
$\d U=T\,\d S-P\,\d V+\mu\,\d N$. Substituting $U=\Phi+TS+\mu N$ and cancelling
gives

$$
\d\Phi=-S\,\d T-P\,\d V-N\,\d\mu.
$$

The natural variables are read off the differential: $\Phi$ is a function of
$T$, $V$, and $\mu$, and its three first derivatives return the entropy,
pressure, and particle number,

$$
S=-\Big(\frac{\partial\Phi}{\partial T}\Big)_{V,\mu},
\qquad
P=-\Big(\frac{\partial\Phi}{\partial V}\Big)_{T,\mu},
\qquad
N=-\Big(\frac{\partial\Phi}{\partial\mu}\Big)_{T,V}.
$$

## The grand potential is $-PV$

The three natural variables of $\Phi$ are $T$, $V$, and $\mu$, of which only $V$
is extensive. Doubling the system at fixed $T$ and $\mu$ doubles $\Phi$ and
doubles $V$, so $\Phi$ must be proportional to $V$ with a coefficient built from
the intensive variables alone.

> **Theorem (Grand potential and pressure).** The grand potential of any bulk
> system equals minus the pressure times the volume,
> $$
> \Phi(T,V,\mu)=-P(T,\mu)\,V,\qquad\text{equivalently}\qquad
> PV=k_BT\ln\Xi.
> $$

> **Proof.** $\Phi(T,V,\mu)$ is extensive and its only extensive argument is
> $V$, so it is a first-degree homogeneous function of $V$ alone:
> $\Phi(T,\lambda V,\mu)=\lambda\,\Phi(T,V,\mu)$. Euler's theorem for such a
> function gives $\Phi=V(\partial\Phi/\partial V)_{T,\mu}$. The volume derivative
> is $-P$ by the differential of $\Phi$, hence $\Phi=-PV$. Equating this to the
> definition $\Phi=-k_BT\ln\Xi$ gives $PV=k_BT\ln\Xi$. The same conclusion
> follows from the Euler relation $U=TS-PV+\mu N$: substituting into
> $\Phi=U-TS-\mu N$ leaves $\Phi=-PV$.

The relation $PV=k_BT\ln\Xi$ is the grand-ensemble counterpart of $F=-k_BT\ln Z$
and is often the fastest route to an equation of state: compute $\ln\Xi$, read
off the pressure directly, and obtain the density from
$N=-\partial\Phi/\partial\mu$.

## Mean energy and particle number

The averages come from derivatives of $\ln\Xi$, mirroring the canonical
construction. Treat $\ln\Xi$ as a function of $\beta$ and the product $\beta\mu$;
each derivative pulls down the corresponding quantity from the Gibbs exponent.
The mean particle number is the derivative with respect to $\mu$ at fixed
temperature,

$$
\langle N\rangle=\sum_s N_s\,P(s)
=\frac{1}{\beta}\Big(\frac{\partial\ln\Xi}{\partial\mu}\Big)_{T,V}
=z\,\frac{\partial\ln\Xi}{\partial z}.
$$

This agrees with $N=-\partial\Phi/\partial\mu$ once $\Phi=-k_BT\ln\Xi$ is
inserted. The mean energy is obtained by differentiating in $\beta$ at fixed
fugacity, which isolates the energy exponent,

$$
\langle E\rangle
=-\Big(\frac{\partial\ln\Xi}{\partial\beta}\Big)_{z,V}+\mu\langle N\rangle,
\qquad\text{equivalently}\qquad
\langle E\rangle-\mu\langle N\rangle
=-\Big(\frac{\partial\ln\Xi}{\partial\beta}\Big)_{\beta\mu,V}.
$$

The combination $\langle E\rangle-\mu\langle N\rangle$ is the quantity conjugate
to $\beta$ in the Gibbs exponent, so it emerges most naturally from the
$\beta$-derivative; the separate mean energy then follows by adding
$\mu\langle N\rangle$. The entropy closes the set through
$\Phi=\langle E\rangle-TS-\mu\langle N\rangle$, giving

$$
S=\frac{\langle E\rangle-\mu\langle N\rangle-\Phi}{T}
=k_B\ln\Xi+\frac{\langle E\rangle-\mu\langle N\rangle}{T}.
$$

$$
% caption: A single computation of $\ln\Xi$ delivers all of equilibrium thermodynamics: differentiating in $\mu$ gives the mean particle number $\langle N\rangle=\beta^{-1}\partial\ln\Xi/\partial\mu$, in $\beta$ the energy combination $\langle E\rangle-\mu\langle N\rangle$, in $V$ the pressure through $PV=k_BT\ln\Xi$, and in $T$ the entropy $S=-\partial\Phi/\partial T$.
\begin{tikzpicture}[>=Latex,font=\footnotesize,scale=1.0]
\definecolor{acc}{HTML}{4A6FA5}
\node[draw,acc,thick,fill=acc!10,minimum width=3.0cm,minimum height=1.0cm,align=center] (X) at (0,0) {log of grand\\sum};
\node[draw,black,thick,fill=black!5,minimum width=1.9cm,minimum height=0.9cm] (N) at (-4.3,1.9) {mean $N$};
\node[draw,black,thick,fill=black!5,minimum width=1.9cm,minimum height=0.9cm] (E) at (-1.5,2.6) {mean $E$};
\node[draw,black,thick,fill=black!5,minimum width=1.5cm,minimum height=0.9cm] (P) at (1.5,2.6) {pressure};
\node[draw,black,thick,fill=black!5,minimum width=1.5cm,minimum height=0.9cm] (S) at (4.3,1.9) {entropy};
\draw[->,black,thick] (X)--(N);
\draw[->,black,thick] (X)--(E);
\draw[->,black,thick] (X)--(P);
\draw[->,black,thick] (X)--(S);
\end{tikzpicture}
$$

## When the grand ensemble is the right choice

The three ensembles predict the same thermodynamics for a macroscopic system, so
the choice among them is a matter of which calculation is easiest. The grand
canonical ensemble is the convenient one whenever the constraint of fixed
particle number obstructs the sum.

- **Quantum ideal gases.** Counting configurations of indistinguishable bosons
  or fermions at fixed total $N$ ties the single-particle occupation numbers
  together through $\sum_i n_i=N$. Releasing $N$ decouples the modes: the grand
  partition function factorizes over single-particle states, and each mode is
  summed independently. This is the derivation of the Bose-Einstein and
  Fermi-Dirac distributions in the next module.
- **Adsorption and chemical equilibrium.** Surfaces, binding sites, and reacting
  species exchange particles with a bath at fixed $\mu$; the equilibrium
  occupation follows directly from the Gibbs factor.
- **Open subvolumes and fluctuations.** A region of a fluid with imaginary walls
  exchanges particles with the surrounding fluid; the grand ensemble is the
  natural setting for density fluctuations, taken up in the next lesson.

> **Worked example.** A single adsorption site on a surface is either empty, with
> energy $0$ and $N=0$, or holds one molecule from a vapor at temperature $T$ and
> chemical potential $\mu$, with binding energy $-\varepsilon$ and $N=1$. The
> grand partition function has two terms,
> $$\Xi=1+e^{-\beta(-\varepsilon-\mu)}=1+e^{\beta(\varepsilon+\mu)}.$$
> The mean occupation is the probability the site is filled,
> $$
> \langle N\rangle=\frac{1}{\beta}\frac{\partial\ln\Xi}{\partial\mu}
> =\frac{e^{\beta(\varepsilon+\mu)}}{1+e^{\beta(\varepsilon+\mu)}}
> =\frac{1}{e^{-\beta(\varepsilon+\mu)}+1}.
> $$
> The occupation is the Fermi-Dirac form, a consequence of the site holding at
> most one molecule. It rises from $0$ at low vapor chemical potential to $1$ at
> high $\mu$, crossing one-half when $\mu=-\varepsilon$, the value at which the
> cost of binding balances the reservoir's supply. This Langmuir isotherm is the
> grand-ensemble calculation in its simplest nontrivial form.

## Summary

- A system exchanging energy and particles with a reservoir at fixed $T$ and
  $\mu$ has microstate probability set by the **Gibbs factor**
  $e^{-\beta(E_s-\mu N_s)}$, obtained by expanding the reservoir entropy to first
  order in $E_s$ and $N_s$ with $\partial S_{\mathcal R}/\partial E=1/T$ and
  $\partial S_{\mathcal R}/\partial N=-\mu/T$.
- The **grand partition function**
  $\Xi=\sum_N e^{\beta\mu N}Z(N,V,T)=\sum_N z^N Z(N,V,T)$ normalizes the Gibbs
  factor; it is a generating function in the fugacity $z=e^{\beta\mu}$ whose
  $z^N$ coefficient is the canonical partition function of $N$ particles.
- The **grand potential** $\Phi=-k_BT\ln\Xi=F-\mu N$ has differential
  $\d\Phi=-S\,\d T-P\,\d V-N\,\d\mu$, so $S$, $P$, and $N$ follow by
  differentiation. Because $V$ is its only extensive variable, $\Phi=-PV$, giving
  $PV=k_BT\ln\Xi$.
- Averages come from derivatives of $\ln\Xi$:
  $\langle N\rangle=z\,\partial\ln\Xi/\partial z$ and
  $\langle E\rangle-\mu\langle N\rangle=-\partial\ln\Xi/\partial\beta$. The grand
  ensemble is the tool of choice when fixed $N$ obstructs the sum, above all for
  the quantum ideal gases.

[^micro]: **Reif**, _Fundamentals of Statistical and Thermal Physics_, §9.1–9.3, and the microcanonical definitions $1/T=(\partial S/\partial E)_{V,N}$ and $\mu=-T(\partial S/\partial N)_{E,V}$ established in the [thermal, mechanical, and diffusive equilibrium lesson](/statistical-mechanics/microcanonical/equilibrium-conditions-temperature-pressure-chemical-potential).
[^canon]: The canonical partition function $Z(N,V,T)=\sum_{s(N)}e^{-\beta E_{s(N)}}$ and the bridge $F=-k_BT\ln Z$ are developed in the [partition function and Helmholtz free energy lesson](/statistical-mechanics/canonical/partition-function-and-the-helmholtz-free-energy). **Schroeder**, _An Introduction to Thermal Physics_, §7.1; companion material at <https://physics.weber.edu/schroeder/thermal/>. **Kardar**, _Statistical Physics of Particles_, §4.9; MIT OCW 8.333, <https://ocw.mit.edu/courses/8-333-statistical-mechanics-i-statistical-mechanics-of-particles-fall-2013/>. **Pathria & Beale**, _Statistical Mechanics_ (4th ed.), §4.1–4.4.
