Web Simulation 

 

 

 

 

Entropy – Statistical Mechanics 

This tutorial visualizes entropy through a two-chamber particle simulation. Instead of the "disorder" cliché, we focus on statistical mechanics: the system has a macrostate (how many particles are on the left vs right) and many possible microstates (which specific particles are where). Entropy measures how many ways that macrostate can be realized.

 

Mathematical foundation

1. Macrostate vs microstate

Suppose N particles are distributed with nL on the left and nR = NnL on the right. The number of microstates (distinguishable arrangements) for that distribution is W = N! / (nL! nR!).

2. Boltzmann entropy

S = kB ln W, where kB is Boltzmann's constant. In the simulation we use natural units (kB = 1) and display ln W, which is proportional to S. Maximum entropy occurs when nLnR (even distribution), because that macrostate has the largest number of microstates. Minimum entropy occurs when all particles are on one side (W = 1, ln W = 0).

3. Spontaneous mixing

When you "open" the barrier, particles mix. The system tends toward the most probable macrostate (even split), not because of a force, but because there are overwhelmingly more microstates for that outcome. The entropy graph rises over time toward the maximum.

Two-Chamber Lab

1

Cyan: 100 L / 0 R

Magenta: 0 L / 100 R

Mixing ln(W): 0

W

State: Minimum entropy (ordered)

Entropy S ∝ ln(W) over time

Cyan and Magenta = particle identity (fixed). Barrier is always open; click Run to see diffusion—both colors mix in both chambers (visual proof of increasing entropy).

 

Usage

Reset to Low Entropy: Puts all 200 particles in the lowest-entropy layout: 100 cyan in the first column (left), 100 magenta in the last column (right). ln(W) starts near its minimum; click Run to see diffusion and entropy rise.

Heatmap / Grid: Heatmap: On draws a cyan density overlay (brighter = more particles per cell). Grid: On shows the 8×10 cell grid used for spatial entropy. Both help connect particle motion to the ln(W) value.

Stats panel: Cyan L/R and Magenta L/R are counts on each side of the midline. ln(W) is computed from the 80-cell grid (multinomial). "Maximum entropy" when well mixed; "Minimum entropy" when ordered in few cells.

History graph: Plots ln(W) over time. Use the Y auto-scale icon (top-right of the plot) to toggle fixed scale (0–max) or auto scale (fit to current data).

Reverse Velocities (Time Flip): Flips every particle's velocity (Loschmidt's / reversibility paradox). Run until fully mixed (high entropy), then click Reverse—particles briefly un-mix toward the walls and the entropy graph dips (a "V" shape) before chaos from rounding takes over again.

Lab ideas

1. Reset to low entropy, then click Run. Watch the entropy curve rise and the state label switch to "Maximum entropy" when the split is roughly even (100–100).

2. With the simulation running, watch fluctuations: Cyan and Magenta L/R counts jitter; ln(W) stays near the maximum but wobbles slightly.

3. After mixing, the two sides stay mixed (you don't get "all left" again spontaneously)—consistent with the second law: entropy does not decrease in an isolated system.

Labs

Structured exercises using the simulation. Follow the steps and observe the stats and graph.

Lab 1: Minimum entropy and expansion
  1. Click Reset to Low Entropy. Cyan particles start in the first column (left), magenta in the last column (right).
  2. Note the stats: ln(W) is near its minimum; State shows "Minimum entropy (ordered)".
  3. Turn Heatmap: On to see density. Turn Grid: On to see the 8×10 cells.
  4. Click Run. Watch the heat map spread and ln(W) rise as particles occupy more cells.
  5. Stop when the curve levels off. State should show "Maximum entropy (mixed)" and Cyan/Magenta L and R will be roughly even.
Lab 2: Step-by-step entropy change
  1. Reset, then ensure Heat map and Grid are On.
  2. Use Step Fwd several times. After each step, check how many grid cells have particles and how ln(W) changes.
  3. Use Step Bwd to go back. Confirm that entropy (and the curve) decrease as the configuration returns to fewer occupied cells.
  4. Relate the number of occupied cells to the value of ln(W) shown in the stats.
Lab 3: Density and macrostate
  1. Reset, turn Heatmap: On, and click Run.
  2. Watch the cyan heat map: bright regions = high particle density. As particles mix, density spreads across the box.
  3. When the system is well mixed, the heat map is more uniform and ln(W) is near maximum.
  4. Compare the heat map (density in space) with the Cyan L/R and Magenta L/R counts (macrostate). The entropy graph reflects both.
Lab 4: Y-axis scale on the history graph
  1. After a run, the entropy-vs-time curve fills the plot. Click the Y auto-scale icon (top-right of the entropy plot): fit icon = turn auto scale On, lock icon = turn Off.
  2. With auto scale On, the Y axis zooms to the current data range so small changes are visible.
  3. With auto scale Off, the Y axis is fixed from 0 to the theoretical maximum ln(W), so you see how close the system is to maximum entropy.
Lab 5: Reversibility paradox (Loschmidt)
  1. Click Reset, then Run. Let the simulation mix until entropy is high (curve near top, State "Maximum entropy").
  2. Turn Heatmap: On to see density. Keep Run going.
  3. Click Reverse Velocities (Time Flip). The canvas border flashes red and "TIME REVERSED" appears briefly.
  4. Watch the Entropy graph and Heat map: particles un-mix toward the left and right walls and ln(W) drops (a "V" shape). After a few seconds, floating-point and collision errors take over and entropy rises again.
  5. Lesson: underlying laws are reversible, but tiny errors make real-world entropy practically irreversible (chaos).