|
||||
File indexing completed on 2025-01-18 09:58:39
0001 // 0002 // ******************************************************************** 0003 // * License and Disclaimer * 0004 // * * 0005 // * The Geant4 software is copyright of the Copyright Holders of * 0006 // * the Geant4 Collaboration. It is provided under the terms and * 0007 // * conditions of the Geant4 Software License, included in the file * 0008 // * LICENSE and available at http://cern.ch/geant4/license . These * 0009 // * include a list of copyright holders. * 0010 // * * 0011 // * Neither the authors of this software system, nor their employing * 0012 // * institutes,nor the agencies providing financial support for this * 0013 // * work make any representation or warranty, express or implied, * 0014 // * regarding this software system or assume any liability for its * 0015 // * use. Please see the license in the file LICENSE and URL above * 0016 // * for the full disclaimer and the limitation of liability. * 0017 // * * 0018 // * This code implementation is the result of the scientific and * 0019 // * technical work of the GEANT4 collaboration. * 0020 // * By using, copying, modifying or distributing the software (or * 0021 // * any work based on the software) you agree to acknowledge its * 0022 // * use in resulting scientific publications, and indicate your * 0023 // * acceptance of all terms of the Geant4 Software license. * 0024 // ******************************************************************** 0025 0026 //--------------------------------------------------------------------------- 0027 // 0028 // ClassName: G4Material 0029 // 0030 // Description: Contains material properties 0031 // 0032 // Class description: 0033 // 0034 // Is used to define the material composition of Geant4 volumes. 0035 // A G4Material is always made of G4Elements. It should has the name, 0036 // the list of G4Elements, material density, material state, temperature, 0037 // pressure. Other parameters are optional and may be set by the user code 0038 // or computed at initialisation. 0039 // 0040 // There is several ways to construct G4Material: 0041 // - from single element; 0042 // - from a list of components (elements or other materials); 0043 // - from internal Geant4 database of materials 0044 // 0045 // A collection of constituent Elements/Materials should be defined 0046 // with specified weights by fractional mass or atom counts (only for Elements). 0047 // 0048 // Quantities, with physical meaning or not, which are constant in a given 0049 // material are computed and stored here as Derived data members. 0050 // 0051 // The class contains as a private static member the Table of defined 0052 // materials (an ordered vector of materials). 0053 // 0054 // It is strongly not recommended to delete materials in user code. 0055 // All materials will be deleted automatically at the end of Geant4 session. 0056 // 0057 // 10-07-96, new data members added by L.Urban 0058 // 12-12-96, new data members added by L.Urban 0059 // 20-01-97, aesthetic rearrangement. RadLength calculation modified 0060 // Data members Zeff and Aeff REMOVED (i.e. passed to the Elements). 0061 // (local definition of Zeff in DensityEffect and FluctModel...) 0062 // Vacuum defined as a G4State. Mixture flag removed, M.Maire 0063 // 29-01-97, State=Vacuum automatically set density=0 in the contructors. 0064 // Subsequent protections have been put in the calculation of 0065 // MeanExcEnergy, ShellCorrectionVector, DensityEffect, M.Maire 0066 // 20-03-97, corrected initialization of pointers, M.Maire 0067 // 10-06-97, new data member added by V.Grichine (fSandiaPhotoAbsCof) 0068 // 27-06-97, new function GetElement(int), M.Maire 0069 // 24-02-98, fFractionVector become fMassFractionVector 0070 // 28-05-98, kState=kVacuum removed: 0071 // The vacuum is an ordinary gas vith very low density, M.Maire 0072 // 12-06-98, new method AddMaterial() allowing mixture of materials, M.Maire 0073 // 09-07-98, Ionisation parameters removed from the class, M.Maire 0074 // 04-08-98, new method GetMaterial(materialName), M.Maire 0075 // 05-10-98, change name: NumDensity -> NbOfAtomsPerVolume 0076 // 18-11-98, SandiaTable interface modified. 0077 // 19-07-99, new data member (chemicalFormula) added by V.Ivanchenko 0078 // 12-03-01, G4bool fImplicitElement (mma) 0079 // 30-03-01, suppression of the warning message in GetMaterial 0080 // 17-07-01, migration to STL. M. Verderi. 0081 // 14-09-01, Suppression of the data member fIndexInTable 0082 // 31-10-01, new function SetChemicalFormula() (mma) 0083 // 26-02-02, fIndexInTable renewed 0084 // 06-08-02, remove constructors with ChemicalFormula (mma) 0085 // 15-11-05, GetMaterial(materialName, G4bool warning=true) 0086 // 13-04-12, std::map<G4Material*,G4double> fMatComponents (mma) 0087 // 21-04-12, fMassOfMolecule (mma) 0088 0089 #ifndef G4MATERIAL_HH 0090 #define G4MATERIAL_HH 1 0091 0092 #include "G4Element.hh" 0093 #include "G4ElementVector.hh" 0094 #include "G4IonisParamMat.hh" 0095 #include "G4MaterialPropertiesTable.hh" 0096 #include "G4MaterialTable.hh" 0097 #include "G4SandiaTable.hh" 0098 #include "G4ios.hh" 0099 #include "globals.hh" 0100 0101 #include <CLHEP/Units/PhysicalConstants.h> 0102 0103 #include <map> 0104 #include <vector> 0105 0106 enum G4State 0107 { 0108 kStateUndefined = 0, 0109 kStateSolid, 0110 kStateLiquid, 0111 kStateGas 0112 }; 0113 0114 static const G4double NTP_Temperature = 293.15 * CLHEP::kelvin; 0115 0116 class G4Material 0117 { 0118 public: // with description 0119 // Constructor to create a material from single element 0120 G4Material(const G4String& name, // its name 0121 G4double z, // atomic number 0122 G4double a, // mass of mole 0123 G4double density, // density 0124 G4State state = kStateUndefined, // solid,gas 0125 G4double temp = NTP_Temperature, // temperature 0126 G4double pressure = CLHEP::STP_Pressure); // pressure 0127 0128 // Constructor to create a material from a combination of elements 0129 // and/or materials subsequently added via AddElement and/or AddMaterial 0130 G4Material(const G4String& name, // its name 0131 G4double density, // density 0132 G4int nComponents, // nbOfComponents 0133 G4State state = kStateUndefined, // solid,gas 0134 G4double temp = NTP_Temperature, // temperature 0135 G4double pressure = CLHEP::STP_Pressure); // pressure 0136 0137 // Constructor to create a material from the base material 0138 G4Material(const G4String& name, // its name 0139 G4double density, // density 0140 const G4Material* baseMaterial, // base material 0141 G4State state = kStateUndefined, // solid,gas 0142 G4double temp = NTP_Temperature, // temperature 0143 G4double pressure = CLHEP::STP_Pressure); // pressure 0144 0145 virtual ~G4Material(); 0146 0147 // These methods allow customisation of corrections to ionisation 0148 // computations. Free electron density above zero means that the material 0149 // is a conductor. Computation of density effect correction of fly 0150 // may be more accurate but require extra computations. 0151 void SetChemicalFormula(const G4String& chF); 0152 void SetFreeElectronDensity(G4double val); 0153 void ComputeDensityEffectOnFly(G4bool val); 0154 0155 G4Material(const G4Material&) = delete; 0156 const G4Material& operator=(const G4Material&) = delete; 0157 0158 // Add an element, giving number of atoms 0159 void AddElementByNumberOfAtoms(const G4Element* elm, G4int nAtoms); 0160 inline void AddElement(G4Element* elm, G4int nAtoms) { AddElementByNumberOfAtoms(elm, nAtoms); } 0161 0162 // Add an element or material, giving fraction of mass 0163 void AddElementByMassFraction(const G4Element* elm, G4double fraction); 0164 inline void AddElement(G4Element* elm, G4double frac) { AddElementByMassFraction(elm, frac); } 0165 0166 void AddMaterial(G4Material* material, G4double fraction); 0167 0168 // 0169 // retrieval methods 0170 // 0171 inline const G4String& GetName() const { return fName; } 0172 inline const G4String& GetChemicalFormula() const { return fChemicalFormula; } 0173 inline G4double GetFreeElectronDensity() const { return fFreeElecDensity; } 0174 inline G4double GetDensity() const { return fDensity; } 0175 inline G4State GetState() const { return fState; } 0176 inline G4double GetTemperature() const { return fTemp; } 0177 inline G4double GetPressure() const { return fPressure; } 0178 0179 // number of elements constituing this material: 0180 inline std::size_t GetNumberOfElements() const { return fNumberOfElements; } 0181 0182 // vector of pointers to elements constituing this material: 0183 inline const G4ElementVector* GetElementVector() const { return theElementVector; } 0184 0185 // vector of fractional mass of each element: 0186 inline const G4double* GetFractionVector() const { return fMassFractionVector; } 0187 0188 // vector of atom count of each element: 0189 inline const G4int* GetAtomsVector() const { return fAtomsVector; } 0190 0191 // return a pointer to an element, given its index in the material: 0192 inline const G4Element* GetElement(G4int iel) const { return (*theElementVector)[iel]; } 0193 0194 // vector of nb of atoms per volume of each element in this material: 0195 inline const G4double* GetVecNbOfAtomsPerVolume() const { return fVecNbOfAtomsPerVolume; } 0196 // total number of atoms per volume: 0197 inline G4double GetTotNbOfAtomsPerVolume() const { return fTotNbOfAtomsPerVolume; } 0198 // total number of electrons per volume: 0199 inline G4double GetTotNbOfElectPerVolume() const { return fTotNbOfElectPerVolume; } 0200 0201 // obsolete names (5-10-98) see the 2 functions above 0202 inline const G4double* GetAtomicNumDensityVector() const { return fVecNbOfAtomsPerVolume; } 0203 inline G4double GetElectronDensity() const { return fTotNbOfElectPerVolume; } 0204 0205 // Radiation length: 0206 inline G4double GetRadlen() const { return fRadlen; } 0207 0208 // Nuclear interaction length 0209 inline G4double GetNuclearInterLength() const { return fNuclInterLen; } 0210 0211 // ionisation parameters: 0212 inline G4IonisParamMat* GetIonisation() const { return fIonisation; } 0213 0214 // Sandia table: 0215 inline G4SandiaTable* GetSandiaTable() const { return fSandiaTable; } 0216 0217 // Base material: 0218 inline const G4Material* GetBaseMaterial() const { return fBaseMaterial; } 0219 0220 // material components: 0221 inline const std::map<G4Material*, G4double>& GetMatComponents() const { return fMatComponents; } 0222 0223 // for chemical compound 0224 inline G4double GetMassOfMolecule() const { return fMassOfMolecule; } 0225 0226 // meaningful only for single material: 0227 G4double GetZ() const; 0228 G4double GetA() const; 0229 0230 // the MaterialPropertiesTable (if any) attached to this material: 0231 void SetMaterialPropertiesTable(G4MaterialPropertiesTable* anMPT); 0232 0233 inline G4MaterialPropertiesTable* GetMaterialPropertiesTable() const 0234 { 0235 return fMaterialPropertiesTable; 0236 } 0237 0238 // the index of this material in the Table: 0239 inline std::size_t GetIndex() const { return fIndexInTable; } 0240 0241 // the static Table of Materials: 0242 static G4MaterialTable* GetMaterialTable(); 0243 0244 static std::size_t GetNumberOfMaterials(); 0245 0246 // return pointer to a material, given its name: 0247 static G4Material* GetMaterial(const G4String& name, G4bool warning = true); 0248 0249 // return pointer to a simple material, given its propeties: 0250 static G4Material* GetMaterial(G4double z, G4double a, G4double dens); 0251 0252 // return pointer to a composit material, given its propeties: 0253 static G4Material* GetMaterial(std::size_t nComp, G4double dens); 0254 0255 // printing methods 0256 friend std::ostream& operator<<(std::ostream&, const G4Material*); 0257 friend std::ostream& operator<<(std::ostream&, const G4Material&); 0258 friend std::ostream& operator<<(std::ostream&, const G4MaterialTable&); 0259 0260 inline void SetName(const G4String& name) { fName = name; } 0261 0262 virtual G4bool IsExtended() const; 0263 0264 // operators 0265 G4bool operator==(const G4Material&) const = delete; 0266 G4bool operator!=(const G4Material&) const = delete; 0267 0268 private: 0269 void InitializePointers(); 0270 0271 // Header routine for all derived quantities 0272 void ComputeDerivedQuantities(); 0273 0274 // Compute Radiation length 0275 void ComputeRadiationLength(); 0276 0277 // Compute Nuclear interaction length 0278 void ComputeNuclearInterLength(); 0279 0280 // Copy pointers of base material 0281 void CopyPointersOfBaseMaterial(); 0282 0283 void FillVectors(); 0284 0285 G4bool IsLocked(); 0286 0287 static G4MaterialTable theMaterialTable; // the material table 0288 0289 const G4Material* fBaseMaterial; // Pointer to the base material 0290 G4MaterialPropertiesTable* fMaterialPropertiesTable; 0291 0292 // 0293 // General atomic properties defined in constructor or 0294 // computed from the basic data members 0295 // 0296 0297 G4ElementVector* theElementVector; // vector of constituent G4Elements 0298 G4int* fAtomsVector; // composition by atom count 0299 G4double* fMassFractionVector; // composition by fractional mass 0300 G4double* fVecNbOfAtomsPerVolume; // number of atoms per volume 0301 0302 G4IonisParamMat* fIonisation; // ionisation parameters 0303 G4SandiaTable* fSandiaTable; // Sandia table 0304 0305 G4double fDensity; // Material density 0306 G4double fFreeElecDensity; // Free electron density 0307 G4double fTemp; // Temperature (defaults: STP) 0308 G4double fPressure; // Pressure (defaults: STP) 0309 0310 G4double fTotNbOfAtomsPerVolume; // Total nb of atoms per volume 0311 G4double fTotNbOfElectPerVolume; // Total nb of electrons per volume 0312 G4double fRadlen; // Radiation length 0313 G4double fNuclInterLen; // Nuclear interaction length 0314 G4double fMassOfMolecule; // Correct for materials built by atoms count 0315 0316 G4State fState; // Material state 0317 std::size_t fIndexInTable; // Index in the material table 0318 G4int fNumberOfElements; // Number of G4Elements in the material 0319 0320 // Class members used only at initialisation 0321 G4int fNbComponents; // Number of components 0322 G4int fIdxComponent; // Index of a new component 0323 G4bool fMassFraction; // Flag of the method to add components 0324 0325 // For composites built 0326 std::vector<G4int>* fAtoms = nullptr; 0327 std::vector<G4double>* fElmFrac = nullptr; 0328 std::vector<const G4Element*>* fElm = nullptr; 0329 0330 // For composites built via AddMaterial() 0331 std::map<G4Material*, G4double> fMatComponents; 0332 0333 G4String fName; // Material name 0334 G4String fChemicalFormula; // Material chemical formula 0335 }; 0336 0337 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |