Geant4 11.3.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ParticleHPThermalScatteringData Class Reference

#include <G4ParticleHPThermalScatteringData.hh>

+ Inheritance diagram for G4ParticleHPThermalScatteringData:

Public Member Functions

 G4ParticleHPThermalScatteringData ()
 
 ~G4ParticleHPThermalScatteringData () override
 
G4bool IsIsoApplicable (const G4DynamicParticle *, G4int, G4int, const G4Element *, const G4Material *) override
 
G4double GetIsoCrossSection (const G4DynamicParticle *, G4int, G4int, const G4Isotope *, const G4Element *, const G4Material *) override
 
G4bool IsApplicable (const G4DynamicParticle *, const G4Element *)
 
G4double GetCrossSection (const G4DynamicParticle *, const G4Element *, const G4Material *)
 
G4double GetInelasticCrossSection (const G4DynamicParticle *, const G4Element *, const G4Material *)
 
G4double GetCoherentCrossSection (const G4DynamicParticle *, const G4Element *, const G4Material *)
 
G4double GetIncoherentCrossSection (const G4DynamicParticle *, const G4Element *, const G4Material *)
 
void BuildPhysicsTable (const G4ParticleDefinition &) override
 
void DumpPhysicsTable (const G4ParticleDefinition &) override
 
void AddUserThermalScatteringFile (const G4String &, const G4String &)
 
void CrossSectionDescription (std::ostream &) const override
 
- Public Member Functions inherited from G4VCrossSectionDataSet
 G4VCrossSectionDataSet (const G4String &nam="")
 
virtual ~G4VCrossSectionDataSet ()
 
virtual G4bool IsElementApplicable (const G4DynamicParticle *, G4int Z, const G4Material *mat=nullptr)
 
G4double GetCrossSection (const G4DynamicParticle *, const G4Element *, const G4Material *mat=nullptr)
 
G4double ComputeCrossSection (const G4DynamicParticle *, const G4Element *, const G4Material *mat=nullptr)
 
virtual G4double ComputeCrossSectionPerElement (G4double kinEnergy, G4double loge, const G4ParticleDefinition *, const G4Element *, const G4Material *mat=nullptr)
 
virtual G4double GetElementCrossSection (const G4DynamicParticle *, G4int Z, const G4Material *mat=nullptr)
 
virtual G4double ComputeIsoCrossSection (G4double kinEnergy, G4double loge, const G4ParticleDefinition *, G4int Z, G4int A, const G4Isotope *iso=nullptr, const G4Element *elm=nullptr, const G4Material *mat=nullptr)
 
virtual const G4IsotopeSelectIsotope (const G4Element *, G4double kinEnergy, G4double logE)
 
virtual void SetVerboseLevel (G4int value)
 
G4double GetMinKinEnergy () const
 
void SetMinKinEnergy (G4double value)
 
G4double GetMaxKinEnergy () const
 
void SetMaxKinEnergy (G4double value)
 
bool ForAllAtomsAndEnergies () const
 
void SetForAllAtomsAndEnergies (G4bool val)
 
const G4StringGetName () const
 
void SetName (const G4String &nam)
 
G4VCrossSectionDataSetoperator= (const G4VCrossSectionDataSet &right)=delete
 
 G4VCrossSectionDataSet (const G4VCrossSectionDataSet &)=delete
 

Additional Inherited Members

- Protected Attributes inherited from G4VCrossSectionDataSet
G4int verboseLevel {0}
 
G4String name
 

Detailed Description

Definition at line 56 of file G4ParticleHPThermalScatteringData.hh.

Constructor & Destructor Documentation

◆ G4ParticleHPThermalScatteringData()

G4ParticleHPThermalScatteringData::G4ParticleHPThermalScatteringData ( )

Definition at line 44 of file G4ParticleHPThermalScatteringData.cc.

45 : G4VCrossSectionDataSet("NeutronHPThermalScatteringData")
46{
47 // Upper limit of neutron energy
48 emax = 4 * eV;
49 SetMinKinEnergy(0 * MeV);
50 SetMaxKinEnergy(emax);
51
52 ke_cache = 0.0;
53 xs_cache = 0.0;
54 element_cache = nullptr;
55 material_cache = nullptr;
56
57 indexOfThermalElement.clear();
58
59 names = new G4ParticleHPThermalScatteringNames();
60}
G4VCrossSectionDataSet(const G4String &nam="")
void SetMaxKinEnergy(G4double value)
void SetMinKinEnergy(G4double value)

◆ ~G4ParticleHPThermalScatteringData()

G4ParticleHPThermalScatteringData::~G4ParticleHPThermalScatteringData ( )
override

Definition at line 62 of file G4ParticleHPThermalScatteringData.cc.

63{
64 clearCurrentXSData();
65
66 delete names;
67}

Member Function Documentation

◆ AddUserThermalScatteringFile()

void G4ParticleHPThermalScatteringData::AddUserThermalScatteringFile ( const G4String & nameG4Element,
const G4String & filename )

Definition at line 445 of file G4ParticleHPThermalScatteringData.cc.

447{
448 names->AddThermalElement(nameG4Element, filename);
449}

◆ BuildPhysicsTable()

void G4ParticleHPThermalScatteringData::BuildPhysicsTable ( const G4ParticleDefinition & aP)
overridevirtual

Reimplemented from G4VCrossSectionDataSet.

Definition at line 161 of file G4ParticleHPThermalScatteringData.cc.

162{
163 if (&aP != G4Neutron::Neutron())
164 throw G4HadronicException(__FILE__, __LINE__,
165 "Attempt to use NeutronHP data for particles other than neutrons!!!");
166
167 // std::map < std::pair < G4Material* , const G4Element* > , G4int > dic;
168 //
169 dic.clear();
170 if (G4Threading::IsMasterThread()) clearCurrentXSData();
171
172 std::map<G4String, G4int> co_dic;
173
174 // Searching Nist Materials
175 static G4ThreadLocal G4MaterialTable* theMaterialTable = nullptr;
176 if (theMaterialTable == nullptr) theMaterialTable = G4Material::GetMaterialTable();
177 std::size_t numberOfMaterials = G4Material::GetNumberOfMaterials();
178 for (std::size_t i = 0; i < numberOfMaterials; ++i) {
179 G4Material* material = (*theMaterialTable)[i];
180 auto numberOfElements = (G4int)material->GetNumberOfElements();
181 for (G4int j = 0; j < numberOfElements; ++j) {
182 const G4Element* element = material->GetElement(j);
183 if (names->IsThisThermalElement(material->GetName(), element->GetName())) {
184 G4int ts_ID_of_this_geometry;
185 G4String ts_ndl_name = names->GetTS_NDL_Name(material->GetName(), element->GetName());
186 if (co_dic.find(ts_ndl_name) != co_dic.cend()) {
187 ts_ID_of_this_geometry = co_dic.find(ts_ndl_name)->second;
188 }
189 else {
190 ts_ID_of_this_geometry = (G4int)co_dic.size();
191 co_dic.insert(std::pair<G4String, G4int>(ts_ndl_name, ts_ID_of_this_geometry));
192 }
193
194 dic.insert(std::pair<std::pair<G4Material*, const G4Element*>, G4int>(
195 std::pair<G4Material*, const G4Element*>(material, element), ts_ID_of_this_geometry));
196 }
197 }
198 }
199
200 // Searching TS Elements
201 auto theElementTable = G4Element::GetElementTable();
202 std::size_t numberOfElements = G4Element::GetNumberOfElements();
203
204 for (std::size_t i = 0; i < numberOfElements; ++i) {
205 const G4Element* element = (*theElementTable)[i];
206 if (names->IsThisThermalElement(element->GetName())) {
207 if (names->IsThisThermalElement(element->GetName())) {
208 G4int ts_ID_of_this_geometry;
209 G4String ts_ndl_name = names->GetTS_NDL_Name(element->GetName());
210 if (co_dic.find(ts_ndl_name) != co_dic.cend()) {
211 ts_ID_of_this_geometry = co_dic.find(ts_ndl_name)->second;
212 }
213 else {
214 ts_ID_of_this_geometry = (G4int)co_dic.size();
215 co_dic.insert(std::pair<G4String, G4int>(ts_ndl_name, ts_ID_of_this_geometry));
216 }
217
218 dic.insert(std::pair<std::pair<const G4Material*, const G4Element*>, G4int>(
219 std::pair<const G4Material*, const G4Element*>((G4Material*)nullptr, element),
220 ts_ID_of_this_geometry));
221 }
222 }
223 }
224
225 G4cout << G4endl;
226 G4cout << "Neutron HP Thermal Scattering Data: Following material-element pairs and/or elements "
227 "are registered."
228 << G4endl;
229 for (const auto& it : dic) {
230 if (it.first.first != nullptr) {
231 G4cout << "Material " << it.first.first->GetName() << " - Element "
232 << it.first.second->GetName() << ", internal thermal scattering id " << it.second
233 << G4endl;
234 }
235 else {
236 G4cout << "Element " << it.first.second->GetName() << ", internal thermal scattering id "
237 << it.second << G4endl;
238 }
239 }
240 G4cout << G4endl;
241
242 G4ParticleHPManager* hpmanager = G4ParticleHPManager::GetInstance();
243
244 coherent = hpmanager->GetThermalScatteringCoherentCrossSections();
245 incoherent = hpmanager->GetThermalScatteringIncoherentCrossSections();
246 inelastic = hpmanager->GetThermalScatteringInelasticCrossSections();
247
249 if (coherent == nullptr)
250 coherent = new std::map<G4int, std::map<G4double, G4ParticleHPVector*>*>;
251 if (incoherent == nullptr)
252 incoherent = new std::map<G4int, std::map<G4double, G4ParticleHPVector*>*>;
253 if (inelastic == nullptr)
254 inelastic = new std::map<G4int, std::map<G4double, G4ParticleHPVector*>*>;
255
256 // Read Cross Section Data files
257
258 G4String dirName;
259 if (G4FindDataDir("G4NEUTRONHPDATA") == nullptr)
260 throw G4HadronicException(
261 __FILE__, __LINE__,
262 "Please setenv G4NEUTRONHPDATA to point to the neutron cross-section files.");
263 G4String baseName = G4FindDataDir("G4NEUTRONHPDATA");
264
265 dirName = baseName + "/ThermalScattering";
266
267 G4String ndl_filename;
268 G4String full_name;
269
270 for (const auto& it : co_dic) {
271 ndl_filename = it.first;
272 G4int ts_ID = it.second;
273
274 // Coherent
275 full_name = dirName + "/Coherent/CrossSection/" + ndl_filename;
276 auto coh_amapTemp_EnergyCross = readData(full_name);
277 coherent->insert(std::pair<G4int, std::map<G4double, G4ParticleHPVector*>*>(
278 ts_ID, coh_amapTemp_EnergyCross));
279
280 // Incoherent
281 full_name = dirName + "/Incoherent/CrossSection/" + ndl_filename;
282 auto incoh_amapTemp_EnergyCross = readData(full_name);
283 incoherent->insert(std::pair<G4int, std::map<G4double, G4ParticleHPVector*>*>(
284 ts_ID, incoh_amapTemp_EnergyCross));
285
286 // Inelastic
287 full_name = dirName + "/Inelastic/CrossSection/" + ndl_filename;
288 auto inela_amapTemp_EnergyCross = readData(full_name);
289 inelastic->insert(std::pair<G4int, std::map<G4double, G4ParticleHPVector*>*>(
290 ts_ID, inela_amapTemp_EnergyCross));
291 }
295 }
296}
const char * G4FindDataDir(const char *)
std::vector< G4Material * > G4MaterialTable
int G4int
Definition G4Types.hh:85
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
static std::size_t GetNumberOfElements()
Definition G4Element.cc:408
const G4String & GetName() const
Definition G4Element.hh:115
static const G4ElementTable * GetElementTable()
Definition G4Element.cc:401
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()
Definition G4Neutron.cc:101
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
static G4ParticleHPManager * GetInstance()
void RegisterThermalScatteringInelasticCrossSections(std::map< G4int, std::map< G4double, G4ParticleHPVector * > * > *val)
std::map< G4int, std::map< G4double, G4ParticleHPVector * > * > * GetThermalScatteringIncoherentCrossSections() const
G4bool IsMasterThread()
#define G4ThreadLocal
Definition tls.hh:77

◆ CrossSectionDescription()

void G4ParticleHPThermalScatteringData::CrossSectionDescription ( std::ostream & outFile) const
overridevirtual

Reimplemented from G4VCrossSectionDataSet.

Definition at line 451 of file G4ParticleHPThermalScatteringData.cc.

452{
453 outFile << "High Precision cross data based on thermal scattering data in evaluated nuclear data "
454 "libraries for neutrons below 5eV on specific materials\n";
455}

◆ DumpPhysicsTable()

void G4ParticleHPThermalScatteringData::DumpPhysicsTable ( const G4ParticleDefinition & aP)
overridevirtual

Reimplemented from G4VCrossSectionDataSet.

Definition at line 322 of file G4ParticleHPThermalScatteringData.cc.

323{
324 if (&aP != G4Neutron::Neutron())
325 throw G4HadronicException(__FILE__, __LINE__,
326 "Attempt to use NeutronHP data for particles other than neutrons!!!");
327}

◆ GetCoherentCrossSection()

G4double G4ParticleHPThermalScatteringData::GetCoherentCrossSection ( const G4DynamicParticle * aP,
const G4Element * anE,
const G4Material * aM )

Definition at line 361 of file G4ParticleHPThermalScatteringData.cc.

364{
365 G4double result = 0;
366 G4int ts_id = getTS_ID(aM, anE);
367 G4double aT = aM->GetTemperature();
368 result = GetX(aP, aT, coherent->find(ts_id)->second);
369 return result;
370}
double G4double
Definition G4Types.hh:83
G4double GetTemperature() const

◆ GetCrossSection()

G4double G4ParticleHPThermalScatteringData::GetCrossSection ( const G4DynamicParticle * aP,
const G4Element * anE,
const G4Material * aM )

Definition at line 329 of file G4ParticleHPThermalScatteringData.cc.

332{
333 G4double result = 0;
334
335 G4int ts_id = getTS_ID(aM, anE);
336
337 if (ts_id == -1) return result;
338
339 G4double aT = aM->GetTemperature();
340
341 G4double Xcoh = GetX(aP, aT, coherent->find(ts_id)->second);
342 G4double Xincoh = GetX(aP, aT, incoherent->find(ts_id)->second);
343 G4double Xinela = GetX(aP, aT, inelastic->find(ts_id)->second);
344
345 result = Xcoh + Xincoh + Xinela;
346
347 return result;
348}

Referenced by GetIsoCrossSection().

◆ GetIncoherentCrossSection()

G4double G4ParticleHPThermalScatteringData::GetIncoherentCrossSection ( const G4DynamicParticle * aP,
const G4Element * anE,
const G4Material * aM )

Definition at line 372 of file G4ParticleHPThermalScatteringData.cc.

375{
376 G4double result = 0;
377 G4int ts_id = getTS_ID(aM, anE);
378 G4double aT = aM->GetTemperature();
379 result = GetX(aP, aT, incoherent->find(ts_id)->second);
380 return result;
381}

◆ GetInelasticCrossSection()

G4double G4ParticleHPThermalScatteringData::GetInelasticCrossSection ( const G4DynamicParticle * aP,
const G4Element * anE,
const G4Material * aM )

Definition at line 350 of file G4ParticleHPThermalScatteringData.cc.

353{
354 G4double result = 0;
355 G4int ts_id = getTS_ID(aM, anE);
356 G4double aT = aM->GetTemperature();
357 result = GetX(aP, aT, inelastic->find(ts_id)->second);
358 return result;
359}

◆ GetIsoCrossSection()

G4double G4ParticleHPThermalScatteringData::GetIsoCrossSection ( const G4DynamicParticle * dp,
G4int ,
G4int ,
const G4Isotope * ,
const G4Element * element,
const G4Material * material )
overridevirtual

Reimplemented from G4VCrossSectionDataSet.

Definition at line 87 of file G4ParticleHPThermalScatteringData.cc.

92{
93 ke_cache = dp->GetKineticEnergy();
94 element_cache = element;
95 material_cache = material;
96 G4double xs = GetCrossSection(dp, element, material);
97 xs_cache = xs;
98 return xs;
99}
G4double GetKineticEnergy() const
G4double GetCrossSection(const G4DynamicParticle *, const G4Element *, const G4Material *)

◆ IsApplicable()

G4bool G4ParticleHPThermalScatteringData::IsApplicable ( const G4DynamicParticle * aP,
const G4Element * anEle )

Definition at line 140 of file G4ParticleHPThermalScatteringData.cc.

142{
143 G4bool result = false;
144
145 G4double eKin = aP->GetKineticEnergy();
146 // Check energy
147 if (eKin < emax) {
148 // Check Particle Species
149 if (aP->GetDefinition() == G4Neutron::Neutron()) {
150 // anEle is one of Thermal elements
151 auto ie = (G4int)anEle->GetIndex();
152 for (int it : indexOfThermalElement) {
153 if (ie == it) return true;
154 }
155 }
156 }
157
158 return result;
159}
bool G4bool
Definition G4Types.hh:86
G4ParticleDefinition * GetDefinition() const
std::size_t GetIndex() const
Definition G4Element.hh:159

◆ IsIsoApplicable()

G4bool G4ParticleHPThermalScatteringData::IsIsoApplicable ( const G4DynamicParticle * dp,
G4int ,
G4int ,
const G4Element * element,
const G4Material * material )
overridevirtual

Reimplemented from G4VCrossSectionDataSet.

Definition at line 69 of file G4ParticleHPThermalScatteringData.cc.

72{
73 G4double eKin = dp->GetKineticEnergy();
74 if (eKin > 4.0 * eV // GetMaxKinEnergy()
75 || eKin < 0 // GetMinKinEnergy()
77 return false;
78
79 if (dic.find(std::pair<const G4Material*, const G4Element*>((G4Material*)nullptr, element))
80 != dic.end()
81 || dic.find(std::pair<const G4Material*, const G4Element*>(material, element)) != dic.end())
82 return true;
83
84 return false;
85}

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