🌊 Stokes Flow
Interactive creeping (Stokes) flow simulation. Watch the Stokeslet velocity field, the famous reversibility experiment where smeared dye re-forms, and low-Re swimming.
About this simulation
This sandbox explores creeping flow, the regime that dominates when a body moves so slowly (or is so small) that viscous forces overwhelm inertia — the exact closed-form Stokes solution for uniform flow past a sphere is evaluated live and used to advect hundreds of tracer particles. A second mode demonstrates the startling reversibility of Stokes flow in a Couette cell: three coloured dye blobs are smeared by an exactly invertible angular shear, and running the shear backward re-forms them perfectly, because inertia (which would scramble the pattern irreversibly) is negligible. A third mode animates a Purcell-style three-link swimmer whose stroke either encloses area in shape-space (net progress) or doesn't (the scallop theorem: zero net displacement, no matter how fast the reciprocal stroke is repeated).
🔬 What it shows
In "Stokeslet flow field" mode, tracer particles are advected by the exact Stokes solution for flow past a fixed sphere (fore-aft symmetric streamlines, independent of Reynolds number). "Reversibility demo" shears three dye blobs in an annulus and lets you reverse the rotation to watch them re-form. "Low-Re swimmer" animates a hinged two-arm swimmer whose net displacement depends on whether its stroke is reciprocal or not.
🎮 How to use
Pick a Mode with the radio buttons, then drag the Reynolds number and Flow speed sliders (Re is logarithmic, from 10^-4 to about 5) and the Tracer count slider in field mode. In the swimmer mode, toggle between Non-reciprocal and Reciprocal strokes; in the reversibility mode, use Forward/Reverse and Auto-cycle to shear and un-shear the dye.
💡 Did you know?
Because the Stokes equations are linear and time-independent, running the exact same motion in reverse exactly undoes it — this is why bacteria can't swim by flapping a single reciprocal paddle (the scallop theorem) and must instead use corkscrew flagella or asymmetric strokes like the non-reciprocal mode shown here.
Frequently asked questions
What does "low Reynolds number" actually mean here?
The Reynolds number Re compares inertial forces to viscous forces in a fluid. The Re slider spans roughly 10^-4 to 5 on a log scale; at the low end, viscosity totally dominates and the flow is "creeping" — no turbulence, no inertia, every motion is instantly damped.
Why do the streamlines around the sphere look the same regardless of Re?
The field mode draws the exact closed-form Stokes solution for uniform flow past a sphere, which is derived assuming inertia is negligible entirely. That solution has no Re dependence built into the velocity field itself, so the streamline pattern only depends on flow speed and sphere size, not on Re — this is the "wow point" noted directly in the code.
How does the reversibility demo actually work?
Dye particles are stored at fixed base positions (r0, a0) inside an annulus, and their displayed position is computed by applying the CURRENT total accumulated shear to that base position. Because the shear-to-position mapping is exactly invertible, running shearTotal back down to zero snaps every particle back to precisely where it started, reproducing the classic Couette-cell dye experiment.
What is the scallop theorem shown in the swimmer mode?
It states that a swimmer using a reciprocal stroke (one that looks identical played forwards or backwards) cannot generate net motion at low Reynolds number. The simulation models thrust as the area enclosed by the two arm angles in shape-space; a reciprocal stroke (phaseShift = 0) traces a loop with zero enclosed area, so net displacement stays at zero however fast you move.
Why does the non-reciprocal swimmer move but the reciprocal one doesn't?
With a 90-degree phase shift between the two arms, the shape-change cycle traces a closed loop in shape-space that encloses a nonzero area, and the code integrates that loop area (a times db/dt) directly into forward displacement (swimX). Set the phase shift to zero (Reciprocal button) and the loop collapses to a line with zero area, so the swimmer oscillates in place instead of advancing.
Drag a sphere through creeping flow at low Reynolds number and watch Stokes-flow reversibility re-form a smeared dye blob.
3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install