McXtrace logo

McXtrace - An X-ray ray-trace simulation package

Synchrotron SOLEIL DTU Physics

McXtrace

About McXtrace
 Publications
 Project Partners
 Project People
 Goal

Download
 Components

Documentation
 Manual
 Commands
 Wiki (GitHub)
 Tutorial

Mailing list

Links

Search

Code-repository (GitHub)

Report bugs (GitHub)


The propagation algorithm

7.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 7.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 7.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).


7.3.1  Known limitations

  • Coincident surfaces. If two volume boundaries coincide exactly, the algorithm cannot reliably determine which volume a ray enters. It is safe, and normal, to overlap volumes – but two volumes should never be placed so that a face merely touches without any overlap or gap; leaving even a micron-scale gap or overlap avoids the problem entirely.

  • No gravity. The underlying intersection algorithms are linear, so Union volumes propagate in straight lines regardless of any gravity setting elsewhere in the instrument (in practice rarely relevant for x-ray instruments).

  • Feature parity with McStas. As noted in section 7.1, loggers, absorption loggers, conditionals, surfaces (reflection/refraction) and ray-history tagging are not currently available for McXtrace’s Union components.


Last Modified: Monday, 05-Oct-2026 10:48:08 CEST
Search website mailinglist archive GitHub repos