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: DG Acoustic Timestep Sweep

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

What This Example Demonstrates

This example performs a timestep refinement sweep for Discontinuous Galerkin (DG) methods. It tests different acoustic solvers (DG, FDTD, k-space FDTD, PSTD) with varying timesteps to show stability and accuracy characteristics.

Solvers Tested

SolverType
DGDiscontinuous Galerkin
FDTDFinite-Difference Time Domain
k-space FDTDk-space corrected FDTD
PSTDPseudo-Spectral Time Domain

Timestep Refinement Levels

LevelDescription
120 steps (coarsest timestep)
240 steps
380 steps (finest timestep)

Output Files

FileDescription
timestep_sweep.pngError vs. timestep for all solvers
timestep_sweep.csvNumerical data

Key Code Snippet

const STEP_COUNTS: [usize; 3] = [20, 40, 80];

let rows = run_timestep_sweep()?;
let out_dir = PathBuf::from("target/dg_acoustic_comparison");
fs::create_dir_all(&out_dir)?;
write_plot(&out_dir.join("timestep_sweep.png"), &rows)?;
write_csv(&out_dir.join("timestep_sweep.csv"), &rows)?;

Book Chapter

← Numerical Methods: FDTD and PSTD