About this simulation
In 1867 James Clerk Maxwell imagined a tiny "demon" guarding a door between two boxes of gas. By letting only fast molecules through one way and slow ones the other, it could make one side hot and the other cold without doing any work, apparently breaking the second law of thermodynamics.
What you're seeing
- Red particles are fast and blue ones slow: half the gas starts above its median speed and half below. Each one bounces off the walls without losing speed and, unless Particles collide is on, passes straight through the others, so it keeps its colour.
- The demon opens the gate only for red particles going one way and blue ones going the other, so the reds gather on one side and the blues on the other.
- shows each chamber's temperature (average kinetic energy) relative to the start.
The key idea
Sorting by speed lowers the gas's entropy: one side warms and the other cools. But to sort, the demon has to measure each particle and remember the result. Erasing that memory costs at least kT ln 2 of energy per bit (Landauer's principle), which creates more entropy than the sorting removed, so the second law survives.
Things to try
- Watch the temperatures drift apart, or open the charts ().
- Be the demon: choose Manual in the settings (), then press and hold on the simulation (mouse, touch or pen), or hold Space, to open the gate. Can you beat the automatic demon?
- Turn on Particles collide in the settings for a more realistic gas. Collisions share energy out, so particles keep speeding up and slowing down (and changing colour) and each chamber stays a mix. The demon still lets only fast ones one way and slow ones the other, so the temperatures still drift apart.
- Try a wider gate, more particles or a higher speed.
toggles fullscreen and restarts.