65 element_cache =
nullptr;
66 material_cache =
nullptr;
68 indexOfThermalElement.clear();
90 if (dic.find(std::pair<const G4Material*, const G4Element*>((
G4Material*)
nullptr, element))
92 || dic.find(std::pair<const G4Material*, const G4Element*>(material, element)) != dic.end())
105 element_cache = element;
106 material_cache = material;
112void G4ParticleHPThermalScatteringData::clearCurrentXSData()
114 if (coherent !=
nullptr) {
115 for (
auto it = coherent->cbegin(); it != coherent->cend(); ++it) {
116 if (it->second !=
nullptr) {
117 for (
auto itt = it->second->cbegin(); itt != it->second->cend(); ++itt) {
126 if (incoherent !=
nullptr) {
127 for (
auto it = incoherent->cbegin(); it != incoherent->cend(); ++it) {
128 if (it->second !=
nullptr) {
129 for (
auto itt = it->second->cbegin(); itt != it->second->cend(); ++itt) {
138 if (inelastic !=
nullptr) {
139 for (
auto it = inelastic->cbegin(); it != inelastic->cend(); ++it) {
140 if (it->second !=
nullptr) {
141 for (
auto itt = it->second->cbegin(); itt != it->second->cend(); ++itt) {
163 for (
int it : indexOfThermalElement) {
164 if (ie == it)
return true;
176 "Attempt to use NeutronHP data for particles other than neutrons!!!");
183 std::map<G4String, G4int> co_dic;
189 for (std::size_t i = 0; i < numberOfMaterials; ++i) {
190 G4Material* material = (*theMaterialTable)[i];
192 for (
G4int j = 0; j < numberOfElements; ++j) {
195 G4int ts_ID_of_this_geometry;
197 if (co_dic.find(ts_ndl_name) != co_dic.cend()) {
198 ts_ID_of_this_geometry = co_dic.find(ts_ndl_name)->second;
201 ts_ID_of_this_geometry = (
G4int)co_dic.size();
202 co_dic.insert(std::pair<G4String, G4int>(ts_ndl_name, ts_ID_of_this_geometry));
205 dic.insert(std::pair<std::pair<G4Material*, const G4Element*>,
G4int>(
206 std::pair<G4Material*, const G4Element*>(material, element), ts_ID_of_this_geometry));
216 for (std::size_t i = 0; i < numberOfElements; ++i) {
217 const G4Element* element = (*theElementTable)[i];
220 G4int ts_ID_of_this_geometry;
222 if (co_dic.find(ts_ndl_name) != co_dic.cend()) {
223 ts_ID_of_this_geometry = co_dic.find(ts_ndl_name)->second;
226 ts_ID_of_this_geometry = (
G4int)co_dic.size();
227 co_dic.insert(std::pair<G4String, G4int>(ts_ndl_name, ts_ID_of_this_geometry));
230 dic.insert(std::pair<std::pair<const G4Material*, const G4Element*>,
G4int>(
231 std::pair<const G4Material*, const G4Element*>((
G4Material*)
nullptr, element),
232 ts_ID_of_this_geometry));
238 G4cout <<
"Neutron HP Thermal Scattering Data: Following material-element pairs and/or elements "
241 for (
const auto& it : dic) {
242 if (it.first.first !=
nullptr) {
243 G4cout <<
"Material " << it.first.first->GetName() <<
" - Element "
244 << it.first.second->GetName() <<
", internal thermal scattering id " << it.second
248 G4cout <<
"Element " << it.first.second->GetName() <<
", internal thermal scattering id "
261 if (coherent ==
nullptr)
262 coherent =
new std::map<G4int, std::map<G4double, G4ParticleHPVector*>*>;
263 if (incoherent ==
nullptr)
264 incoherent =
new std::map<G4int, std::map<G4double, G4ParticleHPVector*>*>;
265 if (inelastic ==
nullptr)
266 inelastic =
new std::map<G4int, std::map<G4double, G4ParticleHPVector*>*>;
274 "Please setenv G4NEUTRONHPDATA to point to the neutron cross-section files.");
277 dirName = baseName +
"/ThermalScattering";
282 for (
const auto& it : co_dic) {
283 ndl_filename = it.first;
284 G4int ts_ID = it.second;
287 full_name = dirName +
"/Coherent/CrossSection/" + ndl_filename;
288 auto coh_amapTemp_EnergyCross = readData(full_name);
289 coherent->insert(std::pair<
G4int, std::map<G4double, G4ParticleHPVector*>*>(
290 ts_ID, coh_amapTemp_EnergyCross));
293 full_name = dirName +
"/Incoherent/CrossSection/" + ndl_filename;
294 auto incoh_amapTemp_EnergyCross = readData(full_name);
295 incoherent->insert(std::pair<
G4int, std::map<G4double, G4ParticleHPVector*>*>(
296 ts_ID, incoh_amapTemp_EnergyCross));
299 full_name = dirName +
"/Inelastic/CrossSection/" + ndl_filename;
300 auto inela_amapTemp_EnergyCross = readData(full_name);
301 inelastic->insert(std::pair<
G4int, std::map<G4double, G4ParticleHPVector*>*>(
302 ts_ID, inela_amapTemp_EnergyCross));
310std::map<G4double, G4ParticleHPVector*>*
311G4ParticleHPThermalScatteringData::readData(
G4String full_name)
313 auto aData =
new std::map<G4double, G4ParticleHPVector*>;
315 std::istringstream theChannel;
319 while (theChannel >> dummy)
327 anEnergyCross->
Init(theChannel, nData, eV, barn);
328 aData->insert(std::pair<G4double, G4ParticleHPVector*>(temp, anEnergyCross));
338 "Attempt to use NeutronHP data for particles other than neutrons!!!");
347 G4int ts_id = getTS_ID(aM, anE);
349 if (ts_id == -1)
return result;
353 G4double Xcoh = GetX(aP, aT, coherent->find(ts_id)->second);
354 G4double Xincoh = GetX(aP, aT, incoherent->find(ts_id)->second);
355 G4double Xinela = GetX(aP, aT, inelastic->find(ts_id)->second);
357 result = Xcoh + Xincoh + Xinela;
367 G4int ts_id = getTS_ID(aM, anE);
369 result = GetX(aP, aT, inelastic->find(ts_id)->second);
378 G4int ts_id = getTS_ID(aM, anE);
380 result = GetX(aP, aT, coherent->find(ts_id)->second);
389 G4int ts_id = getTS_ID(aM, anE);
391 result = GetX(aP, aT, incoherent->find(ts_id)->second);
395G4int G4ParticleHPThermalScatteringData::getTS_ID(
const G4Material* material,
399 if (dic.find(std::pair<const G4Material*, const G4Element*>((
G4Material*)
nullptr, element))
401 return dic.find(std::pair<const G4Material*, const G4Element*>((
G4Material*)
nullptr, element))
403 if (dic.find(std::pair<const G4Material*, const G4Element*>(material, element)) != dic.end())
404 return dic.find(std::pair<const G4Material*, const G4Element*>(material, element))->second;
408G4double G4ParticleHPThermalScatteringData::GetX(
410 std::map<G4double, G4ParticleHPVector*>* amapTemp_EnergyCross)
413 if (amapTemp_EnergyCross->empty())
return result;
417 if (amapTemp_EnergyCross->size() == 1) {
418 if (std::fabs(aT - amapTemp_EnergyCross->cbegin()->first) / amapTemp_EnergyCross->begin()->first
422 <<
"G4ParticleHPThermalScatteringData:: The temperature of material (" << aT / kelvin
423 <<
"K) is different more than 10% from temperature of thermal scattering file expected ("
424 << amapTemp_EnergyCross->begin()->first <<
"K). Result may not be reliable." <<
G4endl;
426 result = amapTemp_EnergyCross->begin()->second->GetXsec(eKinetic);
430 auto it = amapTemp_EnergyCross->cbegin();
431 for (it = amapTemp_EnergyCross->cbegin(); it != amapTemp_EnergyCross->cend(); ++it) {
432 if (aT < it->first)
break;
434 if (it == amapTemp_EnergyCross->cbegin()) {
437 else if (it == amapTemp_EnergyCross->cend()) {
442 G4double XH = it->second->GetXsec(eKinetic);
444 if (it != amapTemp_EnergyCross->cbegin()) --it;
446 G4double XL = it->second->GetXsec(eKinetic);
448 if (TH == TL)
throw G4HadronicException(__FILE__, __LINE__,
"Thermal Scattering Data Error!");
451 G4double X = (XH - XL) / (TH - TL) * (T - TL) + XL;
465 outFile <<
"High Precision cross data based on thermal scattering data in evaluated nuclear data "
466 "libraries for neutrons below 5eV on specific materials\n";
std::vector< G4Element * > G4ElementTable
const char * G4FindDataDir(const char *)
std::vector< G4Material * > G4MaterialTable
G4GLOB_DLL std::ostream G4cout
G4ParticleDefinition * GetDefinition() const
G4double GetKineticEnergy() const
static G4ElementTable * GetElementTable()
static size_t GetNumberOfElements()
const G4String & GetName() const
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()
void RegisterThermalScatteringIncoherentCrossSections(std::map< G4int, std::map< G4double, G4ParticleHPVector * > * > *val)
std::map< G4int, std::map< G4double, G4ParticleHPVector * > * > * GetThermalScatteringCoherentCrossSections() 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(G4String, 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 *)
void AddThermalElement(G4String, G4String)
G4bool IsThisThermalElement(G4String)
G4String GetTS_NDL_Name(G4String nameG4Element)
void Init(std::istream &aDataFile, G4int total, G4double ux=1., G4double uy=1.)
void SetMaxKinEnergy(G4double value)
void SetMinKinEnergy(G4double value)