Physics-informed n-step reinforcement learning for stochastic photon transport in water
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.
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.
Coherent scattering with energy-dependent form factors for water.
Incoherent scattering with recoil electron kinematics.
Shell-specific absorption with electron emission.
Electron-positron pair creation with energy sharing.
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.
# 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.