Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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#include "G4Material.hh"
57#include "globals.hh"
58
60
61#include <vector>
62
64
66{
67 public:
69
71
72 // Find or build a G4Material by name, from dataBase
73 inline G4Material* FindMaterial(const G4String& name) const;
74 G4Material* FindOrBuildMaterial(const G4String& name, G4bool warning = true);
75
76 // Find or build a simple material via atomic number
77 inline G4Material* FindSimpleMaterial(G4int Z) const;
79
80 // construct a G4Material from scratch by atome count
81 G4Material* ConstructNewMaterial(const G4String& name, const std::vector<G4String>& elm,
82 const std::vector<G4int>& nbAtoms, G4double dens, G4State state = kStateSolid,
83 G4double temp = NTP_Temperature, G4double pressure = CLHEP::STP_Pressure);
84
85 // construct a G4Material from scratch by fraction mass
86 G4Material* ConstructNewMaterial(const G4String& name, const std::vector<G4String>& elm,
87 const std::vector<G4double>& weight, G4double dens, G4State state = kStateSolid,
88 G4double temp = NTP_Temperature, G4double pressure = CLHEP::STP_Pressure);
89
90 // construct a gas G4Material from scratch by atome count
92 const G4String& name, const G4String& nameDB, G4double temp, G4double pres);
93
94 // Construct an ideal gas G4Material from scratch by atom count
95 G4Material* ConstructNewIdealGasMaterial(const G4String& name, const std::vector<G4String>& elm,
96 const std::vector<G4int>& nbAtoms, G4double temp = NTP_Temperature,
97 G4double pressure = CLHEP::STP_Pressure);
98
99 // verbosity level defined by G4NistManager
100 void SetVerbose(G4int val);
101
102 // cout predefined materials:
103 // "simple" - only pure materials in basic state (Z = 1, ..., 98)
104 // "compound" - NIST compounds
105 // "hep" - HEP materials and compounds
106 // "biochemical" - bio-chemical materials
107 // "all" - all
108 void ListMaterials(const G4String&) const;
109
110 // cout lists of predefined materials
111 void ListNistSimpleMaterials() const;
112 void ListNistCompoundMaterials() const;
113 void ListHepMaterials() const;
114 void ListSpaceMaterials() const;
115 void ListBioChemicalMaterials() const;
116
117 // access to the list of names of Geant4 predefined materials
118 const std::vector<G4String>& GetMaterialNames() const;
119
120 // access to the NIST mean ionisation potentials and nominal densities
121 inline G4double GetMeanIonisationEnergy(G4int index) const;
122 inline G4double GetNominalDensity(G4int index) const;
123
128
129 private:
130 void Initialise();
131 void NistSimpleMaterials();
132 void NistCompoundMaterials();
133 void NistCompoundMaterials2();
134 void HepAndNuclearMaterials();
135 void SpaceMaterials();
136 void BioChemicalMaterials();
137
138 // add parameters of material from NIST DB to internal vectors
139 // density in g/cm3, mean ionisation potential in eV
140 //
141 void AddMaterial(const G4String& nameMat, G4double dens, G4int Z = 0, G4double pot = 0.0,
142 G4int ncomp = 1, G4State = kStateSolid, G4bool stp = true);
143
144 void AddGas(const G4String& nameMat, G4double T, G4double P);
145
146 void AddElementByWeightFraction(G4int Z, G4double);
147 void AddElementByAtomCount(G4int Z, G4int);
148
149 void AddElementByWeightFraction(const G4String& name, G4double);
150 void AddElementByAtomCount(const G4String& name, G4int);
151
152 // build a G4Material from dataBase
153 G4Material* BuildNistMaterial(const G4String& matname, G4bool warning);
154 G4Material* BuildMaterial(G4int idx);
155
156 void DumpElm(G4int) const;
157 void DumpMix(G4int) const;
158
159 private:
160 G4NistElementBuilder* elmBuilder;
161
162 G4int verbose;
163 G4int nMaterials{0};
164 G4int nComponents{0};
165 G4int nCurrent{0};
166 G4int nElementary;
167 G4int nNIST;
168 G4int nHEP;
169 G4int nSpace;
170
171 std::vector<G4String> names;
172 std::vector<G4String> chFormulas;
173
174 std::vector<G4double> densities;
175 std::vector<G4double> ionPotentials;
176 std::vector<G4State> states;
177 std::vector<G4double> fractions;
178 std::vector<G4bool> atomCount;
179 std::vector<G4int> components;
180 std::vector<G4int> indexes;
181 std::vector<G4int> elements;
182 std::vector<G4int> matIndex;
183 std::vector<G4bool> STP;
184
185 std::vector<G4int> idxGas;
186 std::vector<G4double> gasTemperature;
187 std::vector<G4double> gasPressure;
188};
189
190inline const std::vector<G4String>& G4NistMaterialBuilder::GetMaterialNames() const
191{
192 return names;
193}
194
196{
197 return (index >= 0 && index < nMaterials) ? ionPotentials[index] : 10.0 * index;
198}
199
201{
202 return (index >= 0 && index < nMaterials) ? densities[index] : 0.0;
203}
204
206{
207 const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
208 G4Material* ptr = nullptr;
209 for (auto& mat : *theMaterialTable) {
210 if (name == mat->GetName()) {
211 ptr = mat;
212 break;
213 }
214 }
215 return ptr;
216}
217
219{
220 return (Z > 0 && Z < nElementary) ? FindMaterial(names[Z]) : nullptr;
221}
222
223#endif
std::vector< G4Material * > G4MaterialTable
G4State
@ kStateSolid
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
static G4MaterialTable * GetMaterialTable()
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
G4NistMaterialBuilder(G4NistElementBuilder *, G4int verb=0)
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)