TransportEngine
This class is the primary interface for the Monte Carlo simulation. It allows one to convert a geometric description of materials distributions to an operational Monte-Carlo simulation of photons transport.
Constructor
- class TransportEngine(*args, **kwargs)
Generates a new Monte Carlo transport engine. Optional arguments can be used to initialise the attributes described below (following lexicographic order for positional syntax).
>>> engine = goupil.TransportEngine(geometry)
Attributes
- TransportEngine.geometry: ExternalGeometry | SimpleGeometry
The geometry seen by Monte Carlo trajectories.
- TransportEngine.random: RandomStream
The pseudo-random stream utilised by the Monte Carlo engine.
- TransportEngine.registry: MaterialRegistry
The registry stores pre-computed material tables for use in Monte Carlo transport. It is populated from the
geometrydescription when thecompilemethod is called.
- TransportEngine.settings: TransportSettings
Settings that control the Monte Carlo simulation. These settings are also accessible directly from the engine for convenience, such as
>>> engine.compton_model 'Scattering Function'
Methods
- TransportEngine.compile(mode=None, *, atomic_data=None, **kwargs)
Compiles material tables based on the current engine settings. This function fills the engine’s material
registrybased on thegeometrydescription. The mode parameter determines the strategy used to construct the material tables. Available options include:"All"Compute all possible tables (not recommended for standard usage).
"Backward"Compute only tables needed for backward transport.
"Both"Compute tables needed for both forward and backward transport.
"Forward"Compute only tables needed for forward transport.
If no explicit mode is specified, then the engine will follow either the
"Backward"or"Forward"strategy, depending on the configuredmode.The optional argument atomic_data can be used to specify non-default atomic data. Additional build options can be provided as keyword arguments (kwargs). For more details, refer to the
computemethod in the MaterialRegistry.
- TransportEngine.transport(states, /, *, source_energies=None, random_index=None, vertices=None) numpy.ndarray
Performs a Monte Carlo transport of photon states, which were, e.g., initially generated using the states function. The optional source_energies argument should be used to specify the energies of volume sources, either as a
floator anumpy.ndarrayof floats, for backward mode. Upon completion, the function returns anumpy.ndarrayof integers that map the end-condition of each simulated trajectory. Please refer to TransportStatus for the precise definition of these numbers.Warning
The states array is modified in-place. This means that the final states overwrite the initial ones. If the initial values need to be conserved, then a copy of the states array must be made before calling this method.
If the random_index parameter is set to
True, thetransportmethod will also return an array containing the index of therandomstream at the start of each Monte Carlo event. Alternatively, an array of random indices (of the same size as states) can be provided to set therandomstream state for each event. This option is typically used to replay previously simulated Monte Carlo events (e.g. with additional vertices data).Similarly, if vertices is set to
True, thetransportmethod will also return an array containing the intermediate vertices of Monte Carlo steps.