G4Material.hh

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id: G4Material.hh 67044 2013-01-30 08:50:06Z gcosmo $
00028 //
00029 
00030 //---------------------------------------------------------------------------
00031 //
00032 // ClassName:   G4Material
00033 //
00034 // Description: Contains material properties
00035 //
00036 // Class description:
00037 //
00038 // Is used to define the material composition of Geant4 volumes.
00039 // A G4Material is always made of G4Elements. It should has the name, 
00040 // the list of G4Elements, material density, material state, temperature, 
00041 // pressure. Other parameters are optional and may be set by the user code 
00042 // or computed at initialisation. 
00043 // 
00044 // There is several ways to construct G4Material:
00045 //   - from single element;
00046 //   - from a list of components (elements or other materials);
00047 //   - from internal Geant4 database of materials
00048 //
00049 // A collection of constituent Elements/Materials should be defined 
00050 // with specified weights by fractional mass or atom counts (only for Elements).
00051 //
00052 // Quantities, with physical meaning or not, which are constant in a given 
00053 // material are computed and stored here as Derived data members.
00054 //
00055 // The class contains as a private static member the Table of defined
00056 // materials (an ordered vector of materials).
00057 //
00058 // It is strongly not recommended to delete materials in user code.
00059 // All materials will be deleted automatically at the end of Geant4 session.
00060 //
00061 
00062 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00063 
00064 // 10-07-96, new data members added by L.Urban
00065 // 12-12-96, new data members added by L.Urban
00066 // 20-01-97, aesthetic rearrangement. RadLength calculation modified
00067 //           Data members Zeff and Aeff REMOVED (i.e. passed to the Elements).
00068 //           (local definition of Zeff in DensityEffect and FluctModel...)
00069 //           Vacuum defined as a G4State. Mixture flag removed, M.Maire  
00070 // 29-01-97, State=Vacuum automatically set density=0 in the contructors.
00071 //           Subsequent protections have been put in the calculation of 
00072 //           MeanExcEnergy, ShellCorrectionVector, DensityEffect, M.Maire
00073 // 20-03-97, corrected initialization of pointers, M.Maire
00074 // 10-06-97, new data member added by V.Grichine (fSandiaPhotoAbsCof)
00075 // 27-06-97, new function GetElement(int), M.Maire
00076 // 24-02-98, fFractionVector become fMassFractionVector
00077 // 28-05-98, kState=kVacuum removed: 
00078 //           The vacuum is an ordinary gas vith very low density, M.Maire
00079 // 12-06-98, new method AddMaterial() allowing mixture of materials, M.Maire
00080 // 09-07-98, Ionisation parameters removed from the class, M.Maire
00081 // 04-08-98, new method GetMaterial(materialName), M.Maire
00082 // 05-10-98, change name: NumDensity -> NbOfAtomsPerVolume
00083 // 18-11-98, SandiaTable interface modified.
00084 // 19-07-99, new data member (chemicalFormula) added by V.Ivanchenko
00085 // 12-03-01, G4bool fImplicitElement (mma)
00086 // 30-03-01, suppression of the warning message in GetMaterial
00087 // 17-07-01, migration to STL. M. Verderi.
00088 // 14-09-01, Suppression of the data member fIndexInTable
00089 // 31-10-01, new function SetChemicalFormula() (mma)
00090 // 26-02-02, fIndexInTable renewed
00091 // 06-08-02, remove constructors with ChemicalFormula (mma)
00092 // 15-11-05, GetMaterial(materialName, G4bool warning=true)
00093 // 13-04-12, std::map<G4Material*,G4double> fMatComponents (mma)
00094 // 21-04-12, fMassOfMolecule (mma)
00095 
00096 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00097 
00098 #ifndef G4MATERIAL_HH
00099 #define G4MATERIAL_HH 1
00100 
00101 #include <vector>
00102 #include <map>
00103 #include <CLHEP/Units/PhysicalConstants.h>
00104 
00105 #include "globals.hh"
00106 #include "G4ios.hh"
00107 #include "G4Element.hh"
00108 #include "G4MaterialPropertiesTable.hh"
00109 #include "G4IonisParamMat.hh"
00110 #include "G4SandiaTable.hh"
00111 #include "G4ElementVector.hh"
00112 #include "G4MaterialTable.hh"
00113 
00114 enum G4State { kStateUndefined = 0, kStateSolid, kStateLiquid, kStateGas };
00115 
00116 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00117 
00118 class G4Material
00119 {
00120 public:  // with description
00121 
00122   //
00123   // Constructor to create a material from single element
00124   //
00125   G4Material(const G4String& name,                              //its name
00126                    G4double  z,                                 //atomic number
00127                    G4double  a,                                 //mass of mole
00128                    G4double  density,                           //density
00129                    G4State   state    = kStateUndefined,        //solid,gas
00130                    G4double  temp     = CLHEP::STP_Temperature, //temperature
00131                    G4double  pressure = CLHEP::STP_Pressure);   //pressure
00132 
00133   //
00134   // Constructor to create a material from a combination of elements
00135   // and/or materials subsequently added via AddElement and/or AddMaterial
00136   //
00137   G4Material(const G4String& name,                              //its name
00138                    G4double  density,                           //density
00139                    G4int     nComponents,                       //nbOfComponents
00140                    G4State   state    = kStateUndefined,        //solid,gas
00141                    G4double  temp     = CLHEP::STP_Temperature, //temperature
00142                    G4double  pressure = CLHEP::STP_Pressure);   //pressure
00143 
00144   //
00145   // Constructor to create a material from the base material
00146   //
00147   G4Material(const G4String& name,                              //its name
00148                    G4double  density,                           //density
00149              const G4Material* baseMaterial,                    //base material
00150                    G4State   state    = kStateUndefined,        //solid,gas
00151                    G4double  temp     = CLHEP::STP_Temperature, //temperature
00152                    G4double  pressure = CLHEP::STP_Pressure);   //pressure
00153 
00154   //
00155   // Add an element, giving number of atoms
00156   //
00157   void AddElement(G4Element* element,                           //the element
00158                   G4int      nAtoms);                           //nb of atoms in
00159                                                                 // a molecule
00160   //
00161   // Add an element or material, giving fraction of mass
00162   //
00163   void AddElement (G4Element* element ,                         //the element
00164                    G4double   fraction);                        //fractionOfMass
00165                      
00166   void AddMaterial(G4Material* material,                        //the material
00167                    G4double   fraction);                        //fractionOfMass
00168                      
00169                      
00170   virtual ~G4Material();
00171   
00172   inline void SetChemicalFormula (const G4String& chF) {fChemicalFormula=chF;}
00173 
00174   //
00175   // retrieval methods
00176   // 
00177   inline const G4String& GetName()            const {return fName;}
00178   inline const G4String& GetChemicalFormula() const {return fChemicalFormula;}
00179   inline G4double GetDensity()     const {return fDensity;}
00180   inline G4State  GetState()       const {return fState;}
00181   inline G4double GetTemperature() const {return fTemp;}
00182   inline G4double GetPressure()    const {return fPressure;}
00183     
00184   //number of elements constituing this material:    
00185   inline size_t GetNumberOfElements()  const {return fNumberOfElements;}
00186     
00187   //vector of pointers to elements constituing this material:          
00188   inline const
00189   G4ElementVector* GetElementVector()  const {return theElementVector;}
00190   
00191   //vector of fractional mass of each element:
00192   inline const  
00193   G4double* GetFractionVector() const {return fMassFractionVector;}
00194     
00195   //vector of atom count of each element:
00196   inline const  
00197   G4int*    GetAtomsVector()    const {return fAtomsVector;}
00198 
00199   //return a pointer to an element, given its index in the material:
00200   inline const 
00201   G4Element* GetElement(G4int iel) const {return (*theElementVector)[iel];}
00202   
00203   //vector of nb of atoms per volume of each element in this material:
00204   inline const
00205   G4double* GetVecNbOfAtomsPerVolume() const {return VecNbOfAtomsPerVolume;}
00206   //total number of atoms per volume:
00207   inline
00208   G4double  GetTotNbOfAtomsPerVolume() const {return TotNbOfAtomsPerVolume;}
00209   //total number of electrons per volume:
00210   inline
00211   G4double  GetTotNbOfElectPerVolume() const {return TotNbOfElectPerVolume;}
00212 
00213   //obsolete names (5-10-98) see the 2 functions above
00214   inline const
00215   G4double* GetAtomicNumDensityVector() const {return VecNbOfAtomsPerVolume;}
00216   inline G4double  GetElectronDensity() const {return TotNbOfElectPerVolume;}
00217     
00218   // Radiation length:     
00219   inline G4double  GetRadlen()          const {return fRadlen;}
00220     
00221   // Nuclear interaction length:     
00222   inline G4double GetNuclearInterLength() const {return fNuclInterLen;}
00223         
00224   // ionisation parameters:
00225   inline G4IonisParamMat* GetIonisation() const {return fIonisation;}
00226   
00227   // Sandia table:
00228   inline G4SandiaTable*  GetSandiaTable() const {return fSandiaTable;}
00229 
00230   // Base material:
00231   inline 
00232   const G4Material* GetBaseMaterial()     const {return fBaseMaterial;}
00233   
00234   // material components:
00235   inline 
00236   std::map<G4Material*,G4double> GetMatComponents() const 
00237                                                {return fMatComponents;}
00238                                                
00239   //for chemical compound
00240   inline 
00241   G4double GetMassOfMolecule()     const {return fMassOfMolecule;}
00242       
00243   //meaningful only for single material:
00244   G4double GetZ() const;
00245   G4double GetA() const;
00246   
00247   //the MaterialPropertiesTable (if any) attached to this material:
00248   inline void SetMaterialPropertiesTable(G4MaterialPropertiesTable* anMPT)
00249   {fMaterialPropertiesTable = anMPT;}
00250                                        
00251   inline G4MaterialPropertiesTable* GetMaterialPropertiesTable() const
00252   {return fMaterialPropertiesTable;}
00253 
00254   //the (static) Table of Materials:
00255   //
00256   static const G4MaterialTable* GetMaterialTable();
00257       
00258   static size_t GetNumberOfMaterials();
00259   
00260   //the index of this material in the Table:    
00261   inline size_t GetIndex() const {return fIndexInTable;}
00262     
00263   //return  pointer to a material, given its name:    
00264   static G4Material* GetMaterial(const G4String& name, G4bool warning=true);
00265   
00266   //
00267   //printing methods
00268   //
00269   friend std::ostream& operator<<(std::ostream&, G4Material*);    
00270   friend std::ostream& operator<<(std::ostream&, G4Material&);    
00271   friend std::ostream& operator<<(std::ostream&, G4MaterialTable);
00272     
00273 public:  // without description 
00274        
00275   G4int operator==(const G4Material&) const;
00276   G4int operator!=(const G4Material&) const;
00277   G4Material(__void__&);
00278     // Fake default constructor for usage restricted to direct object
00279     // persistency for clients requiring preallocation of memory for
00280     // persistifiable objects.
00281 
00282   inline void SetName (const G4String& name) {fName=name;}
00283 
00284 private:
00285 
00286   G4Material(const G4Material&);
00287   const G4Material& operator=(const G4Material&);
00288 
00289   void InitializePointers();
00290    
00291   // Header routine for all derived quantities
00292   void ComputeDerivedQuantities();
00293 
00294   // Compute Radiation length
00295   void ComputeRadiationLength();
00296   
00297   // Compute Nuclear interaction length
00298   void ComputeNuclearInterLength();
00299 
00300   // Copy pointers of base material
00301   void CopyPointersOfBaseMaterial();
00302     
00303 private:
00304 
00305   //
00306   // Basic data members ( To define a material)
00307   //
00308   G4String         fName;                 // Material name
00309   G4String         fChemicalFormula;      // Material chemical formula
00310   G4double         fDensity;              // Material density
00311   
00312   G4State          fState;                // Material state (determined 
00313                                           // internally based on density)
00314   G4double         fTemp;                 // Temperature (defaults: STP)
00315   G4double         fPressure;             // Pressure    (defaults: STP)
00316 
00317   G4int            maxNbComponents;       // totalNbOfComponentsInTheMaterial 
00318   G4int            fArrayLength;          // the length of fAtomsVector 
00319   size_t           fNumberOfComponents;   // Nb of components declared so far
00320 
00321   size_t           fNumberOfElements;     // Nb of Elements in the material
00322   G4ElementVector* theElementVector;      // vector of constituent Elements
00323   G4bool           fImplicitElement;      // implicit Element created by this?
00324   G4double*        fMassFractionVector;   // composition by fractional mass
00325   G4int*           fAtomsVector;          // composition by atom count
00326 
00327   G4MaterialPropertiesTable* fMaterialPropertiesTable;
00328 
00329   static
00330   G4MaterialTable theMaterialTable;       // the material table
00331   size_t fIndexInTable;                   // the position in the table 
00332 
00333   //
00334   // Derived data members (computed from the basic data members)
00335   //
00336   // some general atomic properties
00337    
00338   G4double* VecNbOfAtomsPerVolume;        // vector of nb of atoms per volume
00339   G4double  TotNbOfAtomsPerVolume;        // total nb of atoms per volume 
00340   G4double  TotNbOfElectPerVolume;        // total nb of electrons per volume 
00341   G4double  fRadlen;                      // Radiation length
00342   G4double  fNuclInterLen;                // Nuclear interaction length  
00343   
00344   G4IonisParamMat* fIonisation;           // ionisation parameters
00345   G4SandiaTable*   fSandiaTable;          // Sandia table
00346   
00347   // utilities
00348   //         
00349   const G4Material* fBaseMaterial;        // Pointer to the base material
00350   G4double fMassOfMolecule;               // for materials built by atoms count
00351   std::map<G4Material*,G4double> fMatComponents; // for composites built via
00352                                                  // AddMaterial()
00353 };
00354 
00355 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00356 
00357 #endif

Generated on Mon May 27 17:48:50 2013 for Geant4 by  doxygen 1.4.7