Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // >> 26 // $Id: G4NistMaterialBuilder.hh,v 1.17 2010-10-26 16:25:24 vnivanch Exp $ >> 27 // GEANT4 tag $Name: geant4-09-04-patch-01 $ 26 28 27 #ifndef G4NistMaterialBuilder_h 29 #ifndef G4NistMaterialBuilder_h 28 #define G4NistMaterialBuilder_h 1 30 #define G4NistMaterialBuilder_h 1 29 31 30 //-------------------------------------------- 32 //--------------------------------------------------------------------------- 31 // 33 // 32 // ClassName: G4NistMaterialBuilder 34 // ClassName: G4NistMaterialBuilder 33 // 35 // 34 // Description: Utility class to hold and mani 36 // Description: Utility class to hold and manipulate G4Materials 35 // 37 // 36 // Author: V.Ivanchenko 21.11.2004 38 // Author: V.Ivanchenko 21.11.2004 37 // 39 // 38 // Modifications: 40 // Modifications: 39 // 31.10.05 Add chemical effect and gas proper 41 // 31.10.05 Add chemical effect and gas properties (V.Ivanchenko) 40 // 27.02.06 V.Ivanchneko add ConstructNewGasMa 42 // 27.02.06 V.Ivanchneko add ConstructNewGasMaterial 41 // 11.05.06 V.Ivanchneko add warning flag to F 43 // 11.05.06 V.Ivanchneko add warning flag to FindOrBuildMaterial method 42 // 27.07.06 V.Ivanchneko set defaul warning=tr 44 // 27.07.06 V.Ivanchneko set defaul warning=true for FindOrBuildMaterial 43 // 27.07.07 V.Ivanchneko add matIndex vector t 45 // 27.07.07 V.Ivanchneko add matIndex vector to control built materials 44 // 28.07.07 V.Ivanchneko add BuildMaterial met 46 // 28.07.07 V.Ivanchneko add BuildMaterial method using Nist index 45 // 29.04.10 V.Ivanchneko add GetMeanIonisation 47 // 29.04.10 V.Ivanchneko add GetMeanIonisationEnergy method using Nist index 46 // 09.02.12 P.Gumplinger add ConstructNewIdeal << 47 // 48 // 48 //-------------------------------------------- 49 //---------------------------------------------------------------------------- 49 // 50 // 50 // Class Description: 51 // Class Description: 51 // 52 // 52 // Element data from the NIST DB on Atomic Wei 53 // Element data from the NIST DB on Atomic Weights and Isotope Compositions 53 // http://physics.nist.gov/PhysRefData/Composi 54 // http://physics.nist.gov/PhysRefData/Compositions/index.html 54 // 55 // 55 56 56 #include "G4Material.hh" << 57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 57 #include "globals.hh" << 58 << 59 #include <CLHEP/Units/PhysicalConstants.h> << 60 58 >> 59 #include "globals.hh" >> 60 #include "G4Material.hh" 61 #include <vector> 61 #include <vector> 62 62 >> 63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 64 63 class G4NistElementBuilder; 65 class G4NistElementBuilder; 64 66 65 class G4NistMaterialBuilder 67 class G4NistMaterialBuilder 66 { 68 { 67 public: << 69 public: 68 G4NistMaterialBuilder(G4NistElementBuilder*, << 69 << 70 ~G4NistMaterialBuilder() = default; << 71 70 >> 71 G4NistMaterialBuilder(G4NistElementBuilder*, G4int verb=0); >> 72 >> 73 ~G4NistMaterialBuilder(); >> 74 72 // Find or build a G4Material by name, from 75 // Find or build a G4Material by name, from dataBase 73 inline G4Material* FindMaterial(const G4Stri << 76 // 74 G4Material* FindOrBuildMaterial(const G4Stri << 77 G4Material* FindOrBuildMaterial (const G4String& name, 75 << 78 G4bool isotopes=true, 76 // Find or build a simple material via atomi << 79 G4bool warning=true); 77 inline G4Material* FindSimpleMaterial(G4int << 80 78 G4Material* FindOrBuildSimpleMaterial(G4int << 79 << 80 // construct a G4Material from scratch by at 81 // construct a G4Material from scratch by atome count 81 G4Material* ConstructNewMaterial(const G4Str << 82 // 82 const std::vector<G4int>& nbAtoms, G4doubl << 83 G4Material* ConstructNewMaterial (const G4String& name, 83 G4double temp = NTP_Temperature, G4double << 84 const std::vector<G4String>& elm, 84 << 85 const std::vector<G4int>& nbAtoms, >> 86 G4double dens, >> 87 G4bool isotopes=true, >> 88 G4State state = kStateSolid, >> 89 G4double temp = STP_Temperature, >> 90 G4double pressure = STP_Pressure); >> 91 85 // construct a G4Material from scratch by fr 92 // construct a G4Material from scratch by fraction mass 86 G4Material* ConstructNewMaterial(const G4Str << 93 // 87 const std::vector<G4double>& weight, G4dou << 94 G4Material* ConstructNewMaterial (const G4String& name, 88 G4double temp = NTP_Temperature, G4double << 95 const std::vector<G4String>& elm, >> 96 const std::vector<G4double>& weight, >> 97 G4double dens, >> 98 G4bool isotopes=true, >> 99 G4State state = kStateSolid, >> 100 G4double temp = STP_Temperature, >> 101 G4double pressure = STP_Pressure); 89 102 90 // construct a gas G4Material from scratch b << 91 G4Material* ConstructNewGasMaterial( << 92 const G4String& name, const G4String& name << 93 103 94 // Construct an ideal gas G4Material from sc << 104 // construct a gas G4Material from scratch by atome count 95 G4Material* ConstructNewIdealGasMaterial(con << 105 // 96 const std::vector<G4int>& nbAtoms, G4doubl << 106 G4Material* ConstructNewGasMaterial(const G4String& name, 97 G4double pressure = CLHEP::STP_Pressure); << 107 const G4String& nameNist, >> 108 G4double temp, G4double pres, >> 109 G4bool isotopes=true); 98 110 99 // verbosity level defined by G4NistManager 111 // verbosity level defined by G4NistManager >> 112 // 100 void SetVerbose(G4int val); 113 void SetVerbose(G4int val); 101 114 102 // cout predefined materials: 115 // cout predefined materials: 103 // "simple" - only pure materials in basic s 116 // "simple" - only pure materials in basic state (Z = 1, ..., 98) 104 // "compound" - NIST compounds 117 // "compound" - NIST compounds 105 // "hep" - HEP materials and compounds 118 // "hep" - HEP materials and compounds 106 // "biochemical" - bio-chemical materials << 107 // "all" - all 119 // "all" - all 108 void ListMaterials(const G4String&) const; << 120 // >> 121 void ListMaterials(const G4String&); 109 122 110 // cout lists of predefined materials 123 // cout lists of predefined materials 111 void ListNistSimpleMaterials() const; << 124 // 112 void ListNistCompoundMaterials() const; << 125 void ListNistSimpleMaterials(); 113 void ListHepMaterials() const; << 126 void ListNistCompoundMaterials(); 114 void ListSpaceMaterials() const; << 127 void ListHepMaterials(); 115 void ListBioChemicalMaterials() const; << 128 void ListSpaceMaterials(); >> 129 void ListBioChemicalMaterials(); 116 130 117 // access to the list of names of Geant4 pre 131 // access to the list of names of Geant4 predefined materials >> 132 // 118 const std::vector<G4String>& GetMaterialName 133 const std::vector<G4String>& GetMaterialNames() const; 119 134 120 // access to the NIST mean ionisation potent << 135 // access to the NIST mean ionisation potentials >> 136 // 121 inline G4double GetMeanIonisationEnergy(G4in 137 inline G4double GetMeanIonisationEnergy(G4int index) const; 122 inline G4double GetNominalDensity(G4int inde << 123 138 124 G4bool operator==(const G4NistMaterialBuilde << 139 private: 125 G4bool operator!=(const G4NistMaterialBuilde << 126 G4NistMaterialBuilder(const G4NistMaterialBu << 127 const G4NistMaterialBuilder& operator=(const << 128 140 129 private: << 130 void Initialise(); 141 void Initialise(); 131 void NistSimpleMaterials(); 142 void NistSimpleMaterials(); 132 void NistCompoundMaterials(); 143 void NistCompoundMaterials(); 133 void NistCompoundMaterials2(); << 134 void HepAndNuclearMaterials(); 144 void HepAndNuclearMaterials(); 135 void SpaceMaterials(); 145 void SpaceMaterials(); 136 void BioChemicalMaterials(); 146 void BioChemicalMaterials(); 137 147 138 // add parameters of material from NIST DB t 148 // add parameters of material from NIST DB to internal vectors 139 // density in g/cm3, mean ionisation potenti 149 // density in g/cm3, mean ionisation potential in eV 140 // << 150 // 141 void AddMaterial(const G4String& nameMat, G4 << 151 void AddMaterial(const G4String& nameMat, G4double dens, G4int Z=0, 142 G4int ncomp = 1, G4State = kStateSolid, G4 << 152 G4double pot=0.0, G4int ncomp=1, 143 << 153 G4State=kStateSolid, 144 void AddGas(const G4String& nameMat, G4doubl << 154 G4double temp=STP_Temperature, >> 155 G4double pres=STP_Pressure); >> 156 >> 157 void AddChemicalFormula(const G4String& nameMat, const G4String& ch); >> 158 void AddGas(const G4String& nameMat, G4double t=STP_Temperature, >> 159 G4double p=STP_Pressure); 145 160 146 void AddElementByWeightFraction(G4int Z, G4d 161 void AddElementByWeightFraction(G4int Z, G4double); 147 void AddElementByAtomCount(G4int Z, G4int); << 162 void AddElementByAtomCount (G4int Z, G4int); 148 163 149 void AddElementByWeightFraction(const G4Stri 164 void AddElementByWeightFraction(const G4String& name, G4double); 150 void AddElementByAtomCount(const G4String& n << 165 void AddElementByAtomCount (const G4String& name, G4int); 151 166 152 // build a G4Material from dataBase 167 // build a G4Material from dataBase 153 G4Material* BuildNistMaterial(const G4String << 168 G4Material* BuildMaterial(const G4String& name, G4bool isotopes); 154 G4Material* BuildMaterial(G4int idx); << 169 G4Material* BuildMaterial(G4int idx, G4bool isotopes); 155 170 156 void DumpElm(G4int) const; << 171 void DumpElm(G4int); 157 void DumpMix(G4int) const; << 172 void DumpMix(G4int); 158 173 159 private: << 174 private: 160 G4NistElementBuilder* elmBuilder; << 161 175 162 G4int verbose; << 176 G4NistElementBuilder* elmBuilder; 163 G4int nMaterials{0}; << 177 164 G4int nComponents{0}; << 178 G4int verbose; 165 G4int nCurrent{0}; << 179 G4int nMaterials; 166 G4int nElementary; << 180 G4int nComponents; 167 G4int nNIST; << 181 G4int nCurrent; 168 G4int nHEP; << 182 G4int nElementary; 169 G4int nSpace; << 183 G4int nNIST; 170 << 184 G4int nHEP; 171 std::vector<G4String> names; << 185 G4int nSpace; 172 std::vector<G4String> chFormulas; << 186 173 << 187 std::vector<G4String> names; 174 std::vector<G4double> densities; << 188 std::vector<G4String> chFormulas; 175 std::vector<G4double> ionPotentials; << 189 176 std::vector<G4State> states; << 190 std::vector<G4double> densities; 177 std::vector<G4double> fractions; << 191 std::vector<G4double> ionPotentials; 178 std::vector<G4bool> atomCount; << 192 std::vector<G4State> states; 179 std::vector<G4int> components; << 193 std::vector<G4double> fractions; 180 std::vector<G4int> indexes; << 194 std::vector<G4int> components; 181 std::vector<G4int> elements; << 195 std::vector<G4int> indexes; 182 std::vector<G4int> matIndex; << 196 std::vector<G4int> elements; 183 std::vector<G4bool> STP; << 184 << 185 std::vector<G4int> idxGas; << 186 std::vector<G4double> gasTemperature; << 187 std::vector<G4double> gasPressure; << 188 }; << 189 197 190 inline const std::vector<G4String>& G4NistMate << 198 std::vector<G4int> matIndex; 191 { << 192 return names; << 193 } << 194 199 195 inline G4double G4NistMaterialBuilder::GetMean << 200 std::vector<G4double> temperatures; 196 { << 201 std::vector<G4double> presures; 197 return (index >= 0 && index < nMaterials) ? << 198 } << 199 202 200 inline G4double G4NistMaterialBuilder::GetNomi << 203 G4bool first; 201 { << 204 202 return (index >= 0 && index < nMaterials) ? << 205 }; 203 } << 204 206 205 inline G4Material* G4NistMaterialBuilder::Find << 207 inline const std::vector<G4String>& >> 208 G4NistMaterialBuilder::GetMaterialNames() const 206 { 209 { 207 const G4MaterialTable* theMaterialTable = G4 << 210 return names; 208 G4Material* ptr = nullptr; << 209 for (auto& mat : *theMaterialTable) { << 210 if (name == mat->GetName()) { << 211 ptr = mat; << 212 break; << 213 } << 214 } << 215 return ptr; << 216 } 211 } 217 212 218 inline G4Material* G4NistMaterialBuilder::Find << 213 inline G4double >> 214 G4NistMaterialBuilder::GetMeanIonisationEnergy(G4int index) const 219 { 215 { 220 return (Z > 0 && Z < nElementary) ? FindMate << 216 G4double res = 10*index; >> 217 if(index >= 0 && index < nMaterials) { res = ionPotentials[index]; } >> 218 return res; 221 } 219 } 222 220 223 #endif 221 #endif 224 222