Debian Codegraph @

ncrystal_core/src/NCSABIntegrator.cc

raw symbols SCIP
1 ////////////////////////////////////////////////////////////////////////////////cxx . . $ `<file>/ncrystal_core/src/NCSABIntegrator.cc`/
2 // //
3 // This file is part of NCrystal (see https://mctools.github.io/ncrystal/) //
4 // //
5 // Copyright 2015-2022 NCrystal developers //
6 // //
7 // Licensed under the Apache License, Version 2.0 (the "License"); //
8 // you may not use this file except in compliance with the License. //
9 // You may obtain a copy of the License at //
10 // //
11 // http://www.apache.org/licenses/LICENSE-2.0 //
12 // //
13 // Unless required by applicable law or agreed to in writing, software //
14 // distributed under the License is distributed on an "AS IS" BASIS, //
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
16 // See the License for the specific language governing permissions and //
17 // limitations under the License. //
18 // //
19 ////////////////////////////////////////////////////////////////////////////////
20
21 #include "NCrystal/internal/NCSABIntegrator.hh"cxx . . $ `<file>/ncrystal_core/include/NCrystal/internal/NCSABIntegrator.hh`/
22 #include "NCrystal/internal/NCSABSamplerModels.hh"cxx . . $ `<file>/ncrystal_core/include/NCrystal/internal/NCSABSamplerModels.hh`/
23 #include "NCrystal/internal/NCSABUtils.hh"cxx . . $ `<file>/ncrystal_core/include/NCrystal/internal/NCSABUtils.hh`/
24 #include "NCrystal/internal/NCFactoryUtils.hh"cxx . . $ `<file>/ncrystal_core/include/NCrystal/internal/NCFactoryUtils.hh`/
25 #include "NCrystal/internal/NCIter.hh"cxx . . $ `<file>/ncrystal_core/include/NCrystal/internal/NCIter.hh`/
26 #include "NCrystal/internal/NCString.hh"cxx . . $ `<file>/ncrystal_core/include/NCrystal/internal/NCString.hh`/
27 #include <iostream>
28
29 namespace NC = NCrystal;
30 namespace NS = NCrystalcxx . . $ NCrystal/::SAB;
31
32 struct NC::SABcxx . . $ NCrystal/SAB/::SABIntegratorcxx . . $ NCrystal/SAB/SABIntegrator#::Implcxx . . $ NCrystal/SAB/SABIntegrator#Impl# : private NoCopyMovecxx . . $ NCrystal/NoCopyMove# {
33
34 Implcxx . . $ NCrystal/SAB/SABIntegrator#Impl#Impl(6c74bec21d470c44).( shared_objcxx . . $ NCrystal/shared_obj#<const SABDatacxx . . $ NCrystal/SABData#>,
35 const VectDcxx . . $ NCrystal/VectD#* egrid,
36 stdcxx . . $ std/::shared_ptrcxx . . $ std/shared_ptr#<const SABExtendercxx . . $ NCrystal/SAB/SABExtender#> );
37 void doitcxx . . $ NCrystal/SAB/SABIntegrator#Impl#doit(c27fce3384be5caf).(SABXSProvidercxx . . $ NCrystal/SABXSProvider# *, SABSamplercxx . . $ NCrystal/SABSampler#*, Optionalcxx . . $ NCrystal/Optional#<stdcxx . . $ std/::stringcxx . . $ std/string#>*);
38 double determineEMaxcxx . . $ NCrystal/SAB/SABIntegrator#Impl#determineEMax(7e3a3c6b59947c6d).( const double ) const;
39 double determineEMincxx . . $ NCrystal/SAB/SABIntegrator#Impl#determineEMin(7e3a3c6b59947c6d).( const double ) const;
40 void setupEnergyGridcxx . . $ NCrystal/SAB/SABIntegrator#Impl#setupEnergyGrid(49f6e7a06ebc5aa8).();
41
42 //Input data:
43 shared_objcxx . . $ NCrystal/shared_obj#<const SABDatacxx . . $ NCrystal/SABData#> m_datacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_data.;
44 VectDcxx . . $ NCrystal/VectD# m_egridcxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_egrid.;
45 stdcxx . . $ std/::shared_ptrcxx . . $ std/shared_ptr#<const SABExtendercxx . . $ NCrystal/SAB/SABExtender#> m_extendercxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_extender.;
46
47 //Data derived from m_data:
48 stdcxx . . $ std/::shared_ptrcxx . . $ std/shared_ptr#<const SABSamplerAtE_Alg1cxx . . $ NCrystal/SAB/SABSamplerAtE_Alg1#::CommonCachecxx . . $ NCrystal/SAB/SABSamplerAtE_Alg1#CommonCache#> m_derivedDatacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_derivedData.;
49
50 //Setting;
51 SABSamplercxx . . $ NCrystal/SABSampler#::EGridMargincxx . . $ NCrystal/SABSampler#EGridMargin# m_egridMargincxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_egridMargin.;
52
53 typedef stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<SABSamplerAtEcxx . . $ NCrystal/SABSamplerAtE#> SamplerAtE_uptrcxx . . $ NCrystal/SAB/SABIntegrator#Impl#SamplerAtE_uptr#;
54 stdcxx . . $ std/::pair<SamplerAtE_uptrcxx . . $ NCrystal/SAB/SABIntegrator#Impl#SamplerAtE_uptr#,double> analyseEnergyPointcxx . . $ NCrystal/SAB/SABIntegrator#Impl#analyseEnergyPoint(90c812fbb90e6f25).(double ekin, bool doSampler ) const;
55
56 double analyseEnergyPointForXScxx . . $ NCrystal/SAB/SABIntegrator#Impl#analyseEnergyPointForXS(7e3a3c6b59947c6d).(double ekin) const
57 {
58 return analyseEnergyPointcxx . . $ NCrystal/SAB/SABIntegrator#Impl#analyseEnergyPoint(90c812fbb90e6f25).( ekin, false ).second;
59 }
60
61 };
62
63 NS::SABIntegratorcxx . . $ NCrystal/SAB/SABIntegrator#::~cxx . . $ NCrystal/SAB/SABIntegrator#`~SABIntegrator`(ced63f7c635d850d).SABIntegratorcxx . . $ NCrystal/SAB/SABIntegrator#() = default;
64
65 NS::SABIntegratorcxx . . $ NCrystal/SAB/SABIntegrator#::SABIntegratorcxx . . $ NCrystal/SAB/SABIntegrator#SABIntegrator(6c74bec21d470c44).( shared_objcxx . . $ NCrystal/shared_obj#<const SABDatacxx . . $ NCrystal/SABData#> data,
66 const VectDcxx . . $ NCrystal/VectD#* egrid,
67 stdcxx . . $ std/::shared_ptrcxx . . $ std/shared_ptr#<const SABExtendercxx . . $ NCrystal/SAB/SABExtender#> sabextender )
68 : m_implcxx . . $ NCrystal/SAB/SABIntegrator#m_impl.(stdcxx . . $ std/::move(data),egrid,stdcxx . . $ std/::move(sabextender))
69 {
70 }
71
72 void NS::SABIntegratorcxx . . $ NCrystal/SAB/SABIntegrator#::doitcxx . . $ NCrystal/SAB/SABIntegrator#doit(c27fce3384be5caf).(SABXSProvidercxx . . $ NCrystal/SABXSProvider# * out_xs, SABSamplercxx . . $ NCrystal/SABSampler#* out_sampler, Optionalcxx . . $ NCrystal/Optional#<stdcxx . . $ std/::stringcxx . . $ std/string#>* json)
73 {
74 m_implcxx . . $ NCrystal/SAB/SABIntegrator#m_impl.->cxx . . $ NCrystal/Pimpl#`operator->`(155dc7f103cdb9db).doitcxx . . $ NCrystal/SAB/SABIntegrator#Impl#doit(c27fce3384be5caf).(out_xs,out_sampler,json);
75 }
76
77 NS::SABIntegratorcxx . . $ NCrystal/SAB/SABIntegrator#::Implcxx . . $ NCrystal/SAB/SABIntegrator#Impl#::Implcxx . . $ NCrystal/SAB/SABIntegrator#Impl#Impl(6c74bec21d470c44).( shared_objcxx . . $ NCrystal/shared_obj#<const SABDatacxx . . $ NCrystal/SABData#> data,
78 const VectDcxx . . $ NCrystal/VectD#* egrid,
79 stdcxx . . $ std/::shared_ptrcxx . . $ std/shared_ptr#<const SABExtendercxx . . $ NCrystal/SAB/SABExtender#> sabextender )
80 : m_datacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_data.(stdcxx . . $ std/::move(data)),
81 m_egridcxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_egrid.((egrid&&!egrid->emptycxx . . $ std/vector#empty(3482b152b9333168).())?*cxx . . $ std/vector#vector(a1201200cf0efa42).egrid:VectDcxx . . $ std/vector#vector(49f6e7a06ebc5aa8).()),
82 m_extendercxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_extender.(!sabextender?stdcxx . . $ std/shared_ptr#shared_ptr(9ad45c7d2296bc38).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<SABFGExtendercxx . . $ NCrystal/SAB/SABFGExtender#>(m_datacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_data.->cxx . . $ NCrystal/shared_obj#`operator->`(258ee1c9e0a18a5c).temperaturecxx . . $ NCrystal/SABData#temperature(36406a9e08e0f484).(),m_datacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_data.->cxx . . $ NCrystal/shared_obj#`operator->`(258ee1c9e0a18a5c).elementMassAMUcxx . . $ NCrystal/SABData#elementMassAMU(4b88a82f62fd500a).(),m_datacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_data.->cxx . . $ NCrystal/shared_obj#`operator->`(258ee1c9e0a18a5c).boundXScxx . . $ NCrystal/SABData#boundXS(de95084053c28635).()):stdcxx . . $ std/shared_ptr#shared_ptr(e98954a1f10335bf).::move(sabextender)),
83 m_egridMargincxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_egridMargin.{ 1.05 }
84 {
85 }
86
87 namespace NCrystalcxx . . $ NCrystal/ {
88 namespacecxx . . $ NCrystal/`$anonymous_namespace_ncrystal_core/src/NCSABIntegrator.cc`/ {
89 //Derived data factory:
90 typedef stdcxx . . $ std/::pair<UniqueIDValuecxx . . $ NCrystal/UniqueIDValue#, shared_objcxx . . $ NCrystal/shared_obj#<const SABDatacxx . . $ NCrystal/SABData#>* > D2DDKeycxx . . $ NCrystal/`$anonymous_namespace_ncrystal_core/src/NCSABIntegrator.cc`/D2DDKey#;
91 typedef SABcxx . . $ NCrystal/SAB/::SABSamplerAtE_Alg1cxx . . $ NCrystal/SAB/SABSamplerAtE_Alg1#::CommonCachecxx . . $ NCrystal/SAB/SABSamplerAtE_Alg1#CommonCache# DerivedDatacxx . . $ NCrystal/`$anonymous_namespace_ncrystal_core/src/NCSABIntegrator.cc`/DerivedData#;
92 class SABData2DerivedDataFactorycxx . . $ NCrystal/`$anonymous_namespace_ncrystal_core/src/NCSABIntegrator.cc`/SABData2DerivedDataFactory# : public NC::CachedFactoryBasecxx . . $ NCrystal/CachedFactoryBase#<D2DDKeycxx . . $ NCrystal/`$anonymous_namespace_ncrystal_core/src/NCSABIntegrator.cc`/D2DDKey#,DerivedDatacxx . . $ NCrystal/`$anonymous_namespace_ncrystal_core/src/NCSABIntegrator.cc`/DerivedData#> {
93 public:
94 const char* factoryNamecxx . . $ NCrystal/`$anonymous_namespace_ncrystal_core/src/NCSABIntegrator.cc`/SABData2DerivedDataFactory#factoryName(a9f41ea0e82d88cf).() const final { return "SABData2DerivedDataFactory"; }
95 stdcxx . . $ std/::stringcxx . . $ std/string# keyToStringcxx . . $ NCrystal/`$anonymous_namespace_ncrystal_core/src/NCSABIntegrator.cc`/SABData2DerivedDataFactory#keyToString(5ff9e3fd72fc9c93).( const D2DDKeycxx . . $ NCrystal/`$anonymous_namespace_ncrystal_core/src/NCSABIntegrator.cc`/D2DDKey#& key ) const final
96 {
97 stdcxx . . $ std/::ostringstreamcxx . . $ std/ostringstream# sscxx . . $ std/__cxx11/basic_ostringstream#basic_ostringstream(49f6e7a06ebc5aa8).;
98 ss<<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7)."(SABData id="<<cxx . . $ std/basic_ostream#`operator<<`(b09cd8ec4365c7ed).key.first.valuecxx . . $ NCrystal/UniqueIDValue#value.<<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7).")";
99 return ss.strcxx . . $ std/__cxx11/basic_ostringstream#str(d33e1a6fd36255f7).();
100 }
101 protected:
102 virtual ShPtrcxx . . $ NCrystal/CachedFactoryBase#ShPtr# actualCreatecxx . . $ NCrystal/`$anonymous_namespace_ncrystal_core/src/NCSABIntegrator.cc`/SABData2DerivedDataFactory#actualCreate(f8bbdac89693d9c2).( const D2DDKeycxx . . $ NCrystal/`$anonymous_namespace_ncrystal_core/src/NCSABIntegrator.cc`/D2DDKey#& key ) const final
103 {
104 shared_objcxx . . $ NCrystal/shared_obj#<const SABDatacxx . . $ NCrystal/SABData#> data = *cxx . . $ NCrystal/shared_obj#shared_obj(47a5791c012c2b39).key.second;
105 nc_assertcxx . . $ `ncrystal_core/include/NCrystal/NCException.hh:153:11`!( !!data && data->getUniqueID()==key.first );
106
107 const auto& alphaGrid = data->cxx . . $ NCrystal/shared_obj#`operator->`(258ee1c9e0a18a5c).alphaGridcxx . . $ NCrystal/SABData#alphaGrid(413acfe4af9d1b7d).();
108 const auto& sab = data->cxx . . $ NCrystal/shared_obj#`operator->`(258ee1c9e0a18a5c).sabcxx . . $ NCrystal/SABData#sab(413acfe4af9d1b7d).();
109 const stdcxx . . $ std/::size_tcxx . . $ std/size_t# nalpha = alphaGrid.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).();
110 const stdcxx . . $ std/::size_tcxx . . $ std/size_t# nbeta = data->cxx . . $ NCrystal/shared_obj#`operator->`(258ee1c9e0a18a5c).betaGridcxx . . $ NCrystal/SABData#betaGrid(413acfe4af9d1b7d).().sizecxx . . $ std/vector#size(c9b1e749b64d5edc).();
111 const stdcxx . . $ std/::size_tcxx . . $ std/size_t# nalpham1 = nalpha-1;
112
113 //Calculate log(S) values:
114 VectDcxx . . $ NCrystal/VectD# logsabcxx . . $ std/vector#vector(49f6e7a06ebc5aa8).;
115 logsab.reservecxx . . $ std/vector#reserve(2c44cd906ae4e829).(sab.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).());
116 for (auto e: sab)
117 logsab.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).( e>0.0 ? stdcxx . . $ std/::log(e) : -kInfinitycxx . . $ NCrystal/kInfinity.);
118
119 //For each beta-idx, integrate each grid cell along alpha:
120 VectDcxx . . $ NCrystal/VectD# alphaintegrals_cumulcxx . . $ std/vector#vector(49f6e7a06ebc5aa8).;
121 alphaintegrals_cumul.resizecxx . . $ std/vector#resize(3804226c8c0acbc3).(sab.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(),0.);
122 stdcxx . . $ std/::size_tcxx . . $ std/size_t# global_idx(0);
123 for (stdcxx . . $ std/::size_tcxx . . $ std/size_t# ibeta = 0; ibeta<nbeta; ++ibeta, ++global_idx) {
124 double cumul = 0.0;
125 for (stdcxx . . $ std/::size_tcxx . . $ std/size_t# ai = 0; ai < nalpham1; ++ai, ++global_idx) {
126 auto next_idx = global_idx + 1;
127 double integ = SABUtilscxx . . $ NCrystal/SABUtils/::integrateAlphaInterval_fastcxx . . $ NCrystal/SABUtils/integrateAlphaInterval_fast(7ba2c0e50130b3d8).( vectAtcxx . . $ NCrystal/vectAt(38c24354e7825c7b).( alphaGrid, ai ), vectAtcxx . . $ NCrystal/vectAt(38c24354e7825c7b).( sab, global_idx ),
128 vectAtcxx . . $ NCrystal/vectAt(38c24354e7825c7b).( alphaGrid, ai+1 ), vectAtcxx . . $ NCrystal/vectAt(38c24354e7825c7b).( sab, next_idx ),
129 vectAtcxx . . $ NCrystal/vectAt(bc217a45c22e0a7b).( logsab, global_idx ), vectAtcxx . . $ NCrystal/vectAt(bc217a45c22e0a7b).( logsab, next_idx ) );
130 vectAtcxx . . $ NCrystal/vectAt(bc217a45c22e0a7b).( alphaintegrals_cumul, next_idx ) = (cumul += integ);
131 }
132 }
133 nc_assertcxx . . $ `ncrystal_core/include/NCrystal/NCException.hh:153:11`!(global_idx==sab.size());
134
135 //Wrap up and return:
136 return stdcxx . . $ std/::make_sharedcxx . . $ std/make_shared(ffca0f3977536948).<const DerivedDatacxx . . $ NCrystal/`$anonymous_namespace_ncrystal_core/src/NCSABIntegrator.cc`/DerivedData#>(DerivedDatacxx . . $ NCrystal/`$anonymous_namespace_ncrystal_core/src/NCSABIntegrator.cc`/DerivedData#{data,stdcxx . . $ std/::move(logsab),stdcxx . . $ std/::move(alphaintegrals_cumul)});
137 }
138 };
139 static SABData2DerivedDataFactorycxx . . $ NCrystal/`$anonymous_namespace_ncrystal_core/src/NCSABIntegrator.cc`/SABData2DerivedDataFactory# s_SABData2DerivedDataFactorycxx . . $ NCrystal/`$anonymous_namespace_ncrystal_core/src/NCSABIntegrator.cc`/s_SABData2DerivedDataFactory.;
140
141 }
142 }
143
144 double NS::SABIntegratorcxx . . $ NCrystal/SAB/SABIntegrator#::Implcxx . . $ NCrystal/SAB/SABIntegrator#Impl#::determineEMincxx . . $ NCrystal/SAB/SABIntegrator#Impl#determineEMin(7e3a3c6b59947c6d).(const double e_upp) const
145 {
146 // We want to find the energy point below which f(E)=sqrt(E)*sigma(E) essentially
147 // becomes a constant (within the given tolerance).
148 const double tolerance = 1e-3;
149 assertcxx . . $ `<external>/4398592474888995393/assert.h:50:10`!(e_upp>1e-99);
150 auto f = [this](double e) { return stdcxx . . $ std/::sqrt(e)*analyseEnergyPointForXScxx . . $ NCrystal/SAB/SABIntegrator#Impl#analyseEnergyPointForXS(7e3a3c6b59947c6d).(e); };
151 double e_old( e_upp*0.9 );
152 double f_old( f(cxx . . $ NCrystal/SAB/SABIntegrator#Impl#determineEMin(7e3a3c6b59947c6d).$anonymous_type_0#`operator()`(7e3a3c6b59947c6d).e_old) );
153 while(true) {
154 const double e_new = 0.5*e_old;
155 if (e_new <= 1e-30*e_upp)
156 return ncmincxx . . $ NCrystal/ncmin(d8e7e0733fa41c87).(e_old,e_upp*0.01);
157 const double f_new = f(cxx . . $ NCrystal/SAB/SABIntegrator#Impl#determineEMin(7e3a3c6b59947c6d).$anonymous_type_0#`operator()`(7e3a3c6b59947c6d).e_new);
158 if (f_new==0.0) {
159 stdcxx . . $ std/::coutcxx . . $ std/cout.<<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7)."NCrystal WARNING: Encountered sqrt(E)*sigma(E)=0 at E="<<cxx . . $ std/basic_ostream#`operator<<`(968942d578224538).e_new
160 <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7)." while searching for suitable Emin value at which to start SAB"
161 <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7)." energy grid. Will revert to using Emin=0.001*Emax."<<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a).stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
162 return 0.001*e_upp;
163 }
164 if ( ncabscxx . . $ NCrystal/ncabs(447c67c6676f75c3).(f_old/f_new-1.0) < tolerance )
165 return e_old;
166 e_old = e_new;
167 f_old = f_new;
168 }
169 }
170
171 double NS::SABIntegratorcxx . . $ NCrystal/SAB/SABIntegrator#::Implcxx . . $ NCrystal/SAB/SABIntegrator#Impl#::determineEMaxcxx . . $ NCrystal/SAB/SABIntegrator#Impl#determineEMax(7e3a3c6b59947c6d).(const double eUpperLimit) const
172 {
173 FreeGasXSProvidercxx . . $ NCrystal/FreeGasXSProvider# freeXScxx . . $ NCrystal/FreeGasXSProvider#FreeGasXSProvider(2c682fcb1bac57ee).( m_datacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_data.->cxx . . $ NCrystal/shared_obj#`operator->`(8e614c7de0b1573e).temperaturecxx . . $ NCrystal/SABData#temperature(36406a9e08e0f484).(),
174 m_datacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_data.->cxx . . $ NCrystal/shared_obj#`operator->`(8e614c7de0b1573e).elementMassAMUcxx . . $ NCrystal/SABData#elementMassAMU(4b88a82f62fd500a).(),
175 m_datacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_data.->cxx . . $ NCrystal/shared_obj#`operator->`(8e614c7de0b1573e).boundXScxx . . $ NCrystal/SABData#boundXS(de95084053c28635).() );
176 const double stepsize = 0.95;//NB: changing this to e.g. 0.999 might actually give less precise results! Not so simple to just change it.
177 auto xs_dist_to_freeXS = [this,&freeXS](double ekin)
178 {
179 return ncabscxx . . $ NCrystal/ncabs(447c67c6676f75c3).( this->analyseEnergyPointForXScxx . . $ NCrystal/SAB/SABIntegrator#Impl#analyseEnergyPointForXS(7e3a3c6b59947c6d).(ekin) - freeXS.crossSectioncxx . . $ NCrystal/FreeGasXSProvider#crossSection(febf336cfe5dea17).(NeutronEnergycxx . . $ NCrystal/NeutronEnergy#{ekin}).dblcxx . . $ NCrystal/EncapsulatedValue#dbl(683ba587bcaad6a5).() );
180 };
181 double prevDist = kInfinitycxx . . $ NCrystal/kInfinity.;
182 double ekin = eUpperLimit;
183 const double elow = eUpperLimit * 1e-4;//1e-4 and stepsize 0.95 ensures this
184 //fct will have at worst 180 calls to
185 //analyseEnergyPoint (but usually way
186 //less).
187 while (ekin > elow) {
188 double dist = xs_dist_to_freeXS(cxx . . $ NCrystal/SAB/SABIntegrator#Impl#determineEMax(7e3a3c6b59947c6d).$anonymous_type_1#`operator()`(7e3a3c6b59947c6d).ekin);
189 if ( dist > prevDist ) {
190 return stepsize*ekin;//extra stepsize here is safety.
191 }
192 prevDist = dist;
193 ekin *= stepsize;
194 }
195 return 0.0;
196 }
197
198 void NS::SABIntegratorcxx . . $ NCrystal/SAB/SABIntegrator#::Implcxx . . $ NCrystal/SAB/SABIntegrator#Impl#::setupEnergyGridcxx . . $ NCrystal/SAB/SABIntegrator#Impl#setupEnergyGrid(49f6e7a06ebc5aa8).()
199 {
200 //Three numbers: emin (-1 means auto), emax (-1 means auto), npts (-1 means auto).
201
202 if (m_egridcxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_egrid..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).()>3) {
203 //assume user already passed in a correct grid
204 } else {
205 if ( !m_egridcxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_egrid..emptycxx . . $ std/vector#empty(3482b152b9333168).() && m_egridcxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_egrid..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).()!=3 )
206 NCRYSTAL_THROWcxx . . $ `ncrystal_core/include/NCrystal/NCException.hh:105:9`!(BadInput,"SABIntegrator invalid energy grid. It must either be a complete array, empty, or consist of three numbers: {emin, emax, npts}");
207 double emin, emax;
208 unsigned npts;
209 if (m_egridcxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_egrid..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).()==3) {
210 emin = m_egridcxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_egrid..atcxx . . $ std/vector#at(428bb168810b9e52).(0);
211 emax = m_egridcxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_egrid..atcxx . . $ std/vector#at(428bb168810b9e52).(1);
212 double npts_fp = m_egridcxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_egrid..atcxx . . $ std/vector#at(428bb168810b9e52).(2);
213 npts = static_cast<unsigned>(npts_fp);
214 if ( npts != npts_fp )
215 NCRYSTAL_THROWcxx . . $ `ncrystal_core/include/NCrystal/NCException.hh:105:9`!(BadInput,"SABIntegrator invalid energy grid. When the array has 3 elements, the third must be an integral number representing number of points.");
216 } else {
217 emin = 0.0;
218 emax = 0.0;
219 npts = 0;
220 }
221
222 if ( !(emin>=0.0) || !(emax>=0.0) || !( emax==0.0 || emin==0.0 || emax>emin ) )
223 NCRYSTAL_THROWcxx . . $ `ncrystal_core/include/NCrystal/NCException.hh:105:9`!(BadInput,"SABIntegrator invalid energy grid. Values for emin/emax must fullfil 0<emin<emax or be 0 indicating automatic determination.");
224
225 if ( npts==0 )
226 npts = 300;
227
228 const double kT = m_datacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_data.->cxx . . $ NCrystal/shared_obj#`operator->`(258ee1c9e0a18a5c).temperaturecxx . . $ NCrystal/SABData#temperature(36406a9e08e0f484).().kTcxx . . $ NCrystal/Temperature#kT(d8440c0a87ad7443).();
229
230 if ( emax == 0.0 && m_datacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_data.->cxx . . $ NCrystal/shared_obj#`operator->`(258ee1c9e0a18a5c).suggestedEmaxcxx . . $ NCrystal/SABData#suggestedEmax(21b6c25e127938e2).() > 0.0 ) {
231 if ( emin != 0.0 && m_datacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_data.->cxx . . $ NCrystal/shared_obj#`operator->`(258ee1c9e0a18a5c).suggestedEmaxcxx . . $ NCrystal/SABData#suggestedEmax(21b6c25e127938e2).() <= emin )
232 NCRYSTAL_THROWcxx . . $ `ncrystal_core/include/NCrystal/NCException.hh:105:9`!(BadInput,"SABIntegrator invalid energy grid: When emax=0 and table has suggested Emax, the emin value specified must be less than"
233 " this (set emin=0 for automatic emin determination).");
234 emax = m_datacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_data.->cxx . . $ NCrystal/shared_obj#`operator->`(258ee1c9e0a18a5c).suggestedEmaxcxx . . $ NCrystal/SABData#suggestedEmax(21b6c25e127938e2).();
235 }
236
237 if ( emax == 0.0 ) {
238
239 //The energy associated with the kinematic curve touching (alphamax,betamin)
240 //gives us a bound on the upper energy value of the table:
241 const double bmin = m_datacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_data.->cxx . . $ NCrystal/shared_obj#`operator->`(258ee1c9e0a18a5c).betaGridcxx . . $ NCrystal/SABData#betaGrid(413acfe4af9d1b7d).().frontcxx . . $ std/vector#front(af0004c3ce7cab93).();
242 const double amax = m_datacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_data.->cxx . . $ NCrystal/shared_obj#`operator->`(258ee1c9e0a18a5c).alphaGridcxx . . $ NCrystal/SABData#alphaGrid(413acfe4af9d1b7d).().backcxx . . $ std/vector#back(af0004c3ce7cab93).();
243 const double emax_upper_limit = kT*(bmin-amax)*(bmin-amax)/(4*amax);
244 //Try to determine suitable EMax, using very simple algorithm:
245 emax = determineEMaxcxx . . $ NCrystal/SAB/SABIntegrator#Impl#determineEMax(7e3a3c6b59947c6d).(emax_upper_limit);
246 if ( !(emax>0.0) ) {
247 emax = 0.5 * emax_upper_limit;
248 stdcxx . . $ std/::coutcxx . . $ std/cout.<<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "NCrystal WARNING: Algorithm searching for suitable Emax value at which to end SAB"
249 <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " energy grid failed to provide reasonable result. Using crude guess of "
250 <<cxx . . $ std/basic_ostream#`operator<<`(968942d578224538). emax<<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7)."eV. It might be necessary to specify a more suitable value directly"
251 <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " (e.g. using the \"egrid\" keyword in .ncmat files). Consider sharing your"
252 <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " input data with NCrystal developers for further debugging." <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a).stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
253 }
254 }
255
256 if ( emin == 0.0 ) {
257 emin = determineEMincxx . . $ NCrystal/SAB/SABIntegrator#Impl#determineEMin(7e3a3c6b59947c6d).( ncmincxx . . $ NCrystal/ncmin(d8e7e0733fa41c87).(emax*0.01,0.01*kT) );
258 } else {
259 if ( !(emax>emin) )
260 NCRYSTAL_THROWcxx . . $ `ncrystal_core/include/NCrystal/NCException.hh:105:9`!(BadInput,"energy grid does not have emax>emin. Please correct input (possibly by removing hardcoded value of emin).");
261 }
262 nc_assert_alwayscxx . . $ `ncrystal_core/include/NCrystal/NCException.hh:146:9`!(emin>0.0);
263 nc_assert_alwayscxx . . $ `ncrystal_core/include/NCrystal/NCException.hh:146:9`!(emax>emin);
264 nc_assert_alwayscxx . . $ `ncrystal_core/include/NCrystal/NCException.hh:146:9`!(npts>=2);
265 m_egridcxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_egrid. =cxx . . $ std/vector#`operator=`(1104576815caab1a). NC::geomspacecxx . . $ NCrystal/geomspace(f3436739aeb888dd).(emin,emax,npts);
266 }
267
268 if ( m_egridcxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_egrid..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).() < 10 )
269 NCRYSTAL_THROWcxx . . $ `ncrystal_core/include/NCrystal/NCException.hh:105:9`!(BadInput,"SABIntegrator invalid energy grid - must have at least 10 points.");
270
271 if ( !(m_egridcxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_egrid..frontcxx . . $ std/vector#front(6baabfa6fc7b3a8e).()>0.0) || !nc_is_gridcxx . . $ NCrystal/nc_is_grid(aba1006a5da9eb1f).(m_egridcxx . . $ NCrystal/Span#Span(8b3abe35da20f8da).) )
272 NCRYSTAL_THROWcxx . . $ `ncrystal_core/include/NCrystal/NCException.hh:105:9`!(BadInput,"SABIntegrator invalid energy grid - must be sorted with non-repeated and positive values.");
273
274 }
275
276 void NS::SABIntegratorcxx . . $ NCrystal/SAB/SABIntegrator#::Implcxx . . $ NCrystal/SAB/SABIntegrator#Impl#::doitcxx . . $ NCrystal/SAB/SABIntegrator#Impl#doit(c27fce3384be5caf).(SABXSProvidercxx . . $ NCrystal/SABXSProvider# * out_xs, SABSamplercxx . . $ NCrystal/SABSampler#* out_sampler, Optionalcxx . . $ NCrystal/Optional#<stdcxx . . $ std/::stringcxx . . $ std/string#>* json)
277 {
278 nc_assert_alwayscxx . . $ `ncrystal_core/include/NCrystal/NCException.hh:146:9`!( out_xs || out_sampler );
279 if ( !m_derivedDatacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_derivedData. )
280 m_derivedDatacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_derivedData. =cxx . . $ std/shared_ptr#`operator=`(3501e79a789ff953). s_SABData2DerivedDataFactorycxx . . $ NCrystal/`$anonymous_namespace_ncrystal_core/src/NCSABIntegrator.cc`/s_SABData2DerivedDataFactory..createcxx . . $ NCrystal/CachedFactoryBase#create(552d25b19bfd9357).(D2DDKeycxx . . $ NCrystal/`$anonymous_namespace_ncrystal_core/src/NCSABIntegrator.cc`/D2DDKey#(m_datacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_data.->cxx . . $ NCrystal/shared_obj#`operator->`(258ee1c9e0a18a5c).getUniqueIDcxx . . $ NCrystal/UniqueID#getUniqueID(b3cb25941449869).(),&m_datacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_data.));
281
282 const bool doSampler = out_sampler!=nullptr;
283
284 //Prepare and validate energy grid:
285 setupEnergyGridcxx . . $ NCrystal/SAB/SABIntegrator#Impl#setupEnergyGrid(49f6e7a06ebc5aa8).();
286
287 stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<SABSamplerAtEcxx . . $ NCrystal/SABSamplerAtE#>> energyPointSamplerscxx . . $ std/vector#vector(49f6e7a06ebc5aa8).;
288 if ( doSampler )
289 energyPointSamplers.reservecxx . . $ std/vector#reserve(2c44cd906ae4e829).(m_egridcxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_egrid..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).());
290 VectDcxx . . $ NCrystal/VectD# xsvalscxx . . $ std/vector#vector(49f6e7a06ebc5aa8).;
291 xsvals.reservecxx . . $ std/vector#reserve(2c44cd906ae4e829).(m_egridcxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_egrid..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).());
292
293 for (const auto& energy : m_egridcxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_egrid. ) {
294 nc_assertcxx . . $ `ncrystal_core/include/NCrystal/NCException.hh:153:11`!(energy>0.0);
295 auto sampleruptr_and_xs = analyseEnergyPointcxx . . $ NCrystal/SAB/SABIntegrator#Impl#analyseEnergyPoint(90c812fbb90e6f25).(energy, doSampler );
296 if ( doSampler )
297 energyPointSamplers.emplace_backcxx . . $ std/vector#emplace_back(a1bcdfdabc3a37df).(stdcxx . . $ std/::move(sampleruptr_and_xs.first));
298 xsvals.emplace_backcxx . . $ std/vector#emplace_back(a1bcdfdabc3a37df).( sampleruptr_and_xs.second );
299 }
300
301 if ( doSampler )
302 out_sampler->setDatacxx . . $ NCrystal/SABSampler#setData(96d546e9615a11a4).( m_datacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_data.->cxx . . $ NCrystal/shared_obj#`operator->`(258ee1c9e0a18a5c).temperaturecxx . . $ NCrystal/SABData#temperature(36406a9e08e0f484).(),
303 VectDcxx . . $ std/vector#vector(13e0640cd3842f28).(m_egridcxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_egrid..begincxx . . $ std/vector#begin(55a6de06420d4903).(),m_egridcxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_egrid..endcxx . . $ std/vector#end(55a6de06420d4903).()),
304 stdcxx . . $ std/::move(energyPointSamplers),
305 m_extendercxx . . $ std/shared_ptr#shared_ptr(159b2ef84668bf93)., xsvals.backcxx . . $ std/vector#back(6baabfa6fc7b3a8e).(), m_egridMargincxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_egridMargin. );
306 if ( out_xs )
307 out_xs->setDatacxx . . $ NCrystal/SABXSProvider#setData(eb462dee83978dc7).( VectDcxx . . $ std/vector#vector(13e0640cd3842f28).(m_egridcxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_egrid..begincxx . . $ std/vector#begin(55a6de06420d4903).(),m_egridcxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_egrid..endcxx . . $ std/vector#end(55a6de06420d4903).()),
308 stdcxx . . $ std/::move(xsvals),
309 m_extendercxx . . $ std/shared_ptr#shared_ptr(159b2ef84668bf93). );
310
311 if (json) {
312 stdcxx . . $ std/::ostringstreamcxx . . $ std/ostringstream# sscxx . . $ std/__cxx11/basic_ostringstream#basic_ostringstream(49f6e7a06ebc5aa8).;
313 {
314 stdcxx . . $ std/::ostringstreamcxx . . $ std/ostringstream# tmpcxx . . $ std/__cxx11/basic_ostringstream#basic_ostringstream(49f6e7a06ebc5aa8).;
315 tmp <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "nalpha="<<cxx . . $ std/basic_ostream#`operator<<`(b09cd8ec4365c7ed).m_datacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_data.->cxx . . $ NCrystal/shared_obj#`operator->`(258ee1c9e0a18a5c).alphaGridcxx . . $ NCrystal/SABData#alphaGrid(413acfe4af9d1b7d).().sizecxx . . $ std/vector#size(c9b1e749b64d5edc).()<<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7).";nbeta="<<cxx . . $ std/basic_ostream#`operator<<`(b09cd8ec4365c7ed).m_datacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_data.->cxx . . $ NCrystal/shared_obj#`operator->`(258ee1c9e0a18a5c).betaGridcxx . . $ NCrystal/SABData#betaGrid(413acfe4af9d1b7d).().sizecxx . . $ std/vector#size(c9b1e749b64d5edc).();
316 tmp <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). ";Emax="<<cxx . . $ NCrystal/`operator<<`(5b2d821ce67365f7).NeutronEnergycxx . . $ NCrystal/NeutronEnergy#{m_egridcxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_egrid..backcxx . . $ std/vector#back(6baabfa6fc7b3a8e).()};
317 tmp <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). ";T="<<cxx . . $ NCrystal/`operator<<`(5b2d821ce67365f7).m_datacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_data.->cxx . . $ NCrystal/shared_obj#`operator->`(258ee1c9e0a18a5c).temperaturecxx . . $ NCrystal/SABData#temperature(36406a9e08e0f484).();
318 tmp <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). ";M="<<cxx . . $ NCrystal/`operator<<`(5b2d821ce67365f7).m_datacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_data.->cxx . . $ NCrystal/shared_obj#`operator->`(258ee1c9e0a18a5c).elementMassAMUcxx . . $ NCrystal/SABData#elementMassAMU(4b88a82f62fd500a).();
319 tmp <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). ";sigma_free="<<cxx . . $ NCrystal/`operator<<`(5b2d821ce67365f7).m_datacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_data.->cxx . . $ NCrystal/shared_obj#`operator->`(258ee1c9e0a18a5c).boundXScxx . . $ NCrystal/SABData#boundXS(de95084053c28635).().freecxx . . $ NCrystal/SigmaBound#free(2809e9fb98d0f36).(m_datacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_data.->cxx . . $ NCrystal/shared_obj#`operator->`(258ee1c9e0a18a5c).elementMassAMUcxx . . $ NCrystal/SABData#elementMassAMU(4b88a82f62fd500a).());
320 streamJSONDictEntrycxx . . $ NCrystal/streamJSONDictEntry(7d107771f8da1da9).( ss, "summarystr", tmp.strcxx . . $ std/__cxx11/basic_ostringstream#str(d33e1a6fd36255f7).(), JSONDictPoscxx . . $ NCrystal/JSONDictPos#::FIRSTcxx . . $ NCrystal/JSONDictPos#FIRST. );
321 }
322 streamJSONDictEntrycxx . . $ NCrystal/streamJSONDictEntry(7d107771f8da1da9).( ss, "Emax", m_egridcxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_egrid..backcxx . . $ std/vector#back(6baabfa6fc7b3a8e).() );
323 streamJSONDictEntrycxx . . $ NCrystal/streamJSONDictEntry(7d107771f8da1da9).( ss, "Emin", m_egridcxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_egrid..frontcxx . . $ std/vector#front(6baabfa6fc7b3a8e).() );
324 streamJSONDictEntrycxx . . $ NCrystal/streamJSONDictEntry(7d107771f8da1da9).( ss, "negrid", m_egridcxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_egrid..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).() );
325 streamJSONDictEntrycxx . . $ NCrystal/streamJSONDictEntry(7d107771f8da1da9).( ss, "T", m_datacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_data.->cxx . . $ NCrystal/shared_obj#`operator->`(258ee1c9e0a18a5c).temperaturecxx . . $ NCrystal/SABData#temperature(36406a9e08e0f484).().dblcxx . . $ NCrystal/EncapsulatedValue#dbl(683ba587bcaad6a5).() );
326 streamJSONDictEntrycxx . . $ NCrystal/streamJSONDictEntry(7d107771f8da1da9).( ss, "M", m_datacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_data.->cxx . . $ NCrystal/shared_obj#`operator->`(258ee1c9e0a18a5c).elementMassAMUcxx . . $ NCrystal/SABData#elementMassAMU(4b88a82f62fd500a).().dblcxx . . $ NCrystal/EncapsulatedValue#dbl(683ba587bcaad6a5).() );
327 streamJSONDictEntrycxx . . $ NCrystal/streamJSONDictEntry(7d107771f8da1da9).( ss, "sigma_bound", m_datacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_data.->cxx . . $ NCrystal/shared_obj#`operator->`(258ee1c9e0a18a5c).boundXScxx . . $ NCrystal/SABData#boundXS(de95084053c28635).().dblcxx . . $ NCrystal/EncapsulatedValue#dbl(683ba587bcaad6a5).() );
328 streamJSONDictEntrycxx . . $ NCrystal/streamJSONDictEntry(7d107771f8da1da9).( ss, "sigma_free", m_datacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_data.->cxx . . $ NCrystal/shared_obj#`operator->`(258ee1c9e0a18a5c).boundXScxx . . $ NCrystal/SABData#boundXS(de95084053c28635).().freecxx . . $ NCrystal/SigmaBound#free(2809e9fb98d0f36).(m_datacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_data.->cxx . . $ NCrystal/shared_obj#`operator->`(258ee1c9e0a18a5c).elementMassAMUcxx . . $ NCrystal/SABData#elementMassAMU(4b88a82f62fd500a).()).dblcxx . . $ NCrystal/EncapsulatedValue#dbl(683ba587bcaad6a5).() );
329 streamJSONDictEntrycxx . . $ NCrystal/streamJSONDictEntry(7d107771f8da1da9).( ss, "nbeta", m_datacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_data.->cxx . . $ NCrystal/shared_obj#`operator->`(258ee1c9e0a18a5c).betaGridcxx . . $ NCrystal/SABData#betaGrid(413acfe4af9d1b7d).().sizecxx . . $ std/vector#size(c9b1e749b64d5edc).() );
330 streamJSONDictEntrycxx . . $ NCrystal/streamJSONDictEntry(7d107771f8da1da9).( ss, "nalpha", m_datacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_data.->cxx . . $ NCrystal/shared_obj#`operator->`(258ee1c9e0a18a5c).alphaGridcxx . . $ NCrystal/SABData#alphaGrid(413acfe4af9d1b7d).().sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(), JSONDictPoscxx . . $ NCrystal/JSONDictPos#::LASTcxx . . $ NCrystal/JSONDictPos#LAST. );
331 *json =cxx . . $ NCrystal/Optional#`operator=`(cb95957a70e0a527). ss.strcxx . . $ std/__cxx11/basic_ostringstream#str(d33e1a6fd36255f7).();
332 }
333
334 }
335
336 stdcxx . . $ std/::pair<NS::SABIntegratorcxx . . $ NCrystal/SAB/SABIntegrator#::Implcxx . . $ NCrystal/SAB/SABIntegrator#Impl#::SamplerAtE_uptrcxx . . $ NCrystal/SAB/SABIntegrator#Impl#SamplerAtE_uptr#,double> NS::SABIntegratorcxx . . $ NCrystal/SAB/SABIntegrator#::Implcxx . . $ NCrystal/SAB/SABIntegrator#Impl#::analyseEnergyPointcxx . . $ NCrystal/SAB/SABIntegrator#Impl#analyseEnergyPoint(90c812fbb90e6f25).(double ekin, bool doSampler ) const
337 {
338 nc_assert_alwayscxx . . $ `ncrystal_core/include/NCrystal/NCException.hh:146:9`!(ekin>0.0);
339
340 //At each accessible beta-value, figure out the cross-section by integrating
341 //over all allowed alpha values at that given (Ekin,beta). The allowed
342 //alpha-range will usually encompass a number of whole bins (the "middle"),
343 //and have "front" and "back" tail parts into bins just before and after the
344 //middle bins.
345 //
346 //If also setting up sampling, an SamplerAtE instance will also be prepared
347 //and returned. It is likely to change in the future, but for now we only
348 //support the SABSamplerAtE_Alg1 type, which also needs the same information
349 //and breakdown into front/middle/back parts as was used to calculate the
350 //cross section.
351
352 const auto& betaGrid = m_datacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_data.->cxx . . $ NCrystal/shared_obj#`operator->`(8e614c7de0b1573e).betaGridcxx . . $ NCrystal/SABData#betaGrid(413acfe4af9d1b7d).();
353 auto alphaGrid_span = Spancxx . . $ NCrystal/Span#<const double>(m_datacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_data.->cxx . . $ NCrystal/shared_obj#`operator->`(8e614c7de0b1573e).alphaGridcxx . . $ NCrystal/SABData#alphaGrid(413acfe4af9d1b7d).());
354 nc_assertcxx . . $ `ncrystal_core/include/NCrystal/NCException.hh:153:11`!(!!m_derivedData);
355 const VectDcxx . . $ NCrystal/VectD#& logsab = m_derivedDatacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_derivedData.->cxx . . $ std/__shared_ptr_access#`operator->`(34d6acfd341ba7ab).logsabcxx . . $ NCrystal/SAB/SABSamplerAtE_Alg1#CommonCache#logsab.;
356 const VectDcxx . . $ NCrystal/VectD#& alphaintegrals_cumul = m_derivedDatacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_derivedData.->cxx . . $ std/__shared_ptr_access#`operator->`(34d6acfd341ba7ab).alphaintegrals_cumulcxx . . $ NCrystal/SAB/SABSamplerAtE_Alg1#CommonCache#alphaintegrals_cumul.;
357
358 nc_assertcxx . . $ `ncrystal_core/include/NCrystal/NCException.hh:153:11`!(ekin>=0.);
359 const double kT = m_datacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_data.->cxx . . $ NCrystal/shared_obj#`operator->`(8e614c7de0b1573e).temperaturecxx . . $ NCrystal/SABData#temperature(36406a9e08e0f484).().kTcxx . . $ NCrystal/Temperature#kT(d8440c0a87ad7443).();
360 const double ekin_div_kT = ekin / kT;
361 double beta_lower_limit = -ekin_div_kT;
362 bool starts_at_kinematic_endpoint = true;
363 if (beta_lower_limit<betaGrid.frontcxx . . $ std/vector#front(af0004c3ce7cab93).()) {
364 //This can happen at high energies. Push up beta_lower_limit to juuuust
365 //before the first grid point, thus keeping code simple without introducing
366 //too big artifacts (calculate in three different ways and pick smallest for
367 //numerical robustness).
368 beta_lower_limit = ncmincxx . . $ NCrystal/ncmin(7678bba071383ab).( betaGrid.frontcxx . . $ std/vector#front(af0004c3ce7cab93).() - (betaGrid.atcxx . . $ std/vector#at(b61e45a10b63f40a).(1)-betaGrid.frontcxx . . $ std/vector#front(af0004c3ce7cab93).()) * 1e-6,
369 betaGrid.frontcxx . . $ std/vector#front(af0004c3ce7cab93).() - ncabscxx . . $ NCrystal/ncabs(447c67c6676f75c3).(betaGrid.frontcxx . . $ std/vector#front(af0004c3ce7cab93).())*1e-13,
370 stdcxx . . $ std/::nexttoward(betaGrid.frontcxx . . $ std/vector#front(af0004c3ce7cab93).(),beta_lower_limit) );
371 nc_assertcxx . . $ `ncrystal_core/include/NCrystal/NCException.hh:153:11`!(beta_lower_limit<betaGrid.front());
372 starts_at_kinematic_endpoint = false;
373 }
374
375 //Figure out which sab alpha-ranges are involved, i.e. intersects the
376 //kinematically accessible region (see description of activeGridRanges in
377 //NCSABUtils.hh for exactly what is extracted.:
378 stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::pair<uint16_tcxx . . $ uint16_t#,uint16_tcxx . . $ uint16_t#>> alpharangescxx . . $ std/vector#vector(49f6e7a06ebc5aa8).;
379 stdcxx . . $ std/::size_tcxx . . $ std/size_t# ibeta_low;
380 SABUtilscxx . . $ NCrystal/SABUtils/::activeGridRangescxx . . $ NCrystal/SABUtils/activeGridRanges(d309657d69ec9b76).( *cxx . . $ NCrystal/shared_obj#`operator*`(2042464fc1fea03e).m_datacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_data., ekin_div_kT, alpharanges, ibeta_low );
381
382 if ( ibeta_low >= betaGrid.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).() ) {
383 //No alpha ranges at all -> cross section is 0 here.
384 if (!doSampler)
385 return { nullptr, 0.0 };
386 return { stdcxx . . $ std/::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<SABSamplerAtE_NoScattercxx . . $ NCrystal/SAB/SABSamplerAtE_NoScatter#>(), 0.0 };
387 }
388
389 nc_assertcxx . . $ `ncrystal_core/include/NCrystal/NCException.hh:153:11`!( ibeta_low + alpharanges.size() == betaGrid.size() ) ;
390
391 if ( ibeta_low > 0 && beta_lower_limit < vectAtcxx . . $ NCrystal/vectAt(38c24354e7825c7b).(betaGrid,ibeta_low-1) ) {
392 //move up lower limit, there was apparently no kinematically accessible content further down.
393 beta_lower_limit = vectAtcxx . . $ NCrystal/vectAt(38c24354e7825c7b).(betaGrid,ibeta_low-1);
394 starts_at_kinematic_endpoint = false;
395 }
396
397 nc_assertcxx . . $ `ncrystal_core/include/NCrystal/NCException.hh:153:11`!( ibeta_low==0 || beta_lower_limit >= betaGrid.front() );
398 nc_assertcxx . . $ `ncrystal_core/include/NCrystal/NCException.hh:153:11`!( ibeta_low==0 || beta_lower_limit >= betaGrid.at(ibeta_low-1) );
399
400 //Zoom in on the kinematically allowed part of the beta grid:
401 auto relevant_betaGrid = Spancxx . . $ NCrystal/Span#Span(c7b7b5f774df06c8).<const double>(&betaGrid[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).0]+ibeta_low,&betaGrid[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).0] + betaGrid.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).());
402 nc_assertcxx . . $ `ncrystal_core/include/NCrystal/NCException.hh:153:11`!( alpharanges.size() == (std::size_t)relevant_betaGrid.size() );
403
404 //We know (when beta_lower_limit=-E/kT, otherwise it is just something we
405 //assume) that the cross sections take off from 0.0 at beta_lower_limit:
406 PairDDcxx . . $ NCrystal/PairDD# prev_betaxs(beta_lower_limit,0.);
407
408 stdcxx . . $ std/::vectorcxx . . $ std/vector#<PairDDcxx . . $ NCrystal/PairDD#> betasampler_datacxx . . $ std/vector#vector(49f6e7a06ebc5aa8).;
409 VectDcxx . . $ NCrystal/VectD# betasampler_valscxx . . $ std/vector#vector(49f6e7a06ebc5aa8).,betasampler_weightscxx . . $ std/vector#vector(49f6e7a06ebc5aa8).;
410 stdcxx . . $ std/::vectorcxx . . $ std/vector#<SABSamplerAtE_Alg1cxx . . $ NCrystal/SAB/SABSamplerAtE_Alg1#::AlphaSampleInfocxx . . $ NCrystal/SAB/SABSamplerAtE_Alg1#AlphaSampleInfo#> sampler_infoscxx . . $ std/vector#vector(49f6e7a06ebc5aa8).;
411 const stdcxx . . $ std/::size_tcxx . . $ std/size_t# nsamplervals = ( doSampler ? relevant_betaGrid.sizecxx . . $ NCrystal/Span#size(c9b1e749b64d5edc).()+1 : 0 );
412 if (doSampler) {
413 betasampler_vals.reservecxx . . $ std/vector#reserve(2c44cd906ae4e829).( nsamplervals );
414 betasampler_weights.reservecxx . . $ std/vector#reserve(2c44cd906ae4e829).( nsamplervals );
415 sampler_infos.reservecxx . . $ std/vector#reserve(2c44cd906ae4e829).(relevant_betaGrid.sizecxx . . $ NCrystal/Span#size(c9b1e749b64d5edc).());//NB: one less than betasampler_xxx vectors.
416 //first point at (beta_lower_limit,xs=0.0)
417 betasampler_vals.emplace_backcxx . . $ std/vector#emplace_back(a1bcdfdabc3a37df).( prev_betaxs.first );
418 betasampler_weights.emplace_backcxx . . $ std/vector#emplace_back(a1bcdfdabc3a37df).( prev_betaxs.second );
419 }
420
421 StableSumcxx . . $ NCrystal/StableSum# xs_total_stable;
422
423 bool next_bin_has_kinematic_endpoint = starts_at_kinematic_endpoint;
424
425 for ( auto&& beta : enumeratecxx . . $ NCrystal/enumerate(cc3b7692454c18fc).(relevant_betaGrid) ) {
426 if ( beta.valcxx . . $ NCrystal/detail/EnumIter#Entry#val. == beta_lower_limit )
427 continue;//guard against lower limit falling exactly on a grid point
428
429 nc_assertcxx . . $ `ncrystal_core/include/NCrystal/NCException.hh:153:11`!( beta.val >= beta_lower_limit );
430 nc_assertcxx . . $ `ncrystal_core/include/NCrystal/NCException.hh:153:11`!( beta.val >= -ekin_div_kT );
431 nc_assertcxx . . $ `ncrystal_core/include/NCrystal/NCException.hh:153:11`!( beta.idx < alpharanges.size() );
432 double alow,aupp;
433 stdcxx . . $ std/::tiecxx . . $ std/tie(988772b69a7ca893).(alow,aupp) =cxx . . $ std/tuple#`operator=`(18d19790a4ab438c). getAlphaLimitscxx . . $ NCrystal/getAlphaLimits(50b1a336490901e9).(ekin_div_kT, beta.valcxx . . $ NCrystal/detail/EnumIter#Entry#val.);
434
435 nc_assertcxx . . $ `ncrystal_core/include/NCrystal/NCException.hh:153:11`!( aupp >= alow );//since beta>=-E/kT this must be the case
436
437 double xs_at_this_beta = 0.0;
438 const auto rangeidxs = vectAtcxx . . $ NCrystal/vectAt(bc217a45c22e0a7b).( alpharanges, beta.idxcxx . . $ NCrystal/detail/EnumIter#Entry#idx. );
439 unsigned aidx_low(rangeidxs.first), aidx_upp(rangeidxs.second);//unpack shorts to more efficient types
440
441
442 SABUtilscxx . . $ NCrystal/SABUtils/::TailedBreakdowncxx . . $ NCrystal/SABUtils/TailedBreakdown# tb;
443 if ( aidx_upp > aidx_low && aupp > alow ) {
444 //There is non-empty range here and aupp>alow (which can fail for various
445 //reasons, including numerical ones).
446 const auto nalpha = m_datacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_data.->cxx . . $ NCrystal/shared_obj#`operator->`(8e614c7de0b1573e).alphaGridcxx . . $ NCrystal/SABData#alphaGrid(413acfe4af9d1b7d).().sizecxx . . $ std/vector#size(c9b1e749b64d5edc).();
447 auto slice_idx = nalpha*(beta.idxcxx . . $ NCrystal/detail/EnumIter#Entry#idx. + ibeta_low);
448 auto sab_slice = Spancxx . . $ NCrystal/Span#Span(c7b7b5f774df06c8).<const double>(&m_datacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_data.->cxx . . $ NCrystal/shared_obj#`operator->`(8e614c7de0b1573e).sabcxx . . $ NCrystal/SABData#sab(413acfe4af9d1b7d).()[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).0]+slice_idx,&m_datacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_data.->cxx . . $ NCrystal/shared_obj#`operator->`(8e614c7de0b1573e).sabcxx . . $ NCrystal/SABData#sab(413acfe4af9d1b7d).()[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).0]+slice_idx+nalpha);
449 auto logsab_slice = Spancxx . . $ NCrystal/Span#Span(c7b7b5f774df06c8).<const double>(&logsab[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).0]+slice_idx,&logsab[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).0]+slice_idx+nalpha);
450 auto alphaIntegrals_cumul_slice = Spancxx . . $ NCrystal/Span#Span(c7b7b5f774df06c8).<const double>(&alphaintegrals_cumul[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).0]+slice_idx,&alphaintegrals_cumul[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).0]+slice_idx+nalpha);
451 tb =cxx . . $ NCrystal/SABUtils/TailedBreakdown#`operator=`(80501390364b1371). SABUtilscxx . . $ NCrystal/SABUtils/::createTailedBreakdowncxx . . $ NCrystal/SABUtils/createTailedBreakdown(d761f71579d0a99f).( alphaGrid_span, sab_slice, logsab_slice, alphaIntegrals_cumul_slice,
452 alow, aupp, aidx_low, aidx_upp );
453 xs_at_this_beta = tb.xs_frontcxx . . $ NCrystal/SABUtils/TailedBreakdown#xs_front. + tb.xs_backcxx . . $ NCrystal/SABUtils/TailedBreakdown#xs_back. + tb.xs_middlecxx . . $ NCrystal/SABUtils/TailedBreakdown#xs_middle.;
454 } else {
455 //No cross-section here!
456 }
457
458 nc_assertcxx . . $ `ncrystal_core/include/NCrystal/NCException.hh:153:11`!(xs_at_this_beta>=0.0);
459 if (doSampler) {
460 sampler_infos.emplace_backcxx . . $ std/vector#emplace_back(a1bcdfdabc3a37df).();
461 auto& info = sampler_infos.backcxx . . $ std/vector#back(6baabfa6fc7b3a8e).();
462 if (xs_at_this_beta > 0.0) {
463 info.pt_frontcxx . . $ NCrystal/SAB/SABSamplerAtE_Alg1#AlphaSampleInfo#pt_front..alphacxx . . $ NCrystal/SAB/SABSamplerAtE_Alg1#AlphaSampleInfo#SAPoint#alpha. = tb.frontcxx . . $ NCrystal/SABUtils/TailedBreakdown#front..alphacxx . . $ NCrystal/SABUtils/TailedBreakdown#TailPoint#alpha.;
464 info.pt_frontcxx . . $ NCrystal/SAB/SABSamplerAtE_Alg1#AlphaSampleInfo#pt_front..svalcxx . . $ NCrystal/SAB/SABSamplerAtE_Alg1#AlphaSampleInfo#SAPoint#sval. = tb.frontcxx . . $ NCrystal/SABUtils/TailedBreakdown#front..svalcxx . . $ NCrystal/SABUtils/TailedBreakdown#TailPoint#sval.;
465 info.pt_frontcxx . . $ NCrystal/SAB/SABSamplerAtE_Alg1#AlphaSampleInfo#pt_front..logsvalcxx . . $ NCrystal/SAB/SABSamplerAtE_Alg1#AlphaSampleInfo#SAPoint#logsval. = tb.frontcxx . . $ NCrystal/SABUtils/TailedBreakdown#front..logsvalcxx . . $ NCrystal/SABUtils/TailedBreakdown#TailPoint#logsval.;
466 info.pt_backcxx . . $ NCrystal/SAB/SABSamplerAtE_Alg1#AlphaSampleInfo#pt_back..alphacxx . . $ NCrystal/SAB/SABSamplerAtE_Alg1#AlphaSampleInfo#SAPoint#alpha. = tb.backcxx . . $ NCrystal/SABUtils/TailedBreakdown#back..alphacxx . . $ NCrystal/SABUtils/TailedBreakdown#TailPoint#alpha.;
467 info.pt_backcxx . . $ NCrystal/SAB/SABSamplerAtE_Alg1#AlphaSampleInfo#pt_back..svalcxx . . $ NCrystal/SAB/SABSamplerAtE_Alg1#AlphaSampleInfo#SAPoint#sval. = tb.backcxx . . $ NCrystal/SABUtils/TailedBreakdown#back..svalcxx . . $ NCrystal/SABUtils/TailedBreakdown#TailPoint#sval.;
468 info.pt_backcxx . . $ NCrystal/SAB/SABSamplerAtE_Alg1#AlphaSampleInfo#pt_back..logsvalcxx . . $ NCrystal/SAB/SABSamplerAtE_Alg1#AlphaSampleInfo#SAPoint#logsval. = tb.backcxx . . $ NCrystal/SABUtils/TailedBreakdown#back..logsvalcxx . . $ NCrystal/SABUtils/TailedBreakdown#TailPoint#logsval.;
469 if (tb.narrowcxx . . $ NCrystal/SABUtils/TailedBreakdown#narrow.) {
470 info.prob_frontcxx . . $ NCrystal/SAB/SABSamplerAtE_Alg1#AlphaSampleInfo#prob_front. = 1.0;
471 } else {
472 info.prob_frontcxx . . $ NCrystal/SAB/SABSamplerAtE_Alg1#AlphaSampleInfo#prob_front. = tb.xs_frontcxx . . $ NCrystal/SABUtils/TailedBreakdown#xs_front./xs_at_this_beta;
473 info.prob_notbackcxx . . $ NCrystal/SAB/SABSamplerAtE_Alg1#AlphaSampleInfo#prob_notback. = 1.0 - tb.xs_backcxx . . $ NCrystal/SABUtils/TailedBreakdown#xs_back./xs_at_this_beta;
474 info.pt_frontcxx . . $ NCrystal/SAB/SABSamplerAtE_Alg1#AlphaSampleInfo#pt_front..alpha_idxcxx . . $ NCrystal/SAB/SABSamplerAtE_Alg1#AlphaSampleInfo#SAPoint#alpha_idx. = tb.imiddle_lowcxx . . $ NCrystal/SABUtils/TailedBreakdown#imiddle_low.;
475 info.pt_backcxx . . $ NCrystal/SAB/SABSamplerAtE_Alg1#AlphaSampleInfo#pt_back..alpha_idxcxx . . $ NCrystal/SAB/SABSamplerAtE_Alg1#AlphaSampleInfo#SAPoint#alpha_idx. = tb.imiddle_uppcxx . . $ NCrystal/SABUtils/TailedBreakdown#imiddle_upp.;
476 }
477 } else {
478 nc_assertcxx . . $ `ncrystal_core/include/NCrystal/NCException.hh:153:11`!(xs_at_this_beta == 0.0);
479 //0 cross-section. For interpolation purposes we fall-back to sampling
480 //linearly in allowed alpha range (indicated by special value info.prob_front=2.0)
481 info.prob_frontcxx . . $ NCrystal/SAB/SABSamplerAtE_Alg1#AlphaSampleInfo#prob_front. = 2.0;
482 info.pt_frontcxx . . $ NCrystal/SAB/SABSamplerAtE_Alg1#AlphaSampleInfo#pt_front..alphacxx . . $ NCrystal/SAB/SABSamplerAtE_Alg1#AlphaSampleInfo#SAPoint#alpha. = alow;
483 info.pt_backcxx . . $ NCrystal/SAB/SABSamplerAtE_Alg1#AlphaSampleInfo#pt_back..alphacxx . . $ NCrystal/SAB/SABSamplerAtE_Alg1#AlphaSampleInfo#SAPoint#alpha. = aupp;
484 }
485 }
486
487 if ( next_bin_has_kinematic_endpoint ) {
488 //The piece-wise-linear assumption is too crude in the first bin, we want to
489 //use a sqrt(x) shape instead. It just so happen that this increases the
490 //integral of the first bin by a factor of 4/3, which can be accommodated
491 //(faked!) in the piece-wise-linear machinary by moving the first beta value
492 //downwards by 1/3 of the first bin width. The only issue is that when
493 //sampling, we should resample values in the first bin according to the
494 //sqrt(x) shape, which is a piece of information we need to pass on to the
495 //SABSamplerAtE_Alg1 instance.
496 next_bin_has_kinematic_endpoint = false;
497 double db_real = (beta.valcxx . . $ NCrystal/detail/EnumIter#Entry#val. - prev_betaxs.first);
498 prev_betaxs.first -= db_real * (1.0 / 3.0);
499 if ( doSampler ) {
500 nc_assertcxx . . $ `ncrystal_core/include/NCrystal/NCException.hh:153:11`!( betasampler_vals.size() == 1 );
501 betasampler_vals.frontcxx . . $ std/vector#front(6baabfa6fc7b3a8e).() = prev_betaxs.first;
502 }
503 }
504
505 //integrate trapezoidally from (beta,xs) = prev_betaxs
506 xs_total_stable.addcxx . . $ NCrystal/StableSum#add(ba8836b59fb42830).(0.5 * ( beta.valcxx . . $ NCrystal/detail/EnumIter#Entry#val. - prev_betaxs.first ) * ( xs_at_this_beta + prev_betaxs.second ));
507
508 prev_betaxs = { beta.valcxx . . $ NCrystal/detail/EnumIter#Entry#val., xs_at_this_beta };
509 if (doSampler) {
510 betasampler_vals.emplace_backcxx . . $ std/vector#emplace_back(a1bcdfdabc3a37df).( prev_betaxs.first );
511 betasampler_weights.emplace_backcxx . . $ std/vector#emplace_back(a1bcdfdabc3a37df).( prev_betaxs.second );
512 }
513 }
514
515 nc_assertcxx . . $ `ncrystal_core/include/NCrystal/NCException.hh:153:11`!( betasampler_vals.size() == nsamplervals );
516 nc_assertcxx . . $ `ncrystal_core/include/NCrystal/NCException.hh:153:11`!( betasampler_weights.size() == nsamplervals );
517 nc_assertcxx . . $ `ncrystal_core/include/NCrystal/NCException.hh:153:11`!( !doSampler || sampler_infos.size()+1 == nsamplervals );
518
519 //Apply factor C/E, with C=boundXS*kT/4 (cf. eq. 4 in sampling paper):
520 double xs_total = xs_total_stable.sumcxx . . $ NCrystal/StableSum#sum(21b6c25e127938e2).() * m_datacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_data.->cxx . . $ NCrystal/shared_obj#`operator->`(8e614c7de0b1573e).boundXScxx . . $ NCrystal/SABData#boundXS(de95084053c28635).().getcxx . . $ NCrystal/EncapsulatedValue#get(3e552de2bf47e10).() / (4*ekin_div_kT);
521
522 if (!(xs_total>=0.0))
523 xs_total = 0.0;
524
525 if (!doSampler)
526 return { nullptr, xs_total };
527
528 if ( xs_total == 0.0 )
529 return { stdcxx . . $ std/::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<SABSamplerAtE_NoScattercxx . . $ NCrystal/SAB/SABSamplerAtE_NoScatter#>(), xs_total };
530
531 nc_assertcxx . . $ `ncrystal_core/include/NCrystal/NCException.hh:153:11`!(!!m_derivedData);
532 SamplerAtE_uptrcxx . . $ NCrystal/SAB/SABIntegrator#Impl#SamplerAtE_uptr# up = stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<SABSamplerAtE_Alg1cxx . . $ NCrystal/SAB/SABSamplerAtE_Alg1#>( m_derivedDatacxx . . $ NCrystal/SAB/SABIntegrator#Impl#m_derivedData.,
533 stdcxx . . $ std/::move(betasampler_vals),
534 stdcxx . . $ std/::move(betasampler_weights),
535 stdcxx . . $ std/::move(sampler_infos),
536 ibeta_low,
537 ( starts_at_kinematic_endpoint ? beta_lower_limit : 1.0 ) );
538 return { stdcxx . . $ std/::move(up), xs_total };
539 }