The lake on this page
I grew up on Lake Iseo. For sixteen days in the summer of 2016, from 18 June to 3 July, Christo and Jeanne-Claude’s The Floating Piers joined Sulzano to Monte Isola and the small island of San Paolo: about three kilometres of walkway, 226,000 floating cubes and 70,000 square metres of yellow fabric. More than a million people walked across the lake. The orange line on this site is that walkway.
The water next to it is not a looping animation. It is a small simulation, and since physical plausibility is what I work on, it seemed only fair that the drawing should get its physics right.
Waves on deep water
For small waves on deep water, a wave of wavenumber k = 2π/λ oscillates at a frequency fixed by the dispersion relation
ω² = gk + (σ/ρ) k³
The first term is gravity pulling the crests down; the second is surface tension σ (over the density ρ) pulling the surface flat. Long waves are ruled by gravity and short ripples by surface tension, and the two disagree about speed. Among long waves the longest travel fastest; among ripples the shortest do. In between lies a slowest wave: on real water it is about 1.7 cm long and moves at about 23 cm/s.
On this page the constants are scaled so that the slowest wave is about a hundred pixels long. That puts both kinds of wave on the screen at once: the long waves from the breeze roll in slowly, and when you touch the water, the short ripples run out ahead of everything else.
Waves also fade, the short ones much faster than the long ones. Viscosity ν takes their energy at a rate that grows with the square of the wavenumber, γ = γ₀ + 2νk², so a ripple lives for a moment and a swell for much longer.
Solving it exactly
The breeze is seven wave trains, each with its own length and heading, each moving at the speed the dispersion relation gives it.
The ripples are where the equations earn their keep. Because the theory is linear, the surface can be written as a sum of Fourier modes on a periodic grid of 256 × 64, and each mode is then a little oscillator of its own. Its step forward in time can be written down exactly: a rotation by ω(k)Δt in its own phase space, and a shrink by e−γ(k)Δt. No error builds up and nothing blows up, however long the page stays open. A touch adds a small Gaussian dent to the surface, which in Fourier space is a Gaussian too, so it goes into every mode at once. One inverse FFT per frame turns the spectrum back into heights, and the pencil lines follow them.
Move the pointer across the water to leave a wake, or tap it to drop a stone. If your system asks for reduced motion, the lake stays still. The code is in lake.js.