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 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  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 #ifndef G4NistElementBuilder_h
 28 #define G4NistElementBuilder_h 1
 29 
 30 //---------------------------------------------------------------------------
 31 //
 32 // ClassName:   G4NistElementBuilder
 33 //
 34 // Description: Utility class to hold and manipulate G4Elements defined from
 35 //              Nist data base
 36 //
 37 // Author:      V.Ivanchenko 21.11.2004
 38 //
 39 // Modifications:
 40 // 27.02.06 V.Ivanchenko Return m=0 if Z&N combination is out of NIST
 41 // 27.02.06 V.Ivanchenko add GetAtomicMassAmu
 42 // 17.10.06 V.Ivanchenko add GetAtomicMass and GetNistElementNames methods
 43 // 02.05.07 V.Ivanchenko add GetNistFirstIsotopeN and GetNumberOfNistIsotopes
 44 // 06.08.08 V.Ivanchenko add binding energy parameterisation and use isotope
 45 //                       mass in G4 units
 46 //
 47 // Class Description:
 48 //
 49 // Element data from the NIST DB on Atomic Weights and Isotope Compositions
 50 // http://physics.nist.gov/PhysRefData/Compositions/index.html
 51 //
 52 
 53 #include "G4Element.hh"
 54 #include "globals.hh"
 55 
 56 #include <CLHEP/Units/PhysicalConstants.h>
 57 
 58 #include <vector>
 59 
 60 const G4int maxNumElements = 108;
 61 const G4int maxAbundance = 3500;
 62 
 63 class G4NistElementBuilder
 64 {
 65  public:
 66   explicit G4NistElementBuilder(G4int vb);
 67   ~G4NistElementBuilder() = default;
 68 
 69   // Find or build a G4Element by atomic number
 70   inline G4Element* FindElement(G4int Z) const;
 71   G4Element* FindOrBuildElement(G4int Z, G4bool buildIsotopes = true);
 72 
 73   // Find  or build a G4Element by symbol
 74   G4Element* FindOrBuildElement(const G4String& symb, G4bool buildIsotopes = true);
 75   // print element information
 76   void PrintElement(G4int Z) const;
 77 
 78   // Access to the vector of Geant4 predefined element names
 79   const std::vector<G4String>& GetElementNames() const;
 80 
 81   // Get atomic number by element symbol
 82   G4int GetZ(const G4String& symb) const;
 83 
 84   // Get atomic weight in atomic units by element symbol
 85   G4double GetAtomicMassAmu(const G4String& symb) const;
 86 
 87   // Get atomic weight in atomic units - mean mass in units of amu of an atom
 88   // with electron shell for the natural isotope composition
 89   inline G4double GetAtomicMassAmu(G4int Z) const;
 90 
 91   // Get mass of isotope without electron shell in Geant4 energy units
 92   inline G4double GetIsotopeMass(G4int Z, G4int N) const;
 93 
 94   // Get mass in Geant4 energy units of an atom of a particular isotope
 95   // with the electron shell
 96   inline G4double GetAtomicMass(G4int Z, G4int N) const;
 97 
 98   // Get total ionisation energy of an atom
 99   inline G4double GetTotalElectronBindingEnergy(G4int Z) const;
100 
101   // Get natural isotope abundance
102   inline G4double GetIsotopeAbundance(G4int Z, G4int N) const;
103 
104   // Get N for the first natural isotope
105   inline G4int GetNistFirstIsotopeN(G4int Z) const;
106 
107   // Get number of natural isotopes
108   inline G4int GetNumberOfNistIsotopes(G4int Z) const;
109 
110   // Get max Z in the Geant4 element database
111   inline G4int GetMaxNumElements() const;
112 
113   inline void SetVerbose(G4int);
114 
115  private:
116   void Initialise();
117 
118   // Add element parameters to internal G4 database:
119   // Z - atomic number, N - number of nucleons, A - atomic mass (amu),
120   // sigmaA - accuracy of mass in last digits, W - natural abundances (percent)
121   void AddElement(const G4String& symbol, G4int Z, G4int NumberOfIsotopes, const G4int& N,
122     const G4double& A, const G4double& sigmaA, const G4double& W);
123 
124   // Build a G4Element from the G4 dataBase
125   G4Element* BuildElement(G4int Z);
126 
127  private:
128   G4double atomicMass[maxNumElements];  // amu
129   G4double bindingEnergy[maxNumElements];
130   G4int nIsotopes[maxNumElements];
131   G4int nFirstIsotope[maxNumElements];
132   G4int idxIsotopes[maxNumElements];
133 
134   G4int elmIndex[maxNumElements];
135 
136   G4double massIsotopes[maxAbundance];  // G4 units
137   G4double sigMass[maxAbundance];  // G4 units
138   G4double relAbundance[maxAbundance];
139 
140   G4int index;
141   G4int verbose;
142 
143   std::vector<G4String> elmSymbol;
144 };
145 
146 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
147 
148 inline G4double G4NistElementBuilder::GetAtomicMassAmu(G4int Z) const
149 {
150   return (Z > 0 && Z < maxNumElements) ? atomicMass[Z] : 0.0;
151 }
152 
153 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
154 
155 inline G4double G4NistElementBuilder::GetIsotopeMass(G4int Z, G4int N) const
156 {
157   G4double mass = 0.0;
158   if (Z > 0 && Z < maxNumElements) {
159     G4int i = N - nFirstIsotope[Z];
160     if (i >= 0 && i < nIsotopes[Z]) {
161       mass = massIsotopes[i + idxIsotopes[Z]];
162     }
163   }
164   return mass;
165 }
166 
167 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
168 
169 inline G4double G4NistElementBuilder::GetAtomicMass(G4int Z, G4int N) const
170 {
171   G4double mass = 0.0;
172   if (Z > 0 && Z < maxNumElements) {
173     G4int i = N - nFirstIsotope[Z];
174     if (i >= 0 && i < nIsotopes[Z]) {
175       mass = massIsotopes[i + idxIsotopes[Z]] + Z * CLHEP::electron_mass_c2 - bindingEnergy[Z];
176     }
177   }
178   return mass;
179 }
180 
181 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
182 
183 inline G4double G4NistElementBuilder::GetTotalElectronBindingEnergy(G4int Z) const
184 {
185   return (Z > 0 && Z < maxNumElements) ? bindingEnergy[Z] : 0.0;
186 }
187 
188 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
189 
190 inline G4double G4NistElementBuilder::GetIsotopeAbundance(G4int Z, G4int N) const
191 {
192   G4double x = 0.0;
193   if (Z > 0 && Z < maxNumElements) {
194     G4int i = N - nFirstIsotope[Z];
195     if (i >= 0 && i < nIsotopes[Z]) {
196       x = relAbundance[i + idxIsotopes[Z]];
197     }
198   }
199   return x;
200 }
201 
202 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
203 
204 inline G4int G4NistElementBuilder::GetNistFirstIsotopeN(G4int Z) const
205 {
206   return (Z > 0 && Z < maxNumElements) ? nFirstIsotope[Z] : 0;
207 }
208 
209 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
210 
211 inline G4int G4NistElementBuilder::GetNumberOfNistIsotopes(G4int Z) const
212 {
213   return (Z > 0 && Z < maxNumElements) ? nIsotopes[Z] : 0;
214 }
215 
216 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
217 
218 inline const std::vector<G4String>& G4NistElementBuilder::GetElementNames() const
219 {
220   return elmSymbol;
221 }
222 
223 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
224 
225 inline G4int G4NistElementBuilder::GetMaxNumElements() const { return maxNumElements - 1; }
226 
227 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
228 
229 inline void G4NistElementBuilder::SetVerbose(G4int val) { verbose = val; }
230 
231 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
232 
233 inline G4Element* G4NistElementBuilder::FindElement(G4int Z) const
234 {
235   const G4ElementTable* theElementTable = G4Element::GetElementTable();
236   return (Z > 0 && Z < maxNumElements && elmIndex[Z] >= 0) ? (*theElementTable)[elmIndex[Z]]
237                                                            : nullptr;
238 }
239 
240 #endif
241