BoxShape
This class represents a geometric shape in the form of a box. It can be used to
define a collection boundary for
forwards transported gamma-rays, or as a generation surface in the backward
case.
Constructor
- class BoxShape(size, center=None, rotation=None)
This function creates a box with specified dimensions, in cm. The size can be given as a
float(for a cube) or as a size-3 sequence of floats, indicating the width (along x, y) and height (along z) of the box. By default, the box is axis-aligned and centered on the origin. The centre argument can be used to specify an offset, in cm. Additionally, a 3x3 rotation matrix can be specified.For example, the following creates a cubic box of 1m width with a 5 cm offset along the $z$-axis
>>> shape = goupil.BoxShape( ... 1e2, # cm ... center = (0.0, 0.0, 5.0) # cm ... )
Attributes
- BoxShape.center: numpy.ndarray
The Cartesian coordinates of the box center, in cm, as a size-3
numpy.ndarray.
- BoxShape.rotation: numpy.ndarray | None
An optional 3x3 rotation matrix specifying the box orientation, if not axis-aligned.
- BoxShape.size: numpy.ndarray
The box dimensions along the x, y and z-axis (before any rotation), in cm.
Methods
- BoxShape.distance(states, /, *, reverse=None) numpy.ndarray
Returns a
numpy.ndarrayof floats that indicate the distance of Monte Carlo states to the box surface, along their respective momentum directions.By default, Monte Carlo states are assumed to propagate forwards. To trace states backwards instead, set the reverse flag to
False.
- BoxShape.inside(states, /) numpy.ndarray
Returns a
numpy.ndarrayof booleans that indicate whether the provided Monte Carlo states are inside the box or not.
- BoxShape.sample(states, /, *, engine=None, side=None, direction=None, weight=None)
Samples Monte Carlo states over the box surface. The weight boolean flag indicates wether the Monte Carlo states should be weighted by the inverse of the sampling PDF or not.
The side arguments refers to the surface side on which positions are sampled, within a numerical epsilon. Possible values are
"Inside"or"Outside".The direction arguments indicates the orientation of the sampled Monte Carlo states with respect to the box surface. Possible values are
"Ingoing"or"Outgoing". By default, Monte Carlo states are considered as ingoing.If a TransportEngine is provided (using the engine argument), then the sampling is configured based one the simulation
mode. In a a forward simulation Monte Carlo states are generated on the inside by default, while in the backward case, the outside is used.
Note
At return from the sample method, the positions
and directions of Monte Carlo states are modified in-place, along with their
weights if applicable.