A python API and graphical plugin for the penRed Monte Carlo code: Enhancing usability and workflow integration

Published: 20 March 2026| Version 1 | DOI: 10.17632/4c4zvgm2r6.1
Contributors:
,

Description

Monte Carlo (MC) simulations are a cornerstone of scientific computing in fields like medical physics, but their complexity often poses significant usability challenges. Setting up simulations requires intricate configuration and 3D geometry definition, which are error-prone and time-consuming tasks. Furthermore, the integration of MC tools into modern, Python-centric scientific workflows for analysis and AI can be difficult. This work addresses these challenges for the penRed MC code by introducing a comprehensive framework designed to enhance its accessibility, usability, and integration. We present pyPenred, a high-performance Python module that exposes the complete capabilities of penRed within the Python ecosystem. Built with pybind11, it allows computationally intensive particle transport to be handled by optimized C++ binaries while enabling seamless control and analysis in Python. Performance benchmarks show a minimal overhead of only 1–2% for locally compiled versions compared to native C++ execution. To simplify geometry creation and simulation setup, we developed a dedicated Blender plug-in. This integrated graphical environment supports constructing models with both quadric surfaces and triangular meshes, and provides an intuitive interface for defining materials, sources, and tallies. Finally, we have established robust cross-platform compatibility through continuous integration, automatically distributing pre-compiled binaries and pip-installable Python wheels for Linux, Windows, and macOS. Collectively, these contributions transform penRed from a specialized code-centric tool into an integrated and user-friendly simulation platform, lowering the barrier to advanced MC simulations and fostering tighter integration with contemporary data science workflows.

Files

Categories

Computational Physics, Radiation Transport, Application of Monte Carlo Method

Licence