Skip to main content

Bindings supporting NCrystal usage in Geant4.

Project description

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.

To use the NCrystal-Geant4 bindings, one must:

  1. 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".
  2. 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 variable NCrystalGeant4_DIR to point at the src/ncrystal_geant4/cmake subdir of the cloned repo.
  3. Edit your projects CMakeLists.txt to add a find_package(NCrystalGeant4) statement, and adding the NCrystalGeant4::NCrystalGeant4 target as a dependency of the Geant4 application you are building.
  4. 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 before runManager->BeamOn(..) is called.

For an actual example using the recipes above, see the example/ folder next to this README file (or find it online at https://github.com/mctools/ncrystal-geant4/tree/HEAD/example ).

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

ncrystal_geant4-0.0.1.tar.gz (25.2 kB view details)

Uploaded Source

Built Distribution

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

ncrystal_geant4-0.0.1-py3-none-any.whl (27.7 kB view details)

Uploaded Python 3

File details

Details for the file ncrystal_geant4-0.0.1.tar.gz.

File metadata

  • Download URL: ncrystal_geant4-0.0.1.tar.gz
  • Upload date:
  • Size: 25.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for ncrystal_geant4-0.0.1.tar.gz
Algorithm Hash digest
SHA256 b94326da35585c7ea6dbe2df0a8cc45ec430bf7f78e2ad8a088ff08f2449060e
MD5 9ae04acd781630eff3e2fd5416b51225
BLAKE2b-256 44236273214dd95e97577341b4eb4e530f96619a8918485df5bf081597dbd8db

See more details on using hashes here.

File details

Details for the file ncrystal_geant4-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for ncrystal_geant4-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9da8bcfbfd386546e11e783f44f63347802acff029a13311959184efd5d99a05
MD5 e3c5ede12a8ea047115873dcace40dd1
BLAKE2b-256 e477ee61f505d780fd0719fff3de71dbc9dc8c010fc713bc915133826d107995

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