Visualizations
491 / 500

491 · Fluids

Viscous Fingering

Air forced into honey between glass plates splits into branching fingers.

In a Hele-Shaw cell the honey obeys Darcy's law, so its pressure satisfies a Laplace equation, relaxed every frame with red-black SOR on a 286 by 286 grid. Air cells hold one minus surface tension times curvature (measured by counting air in a small disc), and honey cells on the interface fill with the flux pushed out of them until they turn to air, at a fixed total injection rate. Bumps that stick out see steeper gradients and outrun their neighbors, the Saffman-Taylor instability, while surface tension blunts and splits the tips. Grooves etched in the glass raise the permeability so fingers follow them like a growing snowflake, and the image is lit like a light table with Beer-Lambert honey color and a refracting meniscus.

Try it. Drag to etch grooves and watch fingers chase them. Tap to add another air port. Scroll or use the arrow keys to change the injection rate, A cycles growth anisotropy, P shows the pressure field, N jumps to the next scene and R restarts.

  • Laplacian growth with SOR
  • Curvature by disc counting
  • Smoothstep contours from a coarse field

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 viscous fingering simulation, air pushed into honey between two glass plates, 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 square grid of about 200 by 200 cells. Each cell is honey or air. Start with a small disc of air in the middle; cells outside a big circle are the open edge.
- In a thin cell the honey's pressure p obeys Laplace's equation. Fix p = 1 in air and p = 0 at the edge, and relax the honey cells every frame with a few dozen sweeps of successive over-relaxation (each cell moves toward the average of its four neighbors, overshooting by a factor of about 1.9).
- Honey cells touching air gain "fill" equal to the pressure drop from their air neighbors. When a cell's fill passes a threshold, it becomes air. Give each cell a slightly random threshold.
- Draw honey amber and air pale cream with putImageData.

Once that works, make it beautiful:
- Add surface tension: for each air cell on the edge, count the air in a small disc around it and lower its pressure where the air is a sharp bump, so tips blunt and split instead of spiking.
- Scale growth so a fixed area of air is injected per second, and let the mouse wheel change the rate.
- Render smoothly: blur the air map a little, sample it bilinearly at screen resolution, and use a smoothstep around 0.5 with a thin dark line for the meniscus.

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 grooves drawn with the mouse that raise the permeability, anisotropic growth for crystal-like dendrites, or contour lines that show the pressure field.
PreviousDissonance CurvePlomp-Levelt roughness summed over every partial pair: where consonance comes from. NextLateral InhibitionFour brightness illusions, each predicted live by a model of retinal ganglion cells.

Related visualizations

  • Honey CoilingFluids Honey falls onto toast and coils, loops and meanders like a real viscous rope.
  • Rayleigh-Taylor FingersFluids Heavy ink collapses into mushroom fingers in a glass tank you can turn upside down.
  • Coffee RingFluids Coffee drops dry into dark rings, beside two tricks that make them dry evenly.
  • Glass HarpSound Ray-traced wine glasses, tuned with water and sung by stick-slip friction on the rim.
  • Kelvin-Helmholtz BillowsFluids A sunset sky where sliding air layers roll a cloud deck into breaking-wave billows.
  • Soap FilmFluids A draining soap film swirls with true thin-film colors until it turns black and pops.
  • Faraday WavesFluids A shaken dish of liquid locks into stripes, squares, hexagons and a 12-fold quasicrystal.
  • Ink in WaterFluids A real fluid solver swirls colored dye like ink in water.
  • Rain on GlassFluids Raindrops bead, merge and run down a fogged window, each a tiny upside-down city.

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

← More from Emergent Mind Labs