GPU Swarmalators Visualization

What are Swarmalators? Swarmalators are minimal agents that both swarm in space and oscillate in phase. Their spatial attraction/repulsion depends on phase difference while their phase dynamics depends on distance — a two-way coupling that leads to striking self-organized patterns.

The canonical model by O’Keeffe, Hong & Strogatz (2017) couples position ri and phase θi of each of the N agents:

dr_i/dt = (1/N) Σ_{j ≠ i} (r_j − r_i)/|r_j − r_i| · [1 + J·cos(θ_j − θ_i)] − (r_j − r_i)/|r_j − r_i|²
dθ_i/dt = ω_i + (K/N) Σ_{j ≠ i} sin(θ_j − θ_i) / |r_j − r_i|

Our version leverages Three.js along with its TSL (Three Shader Language) compute shaders so that every one of the O(N²) pairwise forces is evaluated in parallel on the GPU. This enables real-time exploration with >10 k particles on commodity graphics cards. We also generalize the original single-species model to up to five species: the spatial (J) and phase (K) couplings are stored in editable matrices Jαβ, Kαβ that let you tailor how species α interacts with species β.

By tuning these matrices—as well as the global offsets— the system exhibits rings, rotating clusters, convection-like flows and many other rich spatio-temporal states.

References

Initializing WebGPU renderer...

Save & Load Configuration

📁 Drop PNG file here or click to load saved configuration

Drag and drop a PNG file containing simulation parameters

Swarmalator Parameters

Global offset added to all J matrix values
Global offset added to all K matrix values
Natural oscillation frequency
Phase lag in Kuramoto coupling (radians)
Simulation time step
Soft boundary radius (particles gently pushed back beyond this)
Strength of boundary force (0 = no boundaries, 2 = strong)
Enable to automatically adjust camera distance based on particle spread

Preset Patterns

Species Coupling Matrices

J Matrix (Spatial Coupling)

K Matrix (Phase Coupling)

Instructions:
• Colors represent particle species (Red/Green/Blue/Yellow/Magenta) with phase brightness modulation
• Species interact via coupling matrices (J, K) + global offsets
• Use mouse to rotate/zoom the view
Species Count: Select 1-5 species (resets simulation)
Global Offsets: J and K sliders add to all matrix values
Matrix Controls: Set specific species-pair interactions
J > 0: particles with similar phases attract
J < 0: particles with opposite phases attract
K > 0: phases synchronize
K < 0: phases desynchronize
α (alpha): phase lag in Kuramoto coupling - shifts synchronization dynamics
Species Presets: Load different interaction patterns