MARLEY (Model of Argon Reaction Low Energy Yields) v2.0.0
A Monte Carlo event generator for tens-of-MeV neutrino interactions
Loading...
Searching...
No Matches
marley::CachedOpticalModel Class Referenceabstract

Nuclear optical model that caches transmission coefficient calculations for efficiency. More...

#include <CachedOpticalModel.hh>

Inheritance diagram for marley::CachedOpticalModel:
marley::OpticalModel marley::KoningDelarocheOpticalModel

Classes

struct  TCKey
 

Public Member Functions

 CachedOpticalModel (int Z, int A)
 
virtual double transmission_coefficient (double total_KE_CM, int fragment_pdg, int two_j, int l, int two_s, int target_charge=0) override
 Calculate the transmission coefficient for a nuclear fragment.
 
- Public Member Functions inherited from marley::OpticalModel
 OpticalModel (int Z, int A)
 
int A () const
 Get the mass number.
 
virtual std::complex< double > optical_model_potential (double r, double fragment_KE_lab, int fragment_pdg, int two_j, int l, int two_s, int target_charge=0)=0
 Calculate the optical model potential (including the Coulomb potential)
 
virtual void print (std::ostream &out) const =0
 Print information about the optical model parameters.
 
virtual double total_cross_section (double fragment_KE_lab, int fragment_pdg, int two_s, size_t l_max, int target_charge=0)=0
 Compute the energy-averaged total cross section (MeV -2) for a nuclear fragment projectile.
 
int Z () const
 Get the atomic number.
 

Static Public Member Functions

static void set_use_cache (bool use_it)
 

Protected Member Functions

virtual double compute_transmission_coefficient (double total_KE_CM, int fragment_pdg, int two_j, int l, int two_s, int target_charge=0)=0
 Do the actual calculation of the transmission coefficient.
 

Protected Attributes

std::map< TCKey, std::shared_ptr< InterpolatingFunction > > tc_cache_
 Saved InterpolatingFunction objects corresponding to previously-encountered transmission coefficient requests.
 
- Protected Attributes inherited from marley::OpticalModel
int A_
 
int Z_
 

Static Protected Attributes

static constexpr double MAX_TOTAL_KE_CM = 100.
 Maximum kinetic energy to use when interacting with the cache.
 
static constexpr double MIN_TOTAL_KE_CM = 1e-10
 Minimum kinetic energy to use when interacting with the cache.
 
static bool USE_CACHE = true
 Boolean switch that allows global enabling/disabling of the cache, which is used by default.
 

Detailed Description

Nuclear optical model that caches transmission coefficient calculations for efficiency.

Definition at line 33 of file CachedOpticalModel.hh.

Constructor & Destructor Documentation

◆ CachedOpticalModel()

marley::CachedOpticalModel::CachedOpticalModel ( int Z,
int A )
inline
Parameters
ZAtomic number of the desired nuclide
AMass number of the desired nuclide

Definition at line 39 of file CachedOpticalModel.hh.

39: OpticalModel( Z, A ) {}
OpticalModel(int Z, int A)
int A() const
Get the mass number.
int Z() const
Get the atomic number.

References marley::OpticalModel::OpticalModel(), marley::OpticalModel::A(), and marley::OpticalModel::Z().

Referenced by marley::KoningDelarocheOpticalModel::KoningDelarocheOpticalModel().

Member Function Documentation

◆ set_use_cache()

static void marley::CachedOpticalModel::set_use_cache ( bool use_it)
inlinestatic

Definition at line 82 of file CachedOpticalModel.hh.

82 {
83 USE_CACHE = use_it;
84 }
static bool USE_CACHE
Boolean switch that allows global enabling/disabling of the cache, which is used by default.

◆ transmission_coefficient()

double marley::CachedOpticalModel::transmission_coefficient ( double total_KE_CM,
int fragment_pdg,
int two_j,
int l,
int two_s,
int target_charge = 0 )
overridevirtual

Calculate the transmission coefficient for a nuclear fragment.

Parameters
total_KE_CMTotal CM frame kinetic energy (MeV)
fragment_pdgPDG code of the fragment
two_jTwo times the total angular momentum of the fragment
lOrbital angular momentum of the fragment
two_sTwo times the spin of the fragment
target_chargeNet charge of the target atom

Implements marley::OpticalModel.

Definition at line 23 of file CachedOpticalModel.cc.

26{
27 // If we're in the region of kinetic energies where we use the cache, then
28 // check whether we've encountered this combination of quantum numbers before
29 if ( USE_CACHE && total_KE_CM >= MIN_TOTAL_KE_CM
30 && total_KE_CM <= MAX_TOTAL_KE_CM )
31 {
32 TCKey temp_key( fragment_pdg, two_j, l, two_s, target_charge );
33 const auto cache_iter = tc_cache_.find( temp_key );
34
35 // If we can find a match in the cache, evaluate the transmission
36 // coefficient value using the stored interpolating function
37 if ( cache_iter != tc_cache_.cend() ) {
38 return cache_iter->second->evaluate( total_KE_CM );
39 }
40
41 // Otherwise, create an interpolating function object over the caching
42 // kinetic energy range
43 std::function< double(double) > t_coeff = [ this, fragment_pdg, two_j,
44 l, two_s, target_charge ]( double tot_KE_CM ) -> double
45 {
46 return this->compute_transmission_coefficient( tot_KE_CM, fragment_pdg,
47 two_j, l, two_s, target_charge );
48 };
49
50 auto t_coeff_interp = std::make_shared<
51 marley::LinearInterpolatingFunction >( t_coeff, MIN_TOTAL_KE_CM,
52 MAX_TOTAL_KE_CM, marley::DEFAULT_N_LINEAR );
53
54 // Compute the interpolated transmission coefficient for the current
55 // call to this function
56 double tc_result = t_coeff_interp->evaluate( total_KE_CM );
57
58 // Add the completed interpolating function to the cache before returning
59 // the current result
60 tc_cache_[ temp_key ] = std::move( t_coeff_interp );
61 return tc_result;
62 }
63
64 // If we're outside the caching energy range, just compute the transmission
65 // coefficient without relying on the cache at all
66 return this->compute_transmission_coefficient( total_KE_CM, fragment_pdg,
67 two_j, l, two_s, target_charge );
68}
static constexpr double MIN_TOTAL_KE_CM
Minimum kinetic energy to use when interacting with the cache.
static constexpr double MAX_TOTAL_KE_CM
Maximum kinetic energy to use when interacting with the cache.
std::map< TCKey, std::shared_ptr< InterpolatingFunction > > tc_cache_
Saved InterpolatingFunction objects corresponding to previously-encountered transmission coefficient ...
virtual double compute_transmission_coefficient(double total_KE_CM, int fragment_pdg, int two_j, int l, int two_s, int target_charge=0)=0
Do the actual calculation of the transmission coefficient.

References compute_transmission_coefficient(), marley::LinearInterpolatingFunction::evaluate(), MAX_TOTAL_KE_CM, MIN_TOTAL_KE_CM, tc_cache_, and USE_CACHE.

Member Data Documentation

◆ MAX_TOTAL_KE_CM

double marley::CachedOpticalModel::MAX_TOTAL_KE_CM = 100.
staticconstexprprotected

Maximum kinetic energy to use when interacting with the cache.

Definition at line 101 of file CachedOpticalModel.hh.

Referenced by transmission_coefficient().

◆ MIN_TOTAL_KE_CM

double marley::CachedOpticalModel::MIN_TOTAL_KE_CM = 1e-10
staticconstexprprotected

Minimum kinetic energy to use when interacting with the cache.

Definition at line 99 of file CachedOpticalModel.hh.

Referenced by transmission_coefficient().

◆ tc_cache_

std::map< TCKey, std::shared_ptr< InterpolatingFunction > > marley::CachedOpticalModel::tc_cache_
protected

Saved InterpolatingFunction objects corresponding to previously-encountered transmission coefficient requests.

Definition at line 96 of file CachedOpticalModel.hh.

Referenced by transmission_coefficient().

◆ USE_CACHE

bool marley::CachedOpticalModel::USE_CACHE = true
staticprotected

Boolean switch that allows global enabling/disabling of the cache, which is used by default.

Definition at line 105 of file CachedOpticalModel.hh.

Referenced by transmission_coefficient().


The documentation for this class was generated from the following files: