Devlog #77 – Wave 57: Lévy Flight, DLA Fractal & Shallow Water Equations

Wave 57 crosses three disciplines — probability theory, generative art, and computational fluid dynamics — with a Lévy flight anomalous diffusion explorer, a real-time DLA fractal generator tracking fractal dimension live, and a 1D shallow water equations solver for dam-break, sloshing, and tidal wave scenarios. The library now stands at 547 simulations.

Wave 57 — 3 simulations added
547
Total simulations
3
New this wave
57
Wave number
77
Devlog #

New Simulations

🦅

Lévy Flight — Anomalous Diffusion

Stability exponent α controls tail heaviness; α=2 is Brownian, α→1 produces rare long jumps. Mantegna algorithm. Log-log step distribution, up to 8 walkers.

🌿

Diffusion-Limited Aggregation — DLA Fractal

Witten–Sander 1981 algorithm. Particles random-walk until contact sticking; live fractal dimension D_f ≈ 1.71 via N ∝ R^D_f. Four colour modes, three seed shapes.

🌊

Shallow Water Equations — 1D SWE Solver

Saint-Venant equations; Lax-Friedrichs scheme. Dam-break, sloshing, tidal wave, hydraulic step. Froude number, wave speed, mass conservation, Manning friction.

🦅 Lévy Flight — Anomalous Diffusion

What is anomalous diffusion?

Standard Brownian motion has a mean-squared displacement that scales linearly with time: MSD ∝ t. Lévy flights generalize this by drawing step lengths from a heavy-tailed stable distribution, where P(l) ~ l−(1+α) with α ∈ (0, 2). Because the distribution lacks a finite variance for α < 2, individual walkers can take rare but arbitrarily long jumps, producing superdiffusion: MSD ∝ tγ with γ > 1.

Lévy flights appear throughout nature: the foraging patterns of albatrosses, lightning bolt branching, earthquake displacement sequences, and even human mobility patterns in cell-phone data all show heavy-tailed step distributions consistent with Lévy statistics.

Mantegna algorithm

Direct inversion sampling from a stable distribution requires numerical quadrature. The Mantegna (1994) algorithm provides an efficient approximation. For a symmetric α-stable random variable:

σ = [Γ(1+α)·sin(πα/2) / (Γ((1+α)/2)·α·2^((α−1)/2))]^(1/α)
u ~ N(0, σ²),  v ~ N(0, 1)
l = u / |v|^(1/α)

When α = 2 this reduces to a Gaussian (standard Brownian). The simulation uses a 6-term Lanczos approximation for Γ(z) to avoid external math libraries.

Reading the log-log plot

The lower panel shows a histogram of accumulated step lengths in log-log space. For a true power-law distribution the histogram decays as a straight line with slope −(1 + α). At α = 2 (Gaussian) the tail drops off faster than any power law and the right end of the histogram curves downward. At α = 1.2 the histogram stays nearly linear across many decades of step size — the distinctive signature of a Lévy stable distribution.

🌿 Diffusion-Limited Aggregation (DLA)

The Witten–Sander model

Introduced by Witten and Sander in 1981, DLA is one of the simplest algorithms that produces fractal geometry. The rules are minimal: place a seed particle at the origin; release a new particle from a circle whose radius slightly exceeds the current cluster; let it random-walk until it is adjacent to the cluster, at which point it sticks permanently. Repeat.

Despite the simplicity, the resulting cluster is a fractal with dimension D_f ≈ 1.71 in 2D (compared to 2.0 for a filled disk and 1.0 for a line). The branching occurs because the tips of the cluster intercept diffusing particles preferentially due to their larger capture cross-section — a phenomenon known as tip-splitting instability.

Implementation details

The simulation uses a flat Uint8Array occupancy grid for O(1) neighbour checks. Particles are spawned at a circle of radius 1.2 × cluster_radius + 30 px and killed if they drift beyond 1.5 × that radius, preventing infinite wandering. Each animation frame launches a batch of up to 10 particles, keeping the framerate smooth even at 5,000-particle targets.

The sticking probability slider (default 1.0) introduces a noise-reduced DLA variant: at lower values particles partially miss on first contact, producing denser, less branchy clusters that more closely resemble viscous fingering patterns.

Fractal dimension estimation

The live D_f estimate uses the simplest box-counting proxy: if N particles occupy a cluster of radius R then D_f ≈ log(N)/log(R). This typically converges to values between 1.65 and 1.75 once the cluster exceeds a few hundred particles. The true DLA fractal dimension has been precisely computed as D_f = 1.713 ± 0.003 by Meakin and colleagues using large-scale simulations.

🌊 Shallow Water Equations (1D SWE)

The Saint-Venant equations

The 1D Saint-Venant (shallow water) equations describe the depth-averaged flow in a channel where the horizontal length scale greatly exceeds the water depth. They form a hyperbolic system of conservation laws:

∂h/∂t + ∂(hu)/∂x = 0           (mass conservation)
∂(hu)/∂t + ∂(hu² + ½gh²)/∂x = S  (momentum)

where h is the water depth, u is the depth-averaged velocity, g = 9.81 m/s² is gravitational acceleration, and S is the Manning friction source term: S = −g·n²·u·|u|·h−1/3.

Lax-Friedrichs scheme

The simulation uses the explicit Lax-Friedrichs finite-difference method, which is first-order accurate in space and time but unconditionally stable under the CFL condition. The time step is computed adaptively at each frame:

dt = CFL · dx / max(|u| + c)    where  c = √(gh)

The CFL slider (0.1–0.48) lets you observe numerical diffusion effects: lower values produce smoother but slower results; values approaching 0.5 sharpen wave fronts but may produce minor oscillations near shocks.

Scenarios

Froude number

The Froude number Fr = |u|/c is the shallow-water analogue of the Mach number. For Fr < 1 (subcritical flow) information can propagate both upstream and downstream. For Fr > 1 (supercritical flow) disturbances can only travel downstream. The transition Fr = 1 corresponds to a hydraulic jump in the steady state, and is marked by a dashed orange line in the velocity plot.

What's Next

Wave 58 will likely explore more probability theory, complex generative art patterns, or physics-based ODE/PDE simulations. The queue includes cell-growth-morphogenesis (reaction-diffusion + force-directed cells), origami-fold (crease pattern viewer), and 3d-generative-art (gyroid surfaces in Three.js).

← Devlog #76 — Wave 56 All posts →