Devlog #80 – Wave 60: Duffing Oscillator, Network Science & Turing Diffusion

Wave 60 covers three cornerstone topics in nonlinear science and complex systems — the driven Duffing oscillator with real-time phase portraits and Poincaré sections, a three-model network science explorer with force-directed layout and degree-distribution histograms, and the Gray-Scott reaction-diffusion model producing Turing morphogenesis patterns (spots, stripes, mazes, coral). The library now stands at 556 simulations.

Wave 60 — 3 simulations added
556
Total simulations
3
New this wave
60
Wave number
80
Devlog #

New Simulations

🌀

Duffing Oscillator — Chaos via Phase Portrait & Poincaré Section

RK4 integration of ẍ + δẋ + αx + βx³ = γcos(ωt). Left canvas: phase portrait (x, ẋ) with fading trail + Poincaré dots sampled every forcing period. Right: x(t) time series. Five presets range from clean chaos to damped decay.

🌐

Network Science — Erdős–Rényi, Barabási–Albert, Watts–Strogatz

Force-directed graph visualization covering three fundamental random network models. Real-time BFS component detection, degree-distribution histogram, clustering coefficient and giant-component fraction. Drag nodes to explore topology.

🔬

Turing Diffusion — Gray-Scott Reaction-Diffusion Morphogenesis

256×256 Gray-Scott model on a periodic grid. Five presets (spots, stripes, maze, coral, mitosis) explore the (F,k) parameter space. Click to plant seeds. Four colour maps; real-time pattern-type detection.

🌀 Duffing Oscillator — Classical Chaos with a Cubic Spring

The equation

George Duffing (1918) introduced one of the first deliberately studied nonlinear oscillators to model hardening springs in machinery. The driven version reads:

ẍ + δẋ + αx + βx³ = γ cos(ωt)

The cubic term βx³ is the key nonlinearity: for β > 0 (hardening) the effective stiffness increases with amplitude; for β < 0 it decreases. The driving force γcos(ωt) continuously injects energy, which damping δẋ dissipates. When driving and damping are balanced in a nonlinear regime, chaotic motion can emerge.

Phase portrait and Poincaré sections

The simulation runs an RK4 integrator with Δt = 0.005 and renders two visualizations simultaneously:

Preset regimes

Regime detector

The Poincaré x-values from the last 100 crossings are accumulated. The variance of this buffer classifies motion: variance > 0.05 → Chaotic; variance > 0.01 → Period-2+; otherwise Periodic. Small samples make this heuristic imperfect, but it stabilises reliably within a few hundred periods.

🌐 Network Science — Three Models of Graph Structure

Why network topology matters

The structure of a network — which nodes connect to which — determines how information, disease, influence or failure propagates through it. Three models capture fundamentally different structural regimes:

Force-directed layout

Node positions are computed by a lightweight Fruchterman-Reingold-style algorithm running at each animation frame: repulsive force ∝ 1/d² pushes all node pairs apart; spring attraction ∝ (d − 60) pulls connected nodes together; a weak centre gravity ∝ 0.003 keeps the graph on screen. Damping 0.88 stabilizes the layout. Nodes can be dragged to anchor positions; releasing resumes physics.

Statistics panel

Computed after every regraph: node count, edge count, average degree ⟨k⟩, global clustering coefficient C, giant component fraction, and max degree (hub size for BA networks). The degree distribution histogram on the right panel uses a log-count y-axis to reveal the power-law tail in BA mode.

🔬 Turing Diffusion — How Alan Turing Explained Biological Patterns

The 1952 paper

In "The Chemical Basis of Morphogenesis" (Philosophical Transactions of the Royal Society B, 1952), Alan Turing showed mathematically that a homogeneous mixture of two reacting chemicals — one (activator) that enhances its own production and a second (inhibitor) that suppresses the activator and diffuses faster — can spontaneously break spatial symmetry and form stable periodic patterns. This Turing instability is now considered the leading theoretical explanation for animal coat markings, finger spacing in embryonic limb development, and the spacing of hair follicles.

Gray-Scott model equations

The simulation implements the Gray-Scott variant, which captures the activator-inhibitor dynamics cleanly:

∂U/∂t = Dᵤ ∇²U  −  UV²  +  F(1 − U)
∂V/∂t = Dᵥ ∇²V  +  UV²  −  (F + k)V

U is the inhibitor (fed from outside at rate F, consumed by the UV² reaction); V is the activator (consumed at rate k+F, produced autocatalytically via UV²). The Laplacian ∇² is discretized on a 256×256 periodic grid with a 5-point stencil. A forward-Euler step with Δt = 1.0 is stable for the diffusion coefficient values used.

The (F, k) parameter space

Small differences in feed rate F and kill rate k produce qualitatively different steady-state patterns:

Click anywhere on the canvas to inject a seed of high-V concentration. The seed triggers pattern growth from that location — useful for watching pattern invasion fronts.

Colour maps and pattern detection

Four colour maps render the V-field: Alien (green/teal/black emphasises mid-range detail), Heat (black→red→yellow), Mint (dark to bright green), and Monochrome (greyscale for publication-style output). The pattern-type classifier computes average V and uses (F,k) heuristics to label the current regime.

Looking Ahead

Wave 61 candidates from the queue include viscoelastic fluid dynamics, cellular-automata rule explorer, an interactive double-pendulum ensemble showing chaos onset across initial conditions, and signal-processing tools (DFT / STFT visualizer). We're also planning a collections / bookmarks feature so visitors can curate and share sets of simulations.

← Devlog #79 — Wave 59 All posts →