69 element_cache =
nullptr;
70 material_cache =
nullptr;
72 indexOfThermalElement.clear();
94 if ( dic.find( std::pair < const G4Material* , const G4Element* > ( (
G4Material*)NULL , element ) ) != dic.end()
95 || dic.find( std::pair < const G4Material* , const G4Element* > ( material , element ) ) != dic.end() )
return true;
107 element_cache = element;
108 material_cache = material;
114void G4ParticleHPThermalScatteringData::clearCurrentXSData()
116 if ( coherent !=
nullptr )
118 for (
auto it=coherent->cbegin() ; it!=coherent->cend(); ++it)
120 if ( it->second !=
nullptr )
122 for (
auto itt=it->second->cbegin(); itt!=it->second->cend(); ++itt)
132 if ( incoherent !=
nullptr )
134 for (
auto it=incoherent->cbegin(); it!=incoherent->cend() ; ++it)
136 if ( it->second !=
nullptr )
138 for (
auto itt=it->second->cbegin(); itt!=it->second->cend(); ++itt)
148 if ( inelastic !=
nullptr )
150 for (
auto it=inelastic->cbegin(); it!=inelastic->cend(); ++it)
152 if ( it->second !=
nullptr )
154 for (
auto itt=it->second->cbegin(); itt!=it->second->cend(); ++itt)
180 for (
auto it = indexOfThermalElement.cbegin();
181 it != indexOfThermalElement.cend() ; ++it)
183 if ( ie == *it )
return true;
196 throw G4HadronicException(__FILE__, __LINE__,
"Attempt to use NeutronHP data for particles other than neutrons!!!");
203 std::map < G4String , G4int > co_dic;
209 for ( std::size_t i = 0 ; i < numberOfMaterials ; ++i )
211 G4Material* material = (*theMaterialTable)[i];
213 for (
G4int j = 0 ; j < numberOfElements ; ++j )
218 G4int ts_ID_of_this_geometry;
220 if ( co_dic.find ( ts_ndl_name ) != co_dic.cend() )
222 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 < G4Material* , const G4Element* > ,
G4int > ( std::pair < G4Material* , const G4Element* > ( material , element ) , ts_ID_of_this_geometry ) );
240 for ( std::size_t i = 0 ; i < numberOfElements ; ++i )
242 const G4Element* element = (*theElementTable)[i];
247 G4int ts_ID_of_this_geometry;
249 if ( co_dic.find ( ts_ndl_name ) != co_dic.cend() )
251 ts_ID_of_this_geometry = co_dic.find ( ts_ndl_name ) -> second;
255 ts_ID_of_this_geometry = (
G4int)co_dic.size();
256 co_dic.insert ( std::pair< G4String , G4int >( ts_ndl_name , ts_ID_of_this_geometry ) );
259 dic.insert( std::pair < std::pair < const G4Material* , const G4Element* > ,
G4int > ( std::pair < const G4Material* , const G4Element* > ( (
G4Material*)NULL , element ) , ts_ID_of_this_geometry ) );
265 G4cout <<
"Neutron HP Thermal Scattering Data: Following material-element pairs and/or elements are registered." <<
G4endl;
266 for (
auto it = dic.cbegin() ; it != dic.cend() ; ++it )
268 if ( it->first.first !=
nullptr )
270 G4cout <<
"Material " << it->first.first->GetName() <<
" - Element "
271 << it->first.second->GetName()
272 <<
", internal thermal scattering id " << it->second <<
G4endl;
276 G4cout <<
"Element " << it->first.second->GetName()
277 <<
", internal thermal scattering id " << it->second <<
G4endl;
290 if ( coherent ==
nullptr )
291 coherent =
new std::map< G4int , std::map< G4double , G4ParticleHPVector* >* >;
292 if ( incoherent ==
nullptr )
293 incoherent =
new std::map< G4int , std::map< G4double , G4ParticleHPVector* >* >;
294 if ( inelastic ==
nullptr )
295 inelastic =
new std::map< G4int , std::map< G4double , G4ParticleHPVector* >* >;
301 throw G4HadronicException(__FILE__, __LINE__,
"Please setenv G4NEUTRONHPDATA to point to the neutron cross-section files.");
304 dirName = baseName +
"/ThermalScattering";
309 for (
auto it = co_dic.cbegin() ; it != co_dic.cend() ; ++it )
311 ndl_filename = it->first;
312 G4int ts_ID = it->second;
315 full_name = dirName +
"/Coherent/CrossSection/" + ndl_filename;
316 auto coh_amapTemp_EnergyCross = readData( full_name );
317 coherent->insert ( std::pair <
G4int , std::map< G4double , G4ParticleHPVector* >* > ( ts_ID , coh_amapTemp_EnergyCross ) );
320 full_name = dirName +
"/Incoherent/CrossSection/" + ndl_filename;
321 auto incoh_amapTemp_EnergyCross = readData( full_name );
322 incoherent->insert ( std::pair <
G4int , std::map< G4double , G4ParticleHPVector* >* > ( ts_ID , incoh_amapTemp_EnergyCross ) );
325 full_name = dirName +
"/Inelastic/CrossSection/" + ndl_filename;
326 auto inela_amapTemp_EnergyCross = readData( full_name );
327 inelastic->insert ( std::pair <
G4int , std::map< G4double , G4ParticleHPVector* >* > ( ts_ID , inela_amapTemp_EnergyCross ) );
336std::map< G4double , G4ParticleHPVector* >*
337G4ParticleHPThermalScatteringData::readData (
G4String full_name )
339 auto aData =
new std::map< G4double , G4ParticleHPVector* >;
341 std::istringstream theChannel;
345 while ( theChannel >> dummy )
353 anEnergyCross->
Init ( theChannel , nData , eV , barn );
354 aData->insert ( std::pair < G4double , G4ParticleHPVector* > ( temp , anEnergyCross ) );
364 throw G4HadronicException(__FILE__, __LINE__,
"Attempt to use NeutronHP data for particles other than neutrons!!!");
372 G4int ts_id =getTS_ID( aM , anE );
374 if ( ts_id == -1 )
return result;
378 G4double Xcoh = GetX ( aP , aT , coherent->find(ts_id)->second );
379 G4double Xincoh = GetX ( aP , aT , incoherent->find(ts_id)->second );
380 G4double Xinela = GetX ( aP , aT , inelastic->find(ts_id)->second );
382 result = Xcoh + Xincoh + Xinela;
391 G4int ts_id = getTS_ID( aM , anE );
393 result = GetX ( aP , aT , inelastic->find( ts_id )->second );
400 G4int ts_id = getTS_ID( aM , anE );
402 result = GetX ( aP , aT , coherent->find( ts_id )->second );
409 G4int ts_id = getTS_ID( aM , anE );
411 result = GetX ( aP , aT , incoherent->find( ts_id )->second );
418 if ( dic.find( std::pair < const G4Material* , const G4Element* > ( (
G4Material*)NULL , element ) ) != dic.end() )
419 return dic.find( std::pair < const G4Material* , const G4Element* > ( (
G4Material*)NULL , element ) )->second;
420 if ( dic.find( std::pair < const G4Material* , const G4Element* > ( material , element ) ) != dic.end() )
421 return dic.find( std::pair < const G4Material* , const G4Element* > ( material , element ) )->second;
428 if ( amapTemp_EnergyCross->size() == 0 )
return result;
432 if ( amapTemp_EnergyCross->size() == 1 ) {
433 if ( std::fabs ( aT - amapTemp_EnergyCross->cbegin()->first ) / amapTemp_EnergyCross->begin()->first > 0.1 ) {
434 G4cout <<
"G4ParticleHPThermalScatteringData:: The temperature of material ("
435 << aT/kelvin <<
"K) is different more than 10% from temperature of thermal scattering file expected ("
436 << amapTemp_EnergyCross->begin()->first <<
"K). Result may not be reliable."
439 result = amapTemp_EnergyCross->begin()->second->GetXsec ( eKinetic );
443 auto it = amapTemp_EnergyCross->cbegin();
444 for (it=amapTemp_EnergyCross->cbegin(); it!=amapTemp_EnergyCross->cend(); ++it)
446 if ( aT < it->first )
break;
448 if ( it == amapTemp_EnergyCross->cbegin() ) {
450 }
else if ( it == amapTemp_EnergyCross->cend() ) {
455 G4double XH = it->second->GetXsec ( eKinetic );
457 if ( it != amapTemp_EnergyCross->cbegin() ) --it;
459 G4double XL = it->second->GetXsec ( eKinetic );
465 G4double X = ( XH - XL ) / ( TH - TL ) * ( T - TL ) + XL;
479 outFile <<
"High Precision cross data based on thermal scattering data in evaluated nuclear data 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
static size_t GetNumberOfMaterials()
G4double GetTemperature() const
const G4Element * GetElement(G4int iel) const
size_t GetNumberOfElements() const
static G4MaterialTable * GetMaterialTable()
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()
std::map< G4int, std::map< G4double, G4ParticleHPVector * > * > * GetThermalScatteringInelasticCrossSections()
void RegisterThermalScatteringCoherentCrossSections(std::map< G4int, std::map< G4double, G4ParticleHPVector * > * > *val)
std::map< G4int, std::map< G4double, G4ParticleHPVector * > * > * GetThermalScatteringIncoherentCrossSections()
static G4ParticleHPManager * GetInstance()
void GetDataStream(G4String, std::istringstream &iss)
void RegisterThermalScatteringInelasticCrossSections(std::map< G4int, std::map< G4double, G4ParticleHPVector * > * > *val)
G4ParticleHPThermalScatteringData()
G4double GetCrossSection(const G4DynamicParticle *, const G4Element *, const G4Material *)
~G4ParticleHPThermalScatteringData()
G4double GetIncoherentCrossSection(const G4DynamicParticle *, const G4Element *, const G4Material *)
void BuildPhysicsTable(const G4ParticleDefinition &)
void AddUserThermalScatteringFile(G4String, G4String)
G4double GetIsoCrossSection(const G4DynamicParticle *, G4int, G4int, const G4Isotope *, const G4Element *, const G4Material *)
G4double GetCoherentCrossSection(const G4DynamicParticle *, const G4Element *, const G4Material *)
void DumpPhysicsTable(const G4ParticleDefinition &)
G4double GetInelasticCrossSection(const G4DynamicParticle *, const G4Element *, const G4Material *)
virtual void CrossSectionDescription(std::ostream &) const
G4bool IsApplicable(const G4DynamicParticle *, const G4Element *)
G4bool IsIsoApplicable(const G4DynamicParticle *, G4int, G4int, const G4Element *, const G4Material *)
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)