pffdtd: wave-based FDTD for room acoustics

The ST-LINE fork of Brian Hamilton’s FDTD solver: grid-based propagation, cost, staircasing and the scope of CUDA optimizations and numerical compatibility.

Published on Updated on Room acousticsFDTDDiscontinuous GalerkinGPU CUDABRASInverse design
Code on GitHub ↗

Fork of pffdtd maintained by ST-LINE: wave-based FDTD solver for room acoustics, its cost, its limits and the changes from Brian Hamilton’s original (numerical scheme unchanged, CUDA engine modified). The repository is at github.com/stefanofante/pffdtd; the showcase card is in Open Lab.

The fork was used as an independent comparison during RaySound development and has been outside its production pipeline since June 2026, as reported in the article. The fork README describes its independent maintenance for research and validation.

FDTD for room acoustics

The Finite-Difference Time-Domain (FDTD) method solves linear acoustics in the time domain by discretising directly the first-order equations that link pressure and particle velocity. With no mean flow and for small perturbations, conservation of momentum and of mass give the system

ρ ∂v∂t=−∇p,\rho\,\frac{\partial \mathbf{v}}{\partial t} = -\nabla p,1ρc2 ∂p∂t=−∇ ⁣⋅v\frac{1}{\rho c^2}\,\frac{\partial p}{\partial t} = -\nabla\!\cdot\mathbf{v}

where pp is the acoustic pressure, v\mathbf{v} the particle velocity, ρ\rho the air density and cc the speed of sound. Eliminating the velocity yields the scalar wave equation ∂ttp=c2∇2p\partial_{tt} p = c^2 \nabla^2 p, and it is this that FDTD marches step by step on a regular grid, replacing the derivatives with centred finite differences in time and space.

Cartesian vs FCC stencil

The choice of stencil — the set of neighbouring nodes that approximate the Laplacian — governs accuracy and cost. The simplest scheme is the 7-point stencil on a Cartesian grid (the central node plus its six nearest axial neighbours). It is cheap but strongly anisotropic: the numerical wave speed depends on the propagation direction relative to the grid, and this numerical dispersion introduces phase error that grows with frequency.

A face-centred cubic (FCC) grid with a 13-point stencil distributes the neighbours more isotropically. For a given tolerated dispersion, FCC allows a coarser spatial step and ends up costing about five times less memory than the 7-point Cartesian stencil — because in FDTD the node count grows with the cube of the maximum frequency and RAM is the dominant constraint.

Stability, CFL and energy conservation

An explicit time-marching scheme is stable only if the time step respects the Courant–Friedrichs–Lewy (CFL) condition: information may not cross more than one cell per step. Compactly,

λ=c ΔtΔx≤λmax⁡\lambda = \frac{c\,\Delta t}{\Delta x} \le \lambda_{\max}

with λmax⁡\lambda_{\max} depending on the stencil (it is 1/31/\sqrt{3} for the 3-D 7-point Cartesian scheme). Exceeding the limit blows the solution up; staying just below it maximises per-node accuracy.

A deeper property is energy conservation. The scheme can be cast in passive form, with a discrete energy functional that never grows in the absence of sources and dissipation. In double precision this conservation is verifiable to machine precision: the energy balance closes to within the numerical epsilon step after step, and it is a sanity check on the solver. In single precision conservation holds only within a wider margin, so the engine adopts safeguards (energy monitoring, careful operation ordering) to avoid slow drift in long runs.

Frequency-dependent impedance boundaries (ADE)

Real materials do not have constant impedance: they absorb differently at different frequencies. Modelling a boundary as a frequency-dependent impedance condition Z(ω)Z(\omega) means, in the time domain, a convolution between pressure and the boundary response — costly and long-memoried. The auxiliary differential equation (ADE) technique sidesteps the convolution: it represents the impedance as a rational function of ω\omega and introduces, for each boundary node, a few auxiliary variables that evolve according to a local ODE. The global convolution thus becomes a small system of ODEs updated in place, compatible with the explicit, local nature of FDTD.

What FDTD costs, in numbers

The cubic growth in node count and the RAM constraint can be quantified for a 500 m³ room, with six points per wavelength at the maximum frequency, 1.5 s of simulated tail, a 7-point Cartesian stencil (CFL 1/√3) and three fields in double precision, that is 24 bytes per node:

f_max Δx Nodes Memory Steps Total updates
250 Hz 0.2287 m 4.2 · 10^4 1 MB 3897 1.6 · 10^8
500 Hz 0.1143 m 3.3 · 10^5 8 MB 7794 2.6 · 10^9
1000 Hz 0.0572 m 2.7 · 10^6 64 MB 15588 4.2 · 10^10
2000 Hz 0.0286 m 2.1 · 10^7 514 MB 31176 6.7 · 10^11
4000 Hz 0.0143 m 1.7 · 10^8 4.1 GB 62353 1.1 · 10^13
8000 Hz 0.0071 m 1.4 · 10^9 32.9 GB 124707 1.7 · 10^14
32 GB1 MB10 MB100 MB1 GB10 GB100 GB2505001k2k4k8kmaximum simulated frequency [Hz]grid memory
Grid memory against the maximum simulated frequency, for a 500 m³ room, on log-log axes. The line has slope 3: every octave costs eight times the memory. The dashed line is the ceiling of a 32 GB machine, reached just below 8 kHz.

The spatial step scales as 1/f, so nodes as f³; but CFL ties the time step to the spatial one, so time steps also grow as f. Total work therefore goes as f⁴: going up one octave costs eight times the memory and sixteen times the time. Between 250 Hz and 8 kHz, five octaves, there are six orders of magnitude of memory and six of work.

This is why FDTD is used at the low end of the spectrum.

What the FCC stencil buys

In a cubic law, five times the memory is worth 5^(1/3) = 1.71 times the maximum frequency, that is about three quarters of an octave more bandwidth on the same machine. And since a spatial step 1.71 times coarser also brings 1.71 times fewer time steps, the saving in total work is 8.5-fold, not fivefold.

Three quarters of an octave is the difference between stopping at 5 kHz and reaching 8.5 kHz, or between a run that fits in 32 GB and one that asks for 160. The choice of stencil therefore comes before any micro-optimisation of the kernel.

Bandwidth limit as a function of volume

The bandwidth ceiling depends on volume, and there too the dependence is cubic. Under the same assumptions, the maximum frequency that fits in memory:

Volume 8 GB 32 GB 128 GB
50 m³ (control room) 10.8 kHz 17.1 kHz 27.1 kHz
500 m³ (lecture hall) 5.0 kHz 7.9 kHz 12.6 kHz
15,000 m³ (concert hall) 1.6 kHz 2.6 kHz 4.1 kHz

A reference for interpreting the bandwidth is the Schroeder frequency, estimating a gradual transition towards stronger modal overlap rather than guaranteeing a diffuse field (see the reverberation wiki). It is about 179 Hz for 50 m³ and T60 = 0.4 s, 89 Hz for 500 m³ and 1 s, and 23 Hz for 15000 m³ and 2 s. Phase, diffraction, geometry and loss distribution can still matter above these values.

In all three examples, the memory-limited maximum frequency is above fS. This comparison measures neither accuracy nor actual runtime: the stated memory covers only the assumed fields, excluding geometry, boundaries, buffers, outputs and runtime resources. Usable bandwidth must be checked for the complete problem.

A hybrid approach can contain repeated-simulation cost while retaining a wave description where needed. Under the table’s assumptions, a 2 kHz calculation for 500 m³ requires about 6.7 × 10¹¹ node updates; one hundred iterations with two calculations each would require about 1.3 × 10¹⁴ updates if each calculation had the same cost. This is not a runtime measurement of a particular inverse algorithm.

Staircasing and its correction

A regular grid represents axis-aligned walls well, but an inclined or curved surface is approximated as a staircase (staircasing). The effective boundary area seen by the scheme is systematically wrong — the steps inflate the exposed area — and since total absorption is proportional to area, staircasing leads to overestimating absorption and hence, at times, to mis-estimating decay times. On unfavourable geometries the reverberation-time error can reach around 50 %.

The effective-area correction fixes this by weighting each boundary node’s contribution with the area actually intercepted by the continuous surface, rather than with the staircase area. Applied on progressively finer grids, it brings the error below 1 %. It remains a remedy, though: the underlying geometry is still staircased, and this is one of the structural reasons why, when exact geometry is needed, one moves to a body-conforming method (see Discontinuous Galerkin below).

The pffdtd fork: what was optimised

pffdtd derives from Brian Hamilton’s FDTD simulator (University of Edinburgh, 2021), under the MIT licence. The ST-LINE fork README distinguishes forward optimizations retaining the Cartesian/FCC scheme from corrections to geometry preparation and data. Numerical compatibility must refer to tested inputs, precision and version: machine-precision identity is not assumed for every path. The public fork is a standalone reference and does not describe RaySound’s implementation.

Optimisations:

  • Build for the actual GPU architecture. Instead of compiling for sm_35 (Kepler) and relying on runtime PTX-JIT recompilation on modern GPUs, the fork builds for the card’s actual architecture. This removes the first-launch JIT latency and the inefficiencies of code generated for an obsolete ISA.
  • Multi-GPU peer access. The fork enables direct access available on the topology. The application has no explicit host-staging route for devices without peer access; multi-GPU behaviour requires tests on the actual topology.
  • Batched source injection. The original launched a <<<1,1>>> kernel — a single thread — per source and per timestep, wasting the GPU’s parallelism. The fork injects sources in batch, in a single kernel.
  • Block-wise read-out. Receiver extraction happens in blocks rather than point-by-point, reducing the number of transfers.
  • Memory-budget check. Comparison against cudaMemGetInfo precedes field allocation; it neither reserves memory nor automatically resizes partitions.

Two hardware tuning profiles

The stated targets are RTX 4500 Ada, 24 GB dedicated VRAM, and DGX Spark GB10, 128 GB shared with the host. Shared physical memory does not imply managed allocation or automatic paging: the documented path uses cudaMalloc. Runtime and host allocations need headroom beyond the numerical fields; a budget check does not guarantee that the entire computation fits.

References

  • B. Hamilton, pffdtd — FDTD solver for room acoustics, 2021, MIT licence. github.com/bsxfun/pffdtd.
  • F. Mondet et al., few-parameter fractional impedance model for acoustic surfaces, 2020. DOI 10.1016/j.apacoust.2019.04.034.
  • J. S. Hesthaven, T. Warburton, Nodal Discontinuous Galerkin Methods: Algorithms, Analysis, and Applications, Springer. DOI 10.1007/978-0-387-72067-8.
  • C. F. Eyring, Reverberation time in “dead” rooms, J. Acoust. Soc. Am., 1930. DOI 10.1121/1.1915175.
  • M. R. Schroeder (1962), Frequency-correlation functions of frequency responses in rooms. DOI 10.1121/1.1909136.
  • L. Aspöck et al., BRAS — Benchmark for Room Acoustical Simulation, TU Berlin, 2020. DOI 10.14279/depositonce-6726.3.

Last updated: · Found an error or outdated information? Let us know

A similar project?