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.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  1 //
  2 // ********************************************************************
  3 // * License and Disclaimer                                           *
  4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.                             *
 10 // *                                                                  *
 11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                                                  *
 18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // ********************************************************************
 25 
 26 // -------------------------------------------------------------------
 27 //
 28 // GEANT4 Class header file
 29 //
 30 // File name:     G4NistManager
 31 //
 32 // Author:        Vladimir Ivanchenko
 33 //
 34 // Creation date: 23.12.2004
 35 //
 36 // Modifications:
 37 // 27.02.06 V.Ivanchneko add GetAtomicMassAmu and ConstructNewGasMaterial
 38 // 11.05.06 V.Ivanchneko add warning flag to FindMaterial method
 39 // 17.10.06 V.Ivanchneko add methods: GetAtomicMass, GetNistElementNames,
 40 //                       GetNistMaterialNames
 41 // 02.05.07 V.Ivanchneko add GetNistFirstIsotopeN and GetNumberOfNistIsotopes
 42 // 28.07.07 V.Ivanchneko make simple methods inline
 43 // 28.10.07 V.Ivanchneko add state, T, P to maetrial build
 44 // 29.04.10 V.Ivanchneko add GetMeanIonisationEnergy method
 45 // 01.11.10 V.Ivanchneko add G4Pow for fast computations
 46 // 09.02.12 P.Gumplinger add ConstructNewIdealGasMaterial
 47 //
 48 // Class Description:
 49 //
 50 // A utility static class
 51 //
 52 // Element data from the NIST DB on Atomic Weights and Isotope Compositions
 53 // http://physics.nist.gov/PhysRefData/Compositions/index.html
 54 //
 55 // -------------------------------------------------------------------
 56 
 57 #ifndef G4NistManager_h
 58 #define G4NistManager_h 1
 59 
 60 #include "G4ICRU90StoppingData.hh"
 61 #include "G4Material.hh"
 62 #include "G4Element.hh"
 63 #include "G4Isotope.hh"
 64 #include "G4NistElementBuilder.hh"
 65 #include "G4NistMaterialBuilder.hh"
 66 #include "G4Pow.hh"
 67 #include "globals.hh"
 68 
 69 #include <CLHEP/Units/PhysicalConstants.h>
 70 
 71 #include <vector>
 72 
 73 class G4NistMessenger;
 74 
 75 class G4NistManager
 76 {
 77  public:
 78   static G4NistManager* Instance();
 79   ~G4NistManager();
 80 
 81   // Get G4Element by index
 82   //
 83   inline G4Element* GetElement(std::size_t index) const;
 84 
 85   // Find or build G4Element by atomic number
 86   //
 87   inline G4Element* FindElement(G4int Z) const;
 88   inline G4Element* FindOrBuildElement(G4int Z, G4bool isotopes = true);
 89 
 90   // Find or build G4Element by symbol
 91   //
 92   inline G4Element* FindOrBuildElement(const G4String& symb, G4bool isotopes = true);
 93 
 94   // Get number of elements
 95   //
 96   inline std::size_t GetNumberOfElements() const;
 97 
 98   // Get atomic number by element symbol
 99   //
100   inline G4int GetZ(const G4String& symb) const;
101 
102   // Get atomic weight by element symbol - mean mass in units of amu of
103   // an atom with electron shell for the natural isotope composition
104   //
105   inline G4double GetAtomicMassAmu(const G4String& symb) const;
106 
107   // Get atomic weight in atomic units - mean mass in units of amu of an atom
108   // with electron shell for the natural isotope composition
109   //
110   inline G4double GetAtomicMassAmu(G4int Z) const;
111 
112   // Get mass of isotope without electron shell in Geant4 energy units
113   //
114   inline G4double GetIsotopeMass(G4int Z, G4int N) const;
115 
116   // Get mass in Geant4 energy units of an atom of a particular isotope
117   // with the electron shell
118   //
119   inline G4double GetAtomicMass(G4int Z, G4int N) const;
120 
121   // Get total ionisation energy of an atom
122   //
123   inline G4double GetTotalElectronBindingEnergy(G4int Z) const;
124 
125   // Get N for the first natural isotope
126   //
127   inline G4int GetNistFirstIsotopeN(G4int Z) const;
128 
129   // Get number of natural isotopes
130   //
131   inline G4int GetNumberOfNistIsotopes(G4int Z) const;
132 
133   // Get natural isotope abundance
134   //
135   inline G4double GetIsotopeAbundance(G4int Z, G4int N) const;
136 
137   // Print element by Z
138   //
139   inline void PrintElement(G4int Z) const;
140 
141   // Print element from internal DB by symbol, if "all" - print all elements
142   //
143   void PrintElement(const G4String&) const;
144 
145   // Print G4Element by name, if "all" - print all G4Elements
146   //
147   void PrintG4Element(const G4String&) const;
148 
149   // Access to the vector of Geant4 predefined element names
150   //
151   inline const std::vector<G4String>& GetNistElementNames() const;
152 
153   // Access mean ionisation energy for atoms (Z <= 98) by its index
154   //
155   inline G4double GetMeanIonisationEnergy(G4int Z) const;
156 
157   // Access nominal density by atomic number for simple materials and
158   // by the index for other NIST materials
159   //
160   inline G4double GetNominalDensity(G4int Z) const;
161 
162   // Get G4Material by index
163   //
164   inline G4Material* GetMaterial(std::size_t index) const;
165 
166   // Find or build a G4Material by name, from the Geant4 dataBase
167   //
168   inline G4Material* FindMaterial(const G4String& name) const;
169   inline G4Material* FindOrBuildMaterial(
170     const G4String& name, G4bool isotopes = true, G4bool warning = false);
171 
172   // Find or build a simple material via atomic number
173   //
174   inline G4Material* FindSimpleMaterial(G4int Z) const;
175   inline G4Material* FindOrBuildSimpleMaterial(G4int Z, G4bool warning = false);
176 
177   // Build G4Material with user defined name and density on base
178   // of a material from Geant4 dataBase
179   //
180   G4Material* BuildMaterialWithNewDensity(const G4String& name, const G4String& basename,
181     G4double density = 0.0, G4double temp = NTP_Temperature, G4double pres = CLHEP::STP_Pressure);
182 
183   // Construct a G4Material from scratch by atome count
184   // temperature and pressure should be consistent with the density
185   //
186   inline G4Material* ConstructNewMaterial(const G4String& name, const std::vector<G4String>& elm,
187     const std::vector<G4int>& nbAtoms, G4double dens, G4bool isotopes = true,
188     G4State state = kStateSolid, G4double temp = NTP_Temperature,
189     G4double pressure = CLHEP::STP_Pressure);
190 
191   // Construct a G4Material from scratch by fraction mass
192   // temperature and pressure should be consistent with the density
193   //
194   inline G4Material* ConstructNewMaterial(const G4String& name, const std::vector<G4String>& elm,
195     const std::vector<G4double>& weight, G4double dens, G4bool isotopes = true,
196     G4State state = kStateSolid, G4double temp = NTP_Temperature,
197     G4double pressure = CLHEP::STP_Pressure);
198 
199   // Construct a gas G4Material from scratch by atome count
200   //
201   inline G4Material* ConstructNewGasMaterial(const G4String& name, const G4String& nameNist,
202     G4double temp, G4double pres, G4bool isotopes = true);
203 
204   // Construct an ideal gas G4Material from scratch by atom count
205   //
206   inline G4Material* ConstructNewIdealGasMaterial(const G4String& name,
207     const std::vector<G4String>& elm, const std::vector<G4int>& nbAtoms, G4bool isotopes = true,
208     G4double temp = NTP_Temperature, G4double pressure = CLHEP::STP_Pressure);
209 
210   // enable/disable density effect calculator by material name
211   //
212   void SetDensityEffectCalculatorFlag(const G4String&, G4bool);
213 
214   // enable/disable density effect calculator by material pointer
215   //
216   void SetDensityEffectCalculatorFlag(G4Material*, G4bool);
217 
218   // Get number of G4Materials
219   //
220   inline std::size_t GetNumberOfMaterials() const;
221 
222   inline G4int GetVerbose() const;
223 
224   void SetVerbose(G4int);
225 
226   // Print G4Material by name
227   //
228   void PrintG4Material(const G4String&) const;
229 
230   // Print predefined Geant4 materials:
231   // "simple" - only pure materials in basic state (Z = 1, ..., 98)
232   // "compound" - NIST compounds
233   // "hep" - HEP materials and compounds
234   // "bio" - bio-medical materials and compounds
235   // "all" - all
236   //
237   inline void ListMaterials(const G4String&) const;
238 
239   // Access to the list of names of Geant4 predefined materials
240   //
241   inline const std::vector<G4String>& GetNistMaterialNames() const;
242 
243   // Fast computation of Z^1/3
244   //
245   inline G4double GetZ13(G4double Z) const;
246   inline G4double GetZ13(G4int Z) const;
247 
248   // Fast computation of A^0.27 for natuaral abundances
249   //
250   inline G4double GetA27(G4int Z) const;
251 
252   // Fast computation of log(A)
253   //
254   inline G4double GetLOGZ(G4int Z) const;
255   inline G4double GetLOGAMU(G4int Z) const;
256 
257   G4ICRU90StoppingData* GetICRU90StoppingData();
258 
259  private:
260   G4NistManager();
261 
262   std::vector<G4Element*> elements;
263   std::vector<G4Material*> materials;
264 
265   G4ICRU90StoppingData* fICRU90;
266   G4NistElementBuilder* elmBuilder;
267   G4NistMaterialBuilder* matBuilder;
268   G4NistMessenger* messenger;
269   G4Pow* g4pow;
270   const G4MaterialTable* theMaterialTable;
271   const G4ElementTable* theElementTable;
272   const G4IsotopeTable* theIsotopeTable;
273 
274   G4double POWERA27[101];
275   G4double LOGAZ[101];
276 
277   std::size_t nElements;
278   std::size_t nMaterials;
279   G4int verbose;
280 };
281 
282 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
283 
284 inline std::size_t G4NistManager::GetNumberOfMaterials() const { return nMaterials; }
285 
286 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
287 
288 inline G4Element* G4NistManager::GetElement(std::size_t index) const
289 {
290   return (index < theElementTable->size()) ? (*theElementTable)[index] : nullptr;
291 }
292 
293 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
294 
295 inline G4Element* G4NistManager::FindElement(G4int Z) const { return elmBuilder->FindElement(Z); }
296 
297 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
298 
299 inline G4Element* G4NistManager::FindOrBuildElement(G4int Z, G4bool isotopes)
300 {
301   return elmBuilder->FindOrBuildElement(Z, isotopes);
302 }
303 
304 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
305 
306 inline G4Element* G4NistManager::FindOrBuildElement(const G4String& symb, G4bool isotopes)
307 {
308   return elmBuilder->FindOrBuildElement(symb, isotopes);
309 }
310 
311 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
312 
313 inline std::size_t G4NistManager::GetNumberOfElements() const { return nElements; }
314 
315 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
316 
317 inline G4int G4NistManager::GetZ(const G4String& symb) const { return elmBuilder->GetZ(symb); }
318 
319 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
320 
321 inline G4double G4NistManager::GetAtomicMassAmu(const G4String& symb) const
322 {
323   return elmBuilder->GetAtomicMassAmu(symb);
324 }
325 
326 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
327 
328 inline G4double G4NistManager::GetAtomicMassAmu(G4int Z) const
329 {
330   return elmBuilder->GetAtomicMassAmu(Z);
331 }
332 
333 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
334 
335 inline G4double G4NistManager::GetIsotopeMass(G4int Z, G4int N) const
336 {
337   return elmBuilder->GetIsotopeMass(Z, N);
338 }
339 
340 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
341 
342 inline G4double G4NistManager::GetAtomicMass(G4int Z, G4int N) const
343 {
344   return elmBuilder->GetAtomicMass(Z, N);
345 }
346 
347 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
348 
349 inline G4double G4NistManager::GetTotalElectronBindingEnergy(G4int Z) const
350 {
351   return elmBuilder->GetTotalElectronBindingEnergy(Z);
352 }
353 
354 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
355 
356 inline G4double G4NistManager::GetIsotopeAbundance(G4int Z, G4int N) const
357 {
358   return elmBuilder->GetIsotopeAbundance(Z, N);
359 }
360 
361 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
362 
363 inline G4int G4NistManager::GetNistFirstIsotopeN(G4int Z) const
364 {
365   return elmBuilder->GetNistFirstIsotopeN(Z);
366 }
367 
368 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
369 
370 inline G4int G4NistManager::GetNumberOfNistIsotopes(G4int Z) const
371 {
372   return elmBuilder->GetNumberOfNistIsotopes(Z);
373 }
374 
375 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
376 
377 inline const std::vector<G4String>& G4NistManager::GetNistElementNames() const
378 {
379   return elmBuilder->GetElementNames();
380 }
381 
382 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
383 
384 inline G4double G4NistManager::GetMeanIonisationEnergy(G4int Z) const
385 {
386   return matBuilder->GetMeanIonisationEnergy(Z);
387 }
388 
389 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
390 
391 inline G4double G4NistManager::GetNominalDensity(G4int Z) const
392 {
393   return matBuilder->GetNominalDensity(Z);
394 }
395 
396 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
397 
398 inline void G4NistManager::PrintElement(G4int Z) const { elmBuilder->PrintElement(Z); }
399 
400 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
401 
402 inline G4Material* G4NistManager::GetMaterial(std::size_t index) const
403 {
404   return (index < theMaterialTable->size()) ? (*theMaterialTable)[index] : nullptr;
405 }
406 
407 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
408 
409 inline G4int G4NistManager::GetVerbose() const { return verbose; }
410 
411 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
412 
413 inline G4Material* G4NistManager::FindMaterial(const G4String& name) const
414 {
415   return matBuilder->FindMaterial(name);
416 }
417 
418 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
419 
420 inline G4Material* G4NistManager::FindOrBuildMaterial(const G4String& name, G4bool, G4bool warning)
421 {
422   return matBuilder->FindOrBuildMaterial(name, warning);
423 }
424 
425 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
426 
427 inline G4Material* G4NistManager::FindSimpleMaterial(G4int Z) const
428 {
429   return matBuilder->FindSimpleMaterial(Z);
430 }
431 
432 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
433 
434 inline G4Material* G4NistManager::FindOrBuildSimpleMaterial(G4int Z, G4bool warning)
435 {
436   return matBuilder->FindOrBuildSimpleMaterial(Z, warning);
437 }
438 
439 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
440 
441 inline G4Material* G4NistManager::ConstructNewMaterial(const G4String& name,
442   const std::vector<G4String>& elm, const std::vector<G4int>& nbAtoms, G4double dens, G4bool,
443   G4State state, G4double T, G4double P)
444 
445 {
446   return matBuilder->ConstructNewMaterial(name, elm, nbAtoms, dens, state, T, P);
447 }
448 
449 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
450 
451 inline G4Material* G4NistManager::ConstructNewMaterial(const G4String& name,
452   const std::vector<G4String>& elm, const std::vector<G4double>& w, G4double dens, G4bool,
453   G4State state, G4double T, G4double P)
454 {
455   return matBuilder->ConstructNewMaterial(name, elm, w, dens, state, T, P);
456 }
457 
458 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
459 
460 inline G4Material* G4NistManager::ConstructNewGasMaterial(
461   const G4String& name, const G4String& nameNist, G4double temp, G4double pres, G4bool)
462 {
463   return matBuilder->ConstructNewGasMaterial(name, nameNist, temp, pres);
464 }
465 
466 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
467 
468 inline G4Material* G4NistManager::ConstructNewIdealGasMaterial(const G4String& name,
469   const std::vector<G4String>& elm, const std::vector<G4int>& nbAtoms, G4bool, G4double T,
470   G4double P)
471 {
472   return matBuilder->ConstructNewIdealGasMaterial(name, elm, nbAtoms, T, P);
473 }
474 
475 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
476 
477 inline void G4NistManager::ListMaterials(const G4String& list) const
478 {
479   matBuilder->ListMaterials(list);
480 }
481 
482 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
483 
484 inline const std::vector<G4String>& G4NistManager::GetNistMaterialNames() const
485 {
486   return matBuilder->GetMaterialNames();
487 }
488 
489 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
490 
491 inline G4double G4NistManager::GetZ13(G4double A) const { return g4pow->A13(A); }
492 
493 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
494 
495 inline G4double G4NistManager::GetZ13(G4int Z) const { return g4pow->Z13(Z); }
496 
497 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
498 
499 inline G4double G4NistManager::GetA27(G4int Z) const
500 {
501   return (0 <= Z && Z < 101) ? POWERA27[Z] : g4pow->powZ(Z, 0.27);
502 }
503 
504 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
505 
506 inline G4double G4NistManager::GetLOGZ(G4int Z) const { return g4pow->logZ(Z); }
507 
508 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
509 
510 inline G4double G4NistManager::GetLOGAMU(G4int Z) const
511 {
512   return (0 <= Z && Z < 101) ? LOGAZ[Z] : 0.0;
513 }
514 
515 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
516 
517 #endif
518