HomeArticlesGibbs Ensemble

Why Heat Flows the Way It Does: A Counting Argument

Entropy is nothing more than the logarithm of how many ways energy can be arranged, and that single fact explains why heat flows from hot to cold and why the Boltzmann distribution appears on its own.

mysimulator teamUpdated June 2026≈ 8 min read▶ Open the simulation

Counting arrangements instead of tracking every atom

Statistical mechanics answers a question that would otherwise be hopeless: given roughly 10²³ particles in a gas, what does the system look like on average, without tracking every single trajectory? The trick, going back to Boltzmann and Gibbs, is to stop asking about any one particle and instead count how many distinct microscopic arrangements — called microstates — correspond to the same macroscopic description. A simple toy version of this, the one this simulation renders directly, distributes a fixed number of indistinguishable energy quanta q among a fixed number of independent oscillators N, keeping the total energy constant — the defining condition of the microcanonical ensemble.

live demo · energy quanta redistributing among oscillators toward the Boltzmann shape● LIVE

Counting the arrangements: the multiplicity function

For q indistinguishable quanta spread across N distinguishable oscillators, the number of distinct ways to do it — the multiplicity, Ω — is a standard combinatorics result, "stars and bars":

Ω(N, q) = (q + N − 1)! / [ q! · (N − 1)! ]
S = k · ln Ω                         (Boltzmann's entropy formula)

That last line, carved on Boltzmann's tombstone in Vienna, is the bridge from pure counting to thermodynamics: entropy S is simply the logarithm of the number of microscopic arrangements consistent with the system's macroscopic state, scaled by the Boltzmann constant k. A system with more ways to arrange its energy has higher entropy, full stop — nothing about heat or disorder needs to be invoked as a separate concept, it falls straight out of counting.

Two blocks in contact: why energy flows the way it does

Put two blocks of oscillators in thermal contact, block A with N₁ oscillators and block B with N₂, sharing a fixed total of q quanta between them, and let the quanta hop randomly between blocks while the total stays fixed. The combined multiplicity for any given split (q₁ quanta in A, q₂ = q − q₁ in B) is Ω_total = Ω(N₁, q₁) · Ω(N₂, q₂), and because this product is astronomically peaked around one particular split once N and q are large, the system overwhelmingly tends to drift toward whichever split maximises Ω_total — not because of any force pushing quanta from one block to the other, but simply because that split corresponds to vastly more arrangements than any other. This is the second law of thermodynamics, in its most literal form: entropy increases because high-entropy configurations vastly outnumber low-entropy ones, so a system exploring its arrangements randomly is overwhelmingly likely to end up in one of them.

Temperature falls out of the counting too

Temperature itself has a definition purely in terms of Ω: 1/T = (∂S/∂E) at fixed volume and particle number — how steeply entropy rises as you feed the system a little more energy. Two systems in thermal contact reach equilibrium exactly when their temperatures, defined this way, match, which is equivalent to saying Ω_total is at its maximum with respect to how the quanta are split. This is a much deeper foundation for the everyday notion of temperature than "how hot something feels" — it's a statement about the curvature of a counting function.

The Boltzmann distribution emerges from the crowd

Zoom in on a single oscillator embedded in a huge reservoir of the others, and ask for the probability that this one oscillator holds exactly n quanta. Because the rest of the reservoir must absorb whatever energy this oscillator doesn't have, and the reservoir's multiplicity function is exponentially sensitive to how much energy it's given, the probability of the tagged oscillator having energy E works out to be proportional to e^(−E/kT) — the Boltzmann distribution. It is not an extra assumption bolted onto the model: it is the direct, inevitable consequence of maximising the total number of arrangements when one small part of a system exchanges energy with a much larger reservoir.

What the simulation shows happening live

Starting from an artificial, ordered arrangement (all quanta piled onto one oscillator), the simulation lets quanta hop randomly between neighbouring oscillators subject to keeping the total energy fixed, and you can watch the occupation histogram relax, quanta by quanta, from that spike into the smooth decaying exponential shape of the Boltzmann distribution — entropy climbing toward its maximum the entire way, exactly as the counting argument above predicts.

Frequently asked questions

What does entropy actually mean in this model?

Entropy is defined as k times the natural log of the multiplicity, the number of distinct microscopic ways the energy quanta can be arranged among the oscillators for a given total energy. A configuration with more possible arrangements has higher entropy; nothing about heat or disorder needs to be added as a separate idea.

Why does energy flow from a hot block to a cold block instead of the other way?

The combined multiplicity of two blocks in contact is sharply peaked around whichever split of quanta maximizes the total number of arrangements. Since that peak corresponds to overwhelmingly more microstates than any other split, the system is statistically almost certain to drift toward it, which is what appears macroscopically as heat flowing from hot to cold.

Where does the Boltzmann distribution come from in this simulation?

It emerges automatically once you look at a single oscillator connected to a large reservoir of many others. Because the reservoir's own multiplicity grows so quickly with the energy it's given, the probability of the tagged oscillator holding a given amount of energy works out to be proportional to an exponential decay, e to the power minus energy over kT, without needing to assume it in advance.

Try it live

Everything above runs in your browser — open Gibbs Ensemble and change the parameters while it is running. Nothing is installed, nothing is uploaded, the whole model lives in one tab.

▶ Open Gibbs Ensemble simulation

What did you find?

Add reproduction steps (optional)