Celeritas  0.5.0-86+4a8eea4
Public Member Functions | List of all members
celeritas::ElementSelector Class Reference

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.
 

Detailed Description

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.

ElementSelector select_element(mat, calc_micro, storage);
real_type total_macro_xs
= select_element.material_micro_xs() * mat.number_density();
ElementComponentId id = select_element(rng);
real_type selected_micro_xs
= select_element.elemental_micro_xs()[el.get()];
ElementView el = mat.make_element_view(id);
// use el.Z(), etc.
@ el
Elastic cross section.
OpaqueId< struct MatElementComponent > ElementComponentId
Opaque index to one elemental component datum in a particular material.
Definition: celeritas/Types.hh:71
CELER_FUNCTION ElementSelector(MaterialView const &material, MicroXsCalc &&calc_micro_xs, SpanReal micro_xs_storage)
Construct with material, xs calculator, and storage.
Definition: ElementSelector.hh:96
double real_type
Numerical type for real numbers.
Definition: corecel/Types.hh:35

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.

Todo:
Refactor to use Selector.

Member Function Documentation

◆ operator()()

template<class Engine >
CELER_FUNCTION ElementComponentId celeritas::ElementSelector::operator() ( Engine &  rng) const
inline

Sample the element with the given RNG.

To reduce register usage, this function starts with the cumulative sums and counts backward.


The documentation for this class was generated from the following file: