Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4Material.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//
28// ClassName: G4Material
29//
30// Description: Contains material properties
31//
32// Class description:
33//
34// Is used to define the material composition of Geant4 volumes.
35// A G4Material is always made of G4Elements. It should has the name,
36// the list of G4Elements, material density, material state, temperature,
37// pressure. Other parameters are optional and may be set by the user code
38// or computed at initialisation.
39//
40// There is several ways to construct G4Material:
41// - from single element;
42// - from a list of components (elements or other materials);
43// - from internal Geant4 database of materials
44//
45// A collection of constituent Elements/Materials should be defined
46// with specified weights by fractional mass or atom counts (only for Elements).
47//
48// Quantities, with physical meaning or not, which are constant in a given
49// material are computed and stored here as Derived data members.
50//
51// The class contains as a private static member the Table of defined
52// materials (an ordered vector of materials).
53//
54// It is strongly not recommended to delete materials in user code.
55// All materials will be deleted automatically at the end of Geant4 session.
56//
57// 10-07-96, new data members added by L.Urban
58// 12-12-96, new data members added by L.Urban
59// 20-01-97, aesthetic rearrangement. RadLength calculation modified
60// Data members Zeff and Aeff REMOVED (i.e. passed to the Elements).
61// (local definition of Zeff in DensityEffect and FluctModel...)
62// Vacuum defined as a G4State. Mixture flag removed, M.Maire
63// 29-01-97, State=Vacuum automatically set density=0 in the contructors.
64// Subsequent protections have been put in the calculation of
65// MeanExcEnergy, ShellCorrectionVector, DensityEffect, M.Maire
66// 20-03-97, corrected initialization of pointers, M.Maire
67// 10-06-97, new data member added by V.Grichine (fSandiaPhotoAbsCof)
68// 27-06-97, new function GetElement(int), M.Maire
69// 24-02-98, fFractionVector become fMassFractionVector
70// 28-05-98, kState=kVacuum removed:
71// The vacuum is an ordinary gas vith very low density, M.Maire
72// 12-06-98, new method AddMaterial() allowing mixture of materials, M.Maire
73// 09-07-98, Ionisation parameters removed from the class, M.Maire
74// 04-08-98, new method GetMaterial(materialName), M.Maire
75// 05-10-98, change name: NumDensity -> NbOfAtomsPerVolume
76// 18-11-98, SandiaTable interface modified.
77// 19-07-99, new data member (chemicalFormula) added by V.Ivanchenko
78// 12-03-01, G4bool fImplicitElement (mma)
79// 30-03-01, suppression of the warning message in GetMaterial
80// 17-07-01, migration to STL. M. Verderi.
81// 14-09-01, Suppression of the data member fIndexInTable
82// 31-10-01, new function SetChemicalFormula() (mma)
83// 26-02-02, fIndexInTable renewed
84// 06-08-02, remove constructors with ChemicalFormula (mma)
85// 15-11-05, GetMaterial(materialName, G4bool warning=true)
86// 13-04-12, std::map<G4Material*,G4double> fMatComponents (mma)
87// 21-04-12, fMassOfMolecule (mma)
88
89#ifndef G4MATERIAL_HH
90#define G4MATERIAL_HH 1
91
92#include "G4Element.hh"
93#include "G4ElementVector.hh"
94#include "G4IonisParamMat.hh"
96#include "G4MaterialTable.hh"
97#include "G4SandiaTable.hh"
98#include "G4ios.hh"
99#include "globals.hh"
100
102
103#include <map>
104#include <vector>
105
113
114static const G4double NTP_Temperature = 293.15 * CLHEP::kelvin;
115
117{
118 public: // with description
119 // Constructor to create a material from single element
120 G4Material(const G4String& name, // its name
121 G4double z, // atomic number
122 G4double a, // mass of mole
123 G4double density, // density
124 G4State state = kStateUndefined, // solid,gas
125 G4double temp = NTP_Temperature, // temperature
126 G4double pressure = CLHEP::STP_Pressure); // pressure
127
128 // Constructor to create a material from a combination of elements
129 // and/or materials subsequently added via AddElement and/or AddMaterial
130 G4Material(const G4String& name, // its name
131 G4double density, // density
132 G4int nComponents, // nbOfComponents
133 G4State state = kStateUndefined, // solid,gas
134 G4double temp = NTP_Temperature, // temperature
135 G4double pressure = CLHEP::STP_Pressure); // pressure
136
137 // Constructor to create a material from the base material
138 G4Material(const G4String& name, // its name
139 G4double density, // density
140 const G4Material* baseMaterial, // base material
141 G4State state = kStateUndefined, // solid,gas
142 G4double temp = NTP_Temperature, // temperature
143 G4double pressure = CLHEP::STP_Pressure); // pressure
144
145 virtual ~G4Material();
146
147 // These methods allow customisation of corrections to ionisation
148 // computations. Free electron density above zero means that the material
149 // is a conductor. Computation of density effect correction of fly
150 // may be more accurate but require extra computations.
151 void SetChemicalFormula(const G4String& chF);
154
155 G4Material(const G4Material&) = delete;
156 const G4Material& operator=(const G4Material&) = delete;
157
158 // Add an element, giving number of atoms
159 void AddElementByNumberOfAtoms(const G4Element* elm, G4int nAtoms);
160 inline void AddElement(G4Element* elm, G4int nAtoms) { AddElementByNumberOfAtoms(elm, nAtoms); }
161
162 // Add an element or material, giving fraction of mass
163 void AddElementByMassFraction(const G4Element* elm, G4double fraction);
164 inline void AddElement(G4Element* elm, G4double frac) { AddElementByMassFraction(elm, frac); }
165
166 void AddMaterial(G4Material* material, G4double fraction);
167
168 //
169 // retrieval methods
170 //
171 inline const G4String& GetName() const { return fName; }
172 inline const G4String& GetChemicalFormula() const { return fChemicalFormula; }
173 inline G4double GetFreeElectronDensity() const { return fFreeElecDensity; }
174 inline G4double GetDensity() const { return fDensity; }
175 inline G4State GetState() const { return fState; }
176 inline G4double GetTemperature() const { return fTemp; }
177 inline G4double GetPressure() const { return fPressure; }
178
179 // number of elements constituing this material:
180 inline std::size_t GetNumberOfElements() const { return fNumberOfElements; }
181
182 // vector of pointers to elements constituing this material:
183 inline const G4ElementVector* GetElementVector() const { return theElementVector; }
184
185 // vector of fractional mass of each element:
186 inline const G4double* GetFractionVector() const { return fMassFractionVector; }
187
188 // vector of atom count of each element:
189 inline const G4int* GetAtomsVector() const { return fAtomsVector; }
190
191 // return a pointer to an element, given its index in the material:
192 inline const G4Element* GetElement(G4int iel) const { return (*theElementVector)[iel]; }
193
194 // vector of nb of atoms per volume of each element in this material:
195 inline const G4double* GetVecNbOfAtomsPerVolume() const { return fVecNbOfAtomsPerVolume; }
196 // total number of atoms per volume:
197 inline G4double GetTotNbOfAtomsPerVolume() const { return fTotNbOfAtomsPerVolume; }
198 // total number of electrons per volume:
199 inline G4double GetTotNbOfElectPerVolume() const { return fTotNbOfElectPerVolume; }
200
201 // obsolete names (5-10-98) see the 2 functions above
202 inline const G4double* GetAtomicNumDensityVector() const { return fVecNbOfAtomsPerVolume; }
203 inline G4double GetElectronDensity() const { return fTotNbOfElectPerVolume; }
204
205 // Radiation length:
206 inline G4double GetRadlen() const { return fRadlen; }
207
208 // Nuclear interaction length
209 inline G4double GetNuclearInterLength() const { return fNuclInterLen; }
210
211 // ionisation parameters:
212 inline G4IonisParamMat* GetIonisation() const { return fIonisation; }
213
214 // Sandia table:
215 inline G4SandiaTable* GetSandiaTable() const { return fSandiaTable; }
216
217 // Base material:
218 inline const G4Material* GetBaseMaterial() const { return fBaseMaterial; }
219
220 // material components:
221 inline const std::map<G4Material*, G4double>& GetMatComponents() const { return fMatComponents; }
222
223 // for chemical compound
224 inline G4double GetMassOfMolecule() const { return fMassOfMolecule; }
225
226 // meaningful only for single material:
227 G4double GetZ() const;
228 G4double GetA() const;
229
230 // the MaterialPropertiesTable (if any) attached to this material:
232
234 {
235 return fMaterialPropertiesTable;
236 }
237
238 // the index of this material in the Table:
239 inline std::size_t GetIndex() const { return fIndexInTable; }
240
241 // the static Table of Materials:
243
244 static std::size_t GetNumberOfMaterials();
245
246 // return pointer to a material, given its name:
247 static G4Material* GetMaterial(const G4String& name, G4bool warning = true);
248
249 // return pointer to a simple material, given its propeties:
250 static G4Material* GetMaterial(G4double z, G4double a, G4double dens);
251
252 // return pointer to a composit material, given its propeties:
253 static G4Material* GetMaterial(std::size_t nComp, G4double dens);
254
255 // printing methods
256 friend std::ostream& operator<<(std::ostream&, const G4Material*);
257 friend std::ostream& operator<<(std::ostream&, const G4Material&);
258 friend std::ostream& operator<<(std::ostream&, const G4MaterialTable&);
259
260 inline void SetName(const G4String& name) { fName = name; }
261
262 virtual G4bool IsExtended() const;
263
264 // operators
265 G4bool operator==(const G4Material&) const = delete;
266 G4bool operator!=(const G4Material&) const = delete;
267
268 private:
269 void InitializePointers();
270
271 // Header routine for all derived quantities
272 void ComputeDerivedQuantities();
273
274 // Compute Radiation length
275 void ComputeRadiationLength();
276
277 // Compute Nuclear interaction length
278 void ComputeNuclearInterLength();
279
280 // Copy pointers of base material
281 void CopyPointersOfBaseMaterial();
282
283 void FillVectors();
284
285 G4bool IsLocked();
286
287 static G4MaterialTable theMaterialTable; // the material table
288
289 const G4Material* fBaseMaterial; // Pointer to the base material
290 G4MaterialPropertiesTable* fMaterialPropertiesTable;
291
292 //
293 // General atomic properties defined in constructor or
294 // computed from the basic data members
295 //
296
297 G4ElementVector* theElementVector; // vector of constituent G4Elements
298 G4int* fAtomsVector; // composition by atom count
299 G4double* fMassFractionVector; // composition by fractional mass
300 G4double* fVecNbOfAtomsPerVolume; // number of atoms per volume
301
302 G4IonisParamMat* fIonisation; // ionisation parameters
303 G4SandiaTable* fSandiaTable; // Sandia table
304
305 G4double fDensity; // Material density
306 G4double fFreeElecDensity; // Free electron density
307 G4double fTemp; // Temperature (defaults: STP)
308 G4double fPressure; // Pressure (defaults: STP)
309
310 G4double fTotNbOfAtomsPerVolume; // Total nb of atoms per volume
311 G4double fTotNbOfElectPerVolume; // Total nb of electrons per volume
312 G4double fRadlen; // Radiation length
313 G4double fNuclInterLen; // Nuclear interaction length
314 G4double fMassOfMolecule; // Correct for materials built by atoms count
315
316 G4State fState; // Material state
317 std::size_t fIndexInTable; // Index in the material table
318 G4int fNumberOfElements; // Number of G4Elements in the material
319
320 // Class members used only at initialisation
321 G4int fNbComponents; // Number of components
322 G4int fIdxComponent; // Index of a new component
323 G4bool fMassFraction; // Flag of the method to add components
324
325 // For composites built
326 std::vector<G4int>* fAtoms = nullptr;
327 std::vector<G4double>* fElmFrac = nullptr;
328 std::vector<const G4Element*>* fElm = nullptr;
329
330 // For composites built via AddMaterial()
331 std::map<G4Material*, G4double> fMatComponents;
332
333 G4String fName; // Material name
334 G4String fChemicalFormula; // Material chemical formula
335};
336
337#endif
std::vector< const G4Element * > G4ElementVector
std::vector< G4Material * > G4MaterialTable
G4State
@ kStateSolid
@ kStateLiquid
@ kStateGas
@ kStateUndefined
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
G4double GetPressure() const
void SetName(const G4String &name)
G4double GetDensity() const
G4bool operator!=(const G4Material &) const =delete
void ComputeDensityEffectOnFly(G4bool val)
const G4String & GetChemicalFormula() const
const std::map< G4Material *, G4double > & GetMatComponents() const
const G4ElementVector * GetElementVector() const
const G4Material * GetBaseMaterial() const
G4MaterialPropertiesTable * GetMaterialPropertiesTable() const
const G4Material & operator=(const G4Material &)=delete
G4double GetTotNbOfAtomsPerVolume() const
G4State GetState() const
G4double GetTemperature() const
const G4Element * GetElement(G4int iel) const
virtual G4bool IsExtended() const
G4double GetZ() const
const G4double * GetFractionVector() const
G4double GetTotNbOfElectPerVolume() const
G4IonisParamMat * GetIonisation() const
G4double GetFreeElectronDensity() const
void AddElement(G4Element *elm, G4int nAtoms)
virtual ~G4Material()
const G4double * GetAtomicNumDensityVector() const
void SetChemicalFormula(const G4String &chF)
const G4int * GetAtomsVector() const
G4double GetA() const
G4SandiaTable * GetSandiaTable() const
G4bool operator==(const G4Material &) const =delete
void AddElementByNumberOfAtoms(const G4Element *elm, G4int nAtoms)
friend std::ostream & operator<<(std::ostream &, const G4Material *)
static std::size_t GetNumberOfMaterials()
G4double GetElectronDensity() const
G4double GetRadlen() const
G4double GetMassOfMolecule() const
void AddElement(G4Element *elm, G4double frac)
const G4double * GetVecNbOfAtomsPerVolume() const
G4Material(const G4String &name, G4double z, G4double a, G4double density, G4State state=kStateUndefined, G4double temp=NTP_Temperature, G4double pressure=CLHEP::STP_Pressure)
Definition G4Material.cc:88
std::size_t GetIndex() const
static G4MaterialTable * GetMaterialTable()
void AddMaterial(G4Material *material, G4double fraction)
std::size_t GetNumberOfElements() const
const G4String & GetName() const
void SetMaterialPropertiesTable(G4MaterialPropertiesTable *anMPT)
void SetFreeElectronDensity(G4double val)
void AddElementByMassFraction(const G4Element *elm, G4double fraction)
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
G4Material(const G4Material &)=delete
G4double GetNuclearInterLength() const