Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-15 08:54:39

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