pub enum Divergence {
None,
Gaussian {
sigma_rad: f64,
},
UniformCone {
half_angle_rad: f64,
},
}Expand description
Beam divergence model.
Variants§
None
No divergence: every particle gets the central direction.
Gaussian
Gaussian divergence: independent normal angular deviations with
standard deviation sigma_rad in two orthogonal planes.
UniformCone
Directions uniform in solid angle within a cone.
Implementations§
Source§impl Divergence
impl Divergence
Sourcepub fn validate(&self) -> Result<(), CrystalError>
pub fn validate(&self) -> Result<(), CrystalError>
Check the parameters.
Sourcepub fn polar_cdf(&self, theta: f64) -> f64
pub fn polar_cdf(&self, theta: f64) -> f64
Target CDF of the polar deflection ϑ (see the module docs).
Divergence::None is a point mass at 0.
Sourcepub fn sample_deflection<R: Rng + ?Sized>(&self, rng: &mut R) -> (f64, f64)
pub fn sample_deflection<R: Rng + ?Sized>(&self, rng: &mut R) -> (f64, f64)
Draw a deflection (ϑ, ψ): polar angle from the central direction
and azimuth about it, radians. Takes two draws (none for
Divergence::None); the parameters must be valid
(Self::validate).
Sourcepub fn sample_direction<R: Rng + ?Sized>(
&self,
central: [f64; 3],
rng: &mut R,
) -> [f64; 3]
pub fn sample_direction<R: Rng + ?Sized>( &self, central: [f64; 3], rng: &mut R, ) -> [f64; 3]
Deflect the unit vector central by a sampled divergence. For
Divergence::None this returns central unchanged and draws
nothing.
Trait Implementations§
Source§impl Clone for Divergence
impl Clone for Divergence
Source§fn clone(&self) -> Divergence
fn clone(&self) -> Divergence
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for Divergence
Source§impl Debug for Divergence
impl Debug for Divergence
Source§impl PartialEq for Divergence
impl PartialEq for Divergence
Source§impl Serialize for Divergence
impl Serialize for Divergence
impl StructuralPartialEq for Divergence
Auto Trait Implementations§
impl Freeze for Divergence
impl RefUnwindSafe for Divergence
impl Send for Divergence
impl Sync for Divergence
impl Unpin for Divergence
impl UnsafeUnpin for Divergence
impl UnwindSafe for Divergence
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more