Component Manual for the Xray-Tracing Package McXtrace, version 3.9

A.3  The propagation algorithm

This section gives a conceptual outline of how Union_master actually propagates rays; see the original thesis [Ber17], written for the McStas Union components but describing the same underlying algorithm, for the full derivation and pseudocode.

Within a volume, the distance to the next scattering position is drawn from the usual exponential distribution set by the total inverse penetration depth (sum over the volume’s absorption and all its processes’ scattering contributions). If this distance is less than the distance to the volume’s boundary, a scattering event occurs there; otherwise, the ray is propagated to the boundary and the simulation continues in whichever volume lies on the other side.

Naively, determining which volume lies on the other side of a boundary would require testing every other defined volume for intersection and containment, for every propagation step – prohibitively expensive once more than a handful of volumes are involved. Instead, in the initialize section of each Union_master, the whole ensemble of volumes is analysed once to build, for every volume, the (usually small) set of other volumes that actually need an intersection test from there, and the set of volumes the ray could possibly end up in immediately after leaving through its own boundary. This turns an \(O(N)\)-per-step cost into something close to \(O(1)\) in typical geometries. Figure A.2 sketches the resulting behaviour for a simple case (illustrated for a neutron ray, but the same principle applies unchanged to McXtrace’s x-rays).


PIC


Figure A.2.: Illustration of the Union propagation algorithm for a single scattering event between two overlapping volumes. Only intersections actually relevant given the ray’s current volume are calculated at each step (the orange volume, never reachable from the ray’s actual path here, is never tested).


A.3.1  Known limitations