Geant4 11.2.2
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#include "G4NistManager.hh"
46#include "G4AutoLock.hh"
47#include "G4Isotope.hh"
48#include "G4NistMessenger.hh"
49
50G4NistManager* G4NistManager::instance = nullptr;
51
52namespace
53{
54G4Mutex nistManagerMutex = G4MUTEX_INITIALIZER;
55}
56
57//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
58
60{
61 if (instance == nullptr) {
62 G4AutoLock l(&nistManagerMutex);
63 if (instance == nullptr) {
64 static G4NistManager manager;
65 instance = &manager;
66 }
67 l.unlock();
68 }
69 return instance;
70}
71
72//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
73
75{
76 const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
77 for (auto const & mat : *theMaterialTable) { delete mat; }
78 const G4ElementTable* theElementTable = G4Element::GetElementTable();
79 for (auto const & elm : *theElementTable) { delete elm; }
80 const G4IsotopeTable* theIsotopeTable = G4Isotope::GetIsotopeTable();
81 for (auto const & iso : *theIsotopeTable) { delete iso; }
82
83 delete messenger;
84 delete matBuilder;
85 delete elmBuilder;
86 delete fICRU90;
87}
88
89//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
90
92 const G4String& basename, G4double density, G4double temperature, G4double pressure)
93{
94 G4Material* bmat = FindOrBuildMaterial(name);
95 if (bmat != nullptr) {
96 G4cout << "G4NistManager::BuildMaterialWithNewDensity ERROR: " << G4endl;
97 G4cout << " New material <" << name << "> cannot be built because material"
98 << " with the same name already exists." << G4endl;
99 G4Exception("G4NistManager::BuildMaterialWithNewDensity()", "mat101", FatalException,
100 "Wrong material name");
101 return nullptr;
102 }
103 bmat = FindOrBuildMaterial(basename);
104 if (bmat == nullptr) {
105 G4cout << "G4NistManager::BuildMaterialWithNewDensity ERROR: " << G4endl;
106 G4cout << " New material <" << name << "> cannot be built because " << G4endl;
107 G4cout << " base material <" << basename << "> does not exist." << G4endl;
108 G4Exception("G4NistManager::BuildMaterialWithNewDensity()", "mat102", FatalException,
109 "Wrong material name");
110 return nullptr;
111 }
112 G4double dens = density;
113 G4double temp = temperature;
114 G4double pres = pressure;
115 if (dens == 0.0) {
116 dens = bmat->GetDensity();
117 temp = bmat->GetTemperature();
118 pres = bmat->GetPressure();
119 }
120 auto mat = new G4Material(name, dens, bmat, bmat->GetState(), temp, pres);
121 return mat;
122}
123
124//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
125
126void G4NistManager::PrintElement(const G4String& symbol) const
127{
128 if (symbol == "all") {
129 elmBuilder->PrintElement(0);
130 }
131 else {
132 elmBuilder->PrintElement(elmBuilder->GetZ(symbol));
133 }
134}
135
136//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
137
139{
140 for (auto const & elm : *G4Element::GetElementTable()) {
141 if (name == elm->GetName() || "all" == name) {
142 G4cout << *elm << G4endl;
143 }
144 }
145}
146
147//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
148
150{
151 for (auto const & mat : *G4Material::GetMaterialTable()) {
152 if (name == mat->GetName() || "all" == name) {
153 G4cout << *mat << G4endl;
154 }
155 }
156}
157
158//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
159
161{
162 verbose = val;
163 elmBuilder->SetVerbose(val);
164 matBuilder->SetVerbose(val);
165}
166
167//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
168
169G4NistManager::G4NistManager()
170{
171 nElements = 0;
172 nMaterials = 0;
173 verbose = 0;
174
175 elmBuilder = new G4NistElementBuilder(verbose);
176 matBuilder = new G4NistMaterialBuilder(elmBuilder, verbose);
177
178 messenger = new G4NistMessenger(this);
179 g4pow = G4Pow::GetInstance();
180
181 // compute frequently used values for mean atomic numbers
182 for (G4int j = 1; j < 101; ++j) {
183 G4double A = elmBuilder->GetAtomicMassAmu(j);
184 POWERA27[j] = std::pow(A, 0.27);
185 LOGAZ[j] = std::log(A);
186 }
187 POWERA27[0] = 1.0;
188 LOGAZ[0] = 0.0;
189 fICRU90 = nullptr;
190}
191
192//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
193
195{
196 if (fICRU90 == nullptr) {
197 G4AutoLock l(&nistManagerMutex);
198 if (fICRU90 == nullptr) {
199 fICRU90 = new G4ICRU90StoppingData();
200 }
201 l.unlock();
202 }
203 return fICRU90;
204}
205
206//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
207
209{
210 if (mname == "all") {
211 for (auto mat : materials) {
213 }
214 }
215 else {
216 G4Material* mat = FindMaterial(mname);
218 }
219}
220
221//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
222
224{
225 if (mat != nullptr) {
227 }
228}
std::vector< G4Element * > G4ElementTable
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::vector< G4Isotope * > G4IsotopeTable
Definition G4Isotope.hh:59
std::vector< G4Material * > G4MaterialTable
#define G4MUTEX_INITIALIZER
std::mutex G4Mutex
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:67
G4GLOB_DLL std::ostream G4cout
static G4ElementTable * GetElementTable()
Definition G4Element.cc:389
static const G4IsotopeTable * GetIsotopeTable()
Definition G4Isotope.cc:132
G4double GetPressure() const
G4double GetDensity() const
void ComputeDensityEffectOnFly(G4bool val)
G4State GetState() const
G4double GetTemperature() const
static G4MaterialTable * GetMaterialTable()
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