Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4NistManager.cc
이 파일의 문서화 페이지로 가기
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.cc 105820 2017-08-22 08:03:26Z gcosmo $
27 //
28 // -------------------------------------------------------------------
29 //
30 // GEANT4 Class file
31 //
32 //
33 // File name: G4NistManager
34 //
35 // Author: Vladimir Ivanchenko
36 //
37 // Creation date: 23.12.2004
38 //
39 // Modifications:
40 // 27.02.06 V.Ivanchneko add ConstructNewGasMaterial
41 // 18.04.06 V.Ivanchneko add combined creation of materials (NIST + user)
42 // 11.05.06 V.Ivanchneko add warning flag to FindMaterial method
43 // 26.07.07 V.Ivanchneko modify destructor to provide complete destruction
44 // of all elements and materials
45 // 27-07-07, improve destructor (V.Ivanchenko)
46 // 28.07.07 V.Ivanchneko make simple methods inline
47 // 28.07.07 V.Ivanchneko simplify Print methods
48 // 26.10.11, new scheme for G4Exception (mma)
49 //
50 // -------------------------------------------------------------------
51 //
52 // Class Description:
53 //
54 // Element data from the NIST DB on Atomic Weights and Isotope Compositions
55 // http://physics.nist.gov/PhysRefData/Compositions/index.html
56 //
57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
59 
60 #include "G4NistManager.hh"
61 #include "G4NistMessenger.hh"
62 #include "G4Isotope.hh"
63 
65 #ifdef G4MULTITHREADED
66  G4Mutex G4NistManager::nistManagerMutex = G4MUTEX_INITIALIZER;
67 #endif
68 
69 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
70 
72 {
73  if (instance == nullptr) {
74 #ifdef G4MULTITHREADED
75  G4MUTEXLOCK(&nistManagerMutex);
76  if (instance == nullptr) {
77 #endif
78  static G4NistManager manager;
79  instance = &manager;
80 #ifdef G4MULTITHREADED
81  }
82  G4MUTEXUNLOCK(&nistManagerMutex);
83 #endif
84  }
85  return instance;
86 }
87 
88 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
89 
91 {
92  // G4cout << "NistManager: start material destruction" << G4endl;
93  const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
94  size_t nmat = theMaterialTable->size();
95  size_t i;
96  for(i=0; i<nmat; i++) {
97  if((*theMaterialTable)[i]) { delete (*theMaterialTable)[i]; }
98  }
99  // G4cout << "NistManager: start element destruction" << G4endl;
100  const G4ElementTable* theElementTable = G4Element::GetElementTable();
101  size_t nelm = theElementTable->size();
102  for(i=0; i<nelm; i++) {
103  if((*theElementTable)[i]) { delete (*theElementTable)[i]; }
104  }
105  // G4cout << "NistManager: start isotope destruction" << G4endl;
106  const G4IsotopeTable* theIsotopeTable = G4Isotope::GetIsotopeTable();
107  size_t niso = theIsotopeTable->size();
108  for(i=0; i<niso; i++) {
109  if((*theIsotopeTable)[i]) { delete (*theIsotopeTable)[i]; }
110  }
111  // G4cout << "NistManager: end isotope destruction" << G4endl;
112  delete messenger;
113  delete matBuilder;
114  delete elmBuilder;
115  // G4cout << "NistManager: end destruction" << G4endl;
116 }
117 
118 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
119 
120 G4Material*
122  const G4String& basename,
123  G4double density,
124  G4double temperature,
125  G4double pressure)
126 {
127  G4Material* bmat = FindOrBuildMaterial(name);
128  if(bmat) {
129  G4cout << "G4NistManager::BuildMaterialWithNewDensity ERROR: " << G4endl;
130  G4cout << " New material <" << name << "> cannot be built because material"
131  << " with the same name already exist" << G4endl;
132  G4Exception("G4NistManager::BuildMaterialWithNewDensity()", "mat101",
133  FatalException, "Wrong material name");
134  return 0;
135  }
136  bmat = FindOrBuildMaterial(basename);
137  if(!bmat) {
138  G4cout << "G4NistManager::BuildMaterialWithNewDensity ERROR: " << G4endl;
139  G4cout << " New material <" << name << "> cannot be built because "
140  << G4endl;
141  G4cout << " base material <" << basename << "> does not exist" << G4endl;
142  G4Exception("G4NistManager::BuildMaterialWithNewDensity()", "mat102",
143  FatalException, "Wrong material name");
144  return 0;
145  }
146  G4double dens = density;
147  G4double temp = temperature;
148  G4double pres = pressure;
149  if(dens == 0.0) {
150  dens = bmat->GetDensity();
151  temp = bmat->GetTemperature();
152  pres = bmat->GetPressure();
153  }
154  G4Material* mat = new G4Material(name, dens, bmat, bmat->GetState(),
155  temp, pres);
156  return mat;
157 }
158 
159 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
160 
161 void G4NistManager::PrintElement(const G4String& symbol) const
162 {
163  if (symbol == "all") { elmBuilder->PrintElement(0); }
164  else { elmBuilder->PrintElement(elmBuilder->GetZ(symbol)); }
165 }
166 
167 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
168 
170 {
171  const G4ElementTable* theElementTable = G4Element::GetElementTable();
172  size_t nelm = theElementTable->size();
173  for(size_t i=0; i<nelm; i++) {
174  G4Element* elm = (*theElementTable)[i];
175  if ( name == elm->GetName() || "all" == name) {
176  G4cout << *elm << G4endl;
177  }
178  }
179 }
180 
181 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
182 
184 {
185  const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
186  size_t nmat = theMaterialTable->size();
187  for(size_t i=0; i<nmat; i++) {
188  G4Material* mat = (*theMaterialTable)[i];
189  if ( name == mat->GetName() || "all" == name) {
190  G4cout << *mat << G4endl;
191  }
192  }
193 }
194 
195 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
196 
198 {
199  verbose = val;
200  elmBuilder->SetVerbose(val);
201  matBuilder->SetVerbose(val);
202 }
203 
204 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
205 
206 #include "G4Threading.hh"
207 
209 {
210  if(G4Threading::IsWorkerThread() == true) {
211  G4Exception ("G4NistMaterial::G4NistManager()", "mat090", FatalException,
212  "Attempt to instantiate G4NistManager in worker thread");
213  }
214 
215  nElements = 0;
216  nMaterials = 0;
217  verbose = 0;
218 
221 
222  messenger = new G4NistMessenger(this);
224 
225  // compute frequently used values for mean atomic numbers
226  for(G4int j=1; j<101; ++j) {
228  POWERA27[j] = std::pow(A,0.27);
229  LOGAZ[j] = std::log(A);
230  }
231  POWERA27[0] = 1.0;
232  LOGAZ[0] = 0.0;
233 }
234 
235 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
const XML_Char * name
Definition: expat.h:151
G4NistElementBuilder * elmBuilder
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:593
G4NistMessenger * messenger
const G4String & GetName() const
Definition: G4Element.hh:127
void PrintElement(G4int Z) const
#define G4endl
Definition: G4ios.hh:61
void PrintG4Element(const G4String &) const
std::vector< G4Isotope * > G4IsotopeTable
Definition: G4Isotope.hh:67
G4Material * BuildMaterialWithNewDensity(const G4String &name, const G4String &basename, G4double density=0.0, G4double temp=NTP_Temperature, G4double pres=CLHEP::STP_Pressure)
const G4String & GetName() const
Definition: G4Material.hh:179
void SetVerbose(G4int)
double G4double
Definition: G4Types.hh:76
#define G4MUTEX_INITIALIZER
Definition: G4Threading.hh:88
static G4Pow * GetInstance()
Definition: G4Pow.cc:57
void PrintG4Material(const G4String &) const
G4State GetState() const
Definition: G4Material.hh:182
G4bool IsWorkerThread()
Definition: G4Threading.cc:129
G4double GetAtomicMassAmu(const G4String &symb) const
G4double LOGAZ[101]
std::vector< G4Element * > G4ElementTable
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
double A(double temperature)
Float_t mat
#define G4MUTEXUNLOCK(mutex)
Definition: G4Threading.hh:234
std::vector< G4Material * > G4MaterialTable
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.hh:65
G4double GetPressure() const
Definition: G4Material.hh:184
int G4int
Definition: G4Types.hh:78
#define G4MUTEXLOCK(mutex)
Definition: G4Threading.hh:233
G4NistMaterialBuilder * matBuilder
G4GLOB_DLL std::ostream G4cout
void PrintElement(G4int Z) const
G4int GetZ(const G4String &symb) const
static G4NistManager * instance
G4double POWERA27[101]
static const G4IsotopeTable * GetIsotopeTable()
Definition: G4Isotope.cc:182
G4double GetTemperature() const
Definition: G4Material.hh:183
static G4NistManager * Instance()
static G4ElementTable * GetElementTable()
Definition: G4Element.cc:398
G4double GetDensity() const
Definition: G4Material.hh:181
std::mutex G4Mutex
Definition: G4Threading.hh:84