45std::vector<G4int>* G4ParticleHPThermalScatteringData::indexOfThermalElement =
nullptr;
46std::map<std::pair<const G4Material*, const G4Element*>,
G4int>* G4ParticleHPThermalScatteringData::dic =
nullptr;
58 element_cache =
nullptr;
59 material_cache =
nullptr;
61 if (
nullptr == names) {
63 indexOfThermalElement =
new std::vector<G4int>;
65 dic =
new std::map<std::pair<const G4Material*, const G4Element*>,
G4int>;
68 coherent =
new std::map<G4int, std::map<G4double, G4ParticleHPVector*>*>;
69 incoherent =
new std::map<G4int, std::map<G4double, G4ParticleHPVector*>*>;
70 inelastic =
new std::map<G4int, std::map<G4double, G4ParticleHPVector*>*>;
80 if (!isInitializer)
return;
82 clearCurrentXSData(coherent);
83 clearCurrentXSData(incoherent);
84 clearCurrentXSData(inelastic);
88 delete indexOfThermalElement;
91 indexOfThermalElement =
nullptr;
101 if (dic->find(std::pair<const G4Material*, const G4Element*>((
G4Material*)
nullptr, element))
103 || dic->find(std::pair<const G4Material*, const G4Element*>(material, element)) != dic->end())
116 element_cache = element;
117 material_cache = material;
123void G4ParticleHPThermalScatteringData::clearCurrentXSData(std::map<
G4int, std::map<G4double, G4ParticleHPVector*>*>* ptr)
125 if (
nullptr == ptr)
return;
126 for (
auto it = ptr->begin(); it != ptr->end(); ++it) {
129 for (
auto itt = p->begin(); itt != p->end(); ++itt) {
147 for (
auto const& it : *indexOfThermalElement) {
148 if (ie == it)
return true;
157 ed <<
"Neutron thermal scattering cannot be applied to " << aP.
GetParticleName();
159 G4Exception(
"G4ParticleHPThermalScatteringData::BuildPhysicsTable",
"hp0001",
176 std::map<G4String, G4int> co_dic;
181 for (std::size_t i = 0; i < numberOfMaterials; ++i) {
182 G4Material* material = (*theMaterialTable)[i];
184 for (
G4int j = 0; j < numberOfElements; ++j) {
186 if (names->IsThisThermalElement(material->
GetName(), element->
GetName())) {
187 G4int ts_ID_of_this_geometry;
189 if (co_dic.find(ts_ndl_name) != co_dic.cend()) {
190 ts_ID_of_this_geometry = co_dic.find(ts_ndl_name)->second;
193 ts_ID_of_this_geometry = (
G4int)co_dic.size();
194 co_dic.insert(std::pair<G4String, G4int>(ts_ndl_name, ts_ID_of_this_geometry));
197 dic->insert(std::pair<std::pair<G4Material*, const G4Element*>,
G4int>(
198 std::pair<G4Material*, const G4Element*>(material, element), ts_ID_of_this_geometry));
207 for (std::size_t i = 0; i < numberOfElements; ++i) {
208 const G4Element* element = (*theElementTable)[i];
209 if (names->IsThisThermalElement(element->
GetName())) {
210 G4int ts_ID_of_this_geometry;
211 const G4String ts_ndl_name = names->GetTS_NDL_Name(element->
GetName());
212 if (co_dic.find(ts_ndl_name) != co_dic.cend()) {
213 ts_ID_of_this_geometry = co_dic.find(ts_ndl_name)->second;
216 ts_ID_of_this_geometry = (
G4int)co_dic.size();
217 co_dic.insert(std::pair<G4String, G4int>(ts_ndl_name, ts_ID_of_this_geometry));
220 dic->insert(std::pair<std::pair<const G4Material*, const G4Element*>,
G4int>(
221 std::pair<const G4Material*, const G4Element*>((
G4Material*)
nullptr, element),
222 ts_ID_of_this_geometry));
227 G4cout <<
"##T## Neutron HP Thermal Scattering Data: Following material-element pairs and/or elements "
228 "are registered for " << dic->size() <<
" materials." <<
G4endl;
230 if (dic->empty())
return;
232 for (
const auto& it : *dic) {
233 if (it.first.first !=
nullptr) {
234 G4cout <<
" Material " << it.first.first->GetName() <<
" - Element "
235 << it.first.second->GetName() <<
", internal thermal scattering id " << it.second
239 G4cout <<
" Element " << it.first.second->GetName() <<
", internal thermal scattering id "
252 for (
const auto& it : co_dic) {
253 ndl_filename = it.first;
254 G4int ts_ID = it.second;
257 full_name = dirName +
"/Coherent/CrossSection/" + ndl_filename;
258 auto coh_amapTemp_EnergyCross = readData(full_name);
259 coherent->insert(std::pair<
G4int, std::map<G4double, G4ParticleHPVector*>*>(
260 ts_ID, coh_amapTemp_EnergyCross));
263 full_name = dirName +
"/Incoherent/CrossSection/" + ndl_filename;
264 auto incoh_amapTemp_EnergyCross = readData(full_name);
265 incoherent->insert(std::pair<
G4int, std::map<G4double, G4ParticleHPVector*>*>(
266 ts_ID, incoh_amapTemp_EnergyCross));
269 full_name = dirName +
"/Inelastic/CrossSection/" + ndl_filename;
270 auto inela_amapTemp_EnergyCross = readData(full_name);
271 inelastic->insert(std::pair<
G4int, std::map<G4double, G4ParticleHPVector*>*>(
272 ts_ID, inela_amapTemp_EnergyCross));
276std::map<G4double, G4ParticleHPVector*>*
277G4ParticleHPThermalScatteringData::readData(
const G4String& full_name)
279 auto aData =
new std::map<G4double, G4ParticleHPVector*>;
281 std::istringstream theChannel;
285 while (theChannel >> dummy)
293 anEnergyCross->Init(theChannel, nData, eV, barn);
294 aData->insert(std::pair<G4double, G4ParticleHPVector*>(temp, anEnergyCross));
308 G4int ts_id = getTS_ID(aM, anE);
310 if (ts_id == -1)
return result;
314 auto u = coherent->find(ts_id);
315 G4double Xcoh = (u != coherent->end()) ? GetX(aP, aT, u->second) : 0.0;
316 auto v = incoherent->find(ts_id);
317 G4double Xincoh = (v != incoherent->end()) ? GetX(aP, aT, v->second) : 0.0;
318 auto w = inelastic->find(ts_id);
319 G4double Xinela = (w != inelastic->end()) ? GetX(aP, aT, w->second) : 0.0;
321 result = Xcoh + Xincoh + Xinela;
331 G4int ts_id = getTS_ID(aM, anE);
332 if (ts_id == -1)
return result;
334 auto ptr = inelastic->find(ts_id);
335 if (ptr != inelastic->end()) {
336 result = GetX(aP, aT, ptr->second);
346 G4int ts_id = getTS_ID(aM, anE);
347 if (ts_id == -1)
return result;
349 auto u = coherent->find(ts_id);
350 if (u != coherent->end()) { result = GetX(aP, aT, u->second); }
359 G4int ts_id = getTS_ID(aM, anE);
360 if (ts_id == -1)
return result;
362 auto u = incoherent->find(ts_id);
363 if (u != incoherent->end()) { result = GetX(aP, aT, u->second); }
367G4int G4ParticleHPThermalScatteringData::getTS_ID(
const G4Material* material,
370 auto it = dic->find(std::pair<const G4Material*, const G4Element*>((
G4Material*)
nullptr, element));
371 if (it != dic->end()) {
return it->second; }
372 auto jt = dic->find(std::pair<const G4Material*, const G4Element*>(material, element));
373 if (jt != dic->end()) {
return jt->second; }
377G4double G4ParticleHPThermalScatteringData::
379 std::map<G4double, G4ParticleHPVector*>* amapTemp_EnergyCross)
381 if (amapTemp_EnergyCross->empty())
385 auto it_begin = amapTemp_EnergyCross->begin();
387 std::size_t
n = amapTemp_EnergyCross->size();
390 if (n == 1 || aT <= Tmin) {
391 return it_begin->second->GetXsec(eKinetic);
395 auto it_end = amapTemp_EnergyCross->end();
399 return it_end->second->GetXsec(eKinetic);
408 if (aT <= TH || it == it_end)
break;
412 G4double XH = it->second->GetXsec(eKinetic);
415 if (TH == TL)
return XH;
417 G4double XL = it->second->GetXsec(eKinetic);
418 return (aT - TL) * (XH - XL) / (TH - TL) + XL;
424 names->AddThermalElement(nameG4Element, filename);
429 outFile <<
"High Precision cross data based on thermal scattering data in evaluated nuclear data "
430 "libraries for neutrons below 5eV on specific materials\n";
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
G4GLOB_DLL std::ostream G4cout
G4double GetKineticEnergy() const
static std::size_t GetNumberOfElements()
std::size_t GetIndex() const
const G4String & GetName() const
static const G4ElementTable * GetElementTable()
G4double GetTemperature() const
const G4Element * GetElement(G4int iel) const
static std::size_t GetNumberOfMaterials()
static G4MaterialTable * GetMaterialTable()
std::size_t GetNumberOfElements() const
const G4String & GetName() const
static G4Neutron * Neutron()
const G4String & GetParticleName() const
void RegisterThermalScatteringIncoherentCrossSections(std::map< G4int, std::map< G4double, G4ParticleHPVector * > * > *val)
G4int GetVerboseLevel() const
std::map< G4int, std::map< G4double, G4ParticleHPVector * > * > * GetThermalScatteringCoherentCrossSections() const
const G4String & GetNeutronHPPath() const
void RegisterThermalScatteringCoherentCrossSections(std::map< G4int, std::map< G4double, G4ParticleHPVector * > * > *val)
std::map< G4int, std::map< G4double, G4ParticleHPVector * > * > * GetThermalScatteringInelasticCrossSections() const
void GetDataStream(const G4String &, std::istringstream &iss)
static G4ParticleHPManager * GetInstance()
void RegisterThermalScatteringInelasticCrossSections(std::map< G4int, std::map< G4double, G4ParticleHPVector * > * > *val)
std::map< G4int, std::map< G4double, G4ParticleHPVector * > * > * GetThermalScatteringIncoherentCrossSections() const
G4ParticleHPThermalScatteringData()
G4double GetCrossSection(const G4DynamicParticle *, const G4Element *, const G4Material *)
G4double GetIncoherentCrossSection(const G4DynamicParticle *, const G4Element *, const G4Material *)
G4bool IsIsoApplicable(const G4DynamicParticle *, G4int, G4int, const G4Element *, const G4Material *) override
G4double GetIsoCrossSection(const G4DynamicParticle *, G4int, G4int, const G4Isotope *, const G4Element *, const G4Material *) override
void CrossSectionDescription(std::ostream &) const override
void AddUserThermalScatteringFile(const G4String &, const G4String &)
G4double GetCoherentCrossSection(const G4DynamicParticle *, const G4Element *, const G4Material *)
void DumpPhysicsTable(const G4ParticleDefinition &) override
G4double GetInelasticCrossSection(const G4DynamicParticle *, const G4Element *, const G4Material *)
void BuildPhysicsTable(const G4ParticleDefinition &) override
~G4ParticleHPThermalScatteringData() override
G4bool IsApplicable(const G4DynamicParticle *, const G4Element *)
G4VCrossSectionDataSet(const G4String &nam="")
void SetMaxKinEnergy(G4double value)
void SetMinKinEnergy(G4double value)