Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4NistManager.cc
Go to the documentation of this file.
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 file
29//
30//
31// File name: G4NistManager
32//
33// Author: Vladimir Ivanchenko
34//
35// Creation date: 23.12.2004
36//
37//
38// -------------------------------------------------------------------
39//
40// Class Description:
41//
42// Element data from the NIST DB on Atomic Weights and Isotope Compositions
43// http://physics.nist.gov/PhysRefData/Compositions/index.html
44//
45//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
46//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
47
48#include "G4NistManager.hh"
49#include "G4NistMessenger.hh"
50#include "G4Isotope.hh"
51#include "G4AutoLock.hh"
52
53G4NistManager* G4NistManager::instance = nullptr;
54
55namespace
56{
57 G4Mutex nistManagerMutex = G4MUTEX_INITIALIZER;
58}
59
60//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
61
63{
64 if (instance == nullptr) {
65 if (instance == nullptr) {
66 static G4NistManager manager;
67 instance = &manager;
68 }
69 }
70 return instance;
71}
72
73//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
74
76{
77 // G4cout << "NistManager: start material destruction" << G4endl;
78 const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
79 size_t nmat = theMaterialTable->size();
80 size_t i;
81 for(i=0; i<nmat; i++) {
82 if((*theMaterialTable)[i] != nullptr)
83 {
84 delete(*theMaterialTable)[i];
85 }
86 }
87 // G4cout << "NistManager: start element destruction" << G4endl;
88 const G4ElementTable* theElementTable = G4Element::GetElementTable();
89 size_t nelm = theElementTable->size();
90 for(i=0; i<nelm; i++) {
91 if((*theElementTable)[i] != nullptr)
92 {
93 delete(*theElementTable)[i];
94 }
95 }
96 // G4cout << "NistManager: start isotope destruction" << G4endl;
97 const G4IsotopeTable* theIsotopeTable = G4Isotope::GetIsotopeTable();
98 size_t niso = theIsotopeTable->size();
99 for(i=0; i<niso; i++) {
100 if((*theIsotopeTable)[i] != nullptr)
101 {
102 delete(*theIsotopeTable)[i];
103 }
104 }
105 // G4cout << "NistManager: end isotope destruction" << G4endl;
106 delete messenger;
107 delete matBuilder;
108 delete elmBuilder;
109 delete fICRU90;
110 // G4cout << "NistManager: end destruction" << G4endl;
111}
112
113//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
114
117 const G4String& basename,
118 G4double density,
119 G4double temperature,
120 G4double pressure)
121{
122 G4Material* bmat = FindOrBuildMaterial(name);
123 if(bmat != nullptr)
124 {
125 G4cout << "G4NistManager::BuildMaterialWithNewDensity ERROR: " << G4endl;
126 G4cout << " New material <" << name << "> cannot be built because material"
127 << " with the same name already exists." << G4endl;
128 G4Exception("G4NistManager::BuildMaterialWithNewDensity()", "mat101",
129 FatalException, "Wrong material name");
130 return nullptr;
131 }
132 bmat = FindOrBuildMaterial(basename);
133 if(bmat == nullptr)
134 {
135 G4cout << "G4NistManager::BuildMaterialWithNewDensity ERROR: " << G4endl;
136 G4cout << " New material <" << name << "> cannot be built because "
137 << G4endl;
138 G4cout << " base material <" << basename << "> does not exist." << G4endl;
139 G4Exception("G4NistManager::BuildMaterialWithNewDensity()", "mat102",
140 FatalException, "Wrong material name");
141 return nullptr;
142 }
143 G4double dens = density;
144 G4double temp = temperature;
145 G4double pres = pressure;
146 if(dens == 0.0) {
147 dens = bmat->GetDensity();
148 temp = bmat->GetTemperature();
149 pres = bmat->GetPressure();
150 }
151 G4Material* mat = new G4Material(name, dens, bmat, bmat->GetState(),
152 temp, pres);
153 return mat;
154}
155
156//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
157
158void G4NistManager::PrintElement(const G4String& symbol) const
159{
160 if (symbol == "all") { elmBuilder->PrintElement(0); }
161 else { elmBuilder->PrintElement(elmBuilder->GetZ(symbol)); }
162}
163
164//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
165
167{
168 const G4ElementTable* theElementTable = G4Element::GetElementTable();
169 size_t nelm = theElementTable->size();
170 for(size_t i=0; i<nelm; i++) {
171 G4Element* elm = (*theElementTable)[i];
172 if ( name == elm->GetName() || "all" == name) {
173 G4cout << *elm << G4endl;
174 }
175 }
176}
177
178//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
179
181{
182 const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
183 size_t nmat = theMaterialTable->size();
184 for(size_t i=0; i<nmat; i++) {
185 G4Material* mat = (*theMaterialTable)[i];
186 if ( name == mat->GetName() || "all" == name) {
187 G4cout << *mat << G4endl;
188 }
189 }
190}
191
192//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
193
195{
196 verbose = val;
197 elmBuilder->SetVerbose(val);
198 matBuilder->SetVerbose(val);
199}
200
201//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
202
203G4NistManager::G4NistManager()
204{
205 nElements = 0;
206 nMaterials = 0;
207 verbose = 0;
208
209 elmBuilder = new G4NistElementBuilder(verbose);
210 matBuilder = new G4NistMaterialBuilder(elmBuilder,verbose);
211
212 messenger = new G4NistMessenger(this);
213 g4pow = G4Pow::GetInstance();
214
215 // compute frequently used values for mean atomic numbers
216 for(G4int j=1; j<101; ++j) {
217 G4double A = elmBuilder->GetAtomicMassAmu(j);
218 POWERA27[j] = std::pow(A,0.27);
219 LOGAZ[j] = std::log(A);
220 }
221 POWERA27[0] = 1.0;
222 LOGAZ[0] = 0.0;
223 fICRU90 = nullptr;
224}
225
226//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
227
229{
230 if(fICRU90 == nullptr)
231 {
232 G4AutoLock l(&nistManagerMutex);
233 if(fICRU90 == nullptr) {
234 fICRU90 = new G4ICRU90StoppingData();
235 }
236 l.unlock();
237 }
238 return fICRU90;
239}
240
241//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
242
244 G4bool val)
245{
246 if(mname == "all") {
247 for(auto mat : materials) {
249 }
250 } else {
251 G4Material* mat = FindMaterial(mname);
253 }
254}
255
256//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
257
259{
260 if(mat != nullptr)
261 {
263 }
264}
265
266//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
std::vector< G4Element * > G4ElementTable
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:59
std::vector< G4Isotope * > G4IsotopeTable
Definition: G4Isotope.hh:67
std::vector< G4Material * > G4MaterialTable
#define G4MUTEX_INITIALIZER
Definition: G4Threading.hh:85
std::mutex G4Mutex
Definition: G4Threading.hh:81
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
const G4double A[17]
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
static G4ElementTable * GetElementTable()
Definition: G4Element.cc:403
const G4String & GetName() const
Definition: G4Element.hh:127
static const G4IsotopeTable * GetIsotopeTable()
Definition: G4Isotope.cc:183
G4double GetPressure() const
Definition: G4Material.hh:178
G4double GetDensity() const
Definition: G4Material.hh:175
G4State GetState() const
Definition: G4Material.hh:176
G4double GetTemperature() const
Definition: G4Material.hh:177
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:677
const G4String & GetName() const
Definition: G4Material.hh:172
void ComputeDensityEffectOnFly(G4bool)
Definition: G4Material.cc:665
G4double GetAtomicMassAmu(const G4String &symb) const
G4int GetZ(const G4String &symb) const
void PrintElement(G4int Z) const
G4ICRU90StoppingData * GetICRU90StoppingData()
void PrintElement(G4int Z) const
void SetDensityEffectCalculatorFlag(const G4String &, G4bool)
G4Material * BuildMaterialWithNewDensity(const G4String &name, const G4String &basename, G4double density=0.0, G4double temp=NTP_Temperature, G4double pres=CLHEP::STP_Pressure)
void PrintG4Material(const G4String &) const
void PrintG4Element(const G4String &) const
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
G4Material * FindMaterial(const G4String &name) const
static G4NistManager * Instance()
void SetVerbose(G4int)
static G4Pow * GetInstance()
Definition: G4Pow.cc:41