Geant4-DNA → WebGPU

Monte Carlo electron track structure,
running in your browser.

A WebGPU port of Geant4-DNA — the CNRS/IN2P3-coordinated Monte Carlo track-structure toolkit for radiobiology. One GPU thread per primary electron, the full particle history in a single fused compute dispatch, Karamitros 2011 IRT chemistry in a worker, and SSB / DSB damage scoring on a 21×21 B-DNA fiber grid. No server, no install, no download.

Run the validation → View source on GitHub
Requires WebGPU. Shipped on-by-default in Chrome / Edge 113+ desktop, Chrome 121+ Android (Android 12+ on Qualcomm / ARM GPUs), Safari 26+ (macOS Tahoe, iOS / iPadOS / visionOS 26, Sep 2025), Firefox 141+ on Windows, and Firefox 145+ on macOS 26 Tahoe (Apple Silicon only). Firefox Linux, Firefox Android, and older Firefox still need dom.webgpu.enabled. Full matrix: caniuse.com/webgpu. A discrete or Apple-silicon GPU is recommended at N ≥ 4096 primaries.
See what changes
0.985×
CSDA @ 10 keV
2714.4 nm vs Geant4 2756.5 nm
100.0%
Energy conservation
Across all 8 ESTAR energies
3.89 Mbp
DNA target
21×21 B-DNA fibers × 3 μm
46 / 46
Tests passing
Cross-sections, CDF, reactions

What changes when it runs in a browser

Same physics, radically different access. The table below is the before / after — traditional Geant4-DNA the way medical physicists and radiobiology labs have run it for two decades, vs. this WebGPU port.

  Traditional Geant4-DNA WebGPU-DNA (this project)
Install 50+ GB toolkit · 2–4 hr C++ compile · CMake, ROOT, Xerces, GDML dependencies · data files from CERN None. Open a URL. 94 KB of JavaScript, 1.3 MB of cross-section data, served over CDN.
Hardware Linux workstation or HPC cluster · typically 16–64 CPU cores to be usable Any laptop or phone with a WebGPU-capable browser. Tested down to Apple M1 and Intel integrated graphics.
Time to first result Hours of setup, then minutes to hours per 10 keV run depending on primaries & core count ~10 seconds from page load to full 8-energy validation sweep at 4096 primaries.
Physics fidelity @ 10 keV Reference (by construction) CSDA 0.985× · energy conservation 100.0% · ions/primary exact match · chemistry within textbook tolerances
Verified side-by-side against a Geant4 11.4 dnaphysics ntuple
Reproducibility Depends on your Geant4 build, compiler, OS, library versions, random seed — "works on my cluster" is a real problem Same URL, same bundle hash, same WGSL shader — same numbers everywhere
Access cost Institutional cluster time, or a workstation admin who lets you install Geant4 $0. No account, no sign-in, no API key, no rate limit.
Who can use it Graduate students and staff in labs with the infrastructure — effectively gate-kept behind institutional access Anyone — med students, high-schoolers, independent researchers, developers curious about WebGPU.
Intended scope Production radiation-therapy planning, space-mission dosimetry, published radiobiology research Education, rapid prototyping, teaching, method exploration. Not a replacement for clinical Geant4-DNA.

Bottom line: a faithful-enough version of the tool that used to require a PhD and a compute cluster, now one click away from anyone.

What's inside

Data-driven cross sections from G4EMLOW, the full 9-reaction IRT chemistry table from Karamitros 2011, and event-level DNA damage scoring — all ported from Geant4 source and validated against a direct dnaphysics ntuple.

Phase A / B — Tracking

Fused physics kernel

Born ionization across 5 shells with paired CDF / E-transfer tables (binary search, 58 energies × 100 breakpoints), Emfietzoglou excitation with level-dependent dissociative branching, Champion tabulated elastic below 200 eV, Sanche 9-mode vibrational.

  • Primary momentum conservation after ionization
  • 3-regime secondary angular sampling (Born angle)
  • Secondary wavefront stepper (2000 steps, elastic-dominated)
Phase C — Chemistry

Karamitros 2011 IRT

Full 9-reaction Independent Reaction Times table from G4EmDNAChemistry_option1. Runs in a dedicated Web Worker so the main thread stays responsive. Includes pre-chemistry: 2.0 nm mother displacement, species-specific product displacement, e⁻aq thermalization at 1.7 eV.

  • Product tracking: H₂O₂ and OH⁻ with full re-pairing
  • 7 time checkpoints, 0.1 ps → 1 μs
  • G(H) / G(H₂) match Karamitros within 15%
DNA damage

Event-level SSB + DSB

Direct SSB from rad_buf ionization sites (nm-scale spatial correlation), indirect SSB from diffused OH at 1 μs, greedy ±10 bp DSB clustering. A kernel-level backbone hit counter cross-checks the JS post-processing — kernel_hits == reach_dir, exactly.

  • 21×21 parallel B-DNA fiber grid, 150 nm spacing
  • Dose XY/YZ projections with log-magma colormap
  • ESTAR validation at 8 energies, 100 eV → 20 keV

How the GPU runs it

The core trick: invert Geant4's sequential tracking loop. Phase A dispatches one GPU thread per primary and runs the full particle history in a WGSL loop — no per-step dispatch overhead. Phase B wavefront-steps secondaries. Phase C is 133 chemistry ticks × 4 dispatches (diffuse → hash → react). Everything writes to a shared 128³ atomic voxel grid and a 16M × 16 B radical buffer.

That “one dispatch, full history” shape is the same single-kernel fusion pattern that has given 3–4 orders of magnitude of speedup on other GPU workloads dominated by launch overhead — here it is what makes the entire electron history cheap enough to run live in a browser tab.

Full pipeline diagram, buffer sizing, and WGSL constraints are in ARCHITECTURE.md. Physics provenance and known gaps are in CLAUDE.md.

Live validation harness

Runs the full 8-energy ESTAR sweep. Chemistry + DNA damage scoring fire at 10 keV. 4096 primaries takes about 6–10 seconds on an M-series laptop GPU.

initializing…
WebGPU not available in this browser. Try Chrome 113+ or enable dom.webgpu.enabled in Firefox.
Energy Therm Esc CSDA Total (nm) ESTAR CSDA Ratio Prod (nm) dE/dx (eV/nm) ESTAR SP Ratio Ions/pri Sec/pri E cons G(OH) G(e⁻aq) G(H) SSB dir SSB ind DSB DSB/Gy/Gbp Total ms
Reading the table. ESTAR ratios of 1.0±0.1 above 3 keV are "passing"; below 1 keV, Geant4-DNA's own models deviate from ESTAR, and agreement within ~2× is expected. G-value columns populate only at the 10 keV row (chemistry gate).
Awaiting 10 keV passDose projection paints after the
full sweep completes
Dose projection (XY, sum over Z) — 10 keV primaries, log magma
Awaiting 10 keV passDose projection paints after the
full sweep completes
Dose projection (YZ, sum over X) — along primary track direction
runtime log