Back to home page

EIC code displayed by LXR

 
 

    


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

0001 //----------------------------------*-C++-*----------------------------------//
0002 // Copyright 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/data/WentzelVIMscData.hh
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include "corecel/Macros.hh"
0011 #include "corecel/cont/Array.hh"
0012 #include "corecel/data/Collection.hh"
0013 #include "celeritas/Quantities.hh"
0014 #include "celeritas/Types.hh"
0015 #include "celeritas/grid/XsGridData.hh"
0016 
0017 #include "CommonCoulombData.hh"
0018 
0019 namespace celeritas
0020 {
0021 //---------------------------------------------------------------------------//
0022 /*!
0023  * Settable parameters and default values for Wentzel VI multiple scattering.
0024  */
0025 struct WentzelVIMscParameters
0026 {
0027     using Energy = units::MevEnergy;
0028 
0029     real_type single_scattering_factor{1.25};
0030     Energy low_energy_limit{0};
0031     Energy high_energy_limit{0};
0032 
0033     //! The minimum value of the true path length limit: 1 nm
0034     static CELER_CONSTEXPR_FUNCTION real_type limit_min_fix()
0035     {
0036         return 1e-7 * units::centimeter;
0037     }
0038 };
0039 
0040 //---------------------------------------------------------------------------//
0041 /*!
0042  * Device data for Wentzel VI MSC.
0043  */
0044 template<Ownership W, MemSpace M>
0045 struct WentzelVIMscData
0046 {
0047     //// TYPES ////
0048 
0049     template<class T>
0050     using Items = Collection<T, W, M>;
0051 
0052     //// DATA ////
0053 
0054     //! Particle IDs
0055     CoulombIds ids;
0056     //! Mass of of electron in MeV
0057     units::MevMass electron_mass;
0058     //! User-assignable options
0059     WentzelVIMscParameters params;
0060     //! Scaled xs data
0061     Items<XsGridData> xs;  //!< [mat][particle]
0062 
0063     // Backend storage
0064     Items<real_type> reals;
0065 
0066     //// METHODS ////
0067 
0068     //! Check whether the data is assigned
0069     explicit CELER_FUNCTION operator bool() const
0070     {
0071         return ids && electron_mass > zero_quantity() && !xs.empty()
0072                && !reals.empty();
0073     }
0074 
0075     //! Assign from another set of data
0076     template<Ownership W2, MemSpace M2>
0077     WentzelVIMscData& operator=(WentzelVIMscData<W2, M2> const& other)
0078     {
0079         CELER_EXPECT(other);
0080         ids = other.ids;
0081         electron_mass = other.electron_mass;
0082         params = other.params;
0083         xs = other.xs;
0084         reals = other.reals;
0085         return *this;
0086     }
0087 
0088     //! Get the data location for a material + particle
0089     CELER_FUNCTION ItemId<XsGridData> at(MaterialId mat, ParticleId par) const
0090     {
0091         CELER_EXPECT(mat && par);
0092         size_type result = mat.unchecked_get() * 2;
0093         result += (par == this->ids.electron ? 0 : 1);
0094         CELER_ENSURE(result < this->xs.size());
0095         return ItemId<XsGridData>{result};
0096     }
0097 };
0098 
0099 }  // namespace celeritas