---
title: Thermal, Mechanical, and Diffusive Equilibrium
module: The Microcanonical Ensemble
moduleNumber: 3
lessonNumber: 2
order: 302
summary: >
  Two isolated subsystems that can exchange energy, volume, or particles reach
  equilibrium at the partition that maximizes their combined entropy. Setting the
  derivative of the total entropy to zero identifies the statistical definitions
  $1/T=(\partial S/\partial E)$, $P/T=(\partial S/\partial V)$, and
  $-\mu/T=(\partial S/\partial N)$, shows heat flows from hot to cold as an
  entropy increase, and recovers the fundamental relation
  $\d S=(\d E+P\,\d V-\mu\,\d N)/T$ from pure counting.
topics: [The Microcanonical Ensemble]
sources:
  - book: Schroeder
    ref: "Ch. 2 — The Second Law; §2.3–2.4, and Ch. 3 — Interactions and Implications; §3.1, 3.4, 3.5"
  - book: Reif
    ref: "Ch. 3 — Statistical Thermodynamics; §3.9–3.12"
  - book: Kardar (Statistical Physics of Particles)
    ref: "Ch. 4 — Classical Statistical Mechanics; §4.4"
draft: false
---

The microcanonical entropy $S=k\ln\Omega$ is a function of the isolated system's
energy, volume, and particle number. Its derivatives with respect to these three
variables are not yet identified with any thermodynamic quantity. That
identification comes from a single construction: bring two systems into contact so
they can exchange one conserved quantity, and ask which partition of that quantity
between them is overwhelmingly the most probable. The answer maximizes the total
entropy, and the condition for the maximum defines temperature, pressure, and
chemical potential as slopes of $S$.

## Two systems sharing energy

Let two systems with fixed total energy $E=E_1+E_2$, each of fixed volume and
particle number, be placed in thermal contact through a rigid, impermeable wall
that passes energy but not particles or volume. The composite is isolated, so its
total energy is conserved while $E_1$ and $E_2$ fluctuate. The number of joint
microstates with the first system at energy $E_1$ is the product of the individual
counts,
$$
\Omega_{\text{tot}}(E_1) = \Omega_1(E_1)\,\Omega_2(E-E_1),
$$
because each of the $\Omega_1(E_1)$ microstates of system 1 can pair with each of
the $\Omega_2(E-E_1)$ microstates of system 2. By the fundamental postulate every
joint microstate is equally likely, so the probability that system 1 holds energy
$E_1$ is proportional to this product,
$$
P(E_1) \propto \Omega_1(E_1)\,\Omega_2(E-E_1).
$$

Each factor is a steeply rising function of its argument — recall
$\Omega\propto E^{\alpha N}$ — so the product of a sharply rising function and a
sharply falling one is sharply peaked. The most probable partition $E_1^\ast$
maximizes $P(E_1)$, equivalently maximizes $\ln P$, and equivalently maximizes the
total entropy $S_{\text{tot}}=S_1(E_1)+S_2(E-E_1)$.

$$
% caption: The joint count $\Omega_1(E_1)\Omega_2(E-E_1)$ is the product of a steeply rising and a steeply falling factor, giving a probability $P(E_1)$ sharply peaked at the equilibrium partition $E_1^\ast$.
\begin{tikzpicture}[>=Latex,font=\footnotesize,scale=1.0]
\definecolor{acc}{HTML}{4A6FA5}
\draw[->,black] (0,0)--(6.2,0) node[right,black]{$E_1$};
\draw[->,black] (0,0)--(0,4.2) node[above,black]{value};
\draw[acc,very thick] plot[domain=0.3:5.6,samples=60] (\x,{0.10*(\x)^(2.4)});
\node[acc] at (5.3,3.55) {count of 1};
\draw[black,very thick,densely dashed] plot[domain=0.4:5.7,samples=60] (\x,{0.10*(6.0-\x)^(2.4)});
\node[black] at (1.05,3.55) {count of 2};
\draw[black,very thick] plot[domain=1.3:4.7,samples=60] (\x,{2.6*exp(-2.4*(\x-3.0)^2)+0.15});
\node[black] at (3.0,3.1) {$P(E_1)$};
\draw[black,dashed] (3.0,0)--(3.0,2.75);
\node[black,below] at (3.0,0) {best split};
\end{tikzpicture}
$$

## Thermal equilibrium defines temperature

At the peak the derivative of the total entropy vanishes. Differentiating
$S_{\text{tot}}=S_1(E_1)+S_2(E-E_1)$ with respect to $E_1$ at fixed total energy,
and using $\d E_2/\d E_1=-1$,
$$
\frac{\d S_{\text{tot}}}{\d E_1}
= \frac{\partial S_1}{\partial E_1}\Big|_{V_1,N_1}
- \frac{\partial S_2}{\partial E_2}\Big|_{V_2,N_2}
= 0,
$$
so equilibrium requires the two systems to share a common value of
$\partial S/\partial E$. This slope is the same quantity that thermodynamics calls
inverse temperature, since $\d S=\delta Q_{\text{rev}}/T$ at fixed volume and
particle number gives $\partial S/\partial E=1/T$.

> **Definition (Statistical temperature).** The absolute temperature of an
> isolated system is fixed by
> $$
> \frac{1}{T} = \left(\frac{\partial S}{\partial E}\right)_{V,N}
> = k\left(\frac{\partial \ln\Omega}{\partial E}\right)_{V,N}.
> $$

Thermal equilibrium is the statement $T_1=T_2$. The definition inverts the usual
intuition: temperature is not primary but derived, the reciprocal of the rate at
which the log of the microstate count grows with energy. A system whose count rises
steeply with energy — many new microstates unlocked per joule added — has a small
$1/T$, meaning a high temperature, and readily surrenders energy. This is exactly
the property expected of a hot body.

$$
% caption: Two systems sharing energy through a diathermal wall reach the partition where the two entropy–energy slopes $\partial S_1/\partial E_1$ and $\partial S_2/\partial E_2$ are equal, that is, where $T_1=T_2$.
\begin{tikzpicture}[>=Latex,font=\footnotesize,scale=1.0]
\definecolor{acc}{HTML}{4A6FA5}
\draw[acc,very thick,fill=acc!10] (0,0) rectangle (2.6,2.2);
\node[acc] at (1.3,1.6) {system 1};
\node[black] at (1.3,0.9) {$E_1$, $T_1$};
\draw[black,very thick,fill=black!6] (2.6,0) rectangle (5.2,2.2);
\node[black] at (3.9,1.6) {system 2};
\node[black] at (3.9,0.9) {$E_2$, $T_2$};
\draw[black,very thick] (2.6,-0.15)--(2.6,2.35);
\node[black,align=center] at (2.6,-0.55) {diathermal wall};
\draw[<->,black,very thick] (2.15,1.85)--(3.05,1.85);
\node[black,align=left] at (7.6,1.55) {energy moves until};
\node[black,align=left] at (7.15,0.85) {$T_1=T_2$};
\end{tikzpicture}
$$

## Heat flows from hot to cold

Suppose the two systems start out of equilibrium, with $T_1<T_2$. The total
entropy is not yet at its maximum, so a spontaneous exchange must increase it. For
a small transfer $\d E_1$ of energy into system 1,
$$
\d S_{\text{tot}}
= \left(\frac{\partial S_1}{\partial E_1}-\frac{\partial S_2}{\partial E_2}\right)\d E_1
= \left(\frac{1}{T_1}-\frac{1}{T_2}\right)\d E_1.
$$
With $T_1<T_2$ the prefactor $1/T_1-1/T_2$ is positive, so $\d S_{\text{tot}}>0$
requires $\d E_1>0$: energy flows into the colder system. The second law, in the
microcanonical setting, is the statement that the composite drifts toward the
partition of larger multiplicity, and that drift carries energy from the hot body
to the cold one until the temperatures match. No new postulate is needed; the
direction of heat flow is a corollary of counting microstates.

The sharpness of the peak guarantees that this is not merely the average behavior
but the observed behavior. Expanding $\ln P(E_1)$ about $E_1^\ast$, the linear term
vanishes at the maximum and the quadratic term sets the width. The relative width
of the energy distribution scales as $N^{-1/2}$, so departures from the
most-probable partition are negligible, which is why the sharpest peak and the
thermodynamic equilibrium are the same thing.

> **Worked example.** Two equal samples of a monatomic ideal gas, each of $N$
> particles, share a fixed total energy $E$ through a diathermal wall. Each sample
> has $\Omega_i\propto E_i^{3N/2}$, so
> $$\ln P(E_1) = \frac{3N}{2}\big[\ln E_1 + \ln(E-E_1)\big] + \text{const},$$
> which is maximized at $E_1^\ast=E/2$, an equal split. The width follows from the
> second derivative at the peak,
> $$
> \frac{\d^2\ln P}{\d E_1^2}\bigg|_{E/2}
> = -\frac{3N}{2}\left(\frac{1}{E_1^2}+\frac{1}{(E-E_1)^2}\right)\bigg|_{E/2}
> = -\frac{12N}{E^2},
> $$
> so the Gaussian variance is
> $\sigma^2=-(\d^2\ln P/\d E_1^2)^{-1}=E^2/12N$ and the relative fluctuation is
> $$\frac{\sigma}{E_1^\ast} = \frac{E/\sqrt{12N}}{E/2} = \frac{1}{\sqrt{3N}}.$$
> For a macroscopic $N\sim10^{22}$ this is
> $1/\sqrt{3\times10^{22}}\approx6\times10^{-12}$: the energy of each half is fixed
> to eleven decimal places by counting alone, which is why the equilibrium value is
> the only value ever observed.

$$
% caption: Starting from $T_1<T_2$, the total entropy rises along the exchange until its maximum at $T_1=T_2$; the initial slope $1/T_1-1/T_2>0$ fixes the direction of spontaneous heat flow into the colder system.
\begin{tikzpicture}[>=Latex,font=\footnotesize,scale=1.0]
\definecolor{acc}{HTML}{4A6FA5}
\draw[->,black] (0,0)--(6.2,0) node[right,black]{$E_1$};
\draw[->,black] (0,0)--(0,4.0) node[above,black]{$S_{\rm tot}$};
\draw[acc,very thick] plot[domain=0.4:5.7,samples=60] (\x,{3.4-0.34*(\x-3.4)^2});
\filldraw[black] (3.4,3.4) circle (1.8pt);
\node[black,above right] at (3.4,3.4) {maximum: $T_1=T_2$};
\filldraw[black] (1.5,{3.4-0.34*(1.5-3.4)^2}) circle (1.8pt);
\node[black,below] at (1.5,1.05) {start: $T_1<T_2$};
\draw[->,black,very thick] (1.75,1.85)--(2.7,2.75);
\node[black] at (2.75,1.75) {heat into 1};
\end{tikzpicture}
$$

## Mechanical and diffusive equilibrium

Replacing the rigid wall by a movable one, or by a permeable one, extends the
construction to volume and particle exchange. A movable wall lets the two systems
trade volume at fixed total $V=V_1+V_2$ while total energy and particle number stay
fixed. The total entropy $S_{\text{tot}}(E_1,V_1)=S_1(E_1,V_1)+S_2(E-E_1,V-V_1)$ is
maximized when its partial derivatives with respect to both $E_1$ and $V_1$ vanish.
The energy condition again gives $T_1=T_2$; the volume condition gives
$$
\frac{\partial S_1}{\partial V_1}\Big|_{E_1,N_1}
= \frac{\partial S_2}{\partial V_2}\Big|_{E_2,N_2}.
$$
Comparison with the thermodynamic relation $\d S=(\d E+P\,\d V)/T$ at fixed energy
and particle number identifies this slope with $P/T$.

> **Definition (Statistical pressure).** The pressure of an isolated system is
> fixed by
> $$\frac{P}{T} = \left(\frac{\partial S}{\partial V}\right)_{E,N}.$$

Mechanical equilibrium across a movable diathermal wall is therefore $T_1=T_2$ and
$P_1=P_2$: temperatures equalize and the wall stops moving when the pressures
balance. Were the pressures unequal, entropy would increase by ceding volume to the
system with the larger $P/T$, and the wall would drift until they matched.

A permeable wall lets the two systems exchange particles at fixed total
$N=N_1+N_2$. Maximizing $S_{\text{tot}}$ with respect to $N_1$ adds the condition
$\partial S_1/\partial N_1=\partial S_2/\partial N_2$, and the thermodynamic
relation $\d S=(\d E+P\,\d V-\mu\,\d N)/T$ identifies this slope with $-\mu/T$.

> **Definition (Chemical potential).** The chemical potential of an isolated
> system is fixed by
> $$\frac{\mu}{T} = -\left(\frac{\partial S}{\partial N}\right)_{E,V}.$$

Diffusive equilibrium is $\mu_1=\mu_2$ (with $T_1=T_2$ already enforced by energy
exchange). Particles flow from high chemical potential to low: if $\mu_1>\mu_2$,
moving a particle from 1 to 2 raises the total entropy, so the net current runs
until the chemical potentials equalize. The minus sign makes $\mu$ the energy cost
of adding a particle rather than a gain, so a particle migrates toward the region
where it is cheaper to place.

$$
% caption: Three walls and three equilibrium conditions: a diathermal wall (energy) equalizes temperature $T_1=T_2$, a movable wall (volume) equalizes pressure $P_1=P_2$, and a permeable wall (particles) equalizes chemical potential $\mu_1=\mu_2$, each from maximizing the total entropy over the shared quantity.
\begin{tikzpicture}[>=Latex,font=\footnotesize,scale=1.0]
\definecolor{acc}{HTML}{4A6FA5}
\draw[black,very thick] (0,0) rectangle (3.0,1.5);
\draw[acc,very thick] (1.5,0)--(1.5,1.5);
\node[black] at (1.5,-0.4) {energy};
\node[black] at (1.5,1.95) {thermal};
\draw[black,very thick] (4.0,0) rectangle (7.0,1.5);
\draw[acc,very thick] (5.5,0)--(5.5,1.5);
\draw[->,acc] (5.2,0.75)--(5.8,0.75);
\node[black] at (5.5,-0.4) {volume};
\node[black] at (5.5,1.95) {mechanical};
\draw[black,very thick] (8.0,0) rectangle (11.0,1.5);
\draw[acc,very thick,dashed] (9.5,0)--(9.5,1.5);
\filldraw[acc] (9.15,0.75) circle (1.4pt);
\draw[->,acc] (9.25,0.9)--(9.75,0.9);
\node[black] at (9.5,-0.4) {particles};
\node[black] at (9.5,1.95) {chemical};
\end{tikzpicture}
$$

## The fundamental relation recovered

The three definitions are the three partial derivatives of the entropy in its
natural variables. Assembling the total differential of $S(E,V,N)$,
$$
\d S = \left(\frac{\partial S}{\partial E}\right)_{V,N}\!\d E
+ \left(\frac{\partial S}{\partial V}\right)_{E,N}\!\d V
+ \left(\frac{\partial S}{\partial N}\right)_{E,V}\!\d N
= \frac{1}{T}\,\d E + \frac{P}{T}\,\d V - \frac{\mu}{T}\,\d N,
$$
and solving for $\d E$ gives the fundamental thermodynamic relation,
$$
\d E = T\,\d S - P\,\d V + \mu\,\d N.
$$
Every term on the right was constructed from a derivative of a microstate count.
The first law's $T\,\d S$, the mechanical work $-P\,\d V$, and the chemical work
$\mu\,\d N$ all emerge from the single requirement that an isolated composite
settles into its most probable partition. Thermodynamics is not assumed here; it is
the macroscopic shadow of the entropy-maximization principle applied to the
exchange of conserved quantities.

The construction also fixes the signs and the physical roles cleanly. Temperature
governs energy exchange and is positive whenever adding energy opens up more
microstates; pressure governs volume exchange and is positive whenever expansion
opens up more microstates; chemical potential governs particle exchange and is
typically negative for a dilute classical gas, where adding a particle at fixed
energy and volume increases the multiplicity, as the ideal-gas entropy of the next
lesson makes explicit.

$$
% caption: The three natural-variable derivatives of the entropy give $(\partial S/\partial E)_{V,N}=1/T$, $(\partial S/\partial V)_{E,N}=P/T$, and $(\partial S/\partial N)_{E,V}=-\mu/T$; assembled, they give the fundamental relation $\d E=T\,\d S-P\,\d V+\mu\,\d N$.
\begin{tikzpicture}[>=Latex,font=\footnotesize,scale=1.0]
\definecolor{acc}{HTML}{4A6FA5}
\draw[acc,very thick,fill=acc!8] (0,0.4) rectangle (2.8,3.2);
\node[acc] at (1.4,2.4) {entropy};
\node[black] at (1.4,1.5) {$S$($E$, $V$, $N$)};
\draw[->,black] (2.9,2.4)--(5.4,2.4) node[right,black]{temperature};
\draw[->,black] (2.9,1.7)--(5.4,1.7) node[right,black]{pressure};
\draw[->,black] (2.9,1.0)--(5.4,1.0) node[right,black]{chem. potential};
\node[black] at (4.15,2.65) {from $E$};
\node[black] at (4.15,1.95) {from $V$};
\node[black] at (4.15,1.25) {from $N$};
\end{tikzpicture}
$$

## Summary

- Two isolated systems exchanging a conserved quantity reach the partition that
  maximizes the total entropy $S_1+S_2$; the joint count $\Omega_1\Omega_2$ is
  sharply peaked, with relative width $\sim N^{-1/2}$, so the most-probable
  partition is the observed one.
- Energy exchange fixes $1/T=(\partial S/\partial E)_{V,N}$; equilibrium is
  $T_1=T_2$, and the entropy increase $\d S_{\text{tot}}=(1/T_1-1/T_2)\,\d E_1$
  sends heat from hot to cold.
- Volume exchange fixes $P/T=(\partial S/\partial V)_{E,N}$ and particle exchange
  fixes $-\mu/T=(\partial S/\partial N)_{E,V}$; the corresponding equilibria are
  $P_1=P_2$ and $\mu_1=\mu_2$.
- The three derivatives assemble into $\d E=T\,\d S-P\,\d V+\mu\,\d N$, so the
  fundamental relation of thermodynamics follows from maximizing a microstate
  count.

[^schroeder-eq]: Schroeder, _An Introduction to Thermal Physics_ (Addison-Wesley, 2000), Ch. 3 §3.1–3.5 defines temperature, pressure, and chemical potential as entropy derivatives; companion page <https://physics.weber.edu/schroeder/thermal/>.

[^reif-eq]: Reif, _Fundamentals of Statistical and Thermal Physics_ (Waveland reprint, 2009), Ch. 3 §3.9–3.12; the sharpness of the energy distribution and the equilibrium conditions are derived there. Kardar, _Statistical Physics of Particles_ (Cambridge, 2007), §4.4, MIT OCW 8.333, <https://ocw.mit.edu/courses/8-333-statistical-mechanics-i-statistical-mechanics-of-particles-fall-2013/>.
