Celeritas
0.5.0-56+6b053cd
|
Make a weighted random selection of an element. More...
#include <ElementSelector.hh>
Public Types | |
Type aliases | |
using | SpanReal = Span< real_type > |
using | SpanConstReal = LdgSpan< real_type const > |
Public Member Functions | |
template<class MicroXsCalc > | |
CELER_FUNCTION | ElementSelector (MaterialView const &material, MicroXsCalc &&calc_micro_xs, SpanReal micro_xs_storage) |
Construct with material, xs calculator, and storage. | |
template<class Engine > | |
CELER_FUNCTION ElementComponentId | operator() (Engine &rng) const |
Sample the element with the given RNG. More... | |
CELER_FUNCTION real_type | material_micro_xs () const |
Weighted material microscopic cross section. | |
CELER_FUNCTION SpanConstReal | elemental_micro_xs () const |
Get individual microscopic cross sections. | |
Make a weighted random selection of an element.
The element chooser is for selecting an elemental component (atom) of a material based on the microscopic cross section and the abundance fraction of the element in the material.
On construction, the element chooser uses the provided arguments to precalculate all the microscopic cross sections in the given storage space. The given function calc_micro_xs
must accept a ElementId
and return a real_type
, a non-negative microscopic cross section.
The element chooser does not calculate macroscopic cross sections because they're multiplied by fraction, not number density, and we only care about the fractional abundances and cross section weighting.
Note that the units of the calculated microscopic cross section will be identical to the units returned by calc_micro_xs
. The macroscopic cross section units (micro times mat.number_density()
) will be 1/len if and only if calc_micro units are len^2.
|
inline |
Sample the element with the given RNG.
To reduce register usage, this function starts with the cumulative sums and counts backward.