Visualizations
121 / 500

121 · Physics

Microswimmers

A flagellum, Purcell's three-link swimmer and a scallop that cannot move, in Stokes flow.

At the scale of a bacterium inertia vanishes and a swimmer moves only while it changes shape, so each swimmer here is solved with resistive force theory: every short piece of body feels a drag proportional to its velocity, twice as strong sideways as lengthwise, and at each instant a 3x3 linear solve finds the translation and rotation that leave the body free of net force and torque. A flagellum passing a travelling wave swims while the same flagellum flapping a standing wave stays put; Purcell's three-link swimmer moves only when its two hinge angles trace a loop in shape space, backwards when the loop is reversed and not at all for a figure eight whose lobes cancel; and the one-hinge scallop, whose shape space is a line, ends every stroke where it started no matter how its opening and closing speeds differ (Purcell's scallop theorem). The water around each body is a sum of regularised Stokeslets carrying the drag forces, drawn as streamlines over a speed wash on graph paper that moves with the fluid, and the panel on the right shows each stroke as a path in its shape space with the net motion per stroke.

Try it. Draw any closed loop in the Purcell panel and the swimmer performs it; click a panel (or press 1, 2, 3) to cycle that swimmer's strokes. Click or drag in the water to drop dye and watch fluid parcels loop as a swimmer goes by. Space drops dye at every swimmer and R clears the tracks.

  • Resistive force theory
  • Regularised Stokeslets
  • Scallop theorem
  • Shape-space geometric phase
  • Streamline tracing

View the source · one module, plus a small shared runtime for sizing, the animation loop and input

Build your own

Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.

Build a low Reynolds number swimming demo with JavaScript and the HTML canvas element. Put everything in a single index.html file with no libraries or build step, so I can open it directly in a browser.

Start simple:
- Make a canvas that fills the window, stays sharp on high-DPI screens (scale by devicePixelRatio), and resizes with the window. Use a clean off-white paper background and dark ink lines, like a textbook figure.
- Model Purcell's three-link swimmer: a middle rod with an arm hinged at each end. Describe its shape by the two hinge angles, and drive them around a square loop in shape space over a few seconds.
- Split each rod into about eight short pieces. Use resistive force theory: each piece feels a drag force equal to minus its velocity, with the coefficient for sideways motion twice that for lengthwise motion.
- Each frame, find the swimmer's velocity and spin. The velocity of a piece is the body's translation plus its rotation plus the shape change (take the shape change by finite differences). Because the drag is linear in the three unknowns, total force zero and total torque zero give a 3 by 3 linear system. Solve it and move the body.
- Draw graph paper fixed to the water so you can see the swimmer advance.

Once that works, make it beautiful:
- Add a second lane with a scallop (one hinge that opens slowly and closes fast) and show that it ends every stroke where it began.
- Compute the water's velocity on a grid as a sum of regularized Stokeslets carrying the drag forces, and draw short streamlines with arrowheads, faded by speed.
- Show the shape-space loop beside the swimmer, and let me draw my own loop with the mouse.

Explain the key ideas in short code comments. When you're done, tell me how to open it and suggest three directions I could take it next, such as a flagellum with a travelling wave, dye that traces fluid parcels, or swimmers near a wall.
PreviousManifold UnrollIsomap and LLE unroll a paper Swiss roll, and tear it when k is too large. NextDark Matter CurveSwitch off the dark halo and watch a spiral galaxy fly apart.

Related visualizations

  • Pond DropNature A drop of pond water under a brightfield microscope, with a focus knob you can turn.
  • Rogue WavesFluids A storm swell where walls of water rise from nowhere through nonlinear focusing.
  • Metachronal WalkerNature A millipede and a centipede ripple across a sketchbook page on waves of legs.
  • Glowing SurfFluids Moonlit waves break on a beach and the plankton in them flash electric blue.
  • Rayleigh-Taylor FingersFluids Heavy ink collapses into mushroom fingers in a glass tank you can turn upside down.
  • Three-Body BalletPhysics Twenty-two periodic three-body orbits, inked like calligraphy until a nudge breaks them.
  • Ink in WaterFluids A real fluid solver swirls colored dye like ink in water.
  • SolitonsFluids Solitary waves in a canal pass through each other unchanged, drawn as a Victorian plate.
  • Wind TunnelFluids A lattice Boltzmann wind tunnel: draw any shape and watch it shed vortices.

Use ← and → to move between demos. While the canvas has focus, keys go to the demo instead.

← More from Emergent Mind Labs