ncrystal-geant4
This package faciliates the usage of low energy neutron scattering physics provided by NCrystal, in the Geant4 simulation framework. Specifically, it allows users of HP physics models, to initialise selected G4Materials based on NCrystal cfg-strings, and to let NCrystal take over the scattering physics of low energy (<5eV) neutrons in those volumes (other particles and physics will still be handled by the usual Geant4 physics list).
The current implementation assumes that the user is using one of Geant4's HP physics lists, and unfortunately does not yet support multi-threaded Geant4 simulations (UPDATE June 2025: The example_bias/ shows how to work with multi-threaded Geant4!!).
To use the NCrystal-Geant4 bindings, one must:
-
Install NCrystal and Geant4. Although it is possible to build both projects manually, it should be noted that both are available on conda-forge. If not using conda, note that NCrystal is also available on PyPI, so assuming Geant4 has already been installed in another manner, it might be possible to simply complete the setup by a
pip install NCrystal. -
Install ncrystal-geant4. This can be done by
pip install ncrystal-geant4, or alternatively by cloning the repository at https://github.com/mctools/ncrystal-geant4 and setting the CMake variableNCrystalGeant4_DIRto point at thesrc/ncrystal_geant4/cmakesubdir of the cloned repo. -
Edit your projects CMakeLists.txt to add a
find_package(NCrystalGeant4)statement, and adding theNCrystalGeant4::NCrystalGeant4target as a dependency of the Geant4 application you are building. -
Edit your C++ code and include the header file
G4NCrystal/G4NCrystal.hh. Then create NCrystal materials based on NCrystal cfg-strings like"Al_sg225.ncmat;temp=80K"using code such as:G4Material * myMat = G4NCrystal::createMaterial("Al_sg225.ncmat;temp=80K");Finally, one must inject the NCrystal physics process into the physics list by placing a statement like:
G4NCrystal::install();Crucially, such a statement must be placed after
runManager->Initialize()and beforerunManager->BeamOn(..)is called.Alternatively, inject NCrystal physics via the Geant4 biasing framework. See the example in the
example_bias/folder next to this README file (or find it online at https://github.com/mctools/ncrystal-geant4/tree/HEAD/example_bias )
For actual examples using the recipes above, see the example/ and
example_bias folders next to this README file (or find them online at
https://github.com/mctools/ncrystal-geant4/tree/HEAD/example and
https://github.com/mctools/ncrystal-geant4/tree/HEAD/example_bias ).
Metadata
Release files for ncrystal-geant4 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ncrystal_geant4-0.1.0.tar.gz | 28.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ncrystal_geant4-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 60.5 kB
Release files / ncrystal_geant4-0.1.0.tar.gz
| Download URL | ncrystal_geant4-0.1.0.tar.gz |
|---|---|
| Size | 28.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
91c9990adcda405bbfad42144ea2a6ef02f1a560da5ac9437574850efa723b04
|
|
BLAKE2b-256 checksum How to use checksums |
6550874b6c1cabbe2fd20588dbb015330474c4d4bb425d3e082b33b82178f79d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 18, 2025.
Transparency logRelease files / ncrystal_geant4-0.1.0-py3-none-any.whl
| Download URL | ncrystal_geant4-0.1.0-py3-none-any.whl |
|---|---|
| Size | 31.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
88d96b4233ef05708b902d16181b9b56e86549bf192c0604dc2c918af612c218
|
|
BLAKE2b-256 checksum How to use checksums |
101b80ac86531b707cba14765fbe84f168aa5acbd57b51daa9d6c21da6327f86
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 18, 2025.
Transparency log