Skip to main content

Module divergence

Module divergence 

Source
Expand description

Beam divergence: the spread of incidence directions about the nominal beam direction, sampled on the per-particle random stream.

A divergence model gives each particle a deflection from the central direction: a polar angle ϑ from it and an azimuth ψ about it. The azimuth is uniform on [0, 2π) for both models, and the polar angle has:

  • Divergence::Gaussian with standard deviation σ: the two angular deviations (ϑ cos ψ, ϑ sin ψ) in orthogonal planes through the central direction are independent normal variables of mean 0 and standard deviation σ. Changing the bivariate normal density exp(-(ξ² + η²) / 2σ²) / (2π σ²) dξ dη to polar coordinates gives (1 / 2π) dψ · (ϑ / σ²) exp(-ϑ² / 2σ²) dϑ: ψ uniform and independent of ϑ, and ϑ Rayleigh distributed with CDF F(ϑ) = 1 - exp(-ϑ² / 2σ²). It is drawn by inversion, ϑ = σ sqrt(-2 ln(1 - U)). The angular deviations are treated as plane angles, which is the small-angle reading of a Gaussian divergence; a draw with ϑ > π has probability exp(-π² / 2σ²) and is still applied as a rotation by ϑ.
  • Divergence::UniformCone with half-angle α: directions uniform in solid angle inside the cone ϑ <= α. The solid-angle element is sin ϑ dϑ dψ, so F(ϑ) = (1 - cos ϑ) / (1 - cos α). Using 1 - cos x = 2 sin²(x / 2), inversion gives ϑ = 2 asin(sqrt(U) sin(α / 2)), which keeps full relative precision for small angles.

§Random numbers

Draws come from the caller’s generator, which for a transport run is the particle’s own stream crate::rng::stream(seed, index), so the result depends only on (seed, index) and not on the thread count. Each sample takes exactly two 64-bit draws, in this order: U for the polar angle, then V for the azimuth ψ = 2π V. Uniforms are the top 53 bits of a draw scaled to [0, 1), as in crate::ion::bca. Divergence::None takes no draws, so a beam without divergence leaves the stream untouched.

The deflected direction is the central direction rotated by ϑ at azimuth ψ with crate::ion::bca::kinematics::rotate; its azimuth zero is a fixed, documented frame, which is immaterial because ψ is uniform.

Enums§

Divergence
Beam divergence model.