Questing · 2026-07-02 · Physics Simulation · Complex Systems · Zero Dependencies

SYNC

Drag a slider. Watch eighty independent oscillators — each spinning at its own rate — suddenly snap into perfect unison. This is the Kuramoto phase transition, and it is the same mechanism behind fireflies, heartbeats, and the power grid.

Open Sync →

What Is Sync?

Sync is a real-time visualizer of the Kuramoto model — the canonical mathematical framework for coupled oscillator synchronization. Eighty oscillators are arranged on a circle, each rotating at a slightly different natural frequency drawn from a Lorentzian distribution. A coupling strength slider K controls how strongly each oscillator is pulled toward the others' mean phase.

Below the critical coupling Kc = 1.0, the oscillators run independently — uniformly scattered, incoherent, the order parameter r ≈ 0. Above Kc, they spontaneously organize: a cluster forms, grows, and eventually the entire ensemble rotates as one. The order parameter r jumps from near-zero to near-one — a genuine phase transition in a continuous dynamical system.

The Kuramoto Model

Proposed by Yoshiki Kuramoto in 1975, the model governs N coupled phase oscillators with natural frequencies ωi and phases θi:

dθᵢ/dt = ωᵢ + (K/N) · Σⱼ sin(θⱼ − θᵢ)    i = 1 … N

The coupling term pulls each oscillator toward the others — the sine of the phase difference is a restoring force: if oscillator j is ahead of i, the force accelerates i; if it is behind, it decelerates it. With enough oscillators, this sum can be written exactly in terms of the order parameter:

Z = r · e^{iψ} = (1/N) · Σⱼ e^{iθⱼ}

r ∈ [0,1]  — coherence (0 = chaos, 1 = perfect sync)
ψ          — mean phase of the ensemble

→  dθᵢ/dt = ωᵢ + K · r · sin(ψ − θᵢ)

This mean-field form is exact, not an approximation. It replaces the N² pairwise interactions with a single pair (r, ψ) computed once per step — making the simulation O(N) per frame. In Sync, Euler integration runs at dt = 0.08 per frame, stable for all K ≤ 3 with N = 80.

The Phase Transition

Below Kc — Incoherent

When coupling is weak, each oscillator runs at its own pace. The phases spread uniformly around the circle. The phasor sum Z averages to near zero: r ≈ 1/√N ≈ 0.11 (the noise floor). No matter how long you wait, the oscillators stay scattered. The coupling is too weak to overcome the spread of natural frequencies.

At K = Kc — Transition

For a Lorentzian frequency distribution with half-width γ, the critical coupling is exactly Kc = 2γ. In Sync, γ = 0.5 so Kc = 1.0. This can be derived exactly: the incoherent state becomes unstable to a small perturbation exactly at Kc. Near the transition, the coherence grows as:

r ≈ √(1 − K_c / K)     (K > K_c, mean-field prediction)

This is a second-order phase transition — analogous to ferromagnetism, where below the Curie temperature domains are aligned but above it thermal fluctuations destroy order.

Above Kc — Synchronized

A subset of oscillators lock to the mean phase and rotate together. The synchronized cluster grows as K increases, absorbing the oscillators with frequencies closest to the mean. The outriders — those with the most extreme natural frequencies — drift away and never lock. But the cluster's rotating comet dominates r.

K = 1.0 (K_c):  r ≈ 0.0  →  oscillators start clustering
K = 1.5:        r ≈ 0.42
K = 2.0:        r ≈ 0.71
K = 3.0:        r ≈ 0.82

Real-World Synchronization

The Kuramoto model is not just a mathematical curiosity — it describes genuine synchronization phenomena across wildly different physical systems:

  • Fireflies: Southeast Asian firefly species (Pteroptyx malaccae) synchronize their flashes to millisecond precision across entire riverbanks. Each firefly is a phase oscillator; visual coupling from neighboring flashes drives K above K_c.
  • Heart pacemaker cells: The sinoatrial node contains ~10,000 pacemaker cells, each with a slightly different intrinsic firing rate. Electrical coupling (K > K_c) locks them to a single rhythm — your heartbeat. When coupling fails, the cells decohere: arrhythmia.
  • Power grids: Every generator on an AC grid is a phase oscillator (frequency 50 or 60 Hz). The transmission lines provide coupling. The grid stays synchronized (r ≈ 1) when coupling is strong enough; blackouts cascade when it is not.
  • Neurons: Sleep spindles, gamma oscillations in working memory, and epileptic seizures all involve populations of neurons synchronizing. The transition from healthy background firing to a seizure is, literally, a Kuramoto transition to over-synchronization.
  • Clapping audiences: Spontaneous rhythmic applause in concert halls is a Kuramoto transition: each person is an oscillator with a slightly different clapping rate; acoustic coupling from the crowd drives synchronization.

The Frequency Distribution

Sync uses a Lorentzian distribution (Cauchy distribution) for natural frequencies:

g(ω) = (γ/π) / ((ω − ω₀)² + γ²)

ω₀ = 1.2 rad/s  (mean)
γ  = 0.5        (half-width)
K_c = 2γ = 1.0  (exact for Lorentzian)

The Lorentzian is the only distribution for which Kc can be derived in closed form. The heavy tails mean a few oscillators have very extreme frequencies — you can see them as fast orange dots (high ω) and slow purple dots (low ω) that trail behind the synchronized cluster even at high K. The color map in Sync is: fast → amber (hue 40°), average → cyan (hue 185°), slow → purple (hue 250°).

The 80 frequencies are sampled via stratified inverse CDF (ωi = ω₀ + γ·tan(π·(i/N − ½))) to give a stable, reproducible distribution without the random fluctuations of Monte Carlo sampling. The phases θi are initialized uniformly at random each time you press SCATTER.

Technical Implementation

Sync uses no libraries, no GPU, no WebGL. The physics runs entirely in vanilla JavaScript on the main thread:

  • Mean-field form: the O(N²) pairwise sum collapses to O(N) via the order parameter Z = (1/N)·Σe^{iθ}. One complex sum per step replaces 6,400 sine evaluations.
  • Forward Euler integration at dt = 0.08 per frame (≈ 4.8 simulation seconds per real second at 60fps). The stiffest eigenvalue at K=3 is λ ≈ −K·r ≈ −2.7; dt·|λ| ≈ 0.21 < 1 — numerically stable.
  • Phosphor trail: each frame filled with rgba(1,13,26, α) where α = 0.13 + 0.08·(1−r). Slower fade when synchronized → longer comet tail for the bunched cluster.
  • Glow dots: per-oscillator radialGradient (9 + 7r pixel radius). The halo scales with r so dots bloom brighter as the system synchronizes.
  • r(t) mini-graph: a Float32Array ring buffer of 220 samples drawn as a canvas 2D polyline, top-right corner, updated every frame.
  • BUNCH button: initializes all phases to a narrow cluster near 0. This "cheats" the system into synchrony — you can watch the order parameter briefly near 1, then lower K to see it dissolve.

Controls

  • Start with K = 0. The dots are uniformly scattered — pure incoherence. The r(t) graph sits near 0.
  • Slowly drag K past the K_c = 1.0 marker. Watch r begin to rise. The oscillators start clustering — a loose rotating blob forms. This takes 2–4 seconds as the system equilibrates.
  • Push K to 2.0 or higher. The cluster tightens into a single rotating comet. The purple and amber outliers that never lock are visible on the trailing edge.
  • Hit SCATTER to randomize phases. Hit BUNCH to pre-cluster them — then lower K to watch synchrony dissolve back into chaos.
  • The mean-phase arrow (dashed line from center) shows where the synchronized cluster is heading.
  • The color of each dot encodes its natural frequency: amber = fast, cyan = average, purple = slow. The rainbow becomes a comet.

Why It's Different

Sync is the first Questing toy about spontaneous order emerging from disorder in a continuous dynamical system. Unlike Chirp (gravitational waves), Mach (shock wave geometry), and Sling (orbital mechanics), the interesting thing here is not the motion of any individual particle — it is the collective state that appears across all 80 oscillators simultaneously when a single parameter crosses a threshold. The transition is not gradual: below Kc, nothing; above it, a comet. That discontinuity — the phase transition — is the whole point. Dragging the slider through Kc = 1.0 is the demonstration of one of the most beautiful results in theoretical physics: that incoherence and synchrony are separated by a knife-edge.

Open Sync →