File indexing completed on 2025-09-16 08:56:31
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027 #ifndef G4NistElementBuilder_h
0028 #define G4NistElementBuilder_h 1
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053 #include "G4Element.hh"
0054 #include "globals.hh"
0055
0056 #include <CLHEP/Units/PhysicalConstants.h>
0057
0058 #include <vector>
0059
0060 const G4int maxNumElements = 108;
0061 const G4int maxAbundance = 3500;
0062
0063 class G4NistElementBuilder
0064 {
0065 public:
0066 explicit G4NistElementBuilder(G4int vb);
0067 ~G4NistElementBuilder() = default;
0068
0069
0070 inline G4Element* FindElement(G4int Z) const;
0071 G4Element* FindOrBuildElement(G4int Z, G4bool buildIsotopes = true);
0072
0073
0074 G4Element* FindOrBuildElement(const G4String& symb, G4bool buildIsotopes = true);
0075
0076 void PrintElement(G4int Z) const;
0077
0078
0079 const std::vector<G4String>& GetElementNames() const;
0080
0081
0082 G4int GetZ(const G4String& symb) const;
0083
0084
0085 G4double GetAtomicMassAmu(const G4String& symb) const;
0086
0087
0088
0089 inline G4double GetAtomicMassAmu(G4int Z) const;
0090
0091
0092 inline G4double GetIsotopeMass(G4int Z, G4int N) const;
0093
0094
0095
0096 inline G4double GetAtomicMass(G4int Z, G4int N) const;
0097
0098
0099 inline G4double GetTotalElectronBindingEnergy(G4int Z) const;
0100
0101
0102 inline G4double GetIsotopeAbundance(G4int Z, G4int N) const;
0103
0104
0105 inline G4int GetNistFirstIsotopeN(G4int Z) const;
0106
0107
0108 inline G4int GetNumberOfNistIsotopes(G4int Z) const;
0109
0110
0111 inline G4int GetMaxNumElements() const;
0112
0113 inline void SetVerbose(G4int);
0114
0115 private:
0116 void Initialise();
0117
0118
0119
0120
0121 void AddElement(const G4String& symbol, G4int Z, G4int NumberOfIsotopes, const G4int& N,
0122 const G4double& A, const G4double& sigmaA, const G4double& W);
0123
0124
0125 G4Element* BuildElement(G4int Z);
0126
0127 private:
0128 G4double atomicMass[maxNumElements];
0129 G4double bindingEnergy[maxNumElements];
0130 G4int nIsotopes[maxNumElements];
0131 G4int nFirstIsotope[maxNumElements];
0132 G4int idxIsotopes[maxNumElements];
0133
0134 G4int elmIndex[maxNumElements];
0135
0136 G4double massIsotopes[maxAbundance];
0137 G4double sigMass[maxAbundance];
0138 G4double relAbundance[maxAbundance];
0139
0140 G4int index;
0141 G4int verbose;
0142
0143 std::vector<G4String> elmSymbol;
0144 };
0145
0146
0147
0148 inline G4double G4NistElementBuilder::GetAtomicMassAmu(G4int Z) const
0149 {
0150 return (Z > 0 && Z < maxNumElements) ? atomicMass[Z] : 0.0;
0151 }
0152
0153
0154
0155 inline G4double G4NistElementBuilder::GetIsotopeMass(G4int Z, G4int N) const
0156 {
0157 G4double mass = 0.0;
0158 if (Z > 0 && Z < maxNumElements) {
0159 G4int i = N - nFirstIsotope[Z];
0160 if (i >= 0 && i < nIsotopes[Z]) {
0161 mass = massIsotopes[i + idxIsotopes[Z]];
0162 }
0163 }
0164 return mass;
0165 }
0166
0167
0168
0169 inline G4double G4NistElementBuilder::GetAtomicMass(G4int Z, G4int N) const
0170 {
0171 G4double mass = 0.0;
0172 if (Z > 0 && Z < maxNumElements) {
0173 G4int i = N - nFirstIsotope[Z];
0174 if (i >= 0 && i < nIsotopes[Z]) {
0175 mass = massIsotopes[i + idxIsotopes[Z]] + Z * CLHEP::electron_mass_c2 - bindingEnergy[Z];
0176 }
0177 }
0178 return mass;
0179 }
0180
0181
0182
0183 inline G4double G4NistElementBuilder::GetTotalElectronBindingEnergy(G4int Z) const
0184 {
0185 return (Z > 0 && Z < maxNumElements) ? bindingEnergy[Z] : 0.0;
0186 }
0187
0188
0189
0190 inline G4double G4NistElementBuilder::GetIsotopeAbundance(G4int Z, G4int N) const
0191 {
0192 G4double x = 0.0;
0193 if (Z > 0 && Z < maxNumElements) {
0194 G4int i = N - nFirstIsotope[Z];
0195 if (i >= 0 && i < nIsotopes[Z]) {
0196 x = relAbundance[i + idxIsotopes[Z]];
0197 }
0198 }
0199 return x;
0200 }
0201
0202
0203
0204 inline G4int G4NistElementBuilder::GetNistFirstIsotopeN(G4int Z) const
0205 {
0206 return (Z > 0 && Z < maxNumElements) ? nFirstIsotope[Z] : 0;
0207 }
0208
0209
0210
0211 inline G4int G4NistElementBuilder::GetNumberOfNistIsotopes(G4int Z) const
0212 {
0213 return (Z > 0 && Z < maxNumElements) ? nIsotopes[Z] : 0;
0214 }
0215
0216
0217
0218 inline const std::vector<G4String>& G4NistElementBuilder::GetElementNames() const
0219 {
0220 return elmSymbol;
0221 }
0222
0223
0224
0225 inline G4int G4NistElementBuilder::GetMaxNumElements() const { return maxNumElements - 1; }
0226
0227
0228
0229 inline void G4NistElementBuilder::SetVerbose(G4int val) { verbose = val; }
0230
0231
0232
0233 inline G4Element* G4NistElementBuilder::FindElement(G4int Z) const
0234 {
0235 const G4ElementTable* theElementTable = G4Element::GetElementTable();
0236 return (Z > 0 && Z < maxNumElements && elmIndex[Z] >= 0) ? (*theElementTable)[elmIndex[Z]]
0237 : nullptr;
0238 }
0239
0240 #endif