Topological Phase Transitions in Your Browser: The 2D XY Model & BKT Vortex Unbinding via Checkerboard Monte Carlo
Every physics simulation we have built so far – from Gross–Pitaevskii superfluids to Cahn–Hilliard spinodal decomposition – evolved a deterministic PDE forward in time. Here we switch to a completely different computational paradigm on the GPU: stochastic Markov Chain Monte Carlo (MCMC) for the 2D classical XY spin model (Nguyen & Boninsegni, 2021, arXiv:2105.14112; arXiv:2407.17507).
By the Mermin–Wagner theorem, a 2D system with continuous $U(1)$ rotational symmetry cannot undergo conventional spontaneous symmetry breaking at any non-zero temperature $T \gt 0$ because long-wavelength spin waves destroy true long-range magnetization ($\langle \vec{s} \rangle = 0$). Yet in the early 1970s, Berezinskii (1971), Kosterlitz, and Thouless (1973) discovered an infinite-order topological phase transition at $T_{\text{BKT}} \approx 0.893\,J/k_B$ driven entirely by the unbinding of quantized $\pm 2\pi$ spin vortex–antivortex pairs!
0. Energy–Entropy Balance of a Single Topological Vortex & Checkerboard Detailed Balance
Assign each site $(i, j)$ on a 2D square lattice a unit planar spin $\vec{s}_i = (\cos\theta_i, \sin\theta_i)$ interacting with its four nearest neighbors via $H = -J \sum_{\langle i, j \rangle} \cos(\theta_i - \theta_j)$. A single isolated $+2\pi$ vortex on a lattice of size $L \times L$ costs elastic energy $E_v \approx \pi J \ln(L/a)$ while gaining configurational entropy $S_v = k_B \ln(L^2 / a^2) = 2 k_B \ln(L/a)$:
Below $T_{\text{BKT}}$, $F_{\text{vortex}} \to +\infty$ as $L \to \infty$, locking vortices into neutral $+1/-1$ dipole pairs with algebraic correlation decay $\langle \vec{s}_0 \cdot \vec{s}_r \rangle \sim r^{-\eta(T)}$. Above $T_{\text{BKT}}$, $F_{\text{vortex}} \to -\infty$ and free vortices proliferate exponentially.
(x + y) % 2 == 0) and Pass B (odd parity (x + y) % 2 == 1) guarantees that no two simultaneously updated spins ever share a bond.
💻 GLSL: Red–Black Checkerboard Metropolis–Hastings Sweep with Stateless PCG PRNGGLSL
// WebGL 2 (GLSL ES 3.00): #version 300 es / precision highp float;
// Only update texels matching current checkerboard parity (0 = red, 1 = black)
ivec2 px = ivec2(gl_FragCoord.xy);
float thOld = texelFetch(uTheta, px, 0).r;
if (((px.x + px.y) & 1) != uParity) {
fragColor = vec4(thOld, 0.0, 0.0, 1.0);
return;
}
// Stateless per-texel PCG hash PRNG driven by (px, uFrameSeed)
vec2 r = pcg2d(uvec2(px) ^ uFrameSeed);
float thNew = wrapPi(thOld + (r.x * 2.0 - 1.0) * 3.14159265);
float eOld = -(cos(thOld - N) + cos(thOld - S) + cos(thOld - E) + cos(thOld - W));
float eNew = -(cos(thNew - N) + cos(thNew - S) + cos(thNew - E) + cos(thNew - W));
float dE = eNew - eOld;
float thOut = (dE <= 0.0 || r.y < exp(-dE / max(0.05, uTemp))) ? thNew : thOld;
fragColor = vec4(thOut, 0.0, 0.0, 1.0);