Skip to main content

Alternative python bindings for Geant4 via pybind11

Project description

Python bindings for Geant4

Tests Wheel PyPI

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 depend on 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 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.

pip3 install geant4-pybind

Building

Unix (Linux, OS X) prerequisits

  • A Geant4 installation version 11.0+, compiled with CMake option GEANT4_BUILD_TLS_MODEL=global-dynamic (make sure it is also added to the path)
  • A C++17 compiler (preferably the one Geant4 was compiled with)
  • Python3
  • pip
  • git

Windows prerequisits

Note: If you haven't downloaded the required datasets yet you can let geant4_pybind handle them.

Installation

git clone --recursive https://github.com/HaarigerHarald/geant4_pybind
pip3 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()

Simulation 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<G4GenericAnalysisManager> becomes G4GenericScoreNtupleWriter).

Bugs?

Yes! Please create an issue if you encounter one.

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

geant4_pybind-0.1.0b6.tar.gz (382.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

geant4_pybind-0.1.0b6-pp37-pypy37_pp73-win_amd64.whl (14.2 MB view details)

Uploaded PyPyWindows x86-64

geant4_pybind-0.1.0b6-pp37-pypy37_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (20.1 MB view details)

Uploaded PyPymanylinux: glibc 2.12+ x86-64

geant4_pybind-0.1.0b6-pp37-pypy37_pp73-macosx_10_9_x86_64.whl (17.1 MB view details)

Uploaded PyPymacOS 10.9+ x86-64

geant4_pybind-0.1.0b6-cp310-cp310-win_amd64.whl (14.2 MB view details)

Uploaded CPython 3.10Windows x86-64

geant4_pybind-0.1.0b6-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (20.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.12+ x86-64

geant4_pybind-0.1.0b6-cp310-cp310-macosx_10_9_x86_64.whl (17.1 MB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

geant4_pybind-0.1.0b6-cp39-cp39-win_amd64.whl (14.8 MB view details)

Uploaded CPython 3.9Windows x86-64

geant4_pybind-0.1.0b6-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (20.1 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.12+ x86-64

geant4_pybind-0.1.0b6-cp39-cp39-macosx_10_9_x86_64.whl (17.1 MB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

geant4_pybind-0.1.0b6-cp38-cp38-win_amd64.whl (14.2 MB view details)

Uploaded CPython 3.8Windows x86-64

geant4_pybind-0.1.0b6-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (20.2 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.12+ x86-64

geant4_pybind-0.1.0b6-cp38-cp38-macosx_10_9_x86_64.whl (17.1 MB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

geant4_pybind-0.1.0b6-cp37-cp37m-win_amd64.whl (14.0 MB view details)

Uploaded CPython 3.7mWindows x86-64

geant4_pybind-0.1.0b6-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (20.1 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.12+ x86-64

geant4_pybind-0.1.0b6-cp37-cp37m-macosx_10_9_x86_64.whl (16.8 MB view details)

Uploaded CPython 3.7mmacOS 10.9+ x86-64

geant4_pybind-0.1.0b6-cp36-cp36m-win_amd64.whl (14.0 MB view details)

Uploaded CPython 3.6mWindows x86-64

geant4_pybind-0.1.0b6-cp36-cp36m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (20.1 MB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.12+ x86-64

geant4_pybind-0.1.0b6-cp36-cp36m-macosx_10_9_x86_64.whl (16.8 MB view details)

Uploaded CPython 3.6mmacOS 10.9+ x86-64

File details

Details for the file geant4_pybind-0.1.0b6.tar.gz.

File metadata

  • Download URL: geant4_pybind-0.1.0b6.tar.gz
  • Upload date:
  • Size: 382.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for geant4_pybind-0.1.0b6.tar.gz
Algorithm Hash digest
SHA256 802572edaa1b7d83f6b063f57934f133233e02c211904c5e2c5512803ea8bba0
MD5 6d5e636421c6b450463c93570eacad48
BLAKE2b-256 073786540d5e83d2e4c0913d0f6f8fa0e794c7b389290b341114a20004d21550

See more details on using hashes here.

File details

Details for the file geant4_pybind-0.1.0b6-pp37-pypy37_pp73-win_amd64.whl.

File metadata

  • Download URL: geant4_pybind-0.1.0b6-pp37-pypy37_pp73-win_amd64.whl
  • Upload date:
  • Size: 14.2 MB
  • Tags: PyPy, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for geant4_pybind-0.1.0b6-pp37-pypy37_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 ed337e3d68b4371e27799d566c9c061924162c3495040d9e3d0a8b2c4b2a3d51
MD5 3be73b90730ec70da10058047453be51
BLAKE2b-256 e237bdcc80ae4674e60c3c1cbadb70f0778056f713cbd0479e43173e1149e5bc

See more details on using hashes here.

File details

Details for the file geant4_pybind-0.1.0b6-pp37-pypy37_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for geant4_pybind-0.1.0b6-pp37-pypy37_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 9d4b31004fb4a445e527122048dbe25406910b255d00b61eae92c0f07481b375
MD5 d3255b2f304fa58c5fe558f6e917527c
BLAKE2b-256 9afff0ee5e8ef479eeb2f8c159132128ad56e10038993a387a13e117f4c63506

See more details on using hashes here.

File details

Details for the file geant4_pybind-0.1.0b6-pp37-pypy37_pp73-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: geant4_pybind-0.1.0b6-pp37-pypy37_pp73-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 17.1 MB
  • Tags: PyPy, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for geant4_pybind-0.1.0b6-pp37-pypy37_pp73-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 1b79b2efb0071bcdf76b7539fc970ddb26a35bedba7212a6cd91c34be4ffb292
MD5 9ff54c2cbe043b0685dda5b5e06d0594
BLAKE2b-256 a342082c92c6e02651c4fd19b1ec36077a17c595f24d5fa1486887bf49fb34ea

See more details on using hashes here.

File details

Details for the file geant4_pybind-0.1.0b6-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: geant4_pybind-0.1.0b6-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 14.2 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for geant4_pybind-0.1.0b6-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 2bc4417b52dbc294cc262380d5028d05337bc68d799ca91a90162924791f5f84
MD5 57e55ff9c52f331b7a9103de3a91896b
BLAKE2b-256 5c45f223e25bf5cd991c75ea17b13530494307dcd6a8f25b5d231ae78f703767

See more details on using hashes here.

File details

Details for the file geant4_pybind-0.1.0b6-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for geant4_pybind-0.1.0b6-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 587e10ce1154dce7a890607f8bc7956ae2e3e97ca44ec40cba1f277f5397907b
MD5 dea4d3ee047131f2086b44ce0da0ebad
BLAKE2b-256 2f1231a183404812d527f8d7e598d3a58b9a680395576420f4fbd1ef659a4636

See more details on using hashes here.

File details

Details for the file geant4_pybind-0.1.0b6-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: geant4_pybind-0.1.0b6-cp310-cp310-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 17.1 MB
  • Tags: CPython 3.10, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for geant4_pybind-0.1.0b6-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 8e2da7c95cacc7982febab17cdc32eec81f165dfdb799e38cb47c02c31720097
MD5 293f8021e0a852d51d61e2aaa45cb38e
BLAKE2b-256 1d675c77baa5105fb80b5257fe8b25e98f49a304faa55e5aadc01684bfcde095

See more details on using hashes here.

File details

Details for the file geant4_pybind-0.1.0b6-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: geant4_pybind-0.1.0b6-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 14.8 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for geant4_pybind-0.1.0b6-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 5ea5b5e7341d3f520091df7f03393975e59158f90b649dad8725fc8c944b0f96
MD5 56ca70570d49323a7e305d8de8d1a915
BLAKE2b-256 99bc170ba1cd0d49454969f3bad15124148fffc3f267405229d1a47341ad04a6

See more details on using hashes here.

File details

Details for the file geant4_pybind-0.1.0b6-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for geant4_pybind-0.1.0b6-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 1bdccc6b6ddfeac6f0eed0660eeb1e1c8dfda667bbfdb25af58f8de7d8650ddb
MD5 be6554103e154b33abebb0bf55c13c55
BLAKE2b-256 e28207cd9ff9060f17a16c481227458fc9d2709f187458e42fe6347e585c522f

See more details on using hashes here.

File details

Details for the file geant4_pybind-0.1.0b6-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: geant4_pybind-0.1.0b6-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 17.1 MB
  • Tags: CPython 3.9, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for geant4_pybind-0.1.0b6-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5128e194f264f703e42aaf64c2fae998b5c0a0a1b712ce5d79b88fe9f771a2a9
MD5 54052ddafc0bb696e763cd914e483e50
BLAKE2b-256 20311fcb05236c36dda5fb40ed0f9b150f78dbd373a5eafb0c8ef947b8991de3

See more details on using hashes here.

File details

Details for the file geant4_pybind-0.1.0b6-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: geant4_pybind-0.1.0b6-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 14.2 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for geant4_pybind-0.1.0b6-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 dd3448fd25297dca2d507a651649f296ac50a85ca76f78d9a83dc4af58906c02
MD5 ed76968de6157902d4c55cfb5ecef115
BLAKE2b-256 7249e520d83a4e378c8e35d82a81e3805a3fcb152aa617cc876a3d40481d33e4

See more details on using hashes here.

File details

Details for the file geant4_pybind-0.1.0b6-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for geant4_pybind-0.1.0b6-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 4b7242bceb5be9304b9956a6acf3fc8bc5a53bfc99c3418bf20394b9c646125b
MD5 9606ca8fdc22b9f7603e67be88a1834c
BLAKE2b-256 9d414dd2fb62810405875e514b51b8b02a84bb217a0291ffe305153d7b4a72ce

See more details on using hashes here.

File details

Details for the file geant4_pybind-0.1.0b6-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: geant4_pybind-0.1.0b6-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 17.1 MB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for geant4_pybind-0.1.0b6-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 85cb51d5ff7a41a9c953f16eb70dabc4f02bea8839168aa0b1f01e319eb62471
MD5 629db28f6940c0d194e55e964d86945a
BLAKE2b-256 8657757789f25c4009ae328e8165318a317c538621adb571a0bf65b22bdefb79

See more details on using hashes here.

File details

Details for the file geant4_pybind-0.1.0b6-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: geant4_pybind-0.1.0b6-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 14.0 MB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for geant4_pybind-0.1.0b6-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 2487fc0a270f0e08099d6a58e919ff31a404d1703e5701f4007a57ebfccea069
MD5 786cd0c35885906a12d443d01fc4ccf1
BLAKE2b-256 1c788ea7d474cf7a21f4f6b0bf445741096ec23b77c03acdc5c9da6d2505bcea

See more details on using hashes here.

File details

Details for the file geant4_pybind-0.1.0b6-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for geant4_pybind-0.1.0b6-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 40afdff714de9a309d9a49f26de805a99e83b5567ea620708816df26c0449d38
MD5 e4669c2d4a660ca3849b851927f7f7ab
BLAKE2b-256 e161a282ebf1fe1b44c424f3101231bc610c881b5988c4d96626efb9c3d4149c

See more details on using hashes here.

File details

Details for the file geant4_pybind-0.1.0b6-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: geant4_pybind-0.1.0b6-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 16.8 MB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for geant4_pybind-0.1.0b6-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 30610ac8fb515e0cb94daec5c777a68929957f90969aa2cf500dd32fa8e6f5b9
MD5 a1085af74a1e1778dced3990f7e85aff
BLAKE2b-256 2908ad9dfe7bd1daa26074e09c1c6d4f8179f5d3c9ef9a49206dea7611785bd2

See more details on using hashes here.

File details

Details for the file geant4_pybind-0.1.0b6-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: geant4_pybind-0.1.0b6-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 14.0 MB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for geant4_pybind-0.1.0b6-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 88c74d67f2ec475bf98ec634539f752efc04967493cfd8132ed5c9d035373066
MD5 9fa0cba91cecc43307a9c85f12bd32c1
BLAKE2b-256 294bd8da75061b47c2a5f04906778ad1dfea24fd6d36c8115f9bd205b54e4803

See more details on using hashes here.

File details

Details for the file geant4_pybind-0.1.0b6-cp36-cp36m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for geant4_pybind-0.1.0b6-cp36-cp36m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 ea254705733fe7c67dd7289b50a028c9ad3ba4605334047748c98dad54daa154
MD5 9b1cc44d6c5f74baf208fab6628a9bf2
BLAKE2b-256 f9d2bcfcd7dc55709f5f8a4d64e4e87d214c5496efde1951c927453cab088575

See more details on using hashes here.

File details

Details for the file geant4_pybind-0.1.0b6-cp36-cp36m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: geant4_pybind-0.1.0b6-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 16.8 MB
  • Tags: CPython 3.6m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for geant4_pybind-0.1.0b6-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 9f494e2eee4d0dfc7b9e68e9a777d39108e757d9aacd2b02a57550f4785fdfb0
MD5 bb341fc3a6811efedbace61985253473
BLAKE2b-256 637ab8acd6064afc68d21463309ff8b2aa2a6ce13715c4da4186f30ca0b16aab

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page