Skip to main content
WaveSimFEM

A GPU-Accelerated Finite Element Framework for Acoustic and Elastic Wave Propagation in Layered Media

Python 3.11+ DOLFINx 0.10.0 MPI / PETSc CUDA / CuPy
PyPI CI License: MIT

Quick Start • Examples • Capabilities • Configuration • Documentation • Discussions • Citation


💡 What is WaveSimFEM?

WaveSimFEM lets you simulate how acoustic, ultrasonic, and seismic waves propagate, reflect, attenuate, and couple across layered media — from Hz-scale earth structures to MHz-scale plates and tissues — without writing finite element code.

Describe your layers, material properties, wave source, and virtual sensors in a plain YAML file, run one command, and obtain waveforms, B-scans, frequency–wavenumber ($f$–$k$) dispersion spectra, and optional 2D wavefield animations. Under the hood, it runs on DOLFINx, PETSc, and optional CuPy GPU acceleration.

1. YAML Config  ──▶  2. Run `wavesim`  ──▶  3. Data (.npz) + Plots + 2D Wave Animations
  (your model)        (CPU, MPI, GPU)         (waveforms, B-scans, f–k, ParaView .bp)

✨ Why Use WaveSimFEM?

  • No FEM boilerplate: Define geometry, materials, sources, and sensors in readable YAML files.
  • Multi-physics layered media: Model isotropic metals, anisotropic composites, viscoelastic tissues, acoustic fluids, and coupled fluid–solid systems.
  • Fast on any hardware: Run on a single laptop CPU, scale across CPU cores with MPI, or accelerate on NVIDIA GPUs with CUDA.
  • Safe defaults & preflight checks: Preview mesh size, time step, and RAM usage (--dry-run) before running, with automatic stability checks so explicit runs do not blow up.
  • Built-in signal analysis & wave animations: Record virtual sensor arrays for waveforms, B-scans, and $f$–$k$ dispersion plots, and optionally export full 2D wavefield snapshots (.bp) for smooth animations in ParaView.

🚀 Quick Start

Step 1 — Install

WaveSimFEM uses Conda (conda-forge) to install the DOLFINx / PETSc / MPI finite element stack cleanly on Linux and macOS:

git clone https://github.com/ductho-le/WaveSimFEM.git
cd WaveSimFEM
conda env create -f environment.yml
conda activate wavesim
pip install --no-deps -e .

Already inside a DOLFINx 0.10.0 Conda or Docker environment? Install directly from PyPI:

pip install --no-deps wavesimfem

(Optional) Add NVIDIA GPU support (CUDA 12.x):

pip install "wavesimfem[cuda]"   # or: pip install -e ".[cuda]" from source
💡 macOS note (only if you see an Xcode linker error)

If you hit unknown architecture arm64e during first-run compilation, prefix the command with Apple's system compiler:

CC=/usr/bin/clang LDSHARED="/usr/bin/clang -bundle -undefined dynamic_lookup" \
  wavesim -c configs/01_plate_aluminum_lamb.yaml --no-usetex

Step 2 — Run Your First Simulation

Start with Example 01 (a 1 MHz Lamb wave in a 3 mm aluminum plate):

# 1. Check mesh size and estimated RAM before running (takes ~1 second)
wavesim -c configs/01_plate_aluminum_lamb.yaml --dry-run

# 2. Run the simulation and generate plots (--no-usetex avoids needing LaTeX installed)
wavesim -c configs/01_plate_aluminum_lamb.yaml --no-usetex

When it finishes, open results_01_plate_aluminum_lamb/full_analysis.png to inspect the recorded waveforms, B-scan, and $f$–$k$ dispersion plot.

Step 3 — Replot or Load Results in Python

Change frequency/wavenumber plot limits anytime without re-running the solver:

wavesim --postprocess results_01_plate_aluminum_lamb/sensor_data.npz \
  --f-max "2 MHz" --k-max "3 rad/mm" --no-usetex

Or load the saved sensor data directly in Python:

import numpy as np

with np.load("results_01_plate_aluminum_lamb/sensor_data.npz", allow_pickle=False) as data:
    times = data["times"]  # Time vector [s]
    sensor_x = data["sensor_x"]  # Sensor positions along x [m]
    u_y = data["sensor_data_y"]  # Vertical displacement [m] (fluid cases use sensor_data_pressure)

print(f"Recorded {u_y.shape[1]} sensors over {len(times)} time steps.")

📚 Ready-to-Run Examples

Pick the example closest to your application under configs/ and adapt it:

Example Structure Physics & Application Source
01 · Aluminum plate 3 mm isotropic plate Lamb waves & NDE/SHM inspection 1 MHz Ricker
02 · CFRP composite 8-ply [0/90/0/90]_s laminate Anisotropic guided-wave dispersion 1 MHz Ricker
03 · Steel halfspace Truncated elastic half-space Rayleigh surface waves 1 MHz Ricker
04 · Soil over bedrock 10 m soil layer on bedrock Seismic surface-wave dispersion 15 Hz Ricker
05 · Cortical bone Soft tissue / bone / marrow Viscoelastic axial-transmission ultrasound 500 kHz Ricker
06 · Immersed plate Aluminum plate in water Leaky Lamb & Scholte waves 1 MHz Ricker
07 · Water channel Acoustic water cavity Pure acoustic pressure waves 1 MHz Ricker
08 · Coupled fluid–solid Aluminum plate on water Fluid–structure interaction 1 MHz Ricker

🌍 What You Can Simulate

The 8 configs above are just starting points — mix any layer stack, material law, source, boundary, and sensor array to model wave physics from Hz-scale geophysics to MHz ultrasonics:

  • NDE & Composites: Lamb modes ($A_0, S_0$, higher-order), narrowband tone-burst tuning, anisotropic CFRP dispersion, bonded/coated plates, and immersed leaky Lamb waves.
  • Acoustics & Fluid–Solid Coupling: Pressure waveguides, cavity resonances, oblique fluid–solid reflection/transmission, and Scholte / quasi-Scholte interface waves.
  • Biomedical Ultrasound: Axial-transmission guided waves in layered tissue/bone/marrow with Kelvin–Voigt viscoelastic attenuation.
  • Geophysics & Seismology: Bulk $P$/$SV$ arrivals, Rayleigh surface waves, dispersive soil-over-bedrock profiles, and synthetic shot gathers.
  • Data Generation & Inversion: Reproducible parameter sweeps producing waveform, dispersion, and 2D wavefield datasets for inverse modeling and ML.

🛠️ Create Your Own Model

Generate a fully commented starter file with:

wavesim --generate-config my_model.yaml

All numeric inputs use standard SI units (m, s, Hz, Pa, kg/m³). Here is a complete, minimal example:

solver:
  type: explicit
  CFL: 0.8

structure:
  mode: 1_layer
  single_layer:
    name: aluminum
    thickness: 3.0e-3          # 3 mm thick plate
    rho: 2700.0                # Density [kg/m^3]
    E: 70.0e9                  # Young's modulus [Pa]
    nu: 0.33                   # Poisson's ratio

geometry:
  sensing_length: 0.10         # 100 mm observation zone
  absorb_length: 0.03          # 30 mm absorbing edges to suppress reflections

mesh:
  nx: 320                      # Elements along x
  ny_per_region: [12]          # Elements through thickness (bottom-to-top)
  degree: 2                    # Quadratic (Q2) elements

excitation:
  source_type: ricker
  f_center: 1.0e6              # 1 MHz center frequency
  traction_max: 1.0e6
  source_fy: -1.0              # Downward normal force

sensors:
  n_sensors: 64
  sensor_offset: 5.0e-3        # Distance from source to first sensor [m]
  sensor_pitch: 1.0e-3         # 1 mm spacing between sensors

output:
  write_vtx: false             # Set true to export 2D wavefield snapshots for ParaView animations
  target_snapshots: 200        # Number of animation frames when write_vtx is true

Need more options? See configs/template.yaml for every available setting.


📁 Output Artifacts

Every run saves a self-contained folder with data, settings, and plots:

  • sensor_data.npz: Recorded waveforms, timestamps, sensor positions, units, and run metadata.
  • simulation_config.yaml: Exact resolved settings and runtime provenance (mesh, $\Delta t$, versions).
  • full_analysis.png / .pdf: Multi-panel summary with waveforms, B-scan, and $f$–$k$ dispersion.
  • wave_physics/, lamb_modes/, characterisation/ (optional): Structure-specific dispersion references, $A_0$/$S_0$ Lamb mode separation, and packet velocity/attenuation reports.
  • *.bp/ (optional, set output.write_vtx: true): Full 2D wavefield time-series snapshots (guided_wave.bp, solid_displacement.bp, acoustic_pressure.bp) for interactive visualization and wave animations in ParaView.

🎬 Creating 2D Wavefield Animations

To visualize the full 2D propagating wavefield (and export .mp4 / .gif animations):

  1. In your YAML config under output:, set write_vtx: true and choose the frame count with target_snapshots (default 200; increase for smoother playback).
  2. Run wavesim -c your_config.yaml as usual — snapshots are saved to guided_wave.bp/ (elastic runs) or solid_displacement.bp/ and acoustic_pressure.bp/ (coupled/acoustic runs).
  3. Open the .bp folder in ParaView (ADIOS2VTXReader), click Apply, press Play to animate the wave propagation, or use File → Save Animation to export a video.

⚙️ Advanced Guides

CLI Flags & Execution Backends (CPU, GPU, MPI, Implicit, SLURM)
wavesim -c configs/01_plate_aluminum_lamb.yaml --device cpu              # Single CPU core
wavesim -c configs/01_plate_aluminum_lamb.yaml --device cuda             # NVIDIA GPU (CuPy)
mpiexec -n 4 wavesim -c configs/01_plate_aluminum_lamb.yaml --device cpu # Multi-core MPI
mpiexec -n 4 wavesim -c configs/01_plate_aluminum_lamb.yaml --solver implicit
Flag Description
-c, --config PATH YAML, TOML, or JSON configuration file
--generate-config PATH Create a commented starter YAML file (--force to overwrite)
--dry-run Print mesh, DOF, $\Delta t$, and memory estimates without running
--solver {explicit,implicit} Explicit RK4 (default) or implicit Newmark-β
--device DEV auto, cpu, cuda, or cuda:N
--precision {double,single} Precision for the single-process explicit solver
--output DIR Custom output directory
--postprocess NPZ Re-run analysis on an existing sensor_data.npz
--no-postprocess Skip figure generation
--f-min, --f-max, --k-min, --k-max Q Dispersion plot limits (SI or unit string, e.g., "2 MHz", "3 rad/mm")
--duration S, --dt S, --cfl F Override duration, max time step, or CFL factor
--usetex / --no-usetex Enable or disable external LaTeX rendering (default: disabled)
-q / -v / --version Quiet output, verbose debug logs, or print version

Minimal SLURM GPU script:

#!/bin/bash
#SBATCH --job-name=wavesim_gpu
#SBATCH --gres=gpu:1
#SBATCH --cpus-per-task=4
#SBATCH --mem=16G
#SBATCH --time=01:00:00

source activate wavesim
wavesim -c configs/08_fluid_solid_acoustic.yaml --device cuda --no-usetex
Supported Physics, Materials & Boundaries
  • Layer layouts: 1_layer, N_layers, halfspace, plate_on_halfspace, plate_in_halfspaces (bottom-to-top).
  • Materials: isotropic, anisotropic ([C11, C12, C16, C22, C26, C66]), viscoelastic (Kelvin–Voigt C and Cv), and inviscid acoustic fluid (rho, c or K).
  • Sources: Solid traction, or fluid acoustic_pressure, acoustic_normal_acceleration, and acoustic_volume, using ricker or Hann-windowed tone_burst pulses.
  • Boundaries: Absorbing sponges on lateral/half-space edges; rigid, pressure_release, or radiation conditions on exterior fluid faces.
  • Observables: displacement / velocity in solids; pressure / particle_velocity in fluids (auto picks the natural observable).
Python API Quickstart
import wavesimfem as ws

# 1. Load config & inspect preflight estimate
cfg = ws.parse_and_resolve_config("configs/01_plate_aluminum_lamb.yaml")
estimate = ws.preflight_estimate(cfg)
print(f"Estimated DOFs: {estimate['ndofs_est']:,} | Steps: {estimate['nsteps_est']:,}")

# 2. Run simulation
archive_path, out_dir = ws.run_simulation(cfg=cfg)

# 3. Generate figures and reports
ws.plot_full_analysis(archive_path, output_dir=out_dir, f_max=2.0e6, k_max=3000.0, usetex=False)
ws.write_structure_report(archive_path, output_dir=out_dir, usetex=False)
Troubleshooting
  • Missing LaTeX error: Pass --no-usetex (or set output.usetex: false in YAML) to use Matplotlib's built-in math fonts without installing TeX.
  • --device cuda fails: Make sure cupy-cuda12x matches your NVIDIA driver/CUDA version; explicit --device cuda exits with code 3 instead of silently falling back to CPU.
  • MPI hangs or libfabric warnings on Linux: Set export FI_PROVIDER=tcp and export OMP_NUM_THREADS=1.
Testing & Verification (for Developers)

WaveSimFEM is verified against analytical dispersion relations (Lamb, Rayleigh, Scholte modes), acoustic cavity resonances, and transmission benchmarks:

python -m pytest                     # Full local test suite
python -m pytest -m "not slow"       # Fast subset
python tools/verify_acoustics.py --case all

Pushes and PRs run lightweight CI (tests.yml: lint, pure-Python/array tests, and distribution smoke checks). The full Python 3.11/3.12 DOLFINx + MPI + LaTeX matrix runs weekly, on release tags, and on demand via gh workflow run tests.yml -f full_tests=true.


🗂️ Project Structure

WaveSimFEM/
├── src/wavesimfem/    # Core package (CLI, configs, elastic/acoustic solvers, GPU/MPI, analysis)
├── configs/           # Annotated template.yaml and 8 flagship example configurations
├── notebooks/         # Interactive quickstart notebook
├── tools/             # Benchmarks, acoustic verification, and release/packaging utilities
├── tests/             # Serial, MPI, acoustic, GPU, and release test suites
├── environment.yml    # Conda-forge environment specification
├── pyproject.toml     # Packaging, pytest, coverage, and Ruff configuration
├── CHANGELOG.md       # Semantic version history
└── CITATION.cff       # Machine-readable citation metadata

📖 Documentation


📜 Citation

If you use WaveSimFEM in your research, please cite:

@misc{le2026wavesimfem,
  author       = {Le, Ductho},
  title        = {{WaveSimFEM}: A {GPU}-accelerated finite element framework for acoustic and elastic wave propagation in layered media},
  year         = {2026},
  howpublished = {\url{https://github.com/ductho-le/WaveSimFEM}},
  note         = {Manuscript in preparation}
}

Machine-readable citation metadata is available in CITATION.cff.


📄 License

Licensed under the MIT License.


Ductho Le · School of Biomedical Engineering, International University – VNU HCMC

ORCID Google Scholar ResearchGate

Metadata

Release files for wavesimfem 0.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wavesimfem 0.5.1
File Size Uploaded Provenance Actions
wavesimfem-0.5.1.tar.gz 345.4 kB With provenance Details for wavesimfem-0.5.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for wavesimfem 0.5.1
File Interpreter ABI Platform Actions
wavesimfem-0.5.1-py3-none-any.whl Python 3 none any Details for wavesimfem-0.5.1-py3-none-any.whl

Total release size: 524.4 kB

Release files / wavesimfem-0.5.1.tar.gz

Download URL wavesimfem-0.5.1.tar.gz
Size 345.4 kB
Tags Source
SHA-256 checksum
How to use checksums
25a7dfe2b4f5b1321404245eae518150ade44dfeb5d71558be2c7243d63f9cd7
BLAKE2b-256 checksum
How to use checksums
672e5de0d39e693d6286fcbf9707ed71d76abacf43318e5d6936b02e4080b52a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

Release files / wavesimfem-0.5.1-py3-none-any.whl

Download URL wavesimfem-0.5.1-py3-none-any.whl
Size 179.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7b477b4857ed150526135c0bc75cea2f701eb2daace637ae755ec35b3713ca3f
BLAKE2b-256 checksum
How to use checksums
d2df9f9bf71fa8193b16118e03b2660019e0d403fd61186c1527102284bd5f46
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

Security for wavesimfem 0.5.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for wavesimfem-0.5.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.5.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page