ExternalGeometry
This class encapsulates an external geometry, usually implemented through the C interface. The geometry is represented as a set of sectors with a specific atomic composition, as defined by a MaterialDefinition, and a density model.
Constructor
- class ExternalGeometry(path)
Loads a Monte Carlo geometry from a shared library located at the specified path. For example, on a Linux system,
>>> geometry = goupil.ExternalGeometry("/path/to/libgeometry.so")
Warning
One must specify an absolute or explicit relative path to the geometry
library, unless it is known system wide (e.g. located under
LD_LIBRARY_PATH on a Linux system).
Attributes
Note
ExternalGeometry attributes are read-only. However, physical
properties can be edited using the update_material and update_sector methods described below.
- ExternalGeometry.lib: CDLL
This attribute provides a
ctypesrepresentation of the geometry library.
Tip
The lib attribute grants access to
user-defined functions that are embedded in the geometry library. These
functions can be used for various purposes, such as initializing Monte Carlo
states. This use case is exemplified by examples/geant4/.
- ExternalGeometry.materials: tuple[MaterialDefinition]
This attribute lists all geometry materials as a tuple.
- ExternalGeometry.sectors: tuple[GeometrySector]
This attribute lists all geometry sectors as a tuple.
Methods
- ExternalGeometry.locate(states) numpy.ndarray
Locates the specified states within the geometry. The input states must be a structured
numpy.ndarraycontaining the"position"field, e.g. as returned by thestatesfunction. Upon completion, the function returns anumpy.ndarrayof sector indices.
- ExternalGeometry.material_index(name) int
Returns the index of a material in the list of geometry
materialsbased on itsname. For instance>>> geometry.material_index("CaCO3") 1
- ExternalGeometry.sector_index(description) int
Returns the index of a sector in the list of geometry
sectorsbased on itsdescription. For instance>>> geometry.sector_index("Atmosphere") 0
- ExternalGeometry.trace(states, lengths=None, density=None) numpy.ndarray
Casts rays through the geometry, starting from the specified states. The states must be a structured
numpy.ndarraycontaining the"position"and"direction"fields, e.g. as returned by thestatesfunction. Upon completion, this function returns anumpy.ndarraycontaining the path length of rays in each geometry sector. Optionally, you can provide a lengthsnumpy.ndarrayof floats, or a single float, indicating the lengths of rays. If no lengths are specified, rays are traced until the geometry outer boundary.If the density parameter is set to
True, this function will return the column depth (grammage) along rays, in each sector, rather than the path length.
- ExternalGeometry.update_material(material, definition)
Replaces the material at the specified
intindex in the list of geometrymaterials. Alternatively, the material argument could be astrindicating thenameof the material to be replaced. The definition argument should be in line with a MaterialDefinition. For instance>>> geometry.update_material("CaCO3", "SiO2")
- ExternalGeometry.update_sector(sector, material=None, density=None)
Alters the material or density model of a sector, identified by its
intindex in the list of geometrysectors. Alternatively, the sector argument could be astrdescribing the sector to be altered. For instance>>> geometry.update_sector("Atmosphere", density=1.205E-03)