
Hv7355 tile
ryancinsight/kwavers
K-wave inspired ultrasound physics in rust with acoustics and optics

K-wave inspired ultrasound physics in rust with acoustics and optics
Nsf neuromod phased array is an open-source printed circuit board by ryancinsight, from the ryancinsight/kwavers repository on GitHub, published under the MIT licence. It is a 6-layer board of 119.9 × 127.5 mm with 54 parts on 69 nets, routed with 2,151 tracks and 248 vias.
It is built around the XC7A200T-2FBG484I, MD1822K6-G and STPS2200U, with the TC8020K6-G and BLM18PG471SN1 among its other parts. Its parts include 16 diodes, 9 ICs, 8 capacitors, 8 resistors and 3 connectors. It belongs with the FPGA and CPLD boards of this library.
An interdisciplinary ultrasound-light physics simulation library. Kwavers models acoustic wave propagation, cavitation dynamics, and sonoluminescence for multi-modal imaging research and physics studies.
Recently completed: the workspace crate split (ADR-011) — the ~460k-LOC
kwavers monolith is decomposed into per-layer crates to cut incremental build
times. There is no facade: consumers (including the Python bindings) depend on
the layer crates directly (kwavers_core, kwavers_grid, kwavers_solver, …).
The kwavers crate is now only a thin top-level app/integration crate — it
hosts the binary and the cross-cutting tests/examples/benches, and re-exports
nothing.
| Crate | Layer / responsibility |
|---|---|
kwavers-core | Constants, error types, arena allocation, time/logging utilities |
kwavers-math | FFT, linear algebra, numerics, geometry, statistics, SIMD |
kwavers-grid | Cartesian/cylindrical grids, coordinates, topology, operators, geometric domains |
kwavers-field | Field component indices (SSOT), field-type mapping, operations, statistics |
kwavers-signal | Waveforms, pulses, sweeps, modulation, windowing, filters |
kwavers-medium | Homogeneous/heterogeneous media, acoustic/elastic/optical/thermal properties |
kwavers-phantom | Clinical tissue-phantom builders and Shepp-Logan references |
kwavers-mesh | Tetrahedral FEM meshes, quality metrics, gaia bridge |
kwavers-boundary | CPML/PML absorbing layers, FEM/BEM boundaries, coupling, periodic |
kwavers-source | Source trait, grid/mask sources, wavefronts, apodization |
kwavers-receiver | Sensor-array geometry (SSOT), recorders, point sensors, grid sampling |
kwavers-transducer | Bowls, phased/linear/matrix/hemispherical arrays, beamforming, PAM, ultrafast |
kwavers-imaging | DICOM/CT/NIfTI loaders, ultrasound/photoacoustic models, CEUS, fusion |
kwavers-physics | Nonlinear acoustics, bubble dynamics, thermal, optics, chemistry, elastic waves |
kwavers-solver | FDTD / PSTD / k-space / Helmholtz, BEM, FWI / RTM / CBS, PINN |
kwavers-gpu | Hephaestus-backed provider-generic GPU backend; concrete ComputeBackend impls |
kwavers-simulation | Builders, runners, multi-physics coupling, modality pipelines, backends |
kwavers-analysis | Signal processing, conservation, validation, ML/uncertainty, plotting |
kwavers-diagnostics | Reconstruction, multi-modal fusion, Doppler, spectroscopy, decision support |
kwavers-therapy | HIFU / histotripsy / lithotripsy planning, theranostic guidance, dose & safety |
kwavers-driver | Physics-guided, manufacturing-aware driver-electronics (PCB) design |
kwavers | Thin top-level app/integration crate: binary + cross-cutting tests/examples/benches (no re-exports) |
kwavers-python | PyO3 bindings (pykwavers); depends on the layer crates directly; no domain logic |
Tyche owns reproducible counter streams, Latin-hypercube and Sobol designs, online moments, correlation screening, and finite-sample conformal calibration. Kwavers owns physical-domain transforms, model execution, Leto array presentation, and domain-specific score definitions. Geometry maps Tyche designs directly into validated rectangles, disks, and balls through one single-allocation collector; Analysis and PINN fixed-design code carry no independent provider algorithms, while model-residual adaptive refinement remains solver-owned. See ADR 043.
Layer crates are at 3.0.0; the completed split targets 4.0.0 (see
RELEASE_v4.0.0 notes in CHANGELOG). kwavers-python is 0.1.0.
Validation status: the k-space pseudospectral solver matches the k-Wave reference solver on the homogeneous-water IVP benchmark at Pearson r = 1.000000000 (2-D) and r = 0.999999994 (3-D). The comparison is a Rust test in the default gate against reference fields committed to this repository — see Reference Benchmark Coverage.
GitHub Releases tagged kwavers-python-v<version> build one locked
Python-3.8-compatible stable-ABI wheel per operating system for Linux, Windows,
and macOS. The workflow installs and imports each wheel as pykwavers, verifies
the kwavers-python distribution identity and Cargo-owned version, attests and
attaches the exact artifacts, then publishes that same wheel set to PyPI
through OIDC Trusted Publishing.
The 23 reusable Rust packages publish to crates.io in local dependency order.
The Crates.io Release workflow validates a named workspace package on manual
dispatch. After its required first release is bootstrapped and its crates.io
Trusted Publisher is registered, a GitHub Release tagged
crate-<package>-v<version> packages, verifies, and publishes the matching
Cargo version with a short-lived OIDC token. Validation runs in a separate
read-only job. The publish job is bound to the GitHub crates-io environment.
The PyO3 and xtask packages are explicitly non-publishable; all Rust library
releases use their package names.
Detailed history lives in CHANGELOG.md; current work and gaps
are tracked in backlog.md, CHECKLIST.md, and
gap_audit.md.
Kwavers follows a layered architecture designed for scientific computing:
Therapy / Diagnostics → Clinical planning, theranostic guidance, dose & safety
Simulation Layer → Multi-physics orchestration, modality pipelines
Analysis Layer → Signal processing, beamforming, imaging algorithms
Solver Layer → Numerical methods (FDTD, PSTD, k-space, FWI, PINN)
Physics Layer → Wave equations, bubble dynamics, constitutive relations
Domain Layer → Problem geometry, materials, sources, sensors
Math Layer → Linear algebra, FFT, numerical primitives
Core Layer → Fundamental types, error handlingThe module DAG is acyclic and linear (core → math → domain → physics → solver → analysis → simulation → diagnostics/therapy); each layer is now its own crate.
Cross-repository foundations remain below that DAG. Public Asclepius owns CEM43, Arrhenius thermal damage, and independent-insult composition. Kwavers converts stored temperatures to Aequitas quantities at its boundaries and retains spatial fields, tissue presets, clinical thresholds, and an independent validation oracle. See ADR 044.
Public Hyperion owns photon and
optical interaction coefficients, reduced scattering, optical depth,
Beer-Lambert transmission, and the diffusion-derived coefficient laws.
kwavers-medium retains tissue identity, refractive index, presets, and maps;
kwavers-physics and kwavers-solver retain spatial transport algorithms and
photoacoustic coupling. This boundary removes the former kwavers-optics
formula module plus the parallel DiffusionOpticalProperties and
OpticalAbsorption models instead of adding a facade around them. See
ADR 046.
Key architectural decisions:
Add the layer crates you need to your Cargo.toml:
[dependencies]
kwavers-grid = "3.0.0"
kwavers-medium = "4.0.0"For GPU acceleration and advanced features, add the top-level integration crate:
[dependencies]
kwavers = { version = "3.0.0", features = ["gpu", "pinn"] }use kwavers_grid::Grid;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a 3D computational grid
let grid = Grid::new(100, 100, 100, 0.001, 0.001, 0.001)?;
println!("Created grid: {}×{}×{} points", grid.nx, grid.ny, grid.nz);
println!("Grid spacing: {} m", grid.dx);
Ok(())
}use kwavers_grid::Grid;
use kwavers_medium::HomogeneousMedium;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a computational grid
let grid = Grid::new(100, 100, 100, 0.001, 0.001, 0.001)?;
// Define acoustic properties for water
let density = 1000.0; // kg/m³
let sound_speed = 1500.0; // m/s
let mu_a = 0.0; // optical absorption coefficient (1/m)
let mu_s_prime = 0.0; // reduced optical scattering coefficient (1/m)
// Create a homogeneous water medium
let medium = HomogeneousMedium::new(
density,
sound_speed,
mu_a,
mu_s_prime,
&grid,
);
println!("Water properties:");
println!(" Density: {} kg/m³", density);// Basic acoustic property calculations
fn main() {
// Acoustic impedance calculation: Z = ρc
let density_water = 1000.0; // kg/m³
let speed_water = 1500.0; // m/s
let impedance_water = density_water * speed_water; // Pa·s/m
println!("Water acoustic impedance: {:.0} Pa·s/m", impedance_water);
// Reflection coefficient: R = (Z2 - Z1)/(Z2 + Z1)
let density_air = 1.2; // kg/m³
let speed_air = 343.0; // m/s
let impedance_air = density_air * speed_air;
let reflection_coeff = (impedance_air - impedance_water) /
(impedance_air + impedance_water);
println!("Air-water reflection coefficient: {:.4}", reflection_coeff);
}docs/See the examples/ directory for basic usage patterns:
# List available examples
cargo run --example
# Run a basic example (if available)
cargo run --example basic_simulationBasic Test: Check compilation
cargo checkKwavers is structured with layered separation intended to support scientific computing workflows:
Clinical Applications → Research use cases, safety monitoring
Analysis & Imaging → Signal processing, reconstruction algorithms
Simulation Orchestration → Multi-physics coupling, time integration
Numerical Solvers → FDTD, PSTD, PINN, spectral methods
Physics Specifications → Wave equations, constitutive relations
Problem Domain → Geometry, materials, boundary conditions
Mathematical Primitives → Linear algebra, FFT, interpolation
Core Infrastructure → Error handling, memory managementThe architecture aims to separate concerns while maintaining flexibility for different research applications. Layer boundaries help organize code but are not strictly enforced in all areas during active development.
This is an active research project under development. Contributions are welcome! The codebase follows strict quality standards and clean architecture principles.
Check Status: Review CHECKLIST.md for current task status
Review Plans: See backlog.md for planned work and gap_audit.md for known gaps
Build a crate: cargo check -p kwavers-core (per-crate checks are fast post-split)
Run Tests: cargo nextest run -p <crate>; use
cargo test-gpu-consumers when changing the shared GPU simulation/Python
dependency graph, so Cargo compiles their common graph once; use
cargo test -p <crate> --doc for doctests
Read Docs: docs/book/ for narratives, docs/ADR/ for design decisions
Install the hooks: git config core.hooksPath .githooks
Git never applies tracked hooks on its own, so this is a one-time step per
clone. The pre-push hook runs scripts/lockfile.py --check, which is the
same check CI runs. It matters most when working inside the Atlas stack: the
stack's [patch] overlay makes cargo resolve first-party dependencies to
local paths and write a Cargo.lock with every source = "git+..." line
stripped. That lock resolves fine under the overlay and fails every
--locked job in CI, so without the hook the corruption is invisible until a
runner reports it. Repair with python3 scripts/lockfile.py --regenerate.
Artifact-driven sprints (see CLAUDE.md governance):
backlog.md — strategy and prioritized workCHECKLIST.md — tactical tasks with change-class tagsgap_audit.md — physics/numerics gap findingsCHANGELOG.md — version historyQuality Standards:
Kwavers is being enhanced with methods from leading ultrasound simulation projects:
Per-version history is consolidated in CHANGELOG.md. The
historical per-sprint/per-phase reports formerly under docs/ were pruned
during the workspace-split docs cleanup and remain recoverable from git history.
Kwavers is licensed under the MIT License. See LICENSE for details.
crates/kwavers/tests/kwave_reference_parity.rs compares the k-space
pseudospectral solver against k-Wave on the homogeneous-water IVP Gaussian case.
The reference fields live in crates/kwavers/tests/reference/kwave/ (156 KB), so
the test runs from a clean clone in the default gate with no external solver
present. scripts/generate_kwave_reference.py regenerates them by driving
k-wave-python over the reference kspaceFirstOrder-OMP binary.
Both codes run the same grid, time step, step count, and Treeby-Cox k-space correction, and are compared over a centred window the wavefront has entered but neither code's boundary treatment has reached.
| Case | Grid | Steps | Relative L2 | Relative L-inf | Pearson r |
|---|---|---|---|---|---|
ivp_homogeneous_2d | 64 × 64 | 100 | 5.50e-7 | 1.05e-6 | 1.000000000 |
ivp_homogeneous_3d | 32 × 32 × 32 | 50 | 1.06e-4 | 2.20e-4 | 0.999999994 |
ivp_absorbing_2d | 64 × 64 | 100 | 8.10e-3 | 4.99e-3 | 0.999999924 |
ivp_layered_2d | 80 × 64 | 120 | 7.97e-3 | 1.54e-2 | 0.999963422 |
src_tone_burst_2d | 96 × 80 | 151 | 2.58e-3 | 2.20e-3 | 0.999996674 |
src_nonlinear_2d | 96 × 80 | 151 | 3.30e-3 | 2.80e-3 | 0.999994550 |
The finite-difference solver is measured against the same reference as a
cross-scheme check, since the pseudospectral solver shares its k-space machinery
and cannot be an independent oracle for it. It separates by 2.53e-2 relative
L2 at r = 0.999647, which is its own fourth-order dispersion error and is
gated as such rather than at the pseudospectral bound.
ivp_absorbing_2d is the lossless 2-D case with power-law absorption
(40 dB/(MHz^1.5 cm), y = 1.5) and nothing else changed, so the pair isolates
the absorption model; the test asserts both that kwavers matches the absorbing
reference and that the absorbing field separates from the lossless one, since
agreement alone would not prove the model ran.
ivp_layered_2d steps sound speed and density across a smoothed interface eight
cells from the seed, so the recorded field carries a transmitted wave, a
reflection, and a refracted front; it is measured against a uniform-medium run at
the same discretization, which it separates from by 0.27. Its grid is
deliberately non-square — a square case cannot distinguish a correct axis
orientation from a transposed one, and two such conventions were live in the
harness until this case exposed them.
src_tone_burst_2d drives a Gaussian-windowed 3 MHz burst from a single
off-centre cell, starting from a zero field. It is the only case that reaches
the source injection path, and it checks four conventions at once: the mask's
cell lookup, the per-step signal indexing, k-Wave's source-term scaling, and the
k-space source correction.
src_nonlinear_2d is that case with finite-amplitude propagation switched on
(B/A = 20 at 5 MPa), sized to reach roughly seventy percent of the plane-wave
shock distance — as far into the nonlinear regime as the smooth-wave assumption
reaches, since neither code has shock capturing. It separates from a linear run
by 4.58e-2, fourteen times its own residual.
k-wave-python ships no 1-D solver, so there is no 1-D row; the axisymmetric
case is a separate geometry and is not yet covered. Elastic propagation and
distributed (multi-cell) sources have no committed reference field yet and are
not covered by this result.
ADR 119 records the reference
provenance, the tolerance derivation, and what the comparison does not establish.
A research library for acoustic and optical physics simulations.
| Qty | Value | Footprint | References |
|---|---|---|---|
| 16 | STPS2200 | kicad-routing:STPS2200 | D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15, D16 |
| 8 | CL10B104KB8NNNC | kicad-routing:CL10B104KB8NNNC | C1, C2, C3, C4, C100, C101, C102, C103 |
| 8 | RC0805FR-0756RL | kicad-routing:RC0805FR-0756RL | R1, R2, R3, R4, R5, R6, R7, R8 |
| 4 | ADUM3480 | kicad-routing:ADUM3480 | U2, U3, U4, U5 |
| 4 | MD1822K6-G | kicad-routing:MD1822K6-G | U10, U11, U12, U13 |
| 4 | — | kicad-routing:MountingHole | MH, MH, MH, MH |
| 3 | — | kicad-routing:FIDUCIAL | FID, FID, FID |
| 2 | TC8020K6-G | kicad-routing:TC8020K6-G | Q1, Q2 |
| 1 | BLM18PG471SN1 | kicad-routing:BLM18PG471SN1 | FB1 |
| 1 | CON16_2X8_TU_TSW_SAI | kicad-routing:CON16_2X8_TU_TSW_SAI | J1 |
| 1 | J_HV_IN | kicad-routing:J_HV_IN | J2 |
| 1 | J_LV_IN | kicad-routing:J_LV_IN | J3 |
| 1 | XC7A200T-2FBG484I | kicad-routing:XC7A200T-2FBG484I | U1 |

ryancinsight/kwavers
K-wave inspired ultrasound physics in rust with acoustics and optics

ryancinsight/kwavers
K-wave inspired ultrasound physics in rust with acoustics and optics

ryancinsight/kwavers
K-wave inspired ultrasound physics in rust with acoustics and optics

ryancinsight/kwavers
K-wave inspired ultrasound physics in rust with acoustics and optics

nguyenthanhluan171205-tech/flyback-converter-10w
Design, simulation, PCB layout, and experimental validation of a 10W Flyback converter (80-220VAC to 12VDC, 90% efficiency).

mgkoenig/lyft
LYFT is a sophisticated remote control for your IKEA BEKANT desk.


Utstumo/Heartbeat-Logger
A small, portable device that will continuously log your ECG - the "waveform" of your heart - onto a memory card for analysis.

daverowntree/SmartDesk
I open sourced a design I made a few years back for a non-paying client. Use it as you see fit!

jonaschramm/race-tracker
Custom PCB data logger for motorcycle racing: GPS position + IMU motion data, logged to a microSD card, with an e-Paper status display. Built around an ESP32-S3 (WiFi/BT built in) so it can also stream/sync over WiFi.

leo-recover/domotics
A simple domotics system using Raspberry-Pi, several smart nodes, and radio modules
It measures 119.9 × 127.5 mm and has 6 copper layers, 1.6 mm thick.
54 parts, built around the XC7A200T-2FBG484I, MD1822K6-G, STPS2200U and TC8020K6-G. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.
From the ryancinsight/kwavers repository on GitHub, at the commit this page was made from: the board is output/boards/nsf_neuromod_phased_array/nsf_neuromod_phased_array.kicad_pcb and its schematic crates/kwavers-driver/docs/reference_design/fpga_tile.kicad_sch. PCBKit opens the board in the browser, with nothing to install.
Its repository publishes it under the MIT licence: you may reuse it on that licence's terms (keep the author's notice, and for a copyleft licence share your changes alike).