Runtime

ORANGE runtime execution will be described here in greater detail in the future.

Acceleration structures

Celeritas uses a bounding volume hierarchy to accelerate volume intersections. Bounding box intersections in the hierarchy use a highly optimized testing function.

template<class T>
inline bool celeritas::intersects_segment(BoundingBox<T> const &bbox, Array<T, 3> const &pos, Array<T, 3> const &dir, T distance)

Check if a line segment may intersect a bounding box.

The line segment is defined from pos in direction dir with length distance. If the position is already inside the bounding box, the result is always true.

This uses a separating-axis test (see Ericson [2004] ). It translates the coordinate system to the center of the bbox and tests six axes (see Fig. 5.23, Table 5.1 in reference):

  • the AABB face normals, and

  • the cross products between the direction vector and face normals .

Modifications have been made from the original algorithm for robustness and GPU performance.

  • Manual unrolling and unconditional evaluation of the off-axis tests lead to a 10% speedup in the along-step kernel and enable automatic vectorization when compiled with clang for aarch64.

  • A relative rather than absolute tolerance is used to support large distances.

  • Instead of using the midpoint of the line segment \( m \equiv x + d/2 - c \), we operate on the translated midpoint of the bbox \( c' \equiv c - x \) . This prevents the distance from being squared before subtraction in the cross-product directions, which can lead to machine-dependent catastrophic floating point errors for distances on the order of \( 1/\epsilon_\mathrm{machine} \) ).

Warning

Large segment lengths are allowed to support degenerate cases, but they may result in false positives (and result in slowing down a BVH search).

Tracking

There are three slightly different algorithms in ORANGE for finding the distance to the next point on a surface on an outer boundary of the volume.

  1. The “simple” algorithm is for volumes that are the intersection of a number of infinite surfaces. All convex volumes are simple, but because quadric surfaces are allowed all simple surfaces do not have to be convex. Intersecting any surface by definition causes the volume to be exited. (A single “blade” of the ATLAS EMEC accordion, a “twisted trapezoid”, has hyperbolic paraboloids on its axial faces. It is simple but not convex. The same is true for a “ring” formed by subtracting two cylinders of the same height.)

  2. The “internal surfaces” algorithm has to track through and discard any surfaces that do not result in the CSG volume changing. Crossing an internal surface is changing from one node inside the CSG tree to another.

  3. Each universe may have a single “background” volume that is selected if a point is not inside any interior volume.

Interface

ORANGE runtime routines are always invoked via the track view, which encapsulates geometry navigation for a single particle track.

class OrangeTrackView

Navigate through an ORANGE geometry on a single thread.

The direction of normal is set to always point out of the volume the track is currently in. On the boundary this is determined by the sense of the track rather than its direction.

Todo:

move_internal with a position should depend on the safety distance, but that check is not yet implemented.