Maxwell's DemonBeta

Sort a gas hot and cold by working a single door

This tool is a beta version still being stabilized. Please let us know if a result looks off.

Goal
Who works the door

Fast molecules right, slow ones left. Win when the right side is 1.5× hotter.

Loading the simulation engine (WebAssembly)…

Door shut

Time left
–
Target
–
Now
–
Left temperature
–
Right temperature
–
Molecules left
–
Molecules right
–
Molecules through the door
–
Information recorded
–
The demon's ledger
Order gained by the gas |ΔS|
0
Cost of erasing the information
0

–

The door stays open while you hold the canvas (or the space bar).

A single door sits in the partition down the middle. Molecules collide perfectly elastically with each other and the walls, so the total energy never changes. Yet if only fast molecules go right, the right side heats up and the left cools down — a temperature difference made without spending energy. Work the door yourself, then compare with the perfect demon and the blind demon. Information is counted as one bit per molecule inspected for the perfect demon, one bit per door flip for you (a lower bound, shown with ≥, since what your eyes took in can't be counted) and one bit per coin toss for the blind demon; the ledger bars put the order gained by the gas next to the cost of erasing that information.

About Maxwell's Demon

A box is split by a partition with one door, and each half holds gas at 300 K. Molecules collide perfectly elastically with each other and with the walls, so the total energy never changes, and moving the door costs nothing. Yet if only fast molecules are let through to the right, the right side warms and the left side cools. Maxwell floated this thought experiment in an 1867 letter, and it looks like a direct violation of the second law of thermodynamics.

The tool lets you compare three demons: you on the door, a perfect demon that looks at every approaching molecule, and a blind demon that flips a coin every 0.12 s to decide whether the door is open. You win if, within 90 seconds, the right side reaches 1.5 times the temperature of the left (sort by temperature) or holds 75% of the molecules (pile to one side).

What the perfect demon looks at

The perfect demon scans every molecule that will reach the door within the next 0.08 s. In temperature mode its threshold is the mean speed at the starting temperature, about 125 px/s. A molecule coming from the left must be faster than that to pass; one coming from the right must be slower. If even one molecule that should be refused is on its way, the door stays shut. In pressure mode everything from the left is let through and everything from the right is blocked.

In a 2D Maxwell–Boltzmann gas, the fraction of molecules faster than the mean is exp(−π/4) ≈ 45.6%, so nearly half the molecules approaching from the left qualify. The blind demon ignores speed altogether, so fast and slow molecules leak across in the same proportion and no temperature difference builds up. The two demons may toggle the door a similar number of times, yet the outcomes differ completely. The only difference between them is information.

Szilard's one-molecule engine

In 1929 Leo Szilard pared the problem down to a single molecule in a box. Slide a partition into the middle, find out which side the molecule is on (one bit), and let that side push a piston outward isothermally. The expansion draws kT·ln2 of work from the surrounding heat. One bit of information has been turned into kT·ln2 of work. Szilard argued that the act of measurement must therefore cost at least that much entropy, or the second law would fail.

The cost is in erasing, not measuring: Landauer and Bennett

In 1961 Rolf Landauer showed that logically irreversible operations, such as resetting a bit to 0 regardless of its previous value, must dissipate at least kT·ln2 of heat per bit. At 300 K that is 1.38×10⁻²³ × 300 × 0.693 ≈ 2.9×10⁻²¹ J, or about 0.018 eV.

In 1982 Charles Bennett used this to settle the demon. Measurement, he argued, can in principle be done reversibly. But a demon with finite memory has to erase old records to keep working, and that erasure pays Landauer's price. The entropy the gas loses is at least matched by the entropy dumped during erasure. In 2012 Bérut and colleagues erased one bit stored in a colloidal bead in a double-well trap and measured the heat approaching kT·ln2 as the erasure was made slower.

What the ledger bars compute

The tool treats the gas as a 2D ideal gas and computes entropy as S/k = Σ N·[ln((A − N·πr²)/N) + ln kT]. A − N·πr² is the free area: the chamber area minus the discs of the molecules themselves (radius r = 4 px). In 2D the heat capacity is k per molecule, so ln T has a coefficient of 1. The difference between now and the start (equal halves, equal temperatures) is shown as the order gained by the gas. On the demon's side the erasure cost is bits × ln2. The perfect demon books one bit (send or not) each time a new molecule enters its view, meaning it will reach the doorway within 0.08 s. When you work the door, what your eyes took in can't be counted, so the number of door-state changes is used as a lower bound and marked with ≥. The blind demon books one bit per coin toss.

The count is still a teaching shortcut. On a 640×420 px canvas the perfect demon inspects roughly 250–290 molecules by the time it finishes the temperature sort, nearly twice its 130–160 door flips, because the molecules it turns away were measured too. Even so, one bit per molecule only records fast or slow; a real demon would need finer position and velocity readings. The blind demon's coin tosses say nothing about the gas, but they are still records that must be erased, so it piles up cost while achieving nothing.

Things to try

Run the perfect demon in temperature mode, then the blind demon, with the same molecule count. Watch the temperatures: the perfect demon drifts steadily apart, the blind one wobbles around 300 K. Then enlarge the door from 70 to 160 px. The perfect demon gets faster at pressure mode, because more molecules reach the door, but in temperature mode a large door means more molecules arrive at once and the door must stay closed more often whenever a single wrong one is among them.

Trying it by hand is instructive for a different reason: you cannot see individual speeds reliably, so your success depends on how well you read the colours. You are gathering information by eye, and your results show how much a sloppy measurement is worth.

Worked examples

Order gained by a temperature split

Input
600 molecules, 300 on each side, right 360 K and left 240 K (ratio 1.5)
Output
ΔS ≈ 300·ln 1.2 + 300·ln 0.8 = 300·ln 0.96 ≈ −12.2k

Energy is conserved, so the two temperatures still average 300 K. Accounting for this order needs 12.2 / 0.693 ≈ 18 bits. The perfect demon inspects more than 250 molecules while building this order, so the ledger ends up comfortably positive.

Order gained by piling molecules to one side

Input
450 of 600 molecules on the right, temperatures roughly equal
Output
ΔS ≈ 150·ln 2 + 450·ln(2/3) ≈ 104.0 − 182.5 = −78.5k

Concentrating molecules is a much bigger drop in entropy than splitting temperatures, and needs about 113 bits to balance. In practice faster molecules reach the door more often, so the right side runs slightly warm and the figure shifts a little.

Landauer's limit at room temperature

Input
T = 300 K, erase 1 bit
Output
kT·ln2 ≈ 2.9×10⁻²¹ J ≈ 0.018 eV

Erasing a gigabyte (8×10⁹ bits) at this limit would release about 2.3×10⁻¹¹ J, many orders of magnitude less than real hardware uses.

How to use it

  1. Choose a goal (temperature or pressure) and who operates the door.
  2. Press start. In manual mode the door is open while you hold the canvas or the space bar.
  3. Watch both temperatures and counts, the recorded bits and the ledger bars.
  4. Run the three demons on the same goal and compare.

Frequently asked questions

So is Maxwell's demon impossible?

As a device that gathers and uses information, no; information engines working with single particles or electrons have been built. What is impossible is beating the second law once the cost of erasing the demon's memory is included.

Why does erasing cost energy but measuring does not?

Measuring copies a state, which can in principle be undone. Erasing merges several possible records into one fixed state, which cannot be undone, and the price is at least kT·ln2 of heat released per bit.

The blind demon sometimes gets close to the target. Why?

With a few hundred molecules per side, temperatures and counts fluctuate by several percent on their own. Those swings are not systematic and regress to the average.

How small is kT·ln2 in practice?

About 2.9×10⁻²¹ J at 300 K. Present-day computers spend several orders of magnitude more per bit operation, so the bound does not yet constrain practical designs directly.

Notes

The entropy formula is the ideal-gas one with a simple excluded-area correction: the free area is the chamber area minus N·πr² for the molecules' own discs. It is a first-order correction, so when the gas gets very crowded (more than about 1,000 molecules squeezed into one side) it still differs from the true entropy of a hard-disc gas.

The bit count is the number of molecules inspected for the perfect demon (one bit each) and the number of door-state changes when you play (a lower bound, shown with ≥). Either way it sits close to a lower bound on the information a real demon handles.

Sources

Last reviewed:

Privacy and how data is handled