Geant4 11.4.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 48 of file G4ParticleHPThermalScatteringData.cc.

49 : G4VCrossSectionDataSet("NeutronHPThermalScatteringData")
50{
51 // Upper limit of neutron energy
52 emax = 4 * CLHEP::eV;
53 SetMinKinEnergy(0 * MeV);
54 SetMaxKinEnergy(emax);
55
56 ke_cache = 0.0;
57 xs_cache = 0.0;
58 element_cache = nullptr;
59 material_cache = nullptr;
60
61 if (nullptr == names) {
62 isInitializer = true;
63 indexOfThermalElement = new std::vector<G4int>;
64 names = new G4ParticleHPThermalScatteringNames();
65 dic = new std::map<std::pair<const G4Material*, const G4Element*>, G4int>;
66
67 G4ParticleHPManager* hpmanager = G4ParticleHPManager::GetInstance();
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*>*>;
71
75 }
76}
int G4int
Definition G4Types.hh:85
void RegisterThermalScatteringIncoherentCrossSections(std::map< G4int, std::map< G4double, G4ParticleHPVector * > * > *val)
void RegisterThermalScatteringCoherentCrossSections(std::map< G4int, std::map< G4double, G4ParticleHPVector * > * > *val)
static G4ParticleHPManager * GetInstance()
void RegisterThermalScatteringInelasticCrossSections(std::map< G4int, std::map< G4double, G4ParticleHPVector * > * > *val)
G4VCrossSectionDataSet(const G4String &nam="")
void SetMaxKinEnergy(G4double value)
void SetMinKinEnergy(G4double value)

◆ ~G4ParticleHPThermalScatteringData()

G4ParticleHPThermalScatteringData::~G4ParticleHPThermalScatteringData ( )
override

Definition at line 78 of file G4ParticleHPThermalScatteringData.cc.

79{
80 if (!isInitializer) return;
81
82 clearCurrentXSData(coherent);
83 clearCurrentXSData(incoherent);
84 clearCurrentXSData(inelastic);
85
86 delete names;
87 delete dic;
88 delete indexOfThermalElement;
89 names = nullptr;
90 dic = nullptr;
91 indexOfThermalElement = nullptr;
92}

Member Function Documentation

◆ AddUserThermalScatteringFile()

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

Definition at line 421 of file G4ParticleHPThermalScatteringData.cc.

423{
424 names->AddThermalElement(nameG4Element, filename);
425}

◆ BuildPhysicsTable()

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

Reimplemented from G4VCrossSectionDataSet.

Definition at line 153 of file G4ParticleHPThermalScatteringData.cc.

154{
155 if (&aP != G4Neutron::Neutron()) {
157 ed << "Neutron thermal scattering cannot be applied to " << aP.GetParticleName();
158
159 G4Exception("G4ParticleHPThermalScatteringData::BuildPhysicsTable","hp0001",
160 FatalException, ed, " run stopped");
161 return;
162 }
163
164 // Common initialisation for all threads
165 G4ParticleHPManager* hpmanager = G4ParticleHPManager::GetInstance();
166 verbose = hpmanager->GetVerboseLevel();
167
168 coherent = hpmanager->GetThermalScatteringCoherentCrossSections();
169 incoherent = hpmanager->GetThermalScatteringIncoherentCrossSections();
170 inelastic = hpmanager->GetThermalScatteringInelasticCrossSections();
171
172 // The initialisation is performed only in the master thread
173 if (!isInitializer)
174 return;
175
176 std::map<G4String, G4int> co_dic;
177
178 // Searching Materials
179 auto const theMaterialTable = G4Material::GetMaterialTable();
180 std::size_t numberOfMaterials = G4Material::GetNumberOfMaterials();
181 for (std::size_t i = 0; i < numberOfMaterials; ++i) {
182 G4Material* material = (*theMaterialTable)[i];
183 auto numberOfElements = (G4int)material->GetNumberOfElements();
184 for (G4int j = 0; j < numberOfElements; ++j) {
185 const G4Element* element = material->GetElement(j);
186 if (names->IsThisThermalElement(material->GetName(), element->GetName())) {
187 G4int ts_ID_of_this_geometry;
188 G4String ts_ndl_name = names->GetTS_NDL_Name(material->GetName(), element->GetName());
189 if (co_dic.find(ts_ndl_name) != co_dic.cend()) {
190 ts_ID_of_this_geometry = co_dic.find(ts_ndl_name)->second;
191 }
192 else {
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));
195 }
196
197 dic->insert(std::pair<std::pair<G4Material*, const G4Element*>, G4int>(
198 std::pair<G4Material*, const G4Element*>(material, element), ts_ID_of_this_geometry));
199 }
200 }
201 }
202
203 // Searching TS Elements
204 auto const theElementTable = G4Element::GetElementTable();
205 std::size_t numberOfElements = G4Element::GetNumberOfElements();
206
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;
214 }
215 else {
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));
218 }
219
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));
223 }
224 }
225
226 if (0 < verbose) {
227 G4cout << "##T## Neutron HP Thermal Scattering Data: Following material-element pairs and/or elements "
228 "are registered for " << dic->size() << " materials." << G4endl;
229
230 if (dic->empty()) return;
231
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
236 << G4endl;
237 }
238 else {
239 G4cout << " Element " << it.first.second->GetName() << ", internal thermal scattering id "
240 << it.second << G4endl;
241 }
242 }
243 G4cout << G4endl;
244 }
245
246 // Read Cross Section Data files
247 const G4String dirName = hpmanager->GetNeutronHPPath() + "/ThermalScattering";
248
249 G4String ndl_filename;
250 G4String full_name;
251
252 for (const auto& it : co_dic) {
253 ndl_filename = it.first;
254 G4int ts_ID = it.second;
255
256 // Coherent
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));
261
262 // Incoherent
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));
267
268 // Inelastic
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));
273 }
274}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
#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
const G4String & GetParticleName() const
std::map< G4int, std::map< G4double, G4ParticleHPVector * > * > * GetThermalScatteringCoherentCrossSections() const
const G4String & GetNeutronHPPath() const
std::map< G4int, std::map< G4double, G4ParticleHPVector * > * > * GetThermalScatteringInelasticCrossSections() const
std::map< G4int, std::map< G4double, G4ParticleHPVector * > * > * GetThermalScatteringIncoherentCrossSections() const

◆ CrossSectionDescription()

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

Reimplemented from G4VCrossSectionDataSet.

Definition at line 427 of file G4ParticleHPThermalScatteringData.cc.

428{
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";
431}

◆ DumpPhysicsTable()

void G4ParticleHPThermalScatteringData::DumpPhysicsTable ( const G4ParticleDefinition & )
overridevirtual

Reimplemented from G4VCrossSectionDataSet.

Definition at line 300 of file G4ParticleHPThermalScatteringData.cc.

301{}

◆ GetCoherentCrossSection()

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

Definition at line 341 of file G4ParticleHPThermalScatteringData.cc.

344{
345 G4double result = 0;
346 G4int ts_id = getTS_ID(aM, anE);
347 if (ts_id == -1) return result;
348 G4double aT = aM->GetTemperature();
349 auto u = coherent->find(ts_id);
350 if (u != coherent->end()) { result = GetX(aP, aT, u->second); }
351 return result;
352}
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 303 of file G4ParticleHPThermalScatteringData.cc.

306{
307 G4double result = 0;
308 G4int ts_id = getTS_ID(aM, anE);
309
310 if (ts_id == -1) return result;
311
312 G4double aT = aM->GetTemperature();
313
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;
320
321 result = Xcoh + Xincoh + Xinela;
322
323 return result;
324}

Referenced by GetIsoCrossSection().

◆ GetIncoherentCrossSection()

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

Definition at line 354 of file G4ParticleHPThermalScatteringData.cc.

357{
358 G4double result = 0;
359 G4int ts_id = getTS_ID(aM, anE);
360 if (ts_id == -1) return result;
361 G4double aT = aM->GetTemperature();
362 auto u = incoherent->find(ts_id);
363 if (u != incoherent->end()) { result = GetX(aP, aT, u->second); }
364 return result;
365}

◆ GetInelasticCrossSection()

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

Definition at line 326 of file G4ParticleHPThermalScatteringData.cc.

329{
330 G4double result = 0;
331 G4int ts_id = getTS_ID(aM, anE);
332 if (ts_id == -1) return result;
333 G4double aT = aM->GetTemperature();
334 auto ptr = inelastic->find(ts_id);
335 if (ptr != inelastic->end()) {
336 result = GetX(aP, aT, ptr->second);
337 }
338 return result;
339}

◆ GetIsoCrossSection()

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

Reimplemented from G4VCrossSectionDataSet.

Definition at line 109 of file G4ParticleHPThermalScatteringData.cc.

114{
115 ke_cache = dp->GetKineticEnergy();
116 element_cache = element;
117 material_cache = material;
118 G4double xs = GetCrossSection(dp, element, material);
119 xs_cache = xs;
120 return xs;
121}
G4double GetKineticEnergy() const
G4double GetCrossSection(const G4DynamicParticle *, const G4Element *, const G4Material *)

◆ IsApplicable()

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

Definition at line 138 of file G4ParticleHPThermalScatteringData.cc.

140{
141 // Check energy
142 if (aP->GetKineticEnergy() > emax)
143 return false;
144
145 // anEle is one of Thermal elements
146 auto ie = (G4int)anEle->GetIndex();
147 for (auto const& it : *indexOfThermalElement) {
148 if (ie == it) return true;
149 }
150 return false;
151}
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 94 of file G4ParticleHPThermalScatteringData.cc.

97{
98 if (dp->GetKineticEnergy() > emax)
99 return false;
100
101 if (dic->find(std::pair<const G4Material*, const G4Element*>((G4Material*)nullptr, element))
102 != dic->end()
103 || dic->find(std::pair<const G4Material*, const G4Element*>(material, element)) != dic->end())
104 return true;
105
106 return false;
107}

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