Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 10:31:16

0001 //----------------------------------*-C++-*----------------------------------//
0002 // Copyright 2021-2024 UT-Battelle, LLC, and other Celeritas developers.
0003 // See the top-level COPYRIGHT file for details.
0004 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0005 //---------------------------------------------------------------------------//
0006 //! \file celeritas/em/executor/LivermorePEExecutor.hh
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include "corecel/Assert.hh"
0011 #include "corecel/Macros.hh"
0012 #include "celeritas/em/data/LivermorePEData.hh"
0013 #include "celeritas/em/interactor/LivermorePEInteractor.hh"
0014 #include "celeritas/em/xs/LivermorePEMicroXsCalculator.hh"
0015 #include "celeritas/global/CoreTrackView.hh"
0016 #include "celeritas/mat/ElementSelector.hh"
0017 
0018 namespace celeritas
0019 {
0020 //---------------------------------------------------------------------------//
0021 struct LivermorePEExecutor
0022 {
0023     inline CELER_FUNCTION Interaction
0024     operator()(celeritas::CoreTrackView const& track);
0025 
0026     LivermorePERef params;
0027 };
0028 
0029 //---------------------------------------------------------------------------//
0030 /*!
0031  * Sample a Livermore photoelectric interaction from the current track.
0032  */
0033 CELER_FUNCTION Interaction
0034 LivermorePEExecutor::operator()(CoreTrackView const& track)
0035 {
0036     auto particle = track.make_particle_view();
0037     auto rng = track.make_rng_engine();
0038 
0039     // Get the element ID if an element was previously sampled
0040     auto elcomp_id = track.make_physics_step_view().element();
0041     if (!elcomp_id)
0042     {
0043         // Sample an element (calculating microscopic cross sections on the
0044         // fly) and store it
0045         auto material_track = track.make_material_view();
0046         auto material = material_track.make_material_view();
0047         ElementSelector select_el(
0048             material,
0049             LivermorePEMicroXsCalculator{params, particle.energy()},
0050             material_track.element_scratch());
0051         elcomp_id = select_el(rng);
0052         CELER_ASSERT(elcomp_id);
0053         track.make_physics_step_view().element(elcomp_id);
0054     }
0055     auto el_id = track.make_material_view().make_material_view().element_id(
0056         elcomp_id);
0057 
0058     // Set up photoelectric interactor with the selected element
0059     auto relaxation
0060         = track.make_physics_step_view().make_relaxation_helper(el_id);
0061     auto cutoffs = track.make_cutoff_view();
0062     auto const& dir = track.make_geo_view().dir();
0063     auto allocate_secondaries
0064         = track.make_physics_step_view().make_secondary_allocator();
0065     LivermorePEInteractor interact(
0066         params, relaxation, el_id, particle, cutoffs, dir, allocate_secondaries);
0067 
0068     // Sample the interaction
0069     return interact(rng);
0070 }
0071 
0072 //---------------------------------------------------------------------------//
0073 }  // namespace celeritas