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 | // $Id: G4NistManager.hh,v 1.23 2008/08/07 10:15:16 vnivanch Exp $ |
---|
27 | // GEANT4 tag $Name: HEAD $ |
---|
28 | // |
---|
29 | // |
---|
30 | // ------------------------------------------------------------------- |
---|
31 | // |
---|
32 | // GEANT4 Class header file |
---|
33 | // |
---|
34 | // File name: G4NistManager |
---|
35 | // |
---|
36 | // Author: Vladimir Ivanchenko |
---|
37 | // |
---|
38 | // Creation date: 23.12.2004 |
---|
39 | // |
---|
40 | // Modifications: |
---|
41 | // 27.02.06 V.Ivanchneko add GetAtomicMassAmu and ConstructNewGasMaterial |
---|
42 | // 11.05.06 V.Ivanchneko add warning flag to FindMaterial method |
---|
43 | // 17.10.06 V.Ivanchneko add methods: GetAtomicMass, GetNistElementNames, |
---|
44 | // GetNistMaterialNames |
---|
45 | // 02.05.07 V.Ivanchneko add GetNistFirstIsotopeN and GetNumberOfNistIsotopes |
---|
46 | // 28.07.07 V.Ivanchneko make simple methods inline |
---|
47 | // 28.10.07 V.Ivanchneko add state, T, P to maetrial build |
---|
48 | // |
---|
49 | // Class Description: |
---|
50 | // |
---|
51 | // A utility static class |
---|
52 | // |
---|
53 | |
---|
54 | // ------------------------------------------------------------------- |
---|
55 | // |
---|
56 | // Class Description: |
---|
57 | // |
---|
58 | // Element data from the NIST DB on Atomic Weights and Isotope Compositions |
---|
59 | // http://physics.nist.gov/PhysRefData/Compositions/index.html |
---|
60 | // |
---|
61 | // ------------------------------------------------------------------- |
---|
62 | // |
---|
63 | |
---|
64 | #ifndef G4NistManager_h |
---|
65 | #define G4NistManager_h 1 |
---|
66 | |
---|
67 | #include <vector> |
---|
68 | #include "globals.hh" |
---|
69 | #include "G4Material.hh" |
---|
70 | #include "G4NistElementBuilder.hh" |
---|
71 | #include "G4NistMaterialBuilder.hh" |
---|
72 | |
---|
73 | class G4NistMessenger; |
---|
74 | |
---|
75 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
76 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
77 | |
---|
78 | class G4NistManager |
---|
79 | { |
---|
80 | |
---|
81 | public: |
---|
82 | |
---|
83 | static G4NistManager* Instance(); |
---|
84 | ~G4NistManager(); |
---|
85 | |
---|
86 | // Get G4Element by index |
---|
87 | // |
---|
88 | inline G4Element* GetElement(size_t index); |
---|
89 | |
---|
90 | // Find or build G4Element by atomic number |
---|
91 | // |
---|
92 | inline G4Element* FindOrBuildElement(G4int Z, G4bool isotopes=true); |
---|
93 | |
---|
94 | // Find or build G4Element by symbol |
---|
95 | // |
---|
96 | inline G4Element* FindOrBuildElement(const G4String& symb, |
---|
97 | G4bool isotopes=true); |
---|
98 | |
---|
99 | // Get number of elements |
---|
100 | // |
---|
101 | inline size_t GetNumberOfElements() const; |
---|
102 | |
---|
103 | // Get atomic number by element symbol |
---|
104 | // |
---|
105 | inline G4int GetZ(const G4String& symb) const; |
---|
106 | |
---|
107 | // Get the mass of the element in amu for the natuaral isotope composition |
---|
108 | // with electron shell |
---|
109 | // |
---|
110 | inline G4double GetAtomicMassAmu(G4int Z) const; |
---|
111 | |
---|
112 | // Get mass of the isotope in Geant4 units without electron shell |
---|
113 | // |
---|
114 | inline G4double GetIsotopeMass(G4int Z, G4int N) const; |
---|
115 | |
---|
116 | // Get mass of the isotope in Geant4 units with electron shell |
---|
117 | // |
---|
118 | inline G4double GetAtomicMass(G4int Z, G4int N) const; |
---|
119 | |
---|
120 | // Get total ionisation energy of an atom |
---|
121 | // |
---|
122 | inline G4double GetTotalElectronBindingEnergy(G4int Z) const; |
---|
123 | |
---|
124 | // Get N for the first natural isotope |
---|
125 | // |
---|
126 | inline G4int GetNistFirstIsotopeN(G4int Z) const; |
---|
127 | |
---|
128 | // Get number of natural isotopes |
---|
129 | // |
---|
130 | inline G4int GetNumberOfNistIsotopes(G4int Z) const; |
---|
131 | |
---|
132 | // Get natural isotope abandance |
---|
133 | // |
---|
134 | inline G4double GetIsotopeAbundance(G4int Z, G4int N) const; |
---|
135 | |
---|
136 | // Print element by Z |
---|
137 | // |
---|
138 | inline void PrintElement(G4int Z); |
---|
139 | |
---|
140 | // Print element from internal DB by symbol, if "all" - print all elements |
---|
141 | // |
---|
142 | void PrintElement(const G4String&); |
---|
143 | |
---|
144 | // Print G4Element by name, if "all" - print all G4Elements |
---|
145 | // |
---|
146 | void PrintG4Element(const G4String&); |
---|
147 | |
---|
148 | // Access to the vector of Geant4 predefined element names |
---|
149 | // |
---|
150 | inline const std::vector<G4String>& GetNistElementNames() const; |
---|
151 | |
---|
152 | // Get G4Material by index |
---|
153 | // |
---|
154 | inline G4Material* GetMaterial(size_t index); |
---|
155 | |
---|
156 | // Find or build a G4Material by name, from the Geant4 dataBase |
---|
157 | // |
---|
158 | inline G4Material* FindOrBuildMaterial(const G4String& name, |
---|
159 | G4bool isotopes=true, |
---|
160 | G4bool warning=false); |
---|
161 | |
---|
162 | // Construct a G4Material from scratch by atome count |
---|
163 | // |
---|
164 | inline G4Material* ConstructNewMaterial( |
---|
165 | const G4String& name, |
---|
166 | const std::vector<G4String>& elm, |
---|
167 | const std::vector<G4int>& nbAtoms, |
---|
168 | G4double dens, |
---|
169 | G4bool isotopes=true, |
---|
170 | G4State state = kStateSolid, |
---|
171 | G4double temp = STP_Temperature, |
---|
172 | G4double pressure = STP_Pressure); |
---|
173 | |
---|
174 | // Construct a G4Material from scratch by fraction mass |
---|
175 | // |
---|
176 | inline G4Material* ConstructNewMaterial( |
---|
177 | const G4String& name, |
---|
178 | const std::vector<G4String>& elm, |
---|
179 | const std::vector<G4double>& weight, |
---|
180 | G4double dens, |
---|
181 | G4bool isotopes=true, |
---|
182 | G4State state = kStateSolid, |
---|
183 | G4double temp = STP_Temperature, |
---|
184 | G4double pressure = STP_Pressure); |
---|
185 | |
---|
186 | // Construct a gas G4Material from scratch by atome count |
---|
187 | // |
---|
188 | inline G4Material* ConstructNewGasMaterial(const G4String& name, |
---|
189 | const G4String& nameNist, |
---|
190 | G4double temp, |
---|
191 | G4double pres, |
---|
192 | G4bool isotopes=true); |
---|
193 | |
---|
194 | // Get number of G4Materials |
---|
195 | // |
---|
196 | inline size_t GetNumberOfMaterials(); |
---|
197 | |
---|
198 | inline G4int GetVerbose(); |
---|
199 | |
---|
200 | void SetVerbose(G4int); |
---|
201 | |
---|
202 | // Print G4Material by name |
---|
203 | // |
---|
204 | void PrintG4Material(const G4String&); |
---|
205 | |
---|
206 | // Print predefined Geant4 materials: |
---|
207 | // "simple" - only pure materials in basic state (Z = 1, ..., 98) |
---|
208 | // "compound" - NIST compounds |
---|
209 | // "hep" - HEP materials and compounds |
---|
210 | // "all" - all |
---|
211 | // |
---|
212 | inline void ListMaterials(const G4String&); |
---|
213 | |
---|
214 | // Access to the list of names of Geant4 predefined materials |
---|
215 | // |
---|
216 | inline const std::vector<G4String>& GetNistMaterialNames() const; |
---|
217 | |
---|
218 | // Fast computation of Z^1/3 |
---|
219 | // |
---|
220 | inline G4double GetZ13(G4double Z); |
---|
221 | inline G4double GetZ13(G4int Z); |
---|
222 | |
---|
223 | // Fast computation of A^0.27 for natuaral abandances |
---|
224 | // |
---|
225 | inline G4double GetA27(G4int Z); |
---|
226 | |
---|
227 | // Fast computation of log(A) |
---|
228 | // |
---|
229 | inline G4double GetLOGA(G4double A); |
---|
230 | inline G4double GetLOGZ(G4int Z); |
---|
231 | |
---|
232 | // Fast computation of log(A) for natuaral abandances |
---|
233 | // |
---|
234 | inline G4double GetLOGA(G4int Z); |
---|
235 | |
---|
236 | private: |
---|
237 | |
---|
238 | G4NistManager(); |
---|
239 | static G4NistManager* instance; |
---|
240 | |
---|
241 | G4double POWERZ13[256]; |
---|
242 | G4double LOGA[256]; |
---|
243 | G4double POWERA27[101]; |
---|
244 | G4double LOGAZ[101]; |
---|
245 | |
---|
246 | std::vector<G4Element*> elements; |
---|
247 | std::vector<G4Material*> materials; |
---|
248 | |
---|
249 | size_t nElements; |
---|
250 | size_t nMaterials; |
---|
251 | |
---|
252 | G4int verbose; |
---|
253 | |
---|
254 | G4NistElementBuilder* elmBuilder; |
---|
255 | G4NistMaterialBuilder* matBuilder; |
---|
256 | G4NistMessenger* messenger; |
---|
257 | |
---|
258 | }; |
---|
259 | |
---|
260 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
261 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
262 | |
---|
263 | inline size_t G4NistManager::GetNumberOfMaterials() |
---|
264 | { |
---|
265 | return nMaterials; |
---|
266 | } |
---|
267 | |
---|
268 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
269 | |
---|
270 | inline G4Element* G4NistManager::GetElement(size_t index) |
---|
271 | { |
---|
272 | G4Element* elm = 0; |
---|
273 | const G4ElementTable* theElementTable = G4Element::GetElementTable(); |
---|
274 | if(index < theElementTable->size()) elm = (*theElementTable)[index]; |
---|
275 | return elm; |
---|
276 | } |
---|
277 | |
---|
278 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
279 | |
---|
280 | inline |
---|
281 | G4Element* G4NistManager::FindOrBuildElement(G4int Z, G4bool isotopes) |
---|
282 | { |
---|
283 | return elmBuilder->FindOrBuildElement(Z, isotopes); |
---|
284 | } |
---|
285 | |
---|
286 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
287 | |
---|
288 | inline |
---|
289 | G4Element* G4NistManager::FindOrBuildElement(const G4String& symb, |
---|
290 | G4bool isotopes) |
---|
291 | { |
---|
292 | return elmBuilder->FindOrBuildElement(symb, isotopes); |
---|
293 | } |
---|
294 | |
---|
295 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
296 | |
---|
297 | inline size_t G4NistManager::GetNumberOfElements() const |
---|
298 | { |
---|
299 | return nElements; |
---|
300 | } |
---|
301 | |
---|
302 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
303 | |
---|
304 | inline G4int G4NistManager::GetZ(const G4String& symb) const |
---|
305 | { |
---|
306 | return elmBuilder->GetZ(symb); |
---|
307 | } |
---|
308 | |
---|
309 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
310 | |
---|
311 | inline G4double G4NistManager::GetAtomicMassAmu(G4int Z) const |
---|
312 | { |
---|
313 | return elmBuilder->GetA(Z); |
---|
314 | } |
---|
315 | |
---|
316 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
317 | |
---|
318 | inline |
---|
319 | G4double G4NistManager::GetIsotopeMass(G4int Z, G4int N) const |
---|
320 | { |
---|
321 | return elmBuilder->GetIsotopeMass(Z, N); |
---|
322 | } |
---|
323 | |
---|
324 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
325 | |
---|
326 | inline |
---|
327 | G4double G4NistManager::GetAtomicMass(G4int Z, G4int N) const |
---|
328 | { |
---|
329 | return elmBuilder->GetAtomicMass(Z, N); |
---|
330 | } |
---|
331 | |
---|
332 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
333 | |
---|
334 | inline |
---|
335 | G4double G4NistManager::GetTotalElectronBindingEnergy(G4int Z) const |
---|
336 | { |
---|
337 | return elmBuilder->GetTotalElectronBindingEnergy(Z); |
---|
338 | } |
---|
339 | |
---|
340 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
341 | |
---|
342 | inline |
---|
343 | G4double G4NistManager::GetIsotopeAbundance(G4int Z, G4int N) const |
---|
344 | { |
---|
345 | return elmBuilder->GetIsotopeAbundance(Z, N); |
---|
346 | } |
---|
347 | |
---|
348 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
349 | |
---|
350 | inline |
---|
351 | G4int G4NistManager::GetNistFirstIsotopeN(G4int Z) const |
---|
352 | { |
---|
353 | return elmBuilder->GetNistFirstIsotopeN(Z); |
---|
354 | } |
---|
355 | |
---|
356 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
357 | |
---|
358 | inline |
---|
359 | G4int G4NistManager::GetNumberOfNistIsotopes(G4int Z) const |
---|
360 | { |
---|
361 | return elmBuilder->GetNumberOfNistIsotopes(Z); |
---|
362 | } |
---|
363 | |
---|
364 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
365 | |
---|
366 | inline |
---|
367 | const std::vector<G4String>& G4NistManager::GetNistElementNames() const |
---|
368 | { |
---|
369 | return elmBuilder->GetElementNames(); |
---|
370 | } |
---|
371 | |
---|
372 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
373 | |
---|
374 | inline void G4NistManager::PrintElement(G4int Z) |
---|
375 | { |
---|
376 | elmBuilder->PrintElement(Z); |
---|
377 | } |
---|
378 | |
---|
379 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
380 | |
---|
381 | inline G4Material* G4NistManager::GetMaterial(size_t index) |
---|
382 | { |
---|
383 | const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable(); |
---|
384 | G4Material* mat = 0; |
---|
385 | if(index < theMaterialTable->size()) mat = (*theMaterialTable)[index]; |
---|
386 | return mat; |
---|
387 | } |
---|
388 | |
---|
389 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
390 | |
---|
391 | inline G4int G4NistManager::GetVerbose() |
---|
392 | { |
---|
393 | return verbose; |
---|
394 | } |
---|
395 | |
---|
396 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
397 | |
---|
398 | inline |
---|
399 | G4Material* G4NistManager::FindOrBuildMaterial(const G4String& name, |
---|
400 | G4bool isotopes, |
---|
401 | G4bool warning) |
---|
402 | { |
---|
403 | return matBuilder->FindOrBuildMaterial(name, isotopes, warning); |
---|
404 | } |
---|
405 | |
---|
406 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
407 | |
---|
408 | inline G4Material* G4NistManager::ConstructNewMaterial( |
---|
409 | const G4String& name, |
---|
410 | const std::vector<G4String>& elm, |
---|
411 | const std::vector<G4int>& nbAtoms, |
---|
412 | G4double dens, |
---|
413 | G4bool isotopes, |
---|
414 | G4State state, |
---|
415 | G4double T, |
---|
416 | G4double P) |
---|
417 | |
---|
418 | { |
---|
419 | return |
---|
420 | matBuilder->ConstructNewMaterial(name,elm,nbAtoms,dens,isotopes,state,T,P); |
---|
421 | } |
---|
422 | |
---|
423 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
424 | |
---|
425 | inline G4Material* G4NistManager::ConstructNewMaterial( |
---|
426 | const G4String& name, |
---|
427 | const std::vector<G4String>& elm, |
---|
428 | const std::vector<G4double>& w, |
---|
429 | G4double dens, |
---|
430 | G4bool isotopes, |
---|
431 | G4State state, |
---|
432 | G4double T, |
---|
433 | G4double P) |
---|
434 | { |
---|
435 | return matBuilder->ConstructNewMaterial(name,elm,w,dens,isotopes,state,T,P); |
---|
436 | } |
---|
437 | |
---|
438 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
439 | |
---|
440 | inline G4Material* G4NistManager::ConstructNewGasMaterial( |
---|
441 | const G4String& name, |
---|
442 | const G4String& nameNist, |
---|
443 | G4double temp, G4double pres, |
---|
444 | G4bool isotopes) |
---|
445 | { |
---|
446 | return matBuilder->ConstructNewGasMaterial(name,nameNist, |
---|
447 | temp,pres,isotopes); |
---|
448 | } |
---|
449 | |
---|
450 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
451 | |
---|
452 | inline void G4NistManager::ListMaterials(const G4String& list) |
---|
453 | { |
---|
454 | matBuilder->ListMaterials(list); |
---|
455 | } |
---|
456 | |
---|
457 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
458 | |
---|
459 | inline |
---|
460 | const std::vector<G4String>& G4NistManager::GetNistMaterialNames() const |
---|
461 | { |
---|
462 | return matBuilder->GetMaterialNames(); |
---|
463 | } |
---|
464 | |
---|
465 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
466 | |
---|
467 | inline G4double G4NistManager::GetZ13(G4double Z) |
---|
468 | { |
---|
469 | G4int iz = G4int(Z); |
---|
470 | G4double x = (Z - G4double(iz))/(3.0*Z); |
---|
471 | if(iz > 255) iz = 255; |
---|
472 | else if(iz < 0) iz = 0; |
---|
473 | return POWERZ13[iz]*(1.0 + x); |
---|
474 | } |
---|
475 | |
---|
476 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
477 | |
---|
478 | inline G4double G4NistManager::GetZ13(G4int Z) |
---|
479 | { |
---|
480 | return POWERZ13[Z]; |
---|
481 | } |
---|
482 | |
---|
483 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
484 | |
---|
485 | inline G4double G4NistManager::GetA27(G4int Z) |
---|
486 | { |
---|
487 | G4double res = 0.0; |
---|
488 | if(Z < 101) res = POWERA27[Z]; |
---|
489 | return res; |
---|
490 | } |
---|
491 | |
---|
492 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
493 | |
---|
494 | inline G4double G4NistManager::GetLOGZ(G4int Z) |
---|
495 | { |
---|
496 | G4double res = 0.0; |
---|
497 | if(Z < 256) res = LOGA[Z]; |
---|
498 | return res; |
---|
499 | } |
---|
500 | |
---|
501 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
502 | |
---|
503 | inline G4double G4NistManager::GetLOGA(G4double A) |
---|
504 | { |
---|
505 | G4int ia = G4int(A); |
---|
506 | G4double x = (A - G4double(ia))/A; |
---|
507 | if(ia > 255) ia = 255; |
---|
508 | else if(ia < 0) ia = 0; |
---|
509 | return LOGA[ia] + x*(1.0 - 0.5*x); |
---|
510 | } |
---|
511 | |
---|
512 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
513 | |
---|
514 | inline G4double G4NistManager::GetLOGA(G4int Z) |
---|
515 | { |
---|
516 | G4double res = 0.0; |
---|
517 | if(Z < 101) res = LOGAZ[Z]; |
---|
518 | return res; |
---|
519 | } |
---|
520 | |
---|
521 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
522 | |
---|
523 | #endif |
---|
524 | |
---|