A python API and graphical plugin for the penRed Monte Carlo code: Enhancing usability and workflow integration
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. Program Title: Parallel Engine for Radiation Energy Deposition (penRed) CPC Library link to program files: (to be added by Technical Editor) Developer’s repository link: https://github.com/PenRed/PenRed Licensing provisions: AGPLv3 Programming language: C++, Python Supplementary material: Journal reference of previous version: S. Oliver a, S. Rodriguez Bosca b, V. Giménez-Alventosa, Enabling particle transport on CAD-based geometries for radiation simulations with penRed Does the new version supersede the previous version?: Yes Reasons for the new version: This major version represents a significant evolution of penRed from a specialized code library into a user-friendly and integrated simulation platform. The release introduces a comprehensive Python API (pyPenred) for seamless integration into modern scientific workflows, a dedicated Blender plugin for intuitive graphical geometry creation and setup, and an automated system for distributing pre-compiled, cross-platform binaries. These developments collectively enhance accessibility, usability, and interoperability without compromising the core computational performance. Summary of revisions: All changes applied through the code versions are summarized in the file CHANGELOG.md in the repository package. Nature of problem(approx. 50-250 words): Monte Carlo simulations for radiation transport, while powerful, present significant usability and integration challenges. Preparing simulations involves defining complex 3D geometries and extensive configuration files, which is a tedious and error-prone process, especially for complex models. Furthermore, integrating these computationally intensive simulations into modern scientific workflows, which heavily rely on Python for data analysis, AI, and visualization, is often cumbersome. Existing solutions typically require expert knowledge of the specific simulation framework’s syntax and compilation process, creating a high barrier to entry for new users and hindering seamless integration with the broader scientific software ecosystem. These challenges limit the accessibility and widespread adoption of Monte Carlo codes like penRed [41] , even within specialized fields such as medical physics. Solution method(approx. 50-250 words): To address these challenges, we developed a multi-faceted software layer for the penRed framework. First, we created pyPenred, a Python module built with pybind11 that exposes all of penRed’s capabilities directly within Python. This allows users to configure, run, and analyze simulations in a unified environment, leveraging popular scientific libraries, while the computationally intensive particle transport is handled by optimized, native C++ binaries. Second, we developed a Blender plug-in that provides a graphical user interface for intuitively constructing simulation geometries and defining parameters, eliminating the need for manual file editing. Finally, we established a robust Continuous Integration (CI) pipeline to automatically build and distribute pre-compiled binaries and pip-installable Python wheels for Linux, Windows, and macOS, ensuring easy installation and cross-platform compatibility.
Authors
- V. Giménez-Alventosa
- S. Oliver
Institutions
- Instituto Nacional de Seguridad y Salud en el Trabajo (ES)
- European Telecommunications Standards Institute (FR)
Publication Details
- Journal
- Computer Physics Communications
- Published
- 2026-03-03
- DOI
- https://doi.org/10.1016/j.cpc.2026.110104
- Primary Topic
- Radiation Therapy and Dosimetry
- Type
- article
- Field-Weighted Citation Impact
- 0.00