This site is version 0.0.1. Most of the code on this site is drafted by an agent and needs review. I apologize for the AI-speak, we are working on rewriting it!
viv-lang.org

Statistical mechanics

The Ising model

demoAIStatistical mechanicswritten with an agent#7746705aea

Metropolis sampling finds Onsager's magnetization

A 16 by 16 grid of spins, each flipped at random by the Metropolis rule, settles at to an average magnetization of . The exact infinite-lattice answer, from Onsager and Yang, is . The critical temperature is where that formula reaches zero.

Magnetization of the 2D Ising model00.20.40.60.811.522.53Tc=2.269temperature T (units of J/kB)magnetization |m|
Onsager and Yang, infinite latticeMetropolis, 16 x 16 gridone run's spread, from 256 reference runs
The 16 x 16 grid below, near and above T_c
The grid at T = 1.8, below T_c
row
column
16 × 16 grid
The grid at T = 2.3, just above T_c
row
column
16 × 16 grid
The grid at T = 3.2, well above T_c
row
column
16 × 16 grid
A 32 x 32 grid at T_c, every two sweeps
row
column
40/40
32 × 32 grid · 40 frames
|m| of the 32 x 32 grid at T_c
|m|
00.10.20.320406080sweep|m|
✓ 6 tests passchecked when the site was built#ising-model#monte-carlo#phase-transitions
ReadOpen in the workbench

Look inside this program

  • Atlas

    The program’s map: every function and which calls which.

  • There’s no recorded run of this program yet.

Random walks and rates

demoAIStatistical mechanicswritten with an agent#fb6a40dd60

A random walk spreads as 2Dt and turns Gaussian

4000 walkers each take 200 random steps, drawn evenly from an interval. Their mean squared distance from the start grows in a straight line, , with the diffusion constant set by the step size; a line through the measurements gives . After one step the walkers are spread flat, and by step 200 they are spread as the Gaussian that solves the diffusion equation: the flatness measure called excess kurtosis falls as , from to zero within the noise.

Mean squared displacement of 4000 walkers
measured2 D t, D = 0.5one standard error
00.51.01.52.00.51.01.52.0time t⟨x2⟩
Excess kurtosis of the walkers' positions-1-0.5010⁰10¹10²Gaussiansteps n⟨x4⟩/⟨x2⟩2−3
exact, -6 / (5 n)measured, 4000 walkers
Where the walkers are, in units of their standard deviation
After 1 step00.10.20.30.4-3-2-10123x / sddensity
Gaussianwalkers
After 200 steps-3-2-10123x / sd
Gaussianwalkers
✓ 8 tests passchecked when the site was built#random-walk#diffusion#central-limit-theorem#monte-carlo#notebook
ReadOpen in the workbench

Look inside this program

  • Atlas

    The program’s map: every function and which calls which.

  • There’s no recorded run of this program yet.

demoAIStatistical mechanicswritten with an agent#45c11d9591

Kinetic Monte Carlo against the master equation

A molecule hops between three states, A to B to C and back, at fixed rates. The master equation gives the exact probability of each state at every time; kinetic Monte Carlo instead follows 10000 molecules one random jump at a time. At 25 times the fraction of molecules in each state matches the exact probability within four standard errors, the intermediate B rises to 0.460 and falls back, and the mean time to first reach C, exactly 1.75, is measured as .

Three KMC trajectories
molecule 1
state
ABCstate
molecule 2
state
ABCstate
molecule 3
state
ABC012345time tstate
Master equation (lines) and10000 KMC molecules (points)00.20.40.60.81012345time tprobability
A, exactB, exactC, exactA, KMCB, KMCC, KMC
Where the 10000 molecules are at t = 100.10.20.30.40.5ABCstatefraction
KMC, four standard errorsmaster equation
✓ 7 tests passchecked when the site was built#kinetic-monte-carlo#gillespie#master-equation#markov-chains#notebook
ReadOpen in the workbench

Look inside this program

  • Atlas

    The program’s map: every function and which calls which.

  • There’s no recorded run of this program yet.