Wave 54: Van der Pol Synchronization, Bacterial Chemotaxis & Genetic Evolution

Three life-science additions: coupled Van der Pol oscillators (RK4) showing in-phase and anti-phase synchronisation analogous to cardiac pacemakers; an E. coli–inspired run-and-tumble chemotaxis colony on a diffusing nutrient grid with quorum-sensing biofilm; and a Darwinian natural-selection sandbox where float-encoded creatures evolve over generations through tournament selection and Gaussian mutation.

Wave 54 at a glance

3
new simulations
6
HTML files
538
total simulations
1
blog post

Van der Pol Sync

Two coupled nonlinear oscillators integrated with RK4. Tune damping μ, coupling κ, and initial phase offset Δφ to explore in-phase, anti-phase, and quasi-periodic behaviour.

Open simulation →
🦠

Bacterial Colony

Run-and-tumble chemotaxis on a 60×60 nutrient field. Gradient sensing biases tumble probability. Watch quorum-sensing biofilm form when local density exceeds the threshold.

Open simulation →
🧬

Genetic Evolution

Creatures with 4-gene float genomes (speed, sight, efficiency, aggression) compete for food. Tournament selection + Gaussian mutation drives adaptation across generations.

Open simulation →

♡ Van der Pol Oscillator Synchronization

In 1920 Balthasar van der Pol studied self-sustained oscillations in triode vacuum-tube circuits. The oscillator he described has a nonlinear damping term that injects energy at small amplitudes and dissipates it at large amplitudes — producing a stable limit cycle regardless of initial conditions.

The equation of motion

A single Van der Pol oscillator obeys the second-order ODE:

ẍ − μ(1 − x²)ẋ + x = 0 — the μ(1−x²) factor acts as negative damping for |x| < 1 (energy input) and positive damping for |x| > 1 (energy removal). The system settles on a closed orbit (limit cycle) in phase space.

When two such oscillators are coupled via their displacement difference, the system can synchronise. The coupled equations are:

ẍ₁ − μ(1 − x₁²)ẋ₁ + x₁ = κ(x₂ − x₁)
ẍ₂ − μ(1 − x₂²)ẋ₂ + x₂ = κ(x₁ − x₂)

Phase locking and the Kuramoto model

The Van der Pol coupling is a precursor to the celebrated Kuramoto model, which describes synchronisation in networks of weakly coupled oscillators. The Kuramoto order parameter r = |⟨eiθⱼ⟩| measures global coherence: r = 1 means full synchrony, r ≈ 0 is incoherence. In our two-oscillator system r = |cos(Δφ)| collapses to a single phase difference.

Biological analogy: cardiac pacemakers

Sinoatrial node cells in the heart are tonically self-firing oscillators. Gap junctions couple them electrically. The Van der Pol model (and its relaxation-oscillator cousin, the FitzHugh–Nagumo model) captures how pacemaker cells entrain one another so the entire nodal region fires as a single synchronised wave front — producing the orderly P-wave on an ECG. If coupling fails, independent sub-pacemakers fire at different rates, producing arrhythmia.

In the simulation: start with Δφ = 180° (anti-phase). Increase κ past ~0.5 and watch the phase difference decay to zero (in-phase synchrony). Increase μ to explore relaxation-oscillator territory.

🦠 Bacterial Colony & Chemotaxis

E. coli and many other bacteria navigate chemical gradients using a biased random walk called run-and-tumble. During a "run" the flagella bundle and rotate in unison — the cell swims straight. During a "tumble" the bundle flies apart and the cell reorients randomly. By modulating the switching frequency based on recent signal history, bacteria perform chemotaxis — drifting up gradients of attractants and away from repellents.

The run-and-tumble algorithm

Each bacterium stores position, heading, and a biofilm flag. Every tick:

The chemotaxis bias parameter controls the strength of directional preference. A bias of 0 produces a pure random walk; bias = 1 makes bacteria reliably track the gradient. Real E. coli achieve effective chemotaxis with a bias around 0.2–0.4 through the methylation-adaptive signalling network (CheA/CheY/CheB pathway).

Nutrient diffusion

The nutrient field evolves according to a discrete diffusion equation with a central source and zero-flux boundary conditions:

n(i,j) ← n + D · ∇²n + source − consumption — where ∇² is the 5-point discrete Laplacian and D is the diffusion coefficient slider.

Quorum sensing and biofilm

When many bacteria accumulate in a region the local density can exceed a threshold — a proxy for the concentration of quorum-sensing signalling molecules (N-acyl homoserine lactones in Gram-negative species). Above the threshold cells switch to biofilm mode: motility drops ~15-fold, and they appear orange in the simulation. Biofilms are notoriously resistant to antibiotics because (a) reduced drug penetration and (b) altered metabolic state.

🧬 Genetic Evolution — Natural Selection

Charles Darwin's key insight was that heritable variation in fitness-relevant traits, combined with differential reproduction, is sufficient to produce adaptation. No foresight, no goal — just differential survival and reproduction across generations.

Genome and phenotype

Each creature carries a genome of four floating-point genes, all in [0, 1]:

Tournament selection

To fill the next generation, for each new offspring we draw k individuals at random (the tournament) and select the one with the highest fitness (food eaten). Tournament selection with k = 2 is roughly equivalent to rank selection; k = 8 approaches truncation selection. The tournament size slider controls selection pressure — higher k means fitter individuals dominate faster, at the cost of genetic diversity.

offspring genome = crossover(parent₁, parent₂) + Gaussian noise σ — uniform crossover randomly picks each gene from one parent or the other (50/50). Gaussian mutation with σ controlled by the slider then perturbs every gene independently, ensuring genetic diversity is never permanently lost unless σ → 0.

Observing adaptation

With default settings (σ = 0.08, k = 4, moderate food) the mean fitness line in the on-canvas history chart typically rises for the first 10–30 generations, then plateaus near the sustainable foraging rate. Raising the mutation rate adds noise to the chromosome pool, slowing convergence but allowing escape from local optima — a classic exploration/exploitation trade-off. Setting k = 10 produces rapid convergence (high selection pressure) at the cost of premature fixation.

Natural selection is not the only force at work. Watch the aggression gene (creature colour) drift over many generations — if the environment provides no fitness advantage to aggression, its value random-walks toward fixation (either all-green or all-red) due to genetic drift, even with no selection acting on it.

← Devlog #73: Laminar-Turbulent, Islamic Geometry & Boundary Layer Blog index →