Low energy gamma-ray simulation with Python.
LegPy is a Monte Carlo (MC) simulation package for the transportation of gamma rays and electrons through any material medium. The algorithm includes several approximations that accelerate the simulation while maintaining reasonably accurate results. Notably, pair production and Bremsstrahlung are ignored, which limits the applicability of the algorithm to low energies (
The description of the MC algorithm and the validation of the various approximations are described in https://doi.org/10.1016/j.radmeas.2023.107029. In the latest version of the code, the generation of atomic
LegPy provides a user-friendly tool to perform simple simulations with just a few lines of code. It is designed to be used in Google Colab (https://colab.research.google.com/) or Jupyter (https://jupyter.org/) notebooks, which are interactive environments that improve user experience without requiring programming skills. Indeed, LegPy is used for educational purposes in both the Physics Degree and Master's Degree in Biomedical Physics at the Complutense University of Madrid.
The package includes an exhaustive tutorial notebook that can be used in both frameworks. The tutorial includes a number of examples and procedures to visualize and analyze the results of the simulation. We recommend using this tutorial notebook as a template.
From a Colab notebook, clone this repository and add the directory where LegPy is located to the Python search path:
!git clone https://github.com/JaimeRosado/LegPy.git
import sys
sys.path.insert(0,'/content/LegPy')
Then import the package:
import LegPy as lpy
Download this repository to your PC. Create a Jupyter notebook in the directory where the package is located (or use the tutorial notebook included in the repository). Then import the package:
import LegPy as lpy
To use LegPy, Matplotlib, Pandas and Numpy need to be installed.