Alternative python bindings for Geant4 via pybind11
Project description
Python bindings for Geant4
Alternative Python bindings for Geant4 via pybind11. It is loosely based on g4py, but retains an API closer to the standard C++ API and does not require Boost.Python.
It currently includes all g4py bindings plus a large portion of very commonly used classes and functions that aren't currently present in g4py. However, it is still far off from replicating the full Geant4 API and is thus (currently) only applicable for simple simulations.
Installation
It's available on PyPI for all major platforms as a fully self-contained (i.e. statically linked) wheel.
pip install geant4-pybind
Building
Unix (Linux, OS X) prerequisits
- A Geant4 installation, version 10.7+ (make sure it is also added to the path)
- A C++14 compiler (preferably the one Geant4 was compiled with)
- CMake
- Python3
- pip
- git
Windows prerequisits
- A Geant4 installation, version 10.7+ (make sure it is also added to the PATH)
- Visual Studio 2019 for C++ development, with CMake
- Python3
- pip
- git
Note: If you haven't downloaded the required datasets yet don't worry, you can let geant4_pybind handle them.
Installation
git clone --recursive https://github.com/HaarigerHarald/geant4_pybind
pip install ./geant4_pybind
Windows notes
The above commands have to be executed in a "Developer Command Prompt for VS 2019" and require that Python3, pip and git are added to the PATH environment variable.
General notes
If the repository was cloned non-recursively you can check out the submodule with:
git -C ./geant4_pybind submodule update --init
Usage
Minimal
A minimal example that just starts a Geant4 shell:
from geant4_pybind import *
import sys
ui = G4UIExecutive(len(sys.argv), sys.argv)
ui.SessionStart()
Full examples
Check out the examples directory, which contains the Geant4 basic examples ported to Python. However, writing simulations in Python should be pretty straight forward as the API is almost identical to the C++ one. One notable exception are template classes, which have been renamed such that their type replaces the T
(i.e. G4TScoreNtupleWriter<G4RootAnalysisManager>
becomes G4RootScoreNtupleWriter
).
Bugs?
Yes!
Though the bigger problem is probably that there is still quite a bit missing.
License
This builds upon Geant4 and g4py and thus the Geant4 license applies. The binding code uses pybind11. All my contributions are public domain.
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
Hashes for geant4_pybind-0.1.0b2-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32cff28f1b771c61d2e96f9066ef92fbaa32a2ecd5cdf3cf9c836a11725a80f0 |
|
MD5 | aa25fe8e13cf6a28ada65c6cd79aa414 |
|
BLAKE2b-256 | a35eaf96fc59a343c16ecabe7bd22e2b49304752c9704d8396583bee3d5d989c |
Hashes for geant4_pybind-0.1.0b2-cp39-cp39-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef9db17f1d4a8938d8eb0489faa5062d4964bc383274bfa064aa9414584be578 |
|
MD5 | 855c48e05fe6f729e48a9b14a4538f79 |
|
BLAKE2b-256 | 41895c7fc73f84ba652b82a7752320382a1a1a6300e745afacf62f942553e2fe |
Hashes for geant4_pybind-0.1.0b2-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b372a1f2acfb03925376a3d35984fe90b81947a5c2da5a3f7896274f8dab9a2 |
|
MD5 | 4839342d761652eacfb198bba7b49b21 |
|
BLAKE2b-256 | 3fd7daac3b5df5e331e4e2986d098c0fff01dee69949fdf0adc4acf0ab303f21 |
Hashes for geant4_pybind-0.1.0b2-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3dcec35e317aadf116c02879f614df39643ed8086ef11d2eab6cef6677c7882 |
|
MD5 | 493776e87db3113291bb266f91fbff11 |
|
BLAKE2b-256 | 0cd1c91dc933c2fc06965eb7a20bfc494970c776795ee2bc6df68e8577fc79b7 |
Hashes for geant4_pybind-0.1.0b2-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c885958baaa23e1771cdae0b91ad5c0264ab5950ae38ce26414aa486ad5addbe |
|
MD5 | 2300f71ac5e605ec448c9431297aef69 |
|
BLAKE2b-256 | c33aef511b834040fea42f534c13caa6d8c47d3b4231eadbd13f831d9a143be9 |
Hashes for geant4_pybind-0.1.0b2-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 87f20dfa2ab85ab7db652d9b78998f06a297aa90a8a51df03d98ee3fa0026828 |
|
MD5 | 84ef09fd95dd7395df47310dac21b78c |
|
BLAKE2b-256 | 363205fa29585d4b8f76fb0141a500249af84ae225e5a1e29ccc104161abd25b |
Hashes for geant4_pybind-0.1.0b2-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0287f77d74957c238a36acfb9fe433e1baa8134a502c1c54bd4b648f9b9a504 |
|
MD5 | e7c6a83e26a12ff8761842d1b0ccf155 |
|
BLAKE2b-256 | 5d5a6b9096f7fcb4f4f4f37d2dd1c5d702eefc90baddb0bee85503fb25ebfd3c |
Hashes for geant4_pybind-0.1.0b2-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c88d4b52f1f21e58942baa41ddb7daa9f4fe73f7d06c90dba74e96de60f74006 |
|
MD5 | fe687f8f3049756a6f36ac58f8098c34 |
|
BLAKE2b-256 | 7de634f636d8b5a5437cb99cc99438cdd7f7d29944bb67a3e0f2198bca6b2129 |
Hashes for geant4_pybind-0.1.0b2-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a75d1908165aca071f96ce8a91e7302f9faf19220a4895cca009989eb9aa4e0 |
|
MD5 | e5af8ca2458e7d0b50f164dda26b73e5 |
|
BLAKE2b-256 | b4f085d27471bdfc414235adac477732aed7ac67cab8651d129e79f157559d50 |
Hashes for geant4_pybind-0.1.0b2-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ffd27ee94c31543f3c6b050a4f83b1265a926d10ccb9342d48a36ff7e9b7c0b6 |
|
MD5 | 1ece4f71011a1f16bd7c81f4986c3859 |
|
BLAKE2b-256 | 6a9b78290adaf54bd37e9fa406a39c5fc59b405cca84f2cc7a93cd62b879b0f5 |
Hashes for geant4_pybind-0.1.0b2-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15e5b38b9820275c467f05cbc447988a7a2307ebdc6ff417b25116d1bdbe9b08 |
|
MD5 | b5fc3aac8fd563e4336c67bbe21fcbd0 |
|
BLAKE2b-256 | b517b2a5766f5253902f3335c1a914d1c44d6817f6f5c2ac32d56559b10a954f |
Hashes for geant4_pybind-0.1.0b2-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3c68486eba034aff149320987c500ba8a78f98f8c5a11f50f23173a457762c5 |
|
MD5 | 250d258c2e7bf1c3081c72a4b54e42e5 |
|
BLAKE2b-256 | bdb950d2c2a5eff378b6509408e6fe5105abac585929961a6c9d9072280657af |
Hashes for geant4_pybind-0.1.0b2-cp35-cp35m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 11ffd1a9246a4dd2d17cf55da32aa89c051546b9ecae42929e27deaf3ac32451 |
|
MD5 | 160e6288229b4f49b9af5d5ec1e0a92f |
|
BLAKE2b-256 | 26c0d3c7bfabed96169b043673fc1684c93efec179cda5201031543025aacfe2 |
Hashes for geant4_pybind-0.1.0b2-cp35-cp35m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 079de84b90d256a73c62f70dccddd4aaf1a35dda769cde6c0b90005efa9f767c |
|
MD5 | 1656307dd896266ef0f56958922b4dfd |
|
BLAKE2b-256 | 8d487e5938eb0a57faa8c88a84ce7f7bd5f38861cfce380044c64b93baaea29b |
Hashes for geant4_pybind-0.1.0b2-cp35-cp35m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f8785696ea69e9e259d85de90bea9a4a7a31c9aeca9112305fc51a4058acfc84 |
|
MD5 | f1343a25a5b468f29d483c0f71b61e7e |
|
BLAKE2b-256 | fcb3b2ed0ca49ae6a9febc5115eebedde2a22e720cf94100fc782ac28a52a6c4 |