This simulation needs WebAssembly, and it could not start in this browser.
The image is a frame from a real run. Check that JavaScript is on, or try another browser.
Jean le Rond d’Alembert wrote down the wave equation in 1747 to describe a vibrating string, and Leonhard Euler soon extended it to membranes and to sound in air. The same equation describes ripples on shallow water, the vibration of a drumhead and, through Maxwell’s equations, each component of a light wave in empty space. This simulation solves it on a square grid of 200 by 200 cells with the leapfrog finite-difference scheme, whose stability limit Richard Courant, Kurt Friedrichs and Hans Lewy worked out in 1928.
What you see
The field on the whole grid: crests are red, troughs blue, and the brightness grows with the amplitude. Walls are dark violet. The edge of the grid holds , like the clamped rim of a drum, so a wave that reaches it is reflected with its sign flipped: a crest comes back as a trough. With Absorbing boundary switched on, a layer 20 cells deep along the edge damps the waves instead.
A pulse released at rest in two dimensions does not leave a single clean ring. The ring is followed by a weak wake that fades slowly, because Huygens’ principle in its sharp form holds only in odd numbers of dimensions.
Governing equation
With grid spacing and time step both set to 1, the update reads
so is the Courant number in cells per step. The scheme is stable for , the Courant limit in two dimensions. Without damping it conserves a discrete energy exactly: in a closed box the measured drift stays below over 8000 steps. With damping the energy falls as . A rectangular box of side has the resonant frequencies
Here cells, since the zero boundary sits one cell outside the grid. The page runs 4 steps per frame, 240 steps per second at 60 frames per second.
Presets
Pulse in a closed box: a Gaussian bump 4 cells wide, released at rest left of center. At the front moves 120 cells per second, reaches the nearest wall after about 140 steps (0.6 s) and comes back inverted. The reflections pile up into an irregular pattern while the total energy stays constant.
Fast waves: the same pulse at , just below the stability limit, so it crosses the box in about 1.2 s.
Damped pulse: per step. The energy drops by a factor every 250 steps, about once per second; the measured value after 248 steps is 0.366 of the start, against .
Absorbing boundary: the pulse in a box with the absorbing layer on. After 400 steps (1.7 s) 0.6 % of the energy is left, after 600 steps 0.3 %, and most of that is the slow wake inside the box rather than reflections.
Wave train through two slits: a train with a wavelength of 12 cells runs into a wall with two slits 6 cells wide and 40 cells apart, center to center. Behind the wall the waves from the two slits interfere: bright fringes lie where the path difference is a whole wavelength, , so the first order lies at 17.5°. Summed over the passage, the intensity 99 cells behind the wall has its first bright fringes 30.5 cells off the axis (31 expected) and its first dark fringes at 15.5 cells (15 expected). The train has passed after about 500 steps (2 s); Reset sends it again.
Standing wave, mode (3, 2): the field starts in the shape , with two vertical and one horizontal nodal line. It oscillates in place with a measured period of 224 steps (0.93 s), against steps.
Parameters
Wave speed (cells per step): , from 0.1 to 0.7. It acts at once.
Damping (per step): , from 0 to 0.02. It acts at once.
Absorbing boundary: switches the absorbing layer along the edge on or off, at once.
Show walls: draws the walls of the two-slit preset; hidden walls look like empty field. It changes only the drawing.