[822] | 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 | // |
---|
[850] | 27 | // $Id: G4Material.hh,v 1.26 2008/08/13 16:06:42 vnivanch Exp $ |
---|
| 28 | // GEANT4 tag $Name: HEAD $ |
---|
[822] | 29 | // |
---|
| 30 | |
---|
| 31 | // class description |
---|
| 32 | // |
---|
| 33 | // Materials defined via the G4Material class are used to define the |
---|
| 34 | // composition of Geant volumes. |
---|
| 35 | // a Material is always made of Elements. It can be defined directly |
---|
| 36 | // from scratch (defined by an implicit, single element), specifying : |
---|
| 37 | // its name, |
---|
| 38 | // density, |
---|
| 39 | // state informations, |
---|
| 40 | // and Z,A of the underlying Element. |
---|
| 41 | // |
---|
| 42 | // or in terms of a collection of constituent Elements with specified weights |
---|
| 43 | // (composition specified either by fractional mass or atom counts). |
---|
| 44 | // |
---|
| 45 | // Quantities, with physical meaning or not, which are constant in a given |
---|
| 46 | // material are computed and stored here as Derived data members. |
---|
| 47 | // |
---|
| 48 | // The class contains as a private static member the Table of defined |
---|
| 49 | // materials (an ordered vector of materials). |
---|
| 50 | // |
---|
| 51 | |
---|
| 52 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
| 53 | |
---|
| 54 | // 10-07-96, new data members added by L.Urban |
---|
| 55 | // 12-12-96, new data members added by L.Urban |
---|
| 56 | // 20-01-97, aesthetic rearrangement. RadLength calculation modified |
---|
| 57 | // Data members Zeff and Aeff REMOVED (i.e. passed to the Elements). |
---|
| 58 | // (local definition of Zeff in DensityEffect and FluctModel...) |
---|
| 59 | // Vacuum defined as a G4State. Mixture flag removed, M.Maire |
---|
| 60 | // 29-01-97, State=Vacuum automatically set density=0 in the contructors. |
---|
| 61 | // Subsequent protections have been put in the calculation of |
---|
| 62 | // MeanExcEnergy, ShellCorrectionVector, DensityEffect, M.Maire |
---|
| 63 | // 20-03-97, corrected initialization of pointers, M.Maire |
---|
| 64 | // 10-06-97, new data member added by V.Grichine (fSandiaPhotoAbsCof) |
---|
| 65 | // 27-06-97, new function GetElement(int), M.Maire |
---|
| 66 | // 24-02-98, fFractionVector become fMassFractionVector |
---|
| 67 | // 28-05-98, kState=kVacuum removed: |
---|
| 68 | // The vacuum is an ordinary gas vith very low density, M.Maire |
---|
| 69 | // 12-06-98, new method AddMaterial() allowing mixture of materials, M.Maire |
---|
| 70 | // 09-07-98, Ionisation parameters removed from the class, M.Maire |
---|
| 71 | // 04-08-98, new method GetMaterial(materialName), M.Maire |
---|
| 72 | // 05-10-98, change name: NumDensity -> NbOfAtomsPerVolume |
---|
| 73 | // 18-11-98, SandiaTable interface modified. |
---|
| 74 | // 19-07-99, new data member (chemicalFormula) added by V.Ivanchenko |
---|
| 75 | // 12-03-01, G4bool fImplicitElement (mma) |
---|
| 76 | // 30-03-01, suppression of the warning message in GetMaterial |
---|
| 77 | // 17-07-01, migration to STL. M. Verderi. |
---|
| 78 | // 14-09-01, Suppression of the data member fIndexInTable |
---|
| 79 | // 31-10-01, new function SetChemicalFormula() (mma) |
---|
| 80 | // 26-02-02, fIndexInTable renewed |
---|
| 81 | // 06-08-02, remove constructors with ChemicalFormula (mma) |
---|
| 82 | // 15-11-05, GetMaterial(materialName, G4bool warning=true) |
---|
| 83 | |
---|
| 84 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
| 85 | |
---|
| 86 | #ifndef G4MATERIAL_HH |
---|
| 87 | #define G4MATERIAL_HH |
---|
| 88 | |
---|
| 89 | #include "globals.hh" |
---|
| 90 | #include "G4ios.hh" |
---|
| 91 | #include <vector> |
---|
| 92 | #include "G4Element.hh" |
---|
| 93 | #include "G4MaterialPropertiesTable.hh" |
---|
| 94 | #include "G4IonisParamMat.hh" |
---|
| 95 | #include "G4SandiaTable.hh" |
---|
| 96 | #include "G4ElementVector.hh" |
---|
| 97 | #include "G4MaterialTable.hh" |
---|
| 98 | |
---|
| 99 | enum G4State { kStateUndefined, kStateSolid, kStateLiquid, kStateGas }; |
---|
| 100 | |
---|
| 101 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
| 102 | |
---|
| 103 | class G4Material |
---|
| 104 | { |
---|
| 105 | public: // with description |
---|
| 106 | |
---|
| 107 | // |
---|
| 108 | // Constructor to create a material from scratch. |
---|
| 109 | // |
---|
| 110 | G4Material(const G4String& name, //its name |
---|
| 111 | G4double z, //atomic number |
---|
| 112 | G4double a, //mass of mole |
---|
| 113 | G4double density, //density |
---|
| 114 | G4State state = kStateUndefined, //solid,gas |
---|
| 115 | G4double temp = STP_Temperature, //temperature |
---|
| 116 | G4double pressure = STP_Pressure); //pressure |
---|
| 117 | |
---|
| 118 | // |
---|
| 119 | // Constructor to create a material from a combination of elements |
---|
| 120 | // and/or materials subsequently added via AddElement and/or AddMaterial |
---|
| 121 | // |
---|
| 122 | G4Material(const G4String& name, //its name |
---|
| 123 | G4double density, //density |
---|
| 124 | G4int nComponents, //nbOfComponents |
---|
| 125 | G4State state = kStateUndefined, //solid,gas |
---|
| 126 | G4double temp = STP_Temperature, //temperature |
---|
| 127 | G4double pressure = STP_Pressure); //pressure |
---|
| 128 | |
---|
| 129 | // |
---|
| 130 | // Add an element, giving number of atoms |
---|
| 131 | // |
---|
| 132 | void AddElement(G4Element* element, //the element |
---|
| 133 | G4int nAtoms); //nb of atoms in |
---|
| 134 | // a molecule |
---|
| 135 | // |
---|
| 136 | // Add an element or material, giving fraction of mass |
---|
| 137 | // |
---|
| 138 | void AddElement (G4Element* element , //the element |
---|
| 139 | G4double fraction); //fractionOfMass |
---|
| 140 | |
---|
| 141 | void AddMaterial(G4Material* material, //the material |
---|
| 142 | G4double fraction); //fractionOfMass |
---|
| 143 | |
---|
| 144 | |
---|
| 145 | virtual ~G4Material(); |
---|
| 146 | |
---|
| 147 | void SetChemicalFormula(const G4String& chF) {fChemicalFormula=chF;}; |
---|
| 148 | |
---|
| 149 | // |
---|
| 150 | // retrieval methods |
---|
| 151 | // |
---|
| 152 | G4String GetName() const {return fName;}; |
---|
| 153 | G4String GetChemicalFormula() const {return fChemicalFormula;}; |
---|
| 154 | G4double GetDensity() const {return fDensity;}; |
---|
| 155 | |
---|
| 156 | G4State GetState() const {return fState;}; |
---|
| 157 | G4double GetTemperature() const {return fTemp;}; |
---|
| 158 | G4double GetPressure() const {return fPressure;}; |
---|
| 159 | |
---|
| 160 | //number of elements constituing this material: |
---|
| 161 | size_t GetNumberOfElements() const {return fNumberOfElements;}; |
---|
| 162 | |
---|
| 163 | //vector of pointers to elements constituing this material: |
---|
| 164 | const |
---|
| 165 | G4ElementVector* GetElementVector() const {return theElementVector;}; |
---|
| 166 | |
---|
| 167 | //vector of fractional mass of each element: |
---|
| 168 | const G4double* GetFractionVector() const {return fMassFractionVector;}; |
---|
| 169 | |
---|
| 170 | //vector of atom count of each element: |
---|
| 171 | const G4int* GetAtomsVector() const {return fAtomsVector;}; |
---|
| 172 | |
---|
| 173 | //return a pointer to an element, given its index in the material: |
---|
| 174 | const |
---|
| 175 | G4Element* GetElement(G4int iel) const {return (*theElementVector)[iel];}; |
---|
| 176 | |
---|
| 177 | //vector of nb of atoms per volume of each element in this material: |
---|
| 178 | const |
---|
| 179 | G4double* GetVecNbOfAtomsPerVolume() const {return VecNbOfAtomsPerVolume;}; |
---|
| 180 | //total number of atoms per volume: |
---|
| 181 | G4double GetTotNbOfAtomsPerVolume() const {return TotNbOfAtomsPerVolume;}; |
---|
| 182 | //total number of electrons per volume: |
---|
| 183 | G4double GetTotNbOfElectPerVolume() const {return TotNbOfElectPerVolume;}; |
---|
| 184 | |
---|
| 185 | //obsolete names (5-10-98) see the 2 functions above |
---|
| 186 | const |
---|
| 187 | G4double* GetAtomicNumDensityVector() const {return VecNbOfAtomsPerVolume;}; |
---|
| 188 | G4double GetElectronDensity() const {return TotNbOfElectPerVolume;}; |
---|
| 189 | |
---|
| 190 | // Radiation length: |
---|
| 191 | G4double GetRadlen() const {return fRadlen;}; |
---|
| 192 | |
---|
| 193 | // Nuclear interaction length: |
---|
| 194 | G4double GetNuclearInterLength() const {return fNuclInterLen;}; |
---|
| 195 | |
---|
| 196 | // ionisation parameters: |
---|
| 197 | G4IonisParamMat* GetIonisation() const {return fIonisation;}; |
---|
| 198 | |
---|
| 199 | // Sandia table: |
---|
| 200 | G4SandiaTable* GetSandiaTable() const {return fSandiaTable;}; |
---|
| 201 | |
---|
| 202 | //meaningful only for single material: |
---|
| 203 | G4double GetZ() const; |
---|
| 204 | G4double GetA() const; |
---|
| 205 | |
---|
| 206 | //the MaterialPropertiesTable (if any) attached to this material: |
---|
| 207 | void SetMaterialPropertiesTable(G4MaterialPropertiesTable* anMPT) |
---|
| 208 | {fMaterialPropertiesTable = anMPT;}; |
---|
| 209 | |
---|
| 210 | G4MaterialPropertiesTable* GetMaterialPropertiesTable() const |
---|
| 211 | {return fMaterialPropertiesTable;}; |
---|
| 212 | |
---|
| 213 | //the (static) Table of Materials: |
---|
| 214 | // |
---|
| 215 | static |
---|
| 216 | const G4MaterialTable* GetMaterialTable(); |
---|
| 217 | |
---|
| 218 | static |
---|
| 219 | size_t GetNumberOfMaterials(); |
---|
| 220 | |
---|
| 221 | //the index of this material in the Table: |
---|
| 222 | size_t GetIndex() const {return fIndexInTable;}; |
---|
| 223 | |
---|
| 224 | //return pointer to a material, given its name: |
---|
| 225 | static G4Material* GetMaterial(G4String name, G4bool warning=true); |
---|
| 226 | |
---|
| 227 | // |
---|
| 228 | //printing methods |
---|
| 229 | // |
---|
| 230 | friend std::ostream& operator<<(std::ostream&, G4Material*); |
---|
| 231 | friend std::ostream& operator<<(std::ostream&, G4Material&); |
---|
| 232 | friend std::ostream& operator<<(std::ostream&, G4MaterialTable); |
---|
| 233 | |
---|
| 234 | public: // without description |
---|
| 235 | |
---|
| 236 | G4int operator==(const G4Material&) const; |
---|
| 237 | G4int operator!=(const G4Material&) const; |
---|
| 238 | G4Material(__void__&); |
---|
| 239 | // Fake default constructor for usage restricted to direct object |
---|
| 240 | // persistency for clients requiring preallocation of memory for |
---|
| 241 | // persistifiable objects. |
---|
| 242 | |
---|
| 243 | private: |
---|
| 244 | |
---|
| 245 | G4Material(const G4Material&); |
---|
| 246 | const G4Material& operator=(const G4Material&); |
---|
| 247 | |
---|
| 248 | void InitializePointers(); |
---|
| 249 | |
---|
| 250 | // Header routine for all derived quantities |
---|
| 251 | void ComputeDerivedQuantities(); |
---|
| 252 | |
---|
| 253 | // Compute Radiation length |
---|
| 254 | void ComputeRadiationLength(); |
---|
| 255 | |
---|
| 256 | // Compute Nuclear interaction length |
---|
| 257 | void ComputeNuclearInterLength(); |
---|
| 258 | |
---|
| 259 | private: |
---|
| 260 | |
---|
| 261 | // |
---|
| 262 | // Basic data members ( To define a material) |
---|
| 263 | // |
---|
| 264 | |
---|
| 265 | G4String fName; // Material name |
---|
| 266 | G4String fChemicalFormula; // Material chemical formula |
---|
| 267 | G4double fDensity; // Material density |
---|
| 268 | |
---|
| 269 | G4State fState; // Material state (determined |
---|
| 270 | // internally based on density) |
---|
| 271 | G4double fTemp; // Temperature (defaults: STP) |
---|
| 272 | G4double fPressure; // Pressure (defaults: STP) |
---|
| 273 | |
---|
| 274 | G4int maxNbComponents; // totalNbOfComponentsInTheMaterial |
---|
[850] | 275 | G4int fArrayLength; // the length of FAtomVector |
---|
[822] | 276 | size_t fNumberOfComponents; // Nb of components declared so far |
---|
| 277 | |
---|
| 278 | size_t fNumberOfElements; // Nb of Elements in the material |
---|
| 279 | G4ElementVector* theElementVector; // vector of constituent Elements |
---|
| 280 | G4bool fImplicitElement; // implicit Element created by this? |
---|
| 281 | G4double* fMassFractionVector; // composition by fractional mass |
---|
| 282 | G4int* fAtomsVector; // composition by atom count |
---|
| 283 | |
---|
| 284 | G4MaterialPropertiesTable* fMaterialPropertiesTable; |
---|
| 285 | |
---|
| 286 | static |
---|
| 287 | G4MaterialTable theMaterialTable; // the material table |
---|
| 288 | size_t fIndexInTable; // the position in the table |
---|
| 289 | |
---|
| 290 | // |
---|
| 291 | // Derived data members (computed from the basic data members) |
---|
| 292 | // |
---|
| 293 | // some general atomic properties |
---|
| 294 | |
---|
| 295 | G4double* VecNbOfAtomsPerVolume; // vector of nb of atoms per volume |
---|
| 296 | G4double TotNbOfAtomsPerVolume; // total nb of atoms per volume |
---|
| 297 | G4double TotNbOfElectPerVolume; // total nb of electrons per volume |
---|
| 298 | G4double fRadlen; // Radiation length |
---|
| 299 | G4double fNuclInterLen; // Nuclear interaction length |
---|
| 300 | |
---|
| 301 | G4IonisParamMat* fIonisation; // ionisation parameters |
---|
| 302 | G4SandiaTable* fSandiaTable; // Sandia table |
---|
| 303 | }; |
---|
| 304 | |
---|
| 305 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
| 306 | |
---|
| 307 | inline |
---|
| 308 | G4double G4Material::GetZ() const |
---|
| 309 | { |
---|
| 310 | if (fNumberOfElements > 1) { |
---|
| 311 | G4cerr << "WARNING in GetZ. The material: " << fName << " is a mixture." |
---|
| 312 | << G4endl; |
---|
| 313 | G4Exception ( " the Atomic number is not well defined." ); |
---|
| 314 | } |
---|
| 315 | return (*theElementVector)[0]->GetZ(); |
---|
| 316 | } |
---|
| 317 | |
---|
| 318 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
| 319 | |
---|
| 320 | inline |
---|
| 321 | G4double G4Material::GetA() const |
---|
| 322 | { |
---|
| 323 | if (fNumberOfElements > 1) { |
---|
| 324 | G4cerr << "WARNING in GetA. The material: " << fName << " is a mixture." |
---|
| 325 | << G4endl; |
---|
| 326 | G4Exception ( " the Atomic mass is not well defined." ); |
---|
| 327 | } |
---|
| 328 | return (*theElementVector)[0]->GetA(); |
---|
| 329 | } |
---|
| 330 | |
---|
| 331 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
| 332 | |
---|
| 333 | #endif |
---|