Wave Lab
Nothing here is drawn from a formula. The 2D acoustic wave equation is solved step by step on a staggered FDTD grid, so reflection from walls, diffraction through slits and interference between array elements all come out of the simulation. The tables then put those measurements next to λL/d, the array factor, the Doppler formula and the room-mode frequencies, and show the error. Drag the listener around and the level and pitch measured at its two ears become sound.
| Quantity | FDTD | Theory | Δ |
|---|
∂p/∂t = −c ∇·v′ + s(x, t), ∂v′/∂t = −c ∇p (v′ = ρc·v)
v′xn+½ = v′xn−½ − S (pi − pi−1)n, pn+1 = pn − S ∇h·v′n+½
S = cΔt/Δx = 0.6 ≤ 1/√2 · sin(ωΔt/2) = S·√(sin²(kxΔx/2) + sin²(kyΔx/2))
Staggered Yee grid, second order in space and time. The second relation is the scheme's own dispersion: waves resolved by fewer cells travel slightly slower than c, which the panel reports as cnum/c.
p = px + py, ∂px/∂t + σxpx = −c ∂v′x/∂x
σ(ξ) = σmax(ξ/L)², σmax = 3c·ln(1/R)/2L, R = 10−5
rigid walls: v′·n = 0 · point source: |p(1 m)| = A via |p| = (ωQ/4)·|H0(kr)|
Split-field PML with exponential time stepping; a pulse test measures its reflection at about −100 dB. Sources are injected on a Gaussian footprint so moving ones don't radiate grid noise.
maxima: d sinθ = mλ ⇒ Δy ≈ λL/d (small angle)
I(y) ∝ |Σapertures ½(1+cosθ) eikr/√r|²
The Huygens sum uses the true path lengths to the screen, so it includes the large-angle and near-field corrections that λL/d leaves out.
τn = xn sinθ0/c · AF(θ) = |Σ wn eikxn(sinθ − sinθ0)| / Σwn
grating lobes: sinθ = sinθ0 − mλ/d, none while d < λ/(1+|sinθ0|)
The arc sits at R = 2.1 m, which is not the far field of a long array, so the FDTD is compared with the exact sum of 2D Green's functions at R. The far-field AF is shown dotted.
f′ = f / (1 − M cosθe), t = te + |xobs − xs(te)|/c
M > 1: Mach cone, sin μ = 1/M
θe is the angle at the moment of emission (retarded time), not where the source is when the sound arrives.
fmn = (c/2)·√((m/Lx)² + (n/Ly)²)
pmn ∝ cos(mπx/Lx)·cos(nπy/Ly)
Rigid walls with a uniform loss γ, so modes ring with T60 = 3 ln10/γ. The response curve comes from one impulse run, H(f) = Pmic(f)/S(f).
What is computed, and what it is checked against
Pressure and particle velocity live on grids offset by half a cell, and ∂p/∂t = −c∇·v′, ∂v′/∂t = −c∇p are integrated to second order. A split-field PML absorbs at the outer boundary; walls are rigid, with zero normal velocity. Each experiment asks one question. Does the fringe spacing really follow λL/d as the slits move apart? Does a delayed array send its beam where it was told? When the element spacing passes λ, do grating lobes appear where predicted? Is the pitch ahead of and behind a moving source f/(1∓M)? Does the room resonate at fmn?
The same engine is checked by scripts/test-wave.ts: wave speed (within 1% of the scheme's dispersion relation), 1/√r spreading and source calibration, PML reflection (about −100 dB), array main-lobe and grating-lobe angles, fringe spacing (including the live lock-in readout the page shows), Doppler shift at fixed mics and at a listener while the pitch sweeps, and room-mode frequencies.
What is simplified
- The simulation is 2D, so every source is a line source normal to the plane and free-field pressure falls as 1/√r, not 1/r.
- Air is lossless and linear. Only the room has a uniform loss γ, and its walls are perfectly rigid.
- Waves resolved by few cells travel slightly slow (numerical dispersion). The panel shows this as cnum/c, and it matters most where wavelengths shrink, such as ahead of a fast source.
- The array's measurement arc (R = 2.1 m) is not in the far field of a long array, so it is compared with the exact sum of Green's functions at that radius.
- The simulation runs hundreds of times slower than real time. The sound is not the waveform played back but a sine resynthesised from each ear's measured level and zero-crossing pitch, and the phase between the ears is not reproduced.
- Heard pitch is a zero-crossing count over the last six periods, so while it sweeps it lags the instantaneous f′(t). The table compares it with f′ averaged over the same window; the instantaneous curve is drawn dotted.
- Supersonic runs show the Mach cone, but no single heard frequency is predicted there: several emission times arrive at once.