TNK LAB

Thermal Contact & Entropy

Two boxes of gas — modeled as Einstein solids of NA and NB independent oscillators — share a fixed pool of Q energy quanta through a shared wall. Each step, one quantum attempts to hop across; whether it succeeds depends on how many more ways the combined system has to arrange itself afterward. Watch temperature equalize and total entropy climb toward its maximum.

State

Exchange Attempts: 0

qA (quanta in A): -
qB (quanta in B): -
TA (ħω/kB): -
TB (ħω/kB): -

Entropy (units of kB)

Stotal = ln ΩAΩB: -
Smax (true peak): -
Fraction of Smax reached: -

How This Is Calculated

$$\Omega(N,q) = \binom{q+N-1}{q}, \qquad S = k_B \ln\big(\Omega_A \Omega_B\big)$$
Ω(N,q) is the number of ways to share q indistinguishable quanta among N distinguishable oscillators (stars and bars). Statistical temperature follows from $$\frac{1}{T} = \frac{\partial S}{\partial q} \approx \ln\Omega(N,q{+}1) - \ln\Omega(N,q)$$
Each attempted hop proposes moving one quantum A→B or B→A with 50/50 prior probability, then accepts with probability min(1, Ωnewold) — a Metropolis step. This is deliberate: a naive model where every existing quantum is equally likely to jump (the classic "flea circus") always settles at qA=Q/2 regardless of NA, NB — equal energy, not equal temperature. That's the same class of bug as an equal-volume assumption in a diffusion model: it's only correct when NA=NB. Weighting by Ω is what makes the walk settle at qA/NA ≈ qB/NB instead — true thermal equilibrium.
Why does entropy increase?
Ωtotal(qA) = Ω(NA,qA)·Ω(NB,Q−qA) counts every microstate consistent with a given split. For large N and Q this product is astronomically peaked at one particular split — the one where TA=TB. Almost every microstate the combined system could possibly be in belongs to that peak.
No individual hop "knows" this. Each one is a local, reversible coin flip weighted only by the immediate Ω ratio — hops toward lower S do happen, just exponentially less often as N grows. What looks like an irreversible, one-directional climb in Stotal(t) is really millions of small reversible steps whose net statistical bias is overwhelming. That's the Second Law as a probability statement, not a mechanical rule.
Try setting NA and NB far apart with a small Q — the entropy curve gets visibly noisier and can dip, because the peak in Ωtotal isn't sharp when the system is small.

Two Boxes of Gas

Cold
Warm
Hot
Dot color/jitter ≈ local temperature — not a real gas trajectory.

Temperature vs. Time

TA
TB

Total Entropy vs. Time

Stotal(t)
Smax (true peak)

Entropy Landscape Stotal(qA)

All accessible splits
Current qA