Beam Weaver

Physics-informed n-step reinforcement learning for stochastic photon transport in water

DOI JOSS status
Status: research prototype License: Apache-2.0 Domain: radiation transport & AI
Beam Weaver is a research software prototype for learning event-by-event photon transport in a homogeneous water phantom. It combines a custom Monte Carlo reference simulator, a physics-informed n-step Soft Actor-Critic reinforcement learning environment, and evaluation tools that compare learned particle histories against conventional transport outputs.

What Beam Weaver Does

Beam Weaver explores whether a Soft Actor-Critic (SAC) agent can learn the stochastic logic of photon transport in water at the event level, rather than only predicting final observables.

For each photon history, the code predicts:

This makes Beam Weaver a learned transport-engine prototype rather than a generic machine-learning regressor.

Photon Interactions Modeled

Rayleigh Scattering

Coherent scattering with energy-dependent form factors for water.

Compton Scattering

Incoherent scattering with recoil electron kinematics.

Photoelectric Absorption

Shell-specific absorption with electron emission.

Pair Production

Electron-positron pair creation with energy sharing.

Training Architecture

Beam Weaver is trained in two stages:

The RL objective is physics-regularized, combining the standard SAC loss with auxiliary physics losses for energy, angle, and interaction-type consistency.

Quick Start

# Create environment
conda env create -f environment.yml
conda activate beam-weaver

# Or with pip
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

# Run Beam Weaver
python Beam_weaver_0.1.0.py

The script is interactive and supports: generating Monte Carlo data, pretraining the physics head, training a SAC model, evaluating trained models, and comparing MC vs. agent outputs.

Authors

Pedro Teles
Assistant Professor, Department of Physics and Astronomy, Faculty of Sciences, University of Porto
João Melo
MSc Student in Medical Physics, Department of Physics and Astronomy, Faculty of Sciences, University of Porto

References