Questing · 2026-09-14 · Active Matter · Zero Dependencies
MURMUR
Each particle has a speed and a direction. It aligns with its neighbours and adds a little noise. Below a critical noise level, they all end up going the same way — a flock that nobody planned and nobody leads.
Open Murmur →The Vicsek Model — 1995
In 1995, Tamás Vicsek and collaborators published a brief paper in Physical Review Letters that introduced one of the simplest models of collective motion. N point particles move in a 2D periodic box at constant speed v₀. At each time step, every particle computes the average direction of all particles within radius r (including itself) and moves in that average direction, plus a random angular perturbation drawn uniformly from [−η/2, +η/2]. That's the entire model.
// Vicsek update rule — applied simultaneously to all particles: // // 1. For particle i, find all j where |r_i − r_j| < R (periodic distance) // 2. Circular mean of their headings: θ_avg = atan2(Σ sin θ_j, Σ cos θ_j) // 3. Add noise: θ_i(t+1) = θ_avg + Uniform(−η/2, +η/2) // 4. Move: r_i(t+1) = r_i(t) + v₀ · (cos θ_i, sin θ_i) // 5. Periodic BC: coordinates wrapped mod L // // Control parameters: // η ∈ [0, 2π] — noise amplitude (Murmur slider: 0 → 4.5) // ρ = N / L² — particle density // v₀ — particle speed (fixed at 0.015 in Murmur) // R — interaction radius (fixed at 0.075 in Murmur)
What made Vicsek’s model surprising was that such a minimal rule — align with your neighbours, add noise — produces a genuine phase transition. Below a critical noise level ηc, a macroscopic ordered state emerges: all particles end up moving in the same direction, which they collectively chose without any leader. Above ηc, thermal-like disorder prevents global coherence, and the particles scatter independently.
The Order Parameter
The degree of collective motion is captured by the polar order parameter ψ — the mean of the unit velocity vectors:
ψ = (1/N) |Σᵢ e^{i θᵢ}| = (1/N) √( (Σ cos θᵢ)² + (Σ sin θᵢ)² )
ψ = 1.0 → perfect alignment — all particles move together
ψ = 0.0 → complete disorder — directions cancel on average
ψ ≈ N^{−1/2} → finite-size floor (even in a disordered gas)In Murmur, ψ is computed live and displayed as a number and a sparkline. Drag the noise slider down from 4.0 to 0.5 and watch ψ rise from near zero to near one. The transition is not sharp at finite N — it smears out around ηc — but it sharpens in the thermodynamic limit N → ∞.
The Phase Transition
The Vicsek model has a non-equilibrium phase transition. It differs from equilibrium transitions (like the Ising ferromagnet) in a crucial way: particles are constantly moving. They carry their local alignment information with them, sweeping through new neighbourhoods and spreading order faster than diffusion alone would allow. This is why Vicsek-like models belong to a different universality class from equilibrium spin systems.
Equilibrium analogy: 2D Ising model
— spins on a fixed lattice, finite T
— long-range order exists below T_c (Onsager 1944)
— analogous to Vicsek below η_c
Key differences for Vicsek:
— particles move (conserved density, convective transport)
— the "magnetisation" is a velocity, not a spin
— the ordered phase breaks continuous rotational symmetry, not Z₂
— debate (2004–2012) about whether the transition is 1st or 2nd order
(Grégoire & Chaté 2004 found a 1st-order discontinuous jump in ψ(η)
at the transition for large N; the true nature is still studied)In Murmur at N=300 you see a smooth crossover rather than a sharp jump — finite-size rounding. At N=500 the transition sharpens. In the original Vicsek 1995 paper with N=300, the order parameter ψ showed a clear but rounded rise from 0 to 1, which Vicsek interpreted as a second-order transition. Later work (Grégoire & Chaté, 2004; Aldana et al., 2007) suggested it is weakly first-order — a still-debated question.
What You See in the Ordered Phase
In the low-noise ordered regime, Murmur displays two things simultaneously. First, the particles form a single coherent group sweeping across the periodic box in one direction — the direction is chosen spontaneously by the initial fluctuations (spontaneous symmetry breaking of the continuous rotational symmetry O(2)). Second, because colour encodes heading angle, the entire canvas glows one pure hue — amber when the flock goes right, blue-violet when it goes left, cycling slowly as the flock direction drifts.
At intermediate noise (near ηc), the ordered phase breaks into high-density bands. These bands — coherent travelling stripes of particles separated by low-density disordered regions — are a hallmark of the Vicsek model’s first-order transition region. They are absent at low noise (single global flock) and at high noise (uniform disorder), and appear only in a narrow window around ηc. Look for them by dragging the noise slider slowly from 2.0 to 3.0.
Real-World Collective Motion
The Vicsek model is a minimal theory for a remarkable array of real phenomena:
Starling murmurations — the fluid, shape-shifting flocks of hundreds of thousands of starlings — are the iconic example. Each starling tracks a fixed number of its topological nearest neighbours (not a fixed radius, a key refinement of the basic Vicsek model). The resulting collective behaviour is so sensitive and fast that the entire flock reacts to a predator in milliseconds despite having no leader. Field data from the STARFLAG project (2008–2012) confirmed that starling interactions are topological (nearest-k, not metric-r) and showed velocity correlations spanning the entire flock — a signature of proximity to a critical point.
Fish schools obey qualitatively similar rules. Individual fish reduce drag by swimming in the pressure wake of neighbours, creating an emergent school hydrodynamics that is collectively more efficient than isolated swimming. Experiments in zebrafish and golden shiners have extracted individual interaction rules from tracking data and confirmed Vicsek-like velocity alignment with a finite interaction range.
Bacterial swarms — particularly Bacillus subtilis at high density — form coherent streaming patterns where millions of rod-shaped bacteria move collectively. The key difference from Vicsek is that bacteria generate their own turbulence (active turbulence), producing swirling vortices rather than straight-line flocking. The Vicsek model’s extension to active nematics (no head-tail distinction, as in rod-shaped bacteria and epithelial cells) gives different symmetry and different phenomenology.
Robot swarms — ranging from laboratory Khepera robots to proposed drone formations — use Vicsek-like alignment algorithms because they require no global communication, no leader, and no map. Each robot only needs to sense the velocities of nearby agents. The ordered phase corresponds to a successfully coordinated swarm; the disordered phase corresponds to a swarm that failed to achieve coherence. The Vicsek model predicts the density and noise thresholds at which coherent formation is possible.
Connection to the Kuramoto Model
Murmur’s predecessor in the Questing series is Sync — which simulates the Kuramoto model of coupled phase oscillators. Both models show spontaneous synchronisation below a critical coupling/noise threshold, and both use a circular mean. But they differ in a key way:
Kuramoto (Sync):
— oscillators have fixed positions, no spatial structure
— mean-field coupling: each oscillator feels the global average
— order parameter r = |(1/N) Σ e^{i θᵢ}| rises at K_c = 2/π σ
— equilibrium universality class
Vicsek (Murmur):
— particles move through space — spatial structure matters
— local coupling: each particle feels only its neighbourhood
— order parameter ψ = r rises at η_c (density-dependent)
— non-equilibrium universality class
— bands near transition (absent in Kuramoto)
The deep analogy: both show spontaneous order from disorder by
alignment interactions competing against noise. The spatial movement
in Vicsek is what makes the physics richer and harder to analyse.Implementation
Murmur runs N self-propelled particles in a periodic unit square. The interaction radius is R = 0.075 and the speed is v₀ = 0.015 per step. Neighbour search uses a spatial linked-list grid: the box is divided into 14×14 cells (cell size ≈ R), each particle is inserted into its cell once per step, and each particle checks only the 3×3 block of neighbouring cells. This reduces the neighbour search from O(N²) to O(N) on average, allowing N=500 to run smoothly.
// Spatial grid — allocation-free per step: // cellHead[cell_idx] = index of first particle in cell (−1 if empty) // cellNext[part_idx] = index of next particle in same cell (−1 if end) // // buildGrid(): fill(−1) then insert each particle as list head O(N) // neighbour search: 9 cells × avg_occupancy ≈ O(N) total // // All particle arrays pre-allocated at MAX_N = 600: // X, Y Float32Array — positions // TH Float32Array — direction angle (radians) // sinTH, cosTH Float32Array — precomputed trig (avoid N² sin/cos calls) // NTH Float32Array — next-step angles (avoids allocation per step) // // Rendering: // Background fade: rgba(6,8,18, 0.20) per frame → ~5 frame trails // Head: filled arc radius 2.5px // Tail: strokeStyle line, length 9px in direction of motion // Color: hue = (θ × 180/π + 30) mod 360 → amber-orange when going right
The colour scheme encodes direction globally: θ = 0 (right) maps to hue ≈ 30° (amber-orange); θ = π (left) maps to hue ≈ 210° (blue-violet); intermediate angles grade continuously. In the ordered phase where all particles share nearly the same heading, the entire canvas glows one pure hue. As the flock slowly wanders (random walk of the mean direction), the hue drifts — a passive read-out of the collective orientation. In the disordered phase, directions are uniformly distributed and the canvas shows a homogeneous colour mix.