Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4NistMaterialBuilder.hh
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 // $Id: G4NistMaterialBuilder.hh 97248 2016-05-30 15:00:11Z gcosmo $
27 
28 #ifndef G4NistMaterialBuilder_h
29 #define G4NistMaterialBuilder_h 1
30 
31 //---------------------------------------------------------------------------
32 //
33 // ClassName: G4NistMaterialBuilder
34 //
35 // Description: Utility class to hold and manipulate G4Materials
36 //
37 // Author: V.Ivanchenko 21.11.2004
38 //
39 // Modifications:
40 // 31.10.05 Add chemical effect and gas properties (V.Ivanchenko)
41 // 27.02.06 V.Ivanchneko add ConstructNewGasMaterial
42 // 11.05.06 V.Ivanchneko add warning flag to FindOrBuildMaterial method
43 // 27.07.06 V.Ivanchneko set defaul warning=true for FindOrBuildMaterial
44 // 27.07.07 V.Ivanchneko add matIndex vector to control built materials
45 // 28.07.07 V.Ivanchneko add BuildMaterial method using Nist index
46 // 29.04.10 V.Ivanchneko add GetMeanIonisationEnergy method using Nist index
47 // 09.02.12 P.Gumplinger add ConstructNewIdealGasMaterial
48 //
49 //----------------------------------------------------------------------------
50 //
51 // Class Description:
52 //
53 // Element data from the NIST DB on Atomic Weights and Isotope Compositions
54 // http://physics.nist.gov/PhysRefData/Compositions/index.html
55 //
56 
57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
58 
59 #include <vector>
61 
62 #include "globals.hh"
63 #include "G4Material.hh"
64 #include "G4Threading.hh"
65 
66 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
67 
69 
71 {
72 public:
73 
75 
77 
78  // Find or build a G4Material by name, from dataBase
79  //
80  inline G4Material* FindMaterial (const G4String& name) const;
82  G4bool isotopes=true,
83  G4bool warning =true);
84 
85 
86  // Find or build a simple material via atomic number
87  //
88  inline G4Material* FindSimpleMaterial(G4int Z) const;
90 
91  // construct a G4Material from scratch by atome count
92  //
94  const std::vector<G4String>& elm,
95  const std::vector<G4int>& nbAtoms,
96  G4double dens,
97  G4bool isotopes = true,
98  G4State state = kStateSolid,
99  G4double temp = NTP_Temperature,
100  G4double pressure = CLHEP::STP_Pressure);
101 
102  // construct a G4Material from scratch by fraction mass
103  //
105  const std::vector<G4String>& elm,
106  const std::vector<G4double>& weight,
107  G4double dens,
108  G4bool isotopes = true,
109  G4State state = kStateSolid,
110  G4double temp = NTP_Temperature,
111  G4double pressure = CLHEP::STP_Pressure);
112 
113 
114  // construct a gas G4Material from scratch by atome count
115  //
117  const G4String& nameDB,
118  G4double temp, G4double pres,
119  G4bool isotopes = true);
120 
121  // Construct an ideal gas G4Material from scratch by atom count
122  //
124  const std::vector<G4String>& elm,
125  const std::vector<G4int>& nbAtoms,
126  G4bool isotopes = true,
127  G4double temp = NTP_Temperature,
128  G4double pressure = CLHEP::STP_Pressure);
129 
130  // verbosity level defined by G4NistManager
131  //
132  void SetVerbose(G4int val);
133 
134  // cout predefined materials:
135  // "simple" - only pure materials in basic state (Z = 1, ..., 98)
136  // "compound" - NIST compounds
137  // "hep" - HEP materials and compounds
138  // "biochemical" - bio-chemical materials
139  // "all" - all
140  //
141  void ListMaterials(const G4String&) const;
142 
143  // cout lists of predefined materials
144  //
145  void ListNistSimpleMaterials() const;
146  void ListNistCompoundMaterials() const;
147  void ListHepMaterials() const;
148  void ListSpaceMaterials() const;
149  void ListBioChemicalMaterials() const;
150 
151  // access to the list of names of Geant4 predefined materials
152  //
153  const std::vector<G4String>& GetMaterialNames() const;
154 
155  // access to the NIST mean ionisation potentials and nominal densities
156  //
157  inline G4double GetMeanIonisationEnergy(G4int index) const;
158  inline G4double GetNominalDensity(G4int index) const;
159 
160 private:
161 
162  void Initialise();
163  void NistSimpleMaterials();
164  void NistCompoundMaterials();
165  void NistCompoundMaterials2();
166  void HepAndNuclearMaterials();
167  void SpaceMaterials();
168  void BioChemicalMaterials();
169 
170  // add parameters of material from NIST DB to internal vectors
171  // density in g/cm3, mean ionisation potential in eV
172  //
173  void AddMaterial(const G4String& nameMat, G4double dens, G4int Z=0,
174  G4double pot=0.0, G4int ncomp=1,
175  G4State=kStateSolid, G4bool stp = true);
176 
177  void AddGas(const G4String& nameMat, G4double t=NTP_Temperature,
179 
180  void AddElementByWeightFraction(G4int Z, G4double);
181  void AddElementByAtomCount (G4int Z, G4int);
182 
183  void AddElementByWeightFraction(const G4String& name, G4double);
184  void AddElementByAtomCount (const G4String& name, G4int);
185 
186  // build a G4Material from dataBase
187  G4Material* BuildNistMaterial(const G4String& matname, G4bool warning);
188  G4Material* BuildMaterial(G4int idx);
189 
190  void DumpElm(G4int) const;
191  void DumpMix(G4int) const;
192 
193 private:
194 
195  G4NistElementBuilder* elmBuilder;
196 
197  G4int verbose;
198  G4int nMaterials;
199  G4int nComponents;
200  G4int nCurrent;
201  G4int nElementary;
202  G4int nNIST;
203  G4int nHEP;
204  G4int nSpace;
205 
206  std::vector<G4String> names;
207  std::vector<G4String> chFormulas;
208 
209  std::vector<G4double> densities;
210  std::vector<G4double> ionPotentials;
211  std::vector<G4State> states;
212  std::vector<G4double> fractions;
213  std::vector<G4bool> atomCount;
214  std::vector<G4int> components;
215  std::vector<G4int> indexes;
216  std::vector<G4int> elements;
217  std::vector<G4int> matIndex;
218  std::vector<G4bool> STP;
219 
220  std::vector<G4int> idxGas;
221  std::vector<G4double> gasTemperature;
222  std::vector<G4double> gasPressure;
223 
224 #ifdef G4MULTITHREADED
225  static G4Mutex nistMaterialMutex;
226 #endif
227 
228 };
229 
230 inline const std::vector<G4String>&
232 {
233  return names;
234 }
235 
236 inline G4double
238 {
239  return (index >= 0 && index < nMaterials) ? ionPotentials[index] : 10.0*index;
240 }
241 
242 inline G4double
244 {
245  return (index >= 0 && index < nMaterials) ? densities[index] : 0.0;
246 }
247 
248 inline G4Material*
250 {
251  const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
252  size_t nmat = theMaterialTable->size();
253  G4Material* ptr = nullptr;
254  for(size_t i=0; i<nmat; ++i) {
255  if(name == ((*theMaterialTable)[i])->GetName()) {
256  ptr = (*theMaterialTable)[i];
257  break;
258  }
259  }
260  return ptr;
261 }
262 
263 inline G4Material*
265 {
266  return (Z>0 && Z<nElementary) ? FindMaterial(names[Z]) : nullptr;
267 }
268 
269 #endif
const XML_Char * name
Definition: expat.h:151
G4double GetMeanIonisationEnergy(G4int index) const
void ListBioChemicalMaterials() const
G4State
Definition: G4Material.hh:114
G4double GetNominalDensity(G4int index) const
const char * p
Definition: xmltok.h:285
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:587
std::vector< G4Material * > G4MaterialTable
static constexpr double STP_Pressure
G4Material * ConstructNewMaterial(const G4String &name, const std::vector< G4String > &elm, const std::vector< G4int > &nbAtoms, G4double dens, G4bool isotopes=true, G4State state=kStateSolid, G4double temp=NTP_Temperature, G4double pressure=CLHEP::STP_Pressure)
void ListMaterials(const G4String &) const
int G4int
Definition: G4Types.hh:78
G4Material * ConstructNewGasMaterial(const G4String &name, const G4String &nameDB, G4double temp, G4double pres, G4bool isotopes=true)
G4Material * FindMaterial(const G4String &name) const
G4NistMaterialBuilder(G4NistElementBuilder *, G4int verb=0)
bool G4bool
Definition: G4Types.hh:79
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=true)
void ListNistCompoundMaterials() const
G4int G4Mutex
Definition: G4Threading.hh:173
G4Material * ConstructNewIdealGasMaterial(const G4String &name, const std::vector< G4String > &elm, const std::vector< G4int > &nbAtoms, G4bool isotopes=true, G4double temp=NTP_Temperature, G4double pressure=CLHEP::STP_Pressure)
static const G4double NTP_Temperature
Definition: G4Material.hh:116
G4Material * FindSimpleMaterial(G4int Z) const
const std::vector< G4String > & GetMaterialNames() const
double G4double
Definition: G4Types.hh:76
G4Material * FindOrBuildSimpleMaterial(G4int Z, G4bool warning)