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.1.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.1.0
File
pypenred-1.15.1.0-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details
pypenred-1.15.1.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.1.0-cp314-cp314-macosx_14_0_x86_64.whl CPython 3.14 CPython 3.14 macOS 14.0+ x86-64 Details
pypenred-1.15.1.0-cp314-cp314-macosx_14_0_arm64.whl CPython 3.14 CPython 3.14 macOS 14.0+ ARM64 Details
pypenred-1.15.1.0-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
pypenred-1.15.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details
pypenred-1.15.1.0-cp313-cp313-macosx_14_0_x86_64.whl CPython 3.13 CPython 3.13 macOS 14.0+ x86-64 Details
pypenred-1.15.1.0-cp313-cp313-macosx_14_0_arm64.whl CPython 3.13 CPython 3.13 macOS 14.0+ ARM64 Details
pypenred-1.15.1.0-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
pypenred-1.15.1.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.1.0-cp312-cp312-macosx_14_0_x86_64.whl CPython 3.12 CPython 3.12 macOS 14.0+ x86-64 Details
pypenred-1.15.1.0-cp312-cp312-macosx_14_0_arm64.whl CPython 3.12 CPython 3.12 macOS 14.0+ ARM64 Details
pypenred-1.15.1.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
pypenred-1.15.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details
pypenred-1.15.1.0-cp311-cp311-macosx_14_0_x86_64.whl CPython 3.11 CPython 3.11 macOS 14.0+ x86-64 Details
pypenred-1.15.1.0-cp311-cp311-macosx_14_0_arm64.whl CPython 3.11 CPython 3.11 macOS 14.0+ ARM64 Details
pypenred-1.15.1.0-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
pypenred-1.15.1.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.1.0-cp310-cp310-macosx_14_0_x86_64.whl CPython 3.10 CPython 3.10 macOS 14.0+ x86-64 Details
pypenred-1.15.1.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.1.0-cp314-cp314-win_amd64.whl

Download URL pypenred-1.15.1.0-cp314-cp314-win_amd64.whl
Size 61.9 MB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
1ec521df062f1b28c449b621c4194524d5fb3ddf725d4fceb097be28714076aa
BLAKE2b-256 checksum
How to use checksums
995f6307317c98a4e773a9a62670e79932772051d7a08dfd69607177ff0d94ec
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.1.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL pypenred-1.15.1.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 62.6 MB
Tags CPython 3.14 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
aa81478193aa8f53e06052d5c3e502fd3c30787e672bd1a54eabb2e7ec0ccec7
BLAKE2b-256 checksum
How to use checksums
ffd62ec7517c1e4e15da9303a22903789b0a8f5537ac15347349e92944295e30
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.1.0-cp314-cp314-macosx_14_0_x86_64.whl

Download URL pypenred-1.15.1.0-cp314-cp314-macosx_14_0_x86_64.whl
Size 61.6 MB
Tags CPython 3.14 macOS 14.0+ x86-64
SHA-256 checksum
How to use checksums
2492ff092538dbb829b9abb2801ee57c3cfac86c481b28fbeb8d6cc170775790
BLAKE2b-256 checksum
How to use checksums
93a679010290027e3bd6becfe392360cb3eae62b17959f4b6b2e2e3c014cb406
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.1.0-cp314-cp314-macosx_14_0_arm64.whl

Download URL pypenred-1.15.1.0-cp314-cp314-macosx_14_0_arm64.whl
Size 62.4 MB
Tags CPython 3.14 macOS 14.0+ ARM64
SHA-256 checksum
How to use checksums
8915b1af7e016ac943f4882c4c9008446fcc4bac0d73f62ac7f555fb9c1bfffc
BLAKE2b-256 checksum
How to use checksums
a9a94753e85404a6987c573e3c46ad04bc721ae8697d0d9bd6e79d29c20a5ede
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.1.0-cp313-cp313-win_amd64.whl

Download URL pypenred-1.15.1.0-cp313-cp313-win_amd64.whl
Size 60.4 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
4f508b0f24e1d08327c3c948696b90c0c584ea693cd657fada17c500e553989c
BLAKE2b-256 checksum
How to use checksums
cdee15103f079430f684a79ba7188c5c6aaddfecc7c6d6b7c4fb80d25d8e0aaf
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.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL pypenred-1.15.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 62.6 MB
Tags CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
ef9b6a2886be45d4136a9c4110d13fe7b4e83e8c8a1a664f2ead9946081d2b8a
BLAKE2b-256 checksum
How to use checksums
dccbc5621df695c9bd179e10a64b31c2605ade880eac9902662806d8ac250838
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.1.0-cp313-cp313-macosx_14_0_x86_64.whl

Download URL pypenred-1.15.1.0-cp313-cp313-macosx_14_0_x86_64.whl
Size 61.6 MB
Tags CPython 3.13 macOS 14.0+ x86-64
SHA-256 checksum
How to use checksums
a4c98cfd6acf803ab35f3f00da341cdfd09a6b145bddfcf805dc818b44251d60
BLAKE2b-256 checksum
How to use checksums
9b5c8e5ca0386492939abe606942bfa54f5b1be8c4a762896025f444c8af8d30
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.1.0-cp313-cp313-macosx_14_0_arm64.whl

Download URL pypenred-1.15.1.0-cp313-cp313-macosx_14_0_arm64.whl
Size 62.4 MB
Tags CPython 3.13 macOS 14.0+ ARM64
SHA-256 checksum
How to use checksums
f86212e8c551b686ec7b9ed3af73a36a43a04b2ec4acc3cb41e07476e551b7f0
BLAKE2b-256 checksum
How to use checksums
5075306cc947a533344f8d062dc6879d5ef934599fdfa8a22ea7d957cf87d468
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.1.0-cp312-cp312-win_amd64.whl

Download URL pypenred-1.15.1.0-cp312-cp312-win_amd64.whl
Size 60.4 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
745eeea02db2fb0a3f80cb6cce0123632ceae3dc53e0b67445c6cd6f3e311bcf
BLAKE2b-256 checksum
How to use checksums
4037fb0f0b6a15a01fbe4221500a1231f6acc983dc5706be15ba9d8f4f04e5ac
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.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL pypenred-1.15.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 62.6 MB
Tags CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
dd2fa4dfafbf8c47664522b2f3bfc5dd29ae378714f519e9faa0a07e000a1e2b
BLAKE2b-256 checksum
How to use checksums
7f48e40277d9e0b5acb3b986fb9083d06fbaa39c19a16eb3c299fd5711440a76
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.1.0-cp312-cp312-macosx_14_0_x86_64.whl

Download URL pypenred-1.15.1.0-cp312-cp312-macosx_14_0_x86_64.whl
Size 61.6 MB
Tags CPython 3.12 macOS 14.0+ x86-64
SHA-256 checksum
How to use checksums
1e6ee61855249ba63fc2dca798e8bf8c30485c87dd5bc4b99468ea5423b2cbad
BLAKE2b-256 checksum
How to use checksums
9170b5c3b609cbdcd63a6a5cc7cc7a35bc8e58c77a059d0e4b620cc45e6fcefa
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.1.0-cp312-cp312-macosx_14_0_arm64.whl

Download URL pypenred-1.15.1.0-cp312-cp312-macosx_14_0_arm64.whl
Size 62.4 MB
Tags CPython 3.12 macOS 14.0+ ARM64
SHA-256 checksum
How to use checksums
ea0410d8cea565937fe813a5ba9db88c32e1d9a65e600a379e6b485bf1f8f970
BLAKE2b-256 checksum
How to use checksums
15225fc2275e41a6dc86e5e047d764f33af63ed821ac70fa2739233bdf737f0f
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.1.0-cp311-cp311-win_amd64.whl

Download URL pypenred-1.15.1.0-cp311-cp311-win_amd64.whl
Size 60.4 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
10c5bf176e56ee838f381c70fc89837596457344bdc8096725af9c0f629de7c7
BLAKE2b-256 checksum
How to use checksums
06f6fe1407da7df7f2876bd06de25531ee6a696dc353b65e5241d78aafec9bb6
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.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL pypenred-1.15.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 62.6 MB
Tags CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
f22cff061f64a32bd89fb8d4cf5e24f5f2960e7bd0f224b17a7f4f0f2d7bfafe
BLAKE2b-256 checksum
How to use checksums
7fc9963dc549385a128cdbe5abbc392afe0522c1566445189f1cb900ddf0db02
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.1.0-cp311-cp311-macosx_14_0_x86_64.whl

Download URL pypenred-1.15.1.0-cp311-cp311-macosx_14_0_x86_64.whl
Size 61.6 MB
Tags CPython 3.11 macOS 14.0+ x86-64
SHA-256 checksum
How to use checksums
dcc7ecd4319d43d7937f4597c8ff5e1d91fae383724f6c66b54d49e19ea2efdc
BLAKE2b-256 checksum
How to use checksums
73f25a0d71c092858ba07e9f3dfd2667f59040080c0f51841f66dfe5b9249edb
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.1.0-cp311-cp311-macosx_14_0_arm64.whl

Download URL pypenred-1.15.1.0-cp311-cp311-macosx_14_0_arm64.whl
Size 62.3 MB
Tags CPython 3.11 macOS 14.0+ ARM64
SHA-256 checksum
How to use checksums
e290e4ace1498feca835f50496baad1c917b5623d163408c44e7f25a779e28ab
BLAKE2b-256 checksum
How to use checksums
5fef0dd7f96197217c488b64ae9639c8409b9edcaf8dfc7df7622614a1ea89cf
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.1.0-cp310-cp310-win_amd64.whl

Download URL pypenred-1.15.1.0-cp310-cp310-win_amd64.whl
Size 60.4 MB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
8f32aa486d241221d2b30395cb399a8828d1ecb3b4ea7d9af67f08394039d973
BLAKE2b-256 checksum
How to use checksums
a0a4dfc8beafaf9ac4ded7da40a384f71f5824c242b638a6d41cf0b109ca218d
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.1.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL pypenred-1.15.1.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 62.6 MB
Tags CPython 3.10 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
69cd5eb02f8e06a61d8b19446f639ed9bfa3fd0c51bf88f3182b989db6d2d218
BLAKE2b-256 checksum
How to use checksums
a6d84c6baeea3eb279bd6b6a8a8881be8401d88b358ab685b6dc7da51b16e847
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.1.0-cp310-cp310-macosx_14_0_x86_64.whl

Download URL pypenred-1.15.1.0-cp310-cp310-macosx_14_0_x86_64.whl
Size 61.6 MB
Tags CPython 3.10 macOS 14.0+ x86-64
SHA-256 checksum
How to use checksums
ec8d8bf3c8ac6c5565b6a572c4e994ef11cf2ebe9165f6a9b6cc925c088c76f1
BLAKE2b-256 checksum
How to use checksums
a4eaf26d1446babcf193371e78440ca7820d9ccdb4bd201267dd5696595b9062
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.1.0-cp310-cp310-macosx_14_0_arm64.whl

Download URL pypenred-1.15.1.0-cp310-cp310-macosx_14_0_arm64.whl
Size 62.3 MB
Tags CPython 3.10 macOS 14.0+ ARM64
SHA-256 checksum
How to use checksums
1d4d7e51925fbc10ff0b498c55f2d194a88a501125603f34de31cd043d326f11
BLAKE2b-256 checksum
How to use checksums
6ab3417fedb957a813175621ee1509bf8e24d287f1f47db242772546d6b8bf5d
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.1.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