Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Example: PSTD vs FDTD Comparison

Crate: kwavers
Run: cargo run -p kwavers --example pstd_fdtd_comparison
Source: crates/kwavers/examples/pstd_fdtd_comparison.rs

What This Example Demonstrates

Solver comparison of three acoustic wave equation discretizations on the same Gaussian pressure-pulse initial value problem in a homogeneous, lossless medium.

SolverMethodk-space correction
Classical FDTDStaggered-grid finite differencesNone
k-space FDTDStaggered-grid + spectral k-space derivativeSpectral
PSTDPseudospectral time-domainFull spectral

Theorem Validated

All three discretizations solve the same linear acoustic Cauchy problem:

ρ₀ ∂u/∂t = −∇p
∂p/∂t = −ρ₀c₀² ∇·u

With KSpaceCorrectionMode::Spectral, the k-space FDTD uses the same spectral derivative family as PSTD — so in short windows (before boundary reflections), it should agree more closely with PSTD than classical FDTD.

Key Code Snippet

use kwavers_solver::{FdtdSolver, KSpaceCorrectionMode, PstdSolver};

// Classical FDTD
let fdtd = FdtdSolver::new(&grid, &medium, KSpaceCorrectionMode::None)?;

// k-space-corrected FDTD
let kfdtd = FdtdSolver::new(&grid, &medium, KSpaceCorrectionMode::Spectral)?;

// PSTD
let pstd = PstdSolver::new(&grid, &medium)?;

References

  • Treeby & Cox (2010). J. Biomed. Opt. 15(2), 021314 — k-space pseudospectral acoustic modeling
  • Yee (1966). IEEE Trans. Antennas Propag. 14(3), 302-307 — FDTD

Book Chapter

← Numerical Methods: FDTD and PSTD