Geant4-11
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
58//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
59
60// 10-07-96, new data members added by L.Urban
61// 12-12-96, new data members added by L.Urban
62// 20-01-97, aesthetic rearrangement. RadLength calculation modified
63// Data members Zeff and Aeff REMOVED (i.e. passed to the Elements).
64// (local definition of Zeff in DensityEffect and FluctModel...)
65// Vacuum defined as a G4State. Mixture flag removed, M.Maire
66// 29-01-97, State=Vacuum automatically set density=0 in the contructors.
67// Subsequent protections have been put in the calculation of
68// MeanExcEnergy, ShellCorrectionVector, DensityEffect, M.Maire
69// 20-03-97, corrected initialization of pointers, M.Maire
70// 10-06-97, new data member added by V.Grichine (fSandiaPhotoAbsCof)
71// 27-06-97, new function GetElement(int), M.Maire
72// 24-02-98, fFractionVector become fMassFractionVector
73// 28-05-98, kState=kVacuum removed:
74// The vacuum is an ordinary gas vith very low density, M.Maire
75// 12-06-98, new method AddMaterial() allowing mixture of materials, M.Maire
76// 09-07-98, Ionisation parameters removed from the class, M.Maire
77// 04-08-98, new method GetMaterial(materialName), M.Maire
78// 05-10-98, change name: NumDensity -> NbOfAtomsPerVolume
79// 18-11-98, SandiaTable interface modified.
80// 19-07-99, new data member (chemicalFormula) added by V.Ivanchenko
81// 12-03-01, G4bool fImplicitElement (mma)
82// 30-03-01, suppression of the warning message in GetMaterial
83// 17-07-01, migration to STL. M. Verderi.
84// 14-09-01, Suppression of the data member fIndexInTable
85// 31-10-01, new function SetChemicalFormula() (mma)
86// 26-02-02, fIndexInTable renewed
87// 06-08-02, remove constructors with ChemicalFormula (mma)
88// 15-11-05, GetMaterial(materialName, G4bool warning=true)
89// 13-04-12, std::map<G4Material*,G4double> fMatComponents (mma)
90// 21-04-12, fMassOfMolecule (mma)
91
92//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
93
94#ifndef G4MATERIAL_HH
95#define G4MATERIAL_HH 1
96
97#include <vector>
98#include <map>
100
101#include "globals.hh"
102#include "G4ios.hh"
103#include "G4Element.hh"
105#include "G4IonisParamMat.hh"
106#include "G4SandiaTable.hh"
107#include "G4ElementVector.hh"
108#include "G4MaterialTable.hh"
109#include "G4Threading.hh"
110
112
114
115//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
116
118{
119public: // with description
120 //
121 // Constructor to create a material from single element
122 //
123 G4Material(const G4String& name, //its name
124 G4double z, //atomic number
125 G4double a, //mass of mole
126 G4double density, //density
127 G4State state = kStateUndefined, //solid,gas
128 G4double temp = NTP_Temperature, //temperature
129 G4double pressure = CLHEP::STP_Pressure); //pressure
130
131 //
132 // Constructor to create a material from a combination of elements
133 // and/or materials subsequently added via AddElement and/or AddMaterial
134 //
135 G4Material(const G4String& name, //its name
136 G4double density, //density
137 G4int nComponents, //nbOfComponents
138 G4State state = kStateUndefined, //solid,gas
139 G4double temp = NTP_Temperature, //temperature
140 G4double pressure = CLHEP::STP_Pressure); //pressure
141
142 //
143 // Constructor to create a material from the base material
144 //
145 G4Material(const G4String& name, //its name
146 G4double density, //density
147 const G4Material* baseMaterial, //base material
148 G4State state = kStateUndefined, //solid,gas
149 G4double temp = NTP_Temperature, //temperature
150 G4double pressure = CLHEP::STP_Pressure); //pressure
151
152 //
153 // Add an element, giving number of atoms
154 //
155 void AddElementByNumberOfAtoms(const G4Element* elm, G4int nAtoms);
156 inline
157 void AddElement(G4Element* elm, G4int nAtoms)
158 { AddElementByNumberOfAtoms(elm, nAtoms); }
159
160 //
161 // Add an element or material, giving fraction of mass
162 //
163 void AddElementByMassFraction(const G4Element* elm, G4double fraction);
164 inline void AddElement (G4Element* elm, G4double frac)
165 { AddElementByMassFraction(elm, frac); }
166
167 void AddMaterial(G4Material* material, G4double fraction);
168
169 virtual ~G4Material();
170 //
171 // retrieval methods
172 //
173 inline const G4String& GetName() const {return fName;}
174 inline const G4String& GetChemicalFormula() const {return fChemicalFormula;}
176 inline G4double GetDensity() const {return fDensity;}
177 inline G4State GetState() const {return fState;}
178 inline G4double GetTemperature() const {return fTemp;}
179 inline G4double GetPressure() const {return fPressure;}
180
181 //number of elements constituing this material:
182 inline size_t GetNumberOfElements() const {return fNumberOfElements;}
183
184 //vector of pointers to elements constituing this material:
185 inline const
187
188 //vector of fractional mass of each element:
189 inline const
191
192 //vector of atom count of each element:
193 inline const
195
196 //return a pointer to an element, given its index in the material:
197 inline const
198 G4Element* GetElement(G4int iel) const {return (*theElementVector)[iel];}
199
200 //vector of nb of atoms per volume of each element in this material:
201 inline const
203 //total number of atoms per volume:
204 inline
206 //total number of electrons per volume:
207 inline
209
210 //obsolete names (5-10-98) see the 2 functions above
211 inline const
214
215 // Radiation length:
216 inline G4double GetRadlen() const {return fRadlen;}
217
218 // Nuclear interaction length
220
221 // ionisation parameters:
222 inline G4IonisParamMat* GetIonisation() const {return fIonisation;}
223
224 // Sandia table:
225 inline G4SandiaTable* GetSandiaTable() const {return fSandiaTable; }
226
227 // Base material:
228 inline
229 const G4Material* GetBaseMaterial() const {return fBaseMaterial;}
230
231 // material components:
232 inline
233 const std::map<G4Material*,G4double>& GetMatComponents() const
234 {return fMatComponents;}
235
236 // for chemical compound
238
239 void SetChemicalFormula(const G4String& chF);
240
242
244
245 // meaningful only for single material:
246 G4double GetZ() const;
247 G4double GetA() const;
248
249 //the MaterialPropertiesTable (if any) attached to this material:
251
254
255 //the index of this material in the Table:
256 inline size_t GetIndex() const {return fIndexInTable;}
257
258 // the static Table of Materials:
259 //
261
262 static size_t GetNumberOfMaterials();
263
264 //return pointer to a material, given its name:
265 static G4Material* GetMaterial(const G4String& name, G4bool warning=true);
266
267 //return pointer to a simple material, given its propeties:
268 static G4Material* GetMaterial(G4double z, G4double a, G4double dens);
269
270 //return pointer to a composit material, given its propeties:
271 static G4Material* GetMaterial(size_t nComp, G4double dens);
272
273 //
274 //printing methods
275 //
276 friend std::ostream& operator<<(std::ostream&, const G4Material*);
277 friend std::ostream& operator<<(std::ostream&, const G4Material&);
278 friend std::ostream& operator<<(std::ostream&, const G4MaterialTable&);
279
280 G4Material(__void__&);
281 // Fake default constructor for usage restricted to direct object
282 // persistency for clients requiring preallocation of memory for
283 // persistifiable objects.
284
285 inline void SetName (const G4String& name) {fName=name;}
286
287 virtual G4bool IsExtended() const;
288
289 // operators
290 G4bool operator==(const G4Material&) const = delete;
291 G4bool operator!=(const G4Material&) const = delete;
292 G4Material(const G4Material&) = delete;
293 const G4Material& operator=(const G4Material&) = delete;
294
295private:
296
297 void InitializePointers();
298
299 // Header routine for all derived quantities
301
302 // Compute Radiation length
304
305 // Compute Nuclear interaction length
307
308 // Copy pointers of base material
310
311private:
312
313 void FillVectors();
314
315 static
316 G4MaterialTable theMaterialTable; // the material table
317
318 const G4Material* fBaseMaterial; // Pointer to the base material
320
321 //
322 // General atomic properties defined in constructor or
323 // computed from the basic data members
324 //
325
326 G4ElementVector* theElementVector; // vector of constituent G4Elements
327 G4int* fAtomsVector; // composition by atom count
328 G4double* fMassFractionVector; // composition by fractional mass
329 G4double* fVecNbOfAtomsPerVolume; // number of atoms per volume
330
331 G4IonisParamMat* fIonisation; // ionisation parameters
332 G4SandiaTable* fSandiaTable; // Sandia table
333
334 G4double fDensity; // Material density
335 G4double fFreeElecDensity; // Free electron density
336 G4double fTemp; // Temperature (defaults: STP)
337 G4double fPressure; // Pressure (defaults: STP)
338
339 G4double fTotNbOfAtomsPerVolume; // Total nb of atoms per volume
340 G4double fTotNbOfElectPerVolume; // Total nb of electrons per volume
341 G4double fRadlen; // Radiation length
342 G4double fNuclInterLen; // Nuclear interaction length
343 G4double fMassOfMolecule; // Correct for materials built by atoms count
344
345 G4State fState; // Material state
346 size_t fIndexInTable; // Index in the material table
347 G4int fNumberOfElements; // Number of G4Elements in the material
348
349 // Class members used only at initialisation
350 G4int fNbComponents; // Number of material components
351 G4int fIdxComponent; // Index of a new component
352 G4bool fMassFraction; // Flag of the method to add components
353
354 // For composites built
355 std::vector<G4int>* fAtoms;
356 std::vector<G4double>* fElmFrac;
357 std::vector<const G4Element*>* fElm;
358
359 // For composites built via AddMaterial()
360 std::map<G4Material*, G4double> fMatComponents;
361
362 G4String fName; // Material name
363 G4String fChemicalFormula; // Material chemical formula
364
365#ifdef G4MULTITHREADED
366 static G4Mutex materialMutex;
367#endif
368};
369
370//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
371
372#endif
std::vector< const G4Element * > G4ElementVector
std::vector< G4Material * > G4MaterialTable
G4State
Definition: G4Material.hh:111
@ kStateSolid
Definition: G4Material.hh:111
@ kStateLiquid
Definition: G4Material.hh:111
@ kStateGas
Definition: G4Material.hh:111
@ kStateUndefined
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
G4double fTotNbOfElectPerVolume
Definition: G4Material.hh:340
G4double GetPressure() const
Definition: G4Material.hh:179
void SetName(const G4String &name)
Definition: G4Material.hh:285
G4double GetDensity() const
Definition: G4Material.hh:176
G4bool operator!=(const G4Material &) const =delete
G4double fFreeElecDensity
Definition: G4Material.hh:335
friend std::ostream & operator<<(std::ostream &, const G4Material *)
Definition: G4Material.cc:764
G4int fIdxComponent
Definition: G4Material.hh:351
const G4String & GetChemicalFormula() const
Definition: G4Material.hh:174
const std::map< G4Material *, G4double > & GetMatComponents() const
Definition: G4Material.hh:233
void SetFreeElectronDensity(G4double)
Definition: G4Material.cc:645
const G4ElementVector * GetElementVector() const
Definition: G4Material.hh:186
const G4Material * GetBaseMaterial() const
Definition: G4Material.hh:229
G4MaterialPropertiesTable * GetMaterialPropertiesTable() const
Definition: G4Material.hh:252
const G4Material & operator=(const G4Material &)=delete
const G4Material * fBaseMaterial
Definition: G4Material.hh:318
G4State fState
Definition: G4Material.hh:345
void ComputeDerivedQuantities()
Definition: G4Material.cc:288
static G4MaterialTable theMaterialTable
Definition: G4Material.hh:316
G4double fDensity
Definition: G4Material.hh:334
G4double fPressure
Definition: G4Material.hh:337
G4double GetTotNbOfAtomsPerVolume() const
Definition: G4Material.hh:205
void InitializePointers()
Definition: G4Material.cc:247
G4String fChemicalFormula
Definition: G4Material.hh:363
static size_t GetNumberOfMaterials()
Definition: G4Material.cc:679
G4State GetState() const
Definition: G4Material.hh:177
G4int fNbComponents
Definition: G4Material.hh:350
G4bool fMassFraction
Definition: G4Material.hh:352
G4SandiaTable * fSandiaTable
Definition: G4Material.hh:332
G4double GetTemperature() const
Definition: G4Material.hh:178
const G4Element * GetElement(G4int iel) const
Definition: G4Material.hh:198
G4double fTemp
Definition: G4Material.hh:336
virtual G4bool IsExtended() const
Definition: G4Material.cc:832
G4double GetZ() const
Definition: G4Material.cc:736
const G4double * GetFractionVector() const
Definition: G4Material.hh:190
void CopyPointersOfBaseMaterial()
Definition: G4Material.cc:321
G4double GetTotNbOfElectPerVolume() const
Definition: G4Material.hh:208
G4int fNumberOfElements
Definition: G4Material.hh:347
G4double fNuclInterLen
Definition: G4Material.hh:342
G4IonisParamMat * GetIonisation() const
Definition: G4Material.hh:222
G4double GetFreeElectronDensity() const
Definition: G4Material.hh:175
void AddElement(G4Element *elm, G4int nAtoms)
Definition: G4Material.hh:157
virtual ~G4Material()
Definition: G4Material.cc:228
size_t GetNumberOfElements() const
Definition: G4Material.hh:182
std::map< G4Material *, G4double > fMatComponents
Definition: G4Material.hh:360
G4double fTotNbOfAtomsPerVolume
Definition: G4Material.hh:339
const G4double * GetAtomicNumDensityVector() const
Definition: G4Material.hh:212
void SetChemicalFormula(const G4String &chF)
Definition: G4Material.cc:632
const G4int * GetAtomsVector() const
Definition: G4Material.hh:194
G4double * fVecNbOfAtomsPerVolume
Definition: G4Material.hh:329
G4double * fMassFractionVector
Definition: G4Material.hh:328
G4double GetA() const
Definition: G4Material.cc:750
G4SandiaTable * GetSandiaTable() const
Definition: G4Material.hh:225
G4bool operator==(const G4Material &) const =delete
std::vector< G4int > * fAtoms
Definition: G4Material.hh:355
void AddElementByNumberOfAtoms(const G4Element *elm, G4int nAtoms)
Definition: G4Material.cc:360
G4ElementVector * theElementVector
Definition: G4Material.hh:326
G4double fRadlen
Definition: G4Material.hh:341
G4double GetElectronDensity() const
Definition: G4Material.hh:213
G4double GetRadlen() const
Definition: G4Material.hh:216
G4double GetMassOfMolecule() const
Definition: G4Material.hh:237
void AddElement(G4Element *elm, G4double frac)
Definition: G4Material.hh:164
const G4double * GetVecNbOfAtomsPerVolume() const
Definition: G4Material.hh:202
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:95
size_t fIndexInTable
Definition: G4Material.hh:346
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:672
G4double fMassOfMolecule
Definition: G4Material.hh:343
void FillVectors()
Definition: G4Material.cc:562
void ComputeNuclearInterLength()
Definition: G4Material.cc:612
void AddMaterial(G4Material *material, G4double fraction)
Definition: G4Material.cc:496
void ComputeRadiationLength()
Definition: G4Material.cc:601
G4int * fAtomsVector
Definition: G4Material.hh:327
const G4String & GetName() const
Definition: G4Material.hh:173
void SetMaterialPropertiesTable(G4MaterialPropertiesTable *anMPT)
Definition: G4Material.cc:839
size_t GetIndex() const
Definition: G4Material.hh:256
void AddElementByMassFraction(const G4Element *elm, G4double fraction)
Definition: G4Material.cc:434
std::vector< G4double > * fElmFrac
Definition: G4Material.hh:356
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
Definition: G4Material.cc:686
void ComputeDensityEffectOnFly(G4bool)
Definition: G4Material.cc:658
G4String fName
Definition: G4Material.hh:362
G4IonisParamMat * fIonisation
Definition: G4Material.hh:331
G4Material(const G4Material &)=delete
G4double GetNuclearInterLength() const
Definition: G4Material.hh:219
G4MaterialPropertiesTable * fMaterialPropertiesTable
Definition: G4Material.hh:319
std::vector< const G4Element * > * fElm
Definition: G4Material.hh:357
static constexpr double STP_Pressure
static constexpr double kelvin
const char * name(G4int ptype)
string material
Definition: eplot.py:19