Plane acoustic waves in a gas obey the linearised conservation laws (p = pressure perturbation, u = particle velocity, ρ density, c speed of sound):
∂u/∂t = −(1/ρ) ∂p/∂x − α u
∂p/∂t = −ρc² ∂u/∂x + ρc² q(x,t)
c = √(γ R T / M) (air 20 °C: 343.2 m/s)
The simulator integrates these two equations with a staggered-grid leapfrog (Yee-type) scheme at CFL = 0.9 and cell size ~5 mm. A closed end is u = 0, an open end is p = 0 at the mouth. The loudspeaker is a point source q; the microphone samples p at its position. Loss is a simple velocity-proportional term α, giving every mode Qn = ωn/α.
Closed–closed, open–open: f_n = n c / (2 L_eff)
Closed–open: f_n = (2n−1) c / (4 L_eff)
L_eff = L + 0.6133 a per open end (end correction, unflanged pipe)
The resonance curve in the bottom pane is not a formula: a Gaussian pulse is launched, the microphone signal is recorded and Fourier transformed (FFT) and divided by the pulse spectrum. Nodes and antinodes in the middle pane come from the simulated pressure and velocity envelopes. Move the speaker onto a node of a mode and that mode disappears from the curve.
Simplifications: 1-D plane waves (valid while wavelength > ~3.4 a, i.e. below the first cross-mode cut-off f≈1.84 c/(2πa)); open ends are ideal pressure-release boundaries (no radiation loss, constant end correction, low-ka limit); loss is frequency-independent (real tubes lose more at high f through viscous/thermal boundary layers); the dots and colours are auto-scaled for visibility and the motion is slowed down by the chosen factor. Sound is optional and plays a plain tone at the drive frequency.