Skip to main content

pyPenred - Python Bindings for PenRed

PenRed logo

https://penred.github.io/PenRed/pyPenred/ Python interface for the [PenRed](https://github.com/PenRed/PenRed) Monte Carlo radiation transport simulator, enabling programmatic control and automation.

Key Features

Currently pyPenred offers:

  • Direct Simulation Control
    Run PenRed simulations directly from Python scripts

  • Configuration management
    Convert between PenRed native configuration format, YAML and Python dicts

  • Workflow Automation
    Chain multiple simulations with parameter sweeps

  • External Software Integration
    Embed PenRed in custom applications and pipelines

Installation

pyPenred can be installed directly from pip as a regular package:

pip install pyPenred

From Source

If the user wants to modify the source code or compile it with native optimizations, another option consists on compiling the binding locally using the installPyPenred scripts in the PenRed repository src folder.

The requirements to compile the code are:

  • Python 3.8+ development headers
  • CMake 3.12+
  • C++14 compatible compiler

If the requirements are fulfilled, just run the corresponding script.

Linux/macOS:

./installPyPenred.sh

Windows:

installPyPenred.bat

Configuration Format Conversion

pyPenred implements a bi-directional conversion between PenRed's native configuration format and Python dictionaries. Parameter paths with slashes map to nested dictionary structures:

Native Format Python Dictionary Equivalent
/geometry/phantom/material config['geometry']['phantom']['material']

Basic Usage

Running a Simulation

To run a simulation using a configuration file located in the current folder, named config.in, just use:

import pyPenred
pyPenred.runFromFile("config.in")  # Supports both native and YAML formats

Modifying Configurations

To modify an existing configuration file (config.in) either in regular PenRed or YAML formats, the following code can be used:

config = pyPenred.readConfigFile("config.in") # Load the file as a dictionary
config['path']['to']['modify'] = 42  # Modify parameters
pyPenred.writeConfigFile("modified.in", config)  # Export to native format

Complete Example

A more complete example can be found in the runFromFile function code. This one configures the simulation and runs it asynchronously reporing the simulation state in regular intervals. Take into account that this function is defined within the pyPenred module. Therefore, the pyPenred module prefix must be used in regular scripts:

def runFromFile(configFile = "config.in",
                statusTime = 20,
                configLog = "config.log",
                simulationLog = "simulation.log"):
    '''
    Configures and runs a simulation from the specified file.
    Reports the simulation status periodically.
    '''

    #Set logs
    simulation.setConfigurationLog(str(configLog))
    simulation.setSimulationLog(str(simulationLog))

    #Create simulation object
    simu = simulation.create()

    #Try to get the configuration from yaml or penred internal format
    try:
        f = open(configFile)
        d = yaml.load(f, Loader=yaml.SafeLoader)
        simu.configure(d)
    except:
        simu.configFromFile(configFile)
        
    print("Configuration set\n")

    #Start the simulation asynchronously
    simu.simulate(True)

    #Simulation started, check status every 30 seconds
    print("Simulation started\n")
    while simu.isSimulating():
        try:
            time.sleep(statusTime)
        except:
            time.sleep(20)
        status = simu.stringifyStatus()
        for e in status:
            print(e)

    print("Simulation finished")

Documentation

📚 pyPenred API

📚 PenRed Documentation

Support

🐞 Report Issues
💬 Discussion Forum

API

To build the authomatic API documentation, you need the sphinx package:

pip install sphinx furo sphinx-copybutton sphinx-autodoc-typehints sphinxcontrib-napoleon myst-parser

once installed, build the documentation running the following instructions inside the docs folder

make html

Finally, the documentation will be available opening the file docs/build/html/index.html with a web browser.

Metadata

Release files for pyPenred 1.15.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for pyPenred 1.15.0.0
File
pypenred-1.15.0.0-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details
pypenred-1.15.0.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
pypenred-1.15.0.0-cp314-cp314-macosx_14_0_x86_64.whl CPython 3.14 CPython 3.14 macOS 14.0+ x86-64 Details
pypenred-1.15.0.0-cp314-cp314-macosx_14_0_arm64.whl CPython 3.14 CPython 3.14 macOS 14.0+ ARM64 Details
pypenred-1.15.0.0-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
pypenred-1.15.0.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
pypenred-1.15.0.0-cp313-cp313-macosx_14_0_x86_64.whl CPython 3.13 CPython 3.13 macOS 14.0+ x86-64 Details
pypenred-1.15.0.0-cp313-cp313-macosx_14_0_arm64.whl CPython 3.13 CPython 3.13 macOS 14.0+ ARM64 Details
pypenred-1.15.0.0-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
pypenred-1.15.0.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
pypenred-1.15.0.0-cp312-cp312-macosx_14_0_x86_64.whl CPython 3.12 CPython 3.12 macOS 14.0+ x86-64 Details
pypenred-1.15.0.0-cp312-cp312-macosx_14_0_arm64.whl CPython 3.12 CPython 3.12 macOS 14.0+ ARM64 Details
pypenred-1.15.0.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
pypenred-1.15.0.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
pypenred-1.15.0.0-cp311-cp311-macosx_14_0_x86_64.whl CPython 3.11 CPython 3.11 macOS 14.0+ x86-64 Details
pypenred-1.15.0.0-cp311-cp311-macosx_14_0_arm64.whl CPython 3.11 CPython 3.11 macOS 14.0+ ARM64 Details
pypenred-1.15.0.0-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
pypenred-1.15.0.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details
pypenred-1.15.0.0-cp310-cp310-macosx_14_0_x86_64.whl CPython 3.10 CPython 3.10 macOS 14.0+ x86-64 Details
pypenred-1.15.0.0-cp310-cp310-macosx_14_0_arm64.whl CPython 3.10 CPython 3.10 macOS 14.0+ ARM64 Details

Total release size: 1.2 GB

Release files / pypenred-1.15.0.0-cp314-cp314-win_amd64.whl

Download URL pypenred-1.15.0.0-cp314-cp314-win_amd64.whl
Size 61.8 MB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
03a1da6556266b25048fc3df64402998dc83a8d23cf1f528584b75fc7317150c
BLAKE2b-256 checksum
How to use checksums
2aecda00331d504878782bee3f9120827a64bc8578059da7988308536ee59fdc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / pypenred-1.15.0.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL pypenred-1.15.0.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 62.4 MB
Tags CPython 3.14 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
5e12a310a21af6bc5704f47232e895e6f3db81e44ce9c357811024d843044bce
BLAKE2b-256 checksum
How to use checksums
b7f1fcdc60f8b3593f741379c0bf59407908301bcfe3b36482062ceed5f03066
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / pypenred-1.15.0.0-cp314-cp314-macosx_14_0_x86_64.whl

Download URL pypenred-1.15.0.0-cp314-cp314-macosx_14_0_x86_64.whl
Size 61.3 MB
Tags CPython 3.14 macOS 14.0+ x86-64
SHA-256 checksum
How to use checksums
4d8fd60a07ef090b99a3e962e42ab5d1ab29f8c7072c4cae27d60464dd850495
BLAKE2b-256 checksum
How to use checksums
23ebf6670dfbf628a640513d0c512b213332775552ee69507afa825f195ab5eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / pypenred-1.15.0.0-cp314-cp314-macosx_14_0_arm64.whl

Download URL pypenred-1.15.0.0-cp314-cp314-macosx_14_0_arm64.whl
Size 62.1 MB
Tags CPython 3.14 macOS 14.0+ ARM64
SHA-256 checksum
How to use checksums
ec488346efcbb018b096af8fb3c49bb43b0212a4b393e54b833fe4b4d42d8a06
BLAKE2b-256 checksum
How to use checksums
65085ae9520c96909fccbd0eb8604ade51469e3d8cbab64fbf16b84a190fd8d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / pypenred-1.15.0.0-cp313-cp313-win_amd64.whl

Download URL pypenred-1.15.0.0-cp313-cp313-win_amd64.whl
Size 60.3 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
f90ff53535e3151ef74fbd8fb724fd2e926e5b66cd6711b1c28f5b8faf8bb38e
BLAKE2b-256 checksum
How to use checksums
d90637fa60981c5b4df1221ef2c0f580cca6a09c7a69e2aafd6334a599c7d6de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / pypenred-1.15.0.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL pypenred-1.15.0.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 62.4 MB
Tags CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
5861edac9618a5cd91d06add9447be9ad785ea533b20833fbefa69d13e3a7609
BLAKE2b-256 checksum
How to use checksums
349b375c6d131abfdaa84c389de904ad3824ccfdc37bae6e68e3f112112eab64
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / pypenred-1.15.0.0-cp313-cp313-macosx_14_0_x86_64.whl

Download URL pypenred-1.15.0.0-cp313-cp313-macosx_14_0_x86_64.whl
Size 61.3 MB
Tags CPython 3.13 macOS 14.0+ x86-64
SHA-256 checksum
How to use checksums
433330f5f162b5a6dd99f370742b689264096711ed59ad05aac4ca7e8e17f612
BLAKE2b-256 checksum
How to use checksums
61b89635a4bde90de61db3d427b729e3ae20efef67cf80c075b59bca7d32b20d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / pypenred-1.15.0.0-cp313-cp313-macosx_14_0_arm64.whl

Download URL pypenred-1.15.0.0-cp313-cp313-macosx_14_0_arm64.whl
Size 62.1 MB
Tags CPython 3.13 macOS 14.0+ ARM64
SHA-256 checksum
How to use checksums
0d42c6d242e76b3a57c7845eefb116a5551e6a0899ab954d9a848274ed1f7346
BLAKE2b-256 checksum
How to use checksums
4eb61c86cd205b998d3eeb500497c8243ec5816b9d91152c1f506f878fc3aa30
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / pypenred-1.15.0.0-cp312-cp312-win_amd64.whl

Download URL pypenred-1.15.0.0-cp312-cp312-win_amd64.whl
Size 60.3 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
d0cf2cf5674db507158a4ef259f8736a147244a795dc5c8ee7cd935ad20222db
BLAKE2b-256 checksum
How to use checksums
f5ad64b88d066067c3ceea331649cde864f6df9ff6e313ad38828f6d93f4bf3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / pypenred-1.15.0.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL pypenred-1.15.0.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 62.4 MB
Tags CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
332a2a483539be24e9f226f9a96cefd81aa7e5e9122db5de1bd1e1364dc91182
BLAKE2b-256 checksum
How to use checksums
99e0b56bb617b69230193f2a34bcd9bd4520f4b9165a636f356b48412edda536
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / pypenred-1.15.0.0-cp312-cp312-macosx_14_0_x86_64.whl

Download URL pypenred-1.15.0.0-cp312-cp312-macosx_14_0_x86_64.whl
Size 61.3 MB
Tags CPython 3.12 macOS 14.0+ x86-64
SHA-256 checksum
How to use checksums
263999bc5613d179258cc880be479657830222dfd073216435d5d58ef55c4859
BLAKE2b-256 checksum
How to use checksums
18b9122de3e26c6c3f021623b66fb2c06209bbe3934112b11fc750444b46e3ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / pypenred-1.15.0.0-cp312-cp312-macosx_14_0_arm64.whl

Download URL pypenred-1.15.0.0-cp312-cp312-macosx_14_0_arm64.whl
Size 62.1 MB
Tags CPython 3.12 macOS 14.0+ ARM64
SHA-256 checksum
How to use checksums
1cb3eb9f17f15b3a877d90327a8a74d206a78bc7641a72fcd93b12c6a8e5466c
BLAKE2b-256 checksum
How to use checksums
45904149fc54615ecc4106053f4f0539c5d0c82e04e690f37d455a8f49b932ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / pypenred-1.15.0.0-cp311-cp311-win_amd64.whl

Download URL pypenred-1.15.0.0-cp311-cp311-win_amd64.whl
Size 60.3 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
db921f2db382e4a3fa967f14be6e4aba425b563cfac0a91deef26878e2769604
BLAKE2b-256 checksum
How to use checksums
1d4f0f41ef3a4883c195a803ced61d228b3571851d972e8c5e316800e2399e07
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / pypenred-1.15.0.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL pypenred-1.15.0.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 62.4 MB
Tags CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
84388a0879e8ee83ca05a3e3b10804fa43d6eb9744f2b2a78d8bd6af47a67d67
BLAKE2b-256 checksum
How to use checksums
5427f2ef21c067f10e731e26685cbb61ac085cca68d3665f99a760736d1563cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / pypenred-1.15.0.0-cp311-cp311-macosx_14_0_x86_64.whl

Download URL pypenred-1.15.0.0-cp311-cp311-macosx_14_0_x86_64.whl
Size 61.3 MB
Tags CPython 3.11 macOS 14.0+ x86-64
SHA-256 checksum
How to use checksums
da130c1a37bd88e6eee57be64b615e61cf9d3604bbc8eb6737714297a1bc666c
BLAKE2b-256 checksum
How to use checksums
2942c1718228ca91689908345453c8e165f0da1556f170838fd02c07056def18
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / pypenred-1.15.0.0-cp311-cp311-macosx_14_0_arm64.whl

Download URL pypenred-1.15.0.0-cp311-cp311-macosx_14_0_arm64.whl
Size 62.1 MB
Tags CPython 3.11 macOS 14.0+ ARM64
SHA-256 checksum
How to use checksums
690d83d7d5f85cab3e91c3b09224d1529b6e69fb15e6800cadb04a5d6c610f96
BLAKE2b-256 checksum
How to use checksums
5beed6055470ca0d0a3074cd534c33f82a43fe141db9587f3b6daabe960beb8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / pypenred-1.15.0.0-cp310-cp310-win_amd64.whl

Download URL pypenred-1.15.0.0-cp310-cp310-win_amd64.whl
Size 60.3 MB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
32a2326b2dfd4fc2c48f05cf2f7121f3480024eb1cfb3443bf5848af008c4f1a
BLAKE2b-256 checksum
How to use checksums
9c6510b6c54ebb2bad8333620a417b32e03ed5fca3369ff4b1d808daf4abc7e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / pypenred-1.15.0.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL pypenred-1.15.0.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 62.4 MB
Tags CPython 3.10 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
a47407ab26f022ddda5ed9dbe109862698bd5d1398f3fac261f7f44b9baf8361
BLAKE2b-256 checksum
How to use checksums
e26773271c054055399ba971eb1ac1e8032d38c88c7d2cffe9cd1fac30ac528b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / pypenred-1.15.0.0-cp310-cp310-macosx_14_0_x86_64.whl

Download URL pypenred-1.15.0.0-cp310-cp310-macosx_14_0_x86_64.whl
Size 61.3 MB
Tags CPython 3.10 macOS 14.0+ x86-64
SHA-256 checksum
How to use checksums
571256fa48b2f270fef2f9a4517bfba31c1d9aeade1a8ee378bfc464ac223526
BLAKE2b-256 checksum
How to use checksums
25c81387749fa6d75f1a9f144645a17eb24ab02a943e8c2739a4e1a5e80d365d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / pypenred-1.15.0.0-cp310-cp310-macosx_14_0_arm64.whl

Download URL pypenred-1.15.0.0-cp310-cp310-macosx_14_0_arm64.whl
Size 62.0 MB
Tags CPython 3.10 macOS 14.0+ ARM64
SHA-256 checksum
How to use checksums
45e976e13969f4d728100d4cbeb7fc0339f2c3dacbee2e7c1e82a72a4d21053c
BLAKE2b-256 checksum
How to use checksums
45aef16f072d75a6fe0b89ddbb2afc267d965f00e09e22ecbd31ed386445aaf1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

1.15.0.0 This release

20 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page