![]() |
|
|||
File indexing completed on 2025-09-17 08:53:40
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/grid/RangeGridCalculator.hh 0007 //---------------------------------------------------------------------------// 0008 #pragma once 0009 0010 #include <vector> 0011 0012 #include "corecel/Assert.hh" 0013 #include "corecel/Macros.hh" 0014 #include "corecel/Types.hh" 0015 #include "corecel/data/Collection.hh" 0016 #include "corecel/grid/SplineDerivCalculator.hh" 0017 #include "corecel/grid/UniformGrid.hh" 0018 #include "corecel/grid/UniformGridData.hh" 0019 #include "celeritas/Quantities.hh" 0020 #include "celeritas/inp/Grid.hh" 0021 0022 namespace celeritas 0023 { 0024 //---------------------------------------------------------------------------// 0025 /*! 0026 * Calculate the range from the energy loss. 0027 * 0028 * The range of a particle with energy \f$ E_0 \f$ is calculated by integrating 0029 * the reciprocal of the stopping power over the energy: 0030 * \f[ 0031 R(E_0) = \int_0^{E_0} - \difd{x}{E} \dif E. 0032 * \f] 0033 * Given an energy loss grid for a single particle type and material, this 0034 * numerically integrates the range. To keep the range tables as consistent as 0035 * possible with what we've been importing from Geant4, this performs the same 0036 * calculation as in Geant4's \c G4LossTableBuilder::BuildRangeTable, which 0037 * uses the midpoint rule with 100 substeps for improved accuracy. 0038 * 0039 * The calculator is constructed with the boundary conditions for cubic spline 0040 * interpolation. If the default constructor is used, or if the number of grid 0041 * points is less than 5, linear interpolation will be used instead. 0042 * 0043 * \todo support polynomial interpolation as well? 0044 */ 0045 class RangeGridCalculator 0046 { 0047 public: 0048 //!@{ 0049 //! \name Type aliases 0050 using BC = SplineDerivCalculator::BoundaryCondition; 0051 //!@} 0052 0053 public: 0054 // Default constructor 0055 RangeGridCalculator(); 0056 0057 // Construct with boundary conditions for spline interpolation 0058 explicit RangeGridCalculator(BC); 0059 0060 // Calculate the range from the energy loss for a single material 0061 inp::UniformGrid operator()(inp::UniformGrid const&) const; 0062 0063 private: 0064 BC bc_; 0065 0066 //! Number of substeps in the numerical integration 0067 static constexpr size_type integration_substeps() { return 100; } 0068 }; 0069 0070 //---------------------------------------------------------------------------// 0071 } // namespace celeritas
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |