Python interface for penRed framework
Project description
pyPenred - Python Bindings for PenRed
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
From PyPI (recommended)
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
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pypenred-1.14.0.4-cp314-cp314-win_amd64.whl.
File metadata
- Download URL: pypenred-1.14.0.4-cp314-cp314-win_amd64.whl
- Upload date:
- Size: 59.9 MB
- Tags: CPython 3.14, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8a75debe01d5d63427dfdd8f00699783b7a0e8f0d1ae5d045eb9ced1d07a9f5
|
|
| MD5 |
eb04c243c7861df327021618316ce13b
|
|
| BLAKE2b-256 |
8af512a2c1f1be3e3529b87411648c827aeb26b8ea8159eca1b94ec1e70c2635
|
File details
Details for the file pypenred-1.14.0.4-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pypenred-1.14.0.4-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 59.6 MB
- Tags: CPython 3.14, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a5d6cad7902c8ac8711d86b2acc5388dd31cc7fc74222528fb8ed275233ab92
|
|
| MD5 |
1465c0f04ee842794308de2dd4c6a376
|
|
| BLAKE2b-256 |
8e8ecb6d748882581eac53578b0a650da1232e06c886da8e9db1955003fbe193
|
File details
Details for the file pypenred-1.14.0.4-cp314-cp314-macosx_14_0_x86_64.whl.
File metadata
- Download URL: pypenred-1.14.0.4-cp314-cp314-macosx_14_0_x86_64.whl
- Upload date:
- Size: 59.0 MB
- Tags: CPython 3.14, macOS 14.0+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72725e43017e97285bf8275ea70c60fca44c1db77c9e653ea176456c15b21b21
|
|
| MD5 |
79d151d90684c2b0ccb2f916d21569d6
|
|
| BLAKE2b-256 |
47dc786c5ac6dd56eba7250daea1ef82c87b11fd03b6c4ff2357d5409e2b4235
|
File details
Details for the file pypenred-1.14.0.4-cp314-cp314-macosx_14_0_arm64.whl.
File metadata
- Download URL: pypenred-1.14.0.4-cp314-cp314-macosx_14_0_arm64.whl
- Upload date:
- Size: 60.0 MB
- Tags: CPython 3.14, macOS 14.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e76a70e5c7ae8ef32b8c590cb005c5c5ae312a3253328cafe5f68a112d42f6b1
|
|
| MD5 |
2671b1a554a47afda1d62d631f12dc30
|
|
| BLAKE2b-256 |
cbf38548ad78731aad2bb1395f56c7c3db473c9b23e850ab2ff41e01cc443e19
|
File details
Details for the file pypenred-1.14.0.4-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: pypenred-1.14.0.4-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 58.4 MB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fbaa5c807cdd505619e646be3114dd4e9e2c62aeb6bbfe486d6ef0b17c40123e
|
|
| MD5 |
1399554011d617806c21c9b8feaca392
|
|
| BLAKE2b-256 |
53505f20a9ba27a5b475982557cca9aa7cba826e16b0d83524076d2b78c79bbd
|
File details
Details for the file pypenred-1.14.0.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pypenred-1.14.0.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 59.6 MB
- Tags: CPython 3.13, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7607dc51f7950485f3709e00d446b32e42f4ca6104211f842357573a9e94de9
|
|
| MD5 |
b4f71c1d8b53cbdffd8fcc330f37558f
|
|
| BLAKE2b-256 |
b9c76031980e33b556543a6cc8da50173539af906173c5a5bfa700db4b09f284
|
File details
Details for the file pypenred-1.14.0.4-cp313-cp313-macosx_14_0_x86_64.whl.
File metadata
- Download URL: pypenred-1.14.0.4-cp313-cp313-macosx_14_0_x86_64.whl
- Upload date:
- Size: 59.0 MB
- Tags: CPython 3.13, macOS 14.0+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85be70e85e2fdb672903667bfb33ed8c35237e88f292b539515b681fd950e276
|
|
| MD5 |
d5764e7a01f01e0c5a47930b84a8f876
|
|
| BLAKE2b-256 |
6de6daf6b6776d3d0651b13d3152d35ec789e7db4a65723a56bf45d2c8d4201d
|
File details
Details for the file pypenred-1.14.0.4-cp313-cp313-macosx_14_0_arm64.whl.
File metadata
- Download URL: pypenred-1.14.0.4-cp313-cp313-macosx_14_0_arm64.whl
- Upload date:
- Size: 60.0 MB
- Tags: CPython 3.13, macOS 14.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
727d96fe3ac515e29b2ab91bcc4c5db4793cde0d42afdd4eb7f93254481c72d2
|
|
| MD5 |
7b93d69cbdb30f7f7656802dbfd14526
|
|
| BLAKE2b-256 |
925a2ae3c15e5352b08f8b864274ef9b419de3fe9b3a3ea1815d95def5fd2adc
|
File details
Details for the file pypenred-1.14.0.4-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: pypenred-1.14.0.4-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 58.4 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
34b598ed13f7e6b2d4119ce0c0627c5722f5e5a35416fe2ce5856b897eb48bb5
|
|
| MD5 |
68728f8a83dbc4c67f44263b81bdce00
|
|
| BLAKE2b-256 |
2635857ca65d26e77a8fcd54ac27eec455480c1289364b11dc153695ed022b7c
|
File details
Details for the file pypenred-1.14.0.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pypenred-1.14.0.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 59.6 MB
- Tags: CPython 3.12, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1a04224c9bff7493735c089a7e5a126a24fc0331498a1e36f1afc050133e4c4
|
|
| MD5 |
a690cc5cbeaebaa58c4484117e6b6ca8
|
|
| BLAKE2b-256 |
7986e51e7548dc21eb1a8786de191bbd9360bed79c87b8316dc04a13916f7d28
|
File details
Details for the file pypenred-1.14.0.4-cp312-cp312-macosx_14_0_x86_64.whl.
File metadata
- Download URL: pypenred-1.14.0.4-cp312-cp312-macosx_14_0_x86_64.whl
- Upload date:
- Size: 59.0 MB
- Tags: CPython 3.12, macOS 14.0+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fbd3280663ab6627d9b2962f681c0ee596b490ea3157b12112cecff5a636f4f8
|
|
| MD5 |
fcfccb23ad444e54999a90574dea6078
|
|
| BLAKE2b-256 |
37364c170ac21b543b3630f0a9b3091bc442c77a20e5f8ad54e0157c749b29b0
|
File details
Details for the file pypenred-1.14.0.4-cp312-cp312-macosx_14_0_arm64.whl.
File metadata
- Download URL: pypenred-1.14.0.4-cp312-cp312-macosx_14_0_arm64.whl
- Upload date:
- Size: 60.0 MB
- Tags: CPython 3.12, macOS 14.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d94450abd6c6134d950aeb948324fc440423ce47b20310c0aa7e89207d9a38e
|
|
| MD5 |
0e83aaf79de677b03cf80c57f913fa18
|
|
| BLAKE2b-256 |
55940e079fa1c97d83670007fdf9cf753fc0bd5e2819d11a0fec2ebe0883b7f5
|
File details
Details for the file pypenred-1.14.0.4-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: pypenred-1.14.0.4-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 58.4 MB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76267ce87db57e23d3996658397a9ccf1c6394ca1b62da0ff31d93013b1a637b
|
|
| MD5 |
13edc89bbee459f188f6a8a835165b89
|
|
| BLAKE2b-256 |
4f3df79bf0f805db06f0b89847af2c7be5b75961e56c3340b65ea163b7025041
|
File details
Details for the file pypenred-1.14.0.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pypenred-1.14.0.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 59.6 MB
- Tags: CPython 3.11, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f42d3be2ca5940e1d2e412e19ce46f5b3e5c5f21923086ff10e24f474ed83449
|
|
| MD5 |
72646ec67b4c30ffe97cddd7984bd9fc
|
|
| BLAKE2b-256 |
e14714255ee709035e8bf6e88b64d5bd04bbaaf5ac22fc1f7526f83eac48ff6b
|
File details
Details for the file pypenred-1.14.0.4-cp311-cp311-macosx_14_0_x86_64.whl.
File metadata
- Download URL: pypenred-1.14.0.4-cp311-cp311-macosx_14_0_x86_64.whl
- Upload date:
- Size: 59.0 MB
- Tags: CPython 3.11, macOS 14.0+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ffb9f22766f7a366d1852ff567c82464e7e8925b85e0c9ebc5787d7c41de6be0
|
|
| MD5 |
6c82383832092fba984a41a3c14fa781
|
|
| BLAKE2b-256 |
8e90e12a37538f90b0de9da3920c4ffe5844452c6558b3a5d8a8c1404897943e
|
File details
Details for the file pypenred-1.14.0.4-cp311-cp311-macosx_14_0_arm64.whl.
File metadata
- Download URL: pypenred-1.14.0.4-cp311-cp311-macosx_14_0_arm64.whl
- Upload date:
- Size: 60.0 MB
- Tags: CPython 3.11, macOS 14.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c63f8c6629b625f59ea10294af26fc05ad3189a733e2a8b56be6fd0b4ac7562d
|
|
| MD5 |
eb26eb5a7df05a4312e5f31a834938b7
|
|
| BLAKE2b-256 |
22ce1a317f5eade364e44e6faf944aa9fd127c571178333ba3600178a7269931
|
File details
Details for the file pypenred-1.14.0.4-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: pypenred-1.14.0.4-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 58.4 MB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70d48fe432b76056de351885ca3eac60d206f1043499aff5b77c4003010caec2
|
|
| MD5 |
53bba380a77ec99f93168ad4c5bc9826
|
|
| BLAKE2b-256 |
c6c7da2433bb8bd22d807dddf22ac4deafaf323be44e628bb2e203d9ef6ef3a6
|
File details
Details for the file pypenred-1.14.0.4-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pypenred-1.14.0.4-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 59.6 MB
- Tags: CPython 3.10, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c237437e44f92a095e1ee9e6bbe96b60d8b7d918c5adf399be0aca7070b5803
|
|
| MD5 |
2fc170ebc0e3e092d1ae65328646ee0e
|
|
| BLAKE2b-256 |
87ed7370702765382c94af61b92be74c3dc5945467d5c9c4e94b7ba8e4dc17f8
|
File details
Details for the file pypenred-1.14.0.4-cp310-cp310-macosx_14_0_x86_64.whl.
File metadata
- Download URL: pypenred-1.14.0.4-cp310-cp310-macosx_14_0_x86_64.whl
- Upload date:
- Size: 59.0 MB
- Tags: CPython 3.10, macOS 14.0+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
497199ab1695d8bb1977b5b0c584c3d86f770d8eb6012661e91762ca7c87f495
|
|
| MD5 |
6b7e6d0426e164c775ac3f1997d637be
|
|
| BLAKE2b-256 |
019b77c3ab1044cfb5c5061a5b0f214d3201e9aacaf4cdbfe34d09dcab92ccba
|
File details
Details for the file pypenred-1.14.0.4-cp310-cp310-macosx_14_0_arm64.whl.
File metadata
- Download URL: pypenred-1.14.0.4-cp310-cp310-macosx_14_0_arm64.whl
- Upload date:
- Size: 60.0 MB
- Tags: CPython 3.10, macOS 14.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4af68f9edc7f80453bb46c64aee85140b674b3b279b89fa3a66858cdd9e379dd
|
|
| MD5 |
a09df5a575f526939d7c854e030dc0c6
|
|
| BLAKE2b-256 |
4228732e854cd4462b8fdc4d8581aeaf613049599ec33102b98fef69ff1ca768
|