Visualizations
192 / 500

192 · Fluids

Plankton Bloom

Eddies stir green diatom and turquoise coccolith blooms, like ocean-color imagery.

Four fields share a grid: nutrients, fast-growing diatoms, slower coccolithophores that win once nutrients run low, and zooplankton that graze both with a sigmoidal appetite and a taste for diatoms. Coastal winds push surface water offshore and upwell deep nutrients, so green diatom blooms hug the coast and age into milky turquoise coccolith swirls as they drift out to sea. The current is the curl of a stream function built from drifting Gaussian eddies, a meandering jet and weak small-scale stirring, masked so the coastline is a streamline. Fields are advected semi-Lagrangian with a MacCormack correction on the plankton to keep filaments sharp, then shown as true-color water or as a log-scale chlorophyll map.

Try it. Drag to paint nutrients and watch a bloom grow and smear along the currents. Choose Spin eddy (or right-drag) and press and drag to steer a new whirlpool through the water. Raise or lower the upwelling wind, switch to the chlorophyll view with the button or V, and press R for a fresh ocean.

  • NPZ ecosystem model
  • Stream function eddies
  • MacCormack advection
  • Ocean color rendering

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 an ocean plankton bloom simulation that looks like satellite ocean-color imagery, 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, and resizes with the window.
- Create a grid about 300 by 200 cells with three fields: nutrients N, phytoplankton P and zooplankton Z.
- Build a current from a stream function: the sum of a dozen Gaussian bumps (eddies) of random size and sign that drift slowly. The velocity is the curl of the stream function (u = d(psi)/dy, v = -d(psi)/dx), which is automatically divergence free.
- Each frame, advect all three fields semi-Lagrangian (trace each cell backward along the velocity, sample with bilinear interpolation), then update the biology: P grows on N with a Michaelis-Menten term, Z grazes on P, and some of what dies returns to N.
- Add nutrients along one edge (an upwelling coast) so blooms keep starting there.
- Color each cell from deep blue (clear water) toward green as P rises, and draw the grid scaled up with smoothing.

Once that works, make it beautiful:
- Split phytoplankton into fast diatoms (green) and slower coccolithophores that do well at low nutrients and turn the water milky turquoise.
- Add a MacCormack correction to the plankton advection so filaments stay sharp.
- Draw a land mass along the coast and make the coastline a streamline by multiplying the stream function by a ramp that is zero at the shore.
- Let the mouse paint nutrients.

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 log-scale chlorophyll false-color view, draggable eddies, or offshore Ekman transport that carries coastal blooms out to sea.
PreviousPCB AnnealerSimulated annealing places chips on a circuit board, then a maze router lays copper. NextFourier DarkroomPaint on a picture's 2D spectrum and watch the inverse FFT redraw it instantly.

Related visualizations

  • Glowing SurfFluids Moonlit waves break on a beach and the plankton in them flash electric blue.
  • Ink in WaterFluids A real fluid solver swirls colored dye like ink in water.
  • Kelvin-Helmholtz BillowsFluids A sunset sky where sliding air layers roll a cloud deck into breaking-wave billows.
  • Pond DropNature A drop of pond water under a brightfield microscope, with a focus knob you can turn.
  • Rayleigh-Taylor FingersFluids Heavy ink collapses into mushroom fingers in a glass tank you can turn upside down.
  • Kelp ForestPhysics Buoyant kelp sways in an ocean surge under god rays and live caustics.
  • Convection CellsFluids Water heated from below boils into mushroom plumes and rolling convection cells.
  • Ocean3D Rolling waves at sunset, built from layered Gerstner waves.
  • Gene SurfingSimulation Drift at a growing colony's edge splits red and green bacteria into jagged sectors.

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

← More from Emergent Mind Labs