Geant4-11
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
27#ifndef G4NistMaterialBuilder_h
28#define G4NistMaterialBuilder_h 1
29
30//---------------------------------------------------------------------------
31//
32// ClassName: G4NistMaterialBuilder
33//
34// Description: Utility class to hold and manipulate G4Materials
35//
36// Author: V.Ivanchenko 21.11.2004
37//
38// Modifications:
39// 31.10.05 Add chemical effect and gas properties (V.Ivanchenko)
40// 27.02.06 V.Ivanchneko add ConstructNewGasMaterial
41// 11.05.06 V.Ivanchneko add warning flag to FindOrBuildMaterial method
42// 27.07.06 V.Ivanchneko set defaul warning=true for FindOrBuildMaterial
43// 27.07.07 V.Ivanchneko add matIndex vector to control built materials
44// 28.07.07 V.Ivanchneko add BuildMaterial method using Nist index
45// 29.04.10 V.Ivanchneko add GetMeanIonisationEnergy method using Nist index
46// 09.02.12 P.Gumplinger add ConstructNewIdealGasMaterial
47//
48//----------------------------------------------------------------------------
49//
50// Class Description:
51//
52// Element data from the NIST DB on Atomic Weights and Isotope Compositions
53// http://physics.nist.gov/PhysRefData/Compositions/index.html
54//
55
56//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
57
58#include <vector>
60
61#include "globals.hh"
62#include "G4Material.hh"
63#include "G4Threading.hh"
64
65//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
66
68
70{
71public:
72
74
76
77 // Find or build a G4Material by name, from dataBase
78 //
79 inline G4Material* FindMaterial (const G4String& name) const;
81 G4bool warning = true);
82
83 // Find or build a simple material via atomic number
84 //
85 inline G4Material* FindSimpleMaterial(G4int Z) const;
87
88 // construct a G4Material from scratch by atome count
89 //
91 const std::vector<G4String>& elm,
92 const std::vector<G4int>& nbAtoms,
93 G4double dens,
94 G4State state = kStateSolid,
96 G4double pressure = CLHEP::STP_Pressure);
97
98 // construct a G4Material from scratch by fraction mass
99 //
101 const std::vector<G4String>& elm,
102 const std::vector<G4double>& weight,
103 G4double dens,
104 G4State state = kStateSolid,
106 G4double pressure = CLHEP::STP_Pressure);
107
108
109 // construct a gas G4Material from scratch by atome count
110 //
112 const G4String& nameDB,
113 G4double temp, G4double pres);
114
115 // Construct an ideal gas G4Material from scratch by atom count
116 //
118 const std::vector<G4String>& elm,
119 const std::vector<G4int>& nbAtoms,
121 G4double pressure = CLHEP::STP_Pressure);
122
123 // verbosity level defined by G4NistManager
124 //
125 void SetVerbose(G4int val);
126
127 // cout predefined materials:
128 // "simple" - only pure materials in basic state (Z = 1, ..., 98)
129 // "compound" - NIST compounds
130 // "hep" - HEP materials and compounds
131 // "biochemical" - bio-chemical materials
132 // "all" - all
133 //
134 void ListMaterials(const G4String&) const;
135
136 // cout lists of predefined materials
137 //
138 void ListNistSimpleMaterials() const;
139 void ListNistCompoundMaterials() const;
140 void ListHepMaterials() const;
141 void ListSpaceMaterials() const;
142 void ListBioChemicalMaterials() const;
143
144 // access to the list of names of Geant4 predefined materials
145 //
146 const std::vector<G4String>& GetMaterialNames() const;
147
148 // access to the NIST mean ionisation potentials and nominal densities
149 //
150 inline G4double GetMeanIonisationEnergy(G4int index) const;
151 inline G4double GetNominalDensity(G4int index) const;
152
157
158private:
159
160 void Initialise();
161 void NistSimpleMaterials();
165 void SpaceMaterials();
167
168 // add parameters of material from NIST DB to internal vectors
169 // density in g/cm3, mean ionisation potential in eV
170 //
171 void AddMaterial(const G4String& nameMat, G4double dens, G4int Z=0,
172 G4double pot=0.0, G4int ncomp=1,
173 G4State=kStateSolid, G4bool stp = true);
174
175 void AddGas(const G4String& nameMat, G4double T, G4double P);
176
179
182
183 // build a G4Material from dataBase
184 G4Material* BuildNistMaterial(const G4String& matname, G4bool warning);
186
187 void DumpElm(G4int) const;
188 void DumpMix(G4int) const;
189
190private:
191
193
202
203 std::vector<G4String> names;
204 std::vector<G4String> chFormulas;
205
206 std::vector<G4double> densities;
207 std::vector<G4double> ionPotentials;
208 std::vector<G4State> states;
209 std::vector<G4double> fractions;
210 std::vector<G4bool> atomCount;
211 std::vector<G4int> components;
212 std::vector<G4int> indexes;
213 std::vector<G4int> elements;
214 std::vector<G4int> matIndex;
215 std::vector<G4bool> STP;
216
217 std::vector<G4int> idxGas;
218 std::vector<G4double> gasTemperature;
219 std::vector<G4double> gasPressure;
220
221#ifdef G4MULTITHREADED
222 static G4Mutex nistMaterialMutex;
223#endif
224
225};
226
227inline const std::vector<G4String>&
229{
230 return names;
231}
232
233inline G4double
235{
236 return (index >= 0 && index < nMaterials) ? ionPotentials[index] : 10.0*index;
237}
238
239inline G4double
241{
242 return (index >= 0 && index < nMaterials) ? densities[index] : 0.0;
243}
244
245inline G4Material*
247{
248 const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
249 G4Material* ptr = nullptr;
250 for(auto & mat : *theMaterialTable) {
251 if(name == mat->GetName()) {
252 ptr = mat;
253 break;
254 }
255 }
256 return ptr;
257}
258
259inline G4Material*
261{
262 return (Z>0 && Z<nElementary) ? FindMaterial(names[Z]) : nullptr;
263}
264
265#endif
std::vector< G4Material * > G4MaterialTable
G4State
Definition: G4Material.hh:111
@ kStateSolid
Definition: G4Material.hh:111
static const G4double NTP_Temperature
Definition: G4Material.hh:113
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 G4int Z[17]
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:672
G4double GetMeanIonisationEnergy(G4int index) const
G4Material * ConstructNewMaterial(const G4String &name, const std::vector< G4String > &elm, const std::vector< G4int > &nbAtoms, G4double dens, G4State state=kStateSolid, G4double temp=NTP_Temperature, G4double pressure=CLHEP::STP_Pressure)
const G4NistMaterialBuilder & operator=(const G4NistMaterialBuilder &)=delete
void ListMaterials(const G4String &) const
std::vector< G4String > names
std::vector< G4State > states
std::vector< G4String > chFormulas
void AddGas(const G4String &nameMat, G4double T, G4double P)
std::vector< G4bool > STP
std::vector< G4int > components
void AddElementByWeightFraction(G4int Z, G4double)
G4Material * FindOrBuildMaterial(const G4String &name, G4bool warning=true)
G4NistMaterialBuilder(const G4NistMaterialBuilder &)=delete
std::vector< G4int > indexes
G4NistMaterialBuilder(G4NistElementBuilder *, G4int verb=0)
std::vector< G4double > gasTemperature
std::vector< G4int > idxGas
G4Material * ConstructNewIdealGasMaterial(const G4String &name, const std::vector< G4String > &elm, const std::vector< G4int > &nbAtoms, G4double temp=NTP_Temperature, G4double pressure=CLHEP::STP_Pressure)
G4bool operator!=(const G4NistMaterialBuilder &) const =delete
G4Material * BuildNistMaterial(const G4String &matname, G4bool warning)
void AddMaterial(const G4String &nameMat, G4double dens, G4int Z=0, G4double pot=0.0, G4int ncomp=1, G4State=kStateSolid, G4bool stp=true)
const std::vector< G4String > & GetMaterialNames() const
G4double GetNominalDensity(G4int index) const
std::vector< G4bool > atomCount
G4bool operator==(const G4NistMaterialBuilder &) const =delete
std::vector< G4double > densities
G4Material * FindSimpleMaterial(G4int Z) const
std::vector< G4int > matIndex
G4Material * FindOrBuildSimpleMaterial(G4int Z, G4bool warning)
G4Material * FindMaterial(const G4String &name) const
std::vector< G4int > elements
G4Material * ConstructNewGasMaterial(const G4String &name, const G4String &nameDB, G4double temp, G4double pres)
G4Material * BuildMaterial(G4int idx)
std::vector< G4double > ionPotentials
void AddElementByAtomCount(G4int Z, G4int)
std::vector< G4double > fractions
std::vector< G4double > gasPressure
G4NistElementBuilder * elmBuilder
static constexpr double STP_Pressure
const char * name(G4int ptype)
static double P[]