gtsimulation.interaction#
Particle interaction models.
This subpackage provides implementations of physical processes describing particle interactions with matter, including nuclear interactions, radiation losses, and photon emission.
Functions
|
The function calls executable binary program that simulate decay of unstable particle and outputs information about products. |
|
The function calls executable binary program that calculate interaction of the charge particle with matter at a given path length and outputs information about secondary particles. |
|
The function calls executable binary program that calculates interaction of the charged particle with the Earth's atmosphere and outputs information about secondary (albedo) particles. |
|
|
|
Cumulatively integrate y(x) using the composite trapezoidal rule. |
|
|
|
|
|
|
|
Compute a definite integral. |
Classes
|
Geant4-backed nuclear interaction simulator with optional process restarts. |
|
Text I/O implementation using an in-memory buffer. |
|
|
|
The Transformer class is for facilitating re-using transforms without needing to re-create them. |
Exceptions
|
Warning on issues during integration. |
- class gtsimulation.interaction.NuclearInteraction(max_generations: int = 1, grammage_threshold: float = 10.0, seed: int = None, restart_limit: int = 20)[source]#
Geant4-backed nuclear interaction simulator with optional process restarts.
This class wraps a Geant4 simulation that propagates a single charged particle through a homogeneous material layer and returns the final primary particle state and the list of produced secondary particles.
The simulation is executed in an isolated
multiprocessing.Process. This makes it possible to fully reset Geant4 state by restarting the worker process when needed.Performance note: restarting the worker is mainly useful when the medium is frequently updated (e.g., many unique material compositions/densities over time). In that scenario, Geant4 internal tables may grow and recalculations for previously used (now irrelevant) materials can slow down subsequent runs, so periodic restarts can keep performance stable.
If you keep using the same material configuration for many runs, restarts are usually unnecessary; the worker can stay alive and repeated calls are significantly faster.
The target geometry is a cylinder filled with a user-defined material mixture:
Cylinder length is computed as
thickness = mass / density / 1e2[m].Cylinder radius equals its length.
The primary particle starts at (0, 0, 0) and travels along the +Z axis.
Tracking stops when the primary particle dies or reaches the cylinder boundary.
Internally, the C++ result object is converted to structured NumPy arrays with the dtypes
PRIMARY_DTYPEandSECONDARY_DTYPE.- Parameters:
max_generations (int, default=1) – Maximum number of secondary particle generations to model in the simulation.
grammage_threshold (float, default=10.) – Grammage threshold [g/cm²] above which the Geant4 subroutine is triggered. Should be set as a fraction of the expected nuclear interaction length in the material.
seed (int) – Random seed used to initialize the Geant4 simulator inside the worker process.
restart_limit (int, default=20) – Number of runs after which the worker process is restarted automatically.
- run_matter_layer(pdg: int, energy: float, mass: float, density: float, element_name: list[str], element_abundance: list[float])[source]#
Simulate interaction of a charged particle with a homogeneous material layer.
- Parameters:
pdg (int) – PDG code of the primary particle.
energy (float) – Primary particle kinetic energy in MeV.
mass (float) – Traversed mass thickness in g/cm^2.
density (float) – Medium density in g/cm^3.
element_name (list of str) – Chemical element symbols (e.g.
["N", "O"]) forming the medium.element_abundance (list of float) – Mass fractions (or the fractions expected by your Geant4 material definition); the sum should be 1.
- Returns:
primary (numpy.ndarray) – Structured NumPy array of shape
(1,)with dtypePRIMARY_DTYPE. Fields:Name: strPDGcode: intMass: float, MeVCharge: intKineticEnergy: float, MeVMomentumDirection: (3,) float, unit vectorPosition: (3,) float, mLastProcess: str
secondary (numpy.ndarray) – Structured NumPy array with dtype
SECONDARY_DTYPEand shape(N,), whereNis the number of secondary particles (may be 0). Fields:Name: strPDGcode: intMass: float, MeVCharge: intKineticEnergy: float, MeVMomentumDirection: (3,) float, unit vector
Modules
11.10.2024 Функция SynchrotronEmission выполняет расчет энергий фотонов, испускаемых заряженной частицей (T_e_MeV, m, Z) за временной промежуток delta_t, движущейся в магнитном поле B под углом alpha. Фотоны испускаются вдоль направления движения частицы. INPUT delta_t - sec - временной промежуток, за который частица испускает излучение T_e_MeV - MeV - кинетическая энергия частицы B - Tesla - средняя индукция магнитного поля, в котором находится частица за delta_t alpha - radians - средний угол между магнитным полем и скоростью частицы за delta_t m - kg - масса частицы Z - units - зарядовое число частицы OUTPUT E_keV_photons - keV - ndarray - массив энергий испускаемых фотонов. |
|
Geant4 Matter Layer Simulator |
|