Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 08:53:41

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/neutron/executor/ChipsNeutronElasticExecutor.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "corecel/Assert.hh"
0010 #include "celeritas/global/CoreTrackView.hh"
0011 #include "celeritas/mat/ElementView.hh"
0012 #include "celeritas/mat/IsotopeView.hh"
0013 #include "celeritas/neutron/data/NeutronElasticData.hh"
0014 #include "celeritas/neutron/interactor/ChipsNeutronElasticInteractor.hh"
0015 #include "celeritas/neutron/xs/NeutronElasticMicroXsCalculator.hh"
0016 #include "celeritas/phys/Interaction.hh"
0017 #include "celeritas/random/ElementSelector.hh"
0018 #include "celeritas/random/IsotopeSelector.hh"
0019 
0020 namespace celeritas
0021 {
0022 //---------------------------------------------------------------------------//
0023 struct ChipsNeutronElasticExecutor
0024 {
0025     inline CELER_FUNCTION Interaction
0026     operator()(celeritas::CoreTrackView const& track);
0027 
0028     NeutronElasticRef params;
0029 };
0030 
0031 //---------------------------------------------------------------------------//
0032 /*!
0033  * Apply the NeutronElasticInteractor to the current track.
0034  */
0035 CELER_FUNCTION Interaction
0036 ChipsNeutronElasticExecutor::operator()(CoreTrackView const& track)
0037 {
0038     auto particle = track.particle();
0039     auto const& dir = track.geometry().dir();
0040     auto rng = track.rng();
0041 
0042     // Select a target element
0043     auto material = track.material().material_record();
0044     auto elcomp_id = track.physics_step().element();
0045     if (!elcomp_id)
0046     {
0047         // Sample an element (based on element cross sections on the fly)
0048         ElementSelector select_el(
0049             material,
0050             NeutronElasticMicroXsCalculator{params, particle.energy()},
0051             track.material().element_scratch());
0052         elcomp_id = select_el(rng);
0053         CELER_ASSERT(elcomp_id);
0054         track.physics_step().element(elcomp_id);
0055     }
0056     ElementView element = material.element_record(elcomp_id);
0057 
0058     // Select a target nucleus
0059     IsotopeSelector iso_select(element);
0060     IsotopeView target = element.isotope_record(iso_select(rng));
0061 
0062     // Construct the interactor
0063     ChipsNeutronElasticInteractor interact(params, particle, dir, target);
0064 
0065     // Execute the interactor
0066     return interact(rng);
0067 }
0068 
0069 //---------------------------------------------------------------------------//
0070 }  // namespace celeritas