Presets
Playback
Swarm
Coupling
Flash look and speed
External lamp
Camera
Layers
Quality
Model check
The science
The model: coupled phase oscillators
Each firefly has a phase θi that advances at its own natural rate ωi = ω0 + σ zi (a Gaussian spread) and flashes when the phase passes zero. A firefly nudges its phase toward the flashes it sees within the radius R: dθi/dt = ωi + (K/ni) Σj sin(θj − θi) + F sin(Ωt − θi) + noise. This is the Kuramoto model; real Photinus carolinus and Pteroptyx malaccae swarms synchronise through a similar phase-response curve.
The order parameter and the threshold
The swarm coherence is r eiψ = (1/N) Σ eiθj. For all-to-all coupling and a Gaussian frequency spread, Kuramoto showed that incoherence is stable below Kc = 2/(π g(0)) = 2σ√(2π)/π ≈ 1.596 σ and that above it the order parameter solves r = K r ∫−π/2π/2 cos2φ g(K r sinφ) dφ. Near threshold r ∝ √(K − Kc). The green curve in the last graph is this theory; the pink dots are separate N = 250 simulations.
Finite size, range and noise
A random swarm of N fireflies has r ≈ 1/√N even without any coupling (grey line). Limiting the sight radius makes the effective coupling local: synchrony then spreads as travelling waves and clusters rather than all at once, and the threshold rises. Phase noise D keeps pulling fireflies out of lock and also raises the threshold.
Entrainment by a lamp
A periodic lamp is a forcing term F sin(Ωt − θ). With ψ = θ − Ωt the Adler equation dψ/dt = Δ − F sinψ (with Δ = ω − Ω) locks when |Δ| < F at sinψ = Δ/F; outside that range the phase slips at the beat rate √(Δ2 − F2) (this is how fireflies are entrained experimentally by LEDs).
Honest simplifications
Real fireflies reset their rhythm with a measured phase-response curve rather than a smooth sine coupling, flash patterns have species-specific trains and pauses, and vision is directional and blocked by foliage. The lantern is seen by every firefly equally. The mean flash rate here is also much faster than a real swarm (seconds, not tens of seconds), to keep the demo lively. The model shows the mechanism, not a particular species.
Model checks in this page
(1) two coupled fireflies lock with the analytic lag asin(Δω/2K); (2) the lamp locking angle and the unlocked drift rate match the Adler formulas; (3) an N = 400 all-to-all swarm gives the self-consistent Kuramoto r, and stays near the noise floor below Kc.