Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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
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
64//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
65
67
69{
70public:
71
73
75
76 // Find or build a G4Material by name, from dataBase
77 //
78 inline G4Material* FindMaterial (const G4String& name) const;
80 G4bool warning = true);
81
82 // Find or build a simple material via atomic number
83 //
84 inline G4Material* FindSimpleMaterial(G4int Z) const;
86
87 // construct a G4Material from scratch by atome count
88 //
90 const std::vector<G4String>& elm,
91 const std::vector<G4int>& nbAtoms,
92 G4double dens,
93 G4State state = kStateSolid,
94 G4double temp = NTP_Temperature,
95 G4double pressure = CLHEP::STP_Pressure);
96
97 // construct a G4Material from scratch by fraction mass
98 //
100 const std::vector<G4String>& elm,
101 const std::vector<G4double>& weight,
102 G4double dens,
103 G4State state = kStateSolid,
104 G4double temp = NTP_Temperature,
105 G4double pressure = CLHEP::STP_Pressure);
106
107
108 // construct a gas G4Material from scratch by atome count
109 //
111 const G4String& nameDB,
112 G4double temp, G4double pres);
113
114 // Construct an ideal gas G4Material from scratch by atom count
115 //
117 const std::vector<G4String>& elm,
118 const std::vector<G4int>& nbAtoms,
119 G4double temp = NTP_Temperature,
120 G4double pressure = CLHEP::STP_Pressure);
121
122 // verbosity level defined by G4NistManager
123 //
124 void SetVerbose(G4int val);
125
126 // cout predefined materials:
127 // "simple" - only pure materials in basic state (Z = 1, ..., 98)
128 // "compound" - NIST compounds
129 // "hep" - HEP materials and compounds
130 // "biochemical" - bio-chemical materials
131 // "all" - all
132 //
133 void ListMaterials(const G4String&) const;
134
135 // cout lists of predefined materials
136 //
137 void ListNistSimpleMaterials() const;
138 void ListNistCompoundMaterials() const;
139 void ListHepMaterials() const;
140 void ListSpaceMaterials() const;
141 void ListBioChemicalMaterials() const;
142
143 // access to the list of names of Geant4 predefined materials
144 //
145 const std::vector<G4String>& GetMaterialNames() const;
146
147 // access to the NIST mean ionisation potentials and nominal densities
148 //
149 inline G4double GetMeanIonisationEnergy(G4int index) const;
150 inline G4double GetNominalDensity(G4int index) const;
151
156
157private:
158
159 void Initialise();
160 void NistSimpleMaterials();
161 void NistCompoundMaterials();
162 void NistCompoundMaterials2();
163 void HepAndNuclearMaterials();
164 void SpaceMaterials();
165 void BioChemicalMaterials();
166
167 // add parameters of material from NIST DB to internal vectors
168 // density in g/cm3, mean ionisation potential in eV
169 //
170 void AddMaterial(const G4String& nameMat, G4double dens, G4int Z=0,
171 G4double pot=0.0, G4int ncomp=1,
172 G4State=kStateSolid, G4bool stp = true);
173
174 void AddGas(const G4String& nameMat, G4double T, G4double P);
175
176 void AddElementByWeightFraction(G4int Z, G4double);
177 void AddElementByAtomCount (G4int Z, G4int);
178
179 void AddElementByWeightFraction(const G4String& name, G4double);
180 void AddElementByAtomCount (const G4String& name, G4int);
181
182 // build a G4Material from dataBase
183 G4Material* BuildNistMaterial(const G4String& matname, G4bool warning);
184 G4Material* BuildMaterial(G4int idx);
185
186 void DumpElm(G4int) const;
187 void DumpMix(G4int) const;
188
189private:
190
191 G4NistElementBuilder* elmBuilder;
192
193 G4int verbose;
194 G4int nMaterials;
195 G4int nComponents;
196 G4int nCurrent;
197 G4int nElementary;
198 G4int nNIST;
199 G4int nHEP;
200 G4int nSpace;
201
202 std::vector<G4String> names;
203 std::vector<G4String> chFormulas;
204
205 std::vector<G4double> densities;
206 std::vector<G4double> ionPotentials;
207 std::vector<G4State> states;
208 std::vector<G4double> fractions;
209 std::vector<G4bool> atomCount;
210 std::vector<G4int> components;
211 std::vector<G4int> indexes;
212 std::vector<G4int> elements;
213 std::vector<G4int> matIndex;
214 std::vector<G4bool> STP;
215
216 std::vector<G4int> idxGas;
217 std::vector<G4double> gasTemperature;
218 std::vector<G4double> gasPressure;
219};
220
221inline const std::vector<G4String>&
223{
224 return names;
225}
226
227inline G4double
229{
230 return (index >= 0 && index < nMaterials) ? ionPotentials[index] : 10.0*index;
231}
232
233inline G4double
235{
236 return (index >= 0 && index < nMaterials) ? densities[index] : 0.0;
237}
238
239inline G4Material*
241{
242 const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
243 G4Material* ptr = nullptr;
244 for(auto & mat : *theMaterialTable) {
245 if(name == mat->GetName()) {
246 ptr = mat;
247 break;
248 }
249 }
250 return ptr;
251}
252
253inline G4Material*
255{
256 return (Z>0 && Z<nElementary) ? FindMaterial(names[Z]) : nullptr;
257}
258
259#endif
std::vector< G4Material * > G4MaterialTable
G4State
Definition: G4Material.hh:110
@ kStateSolid
Definition: G4Material.hh:110
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:677
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
G4Material * FindOrBuildMaterial(const G4String &name, G4bool warning=true)
G4NistMaterialBuilder(const G4NistMaterialBuilder &)=delete
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
const std::vector< G4String > & GetMaterialNames() const
G4double GetNominalDensity(G4int index) const
G4bool operator==(const G4NistMaterialBuilder &) const =delete
G4Material * FindSimpleMaterial(G4int Z) const
G4Material * FindOrBuildSimpleMaterial(G4int Z, G4bool warning)
G4Material * FindMaterial(const G4String &name) const
~G4NistMaterialBuilder()=default
G4Material * ConstructNewGasMaterial(const G4String &name, const G4String &nameDB, G4double temp, G4double pres)