76 : fName(name), fSymbol(symbol)
81 ed <<
"Failed to create G4Element " << name
82 <<
" Z= " << zeff <<
" < 1 !";
85 if (std::abs(zeff - iz) > perMillion) {
87 ed <<
"G4Element Warning: " << name <<
" Z= " << zeff
88 <<
" A= " << aeff/(g/mole);
96 fNeff = fAeff/(g/mole);
105 ed <<
"Failed to create G4Element " << name
106 <<
" with Z= " << zeff <<
" N= " << fNeff
107 <<
" N < Z is not allowed" <<
G4endl;
112 fAtomicShells =
new G4double[fNbOfAtomicShells];
113 fNbOfShellElectrons =
new G4int[fNbOfAtomicShells];
115 AddNaturalIsotopes();
117 for (
G4int i=0; i<fNbOfAtomicShells; ++i)
122 ComputeDerivedQuantities();
132 : fName(name),fSymbol(symbol)
134 InitializePointers();
136 size_t n = size_t(nIsotopes);
140 ed <<
"Failed to create G4Element " << name
141 <<
" <" << symbol <<
"> with " << nIsotopes
146 fRelativeAbundanceVector =
new G4double[nIsotopes];
156 if(theIsotopeVector ==
nullptr)
159 ed <<
"Failed to add Isotope to G4Element " << fName
160 <<
" with Z= " << fZeff <<
" N= " << fNeff;
167 if ( fNumberOfIsotopes < (
G4int)theIsotopeVector->size() ) {
169 if (fNumberOfIsotopes==0) { fZeff =
G4double(iz); }
172 ed <<
"Failed to add Isotope Z= " << iz <<
" to G4Element " << fName
173 <<
" with different Z= " << fZeff << fNeff;
178 fRelativeAbundanceVector[fNumberOfIsotopes] = abundance;
179 (*theIsotopeVector)[fNumberOfIsotopes] = isotope;
184 ed <<
"Failed to add Isotope Z= " << iz <<
" to G4Element " << fName
185 <<
" - more isotopes than declared.";
191 if ( fNumberOfIsotopes == (
G4int)theIsotopeVector->size() ) {
194 for (
G4int i=0; i<fNumberOfIsotopes; ++i) {
195 fAeff += fRelativeAbundanceVector[i]*(*theIsotopeVector)[i]->GetA();
196 wtSum += fRelativeAbundanceVector[i];
198 if(wtSum > 0.0) { fAeff /= wtSum; }
199 fNeff = fAeff/(g/mole);
202 for (
G4int i=0; i<fNumberOfIsotopes; ++i) {
203 fRelativeAbundanceVector[i] /= wtSum;
208 fAtomicShells =
new G4double[fNbOfAtomicShells];
209 fNbOfShellElectrons =
new G4int[fNbOfAtomicShells];
211 for (
G4int j = 0; j < fNbOfAtomicShells; ++j)
216 ComputeDerivedQuantities();
222void G4Element::InitializePointers()
224 theIsotopeVector =
nullptr;
225 fRelativeAbundanceVector =
nullptr;
226 fAtomicShells =
nullptr;
227 fNbOfShellElectrons =
nullptr;
228 fIonisation =
nullptr;
229 fNumberOfIsotopes = 0;
230 fNaturalAbundance =
false;
236 fNbOfAtomicShells = 0;
249 : fZeff(0), fNeff(0), fAeff(0)
251 InitializePointers();
258 delete theIsotopeVector;
259 delete[] fRelativeAbundanceVector;
260 delete[] fAtomicShells;
261 delete[] fNbOfShellElectrons;
265 theElementTable[fIndexInTable] =
nullptr;
270void G4Element::ComputeDerivedQuantities()
275 theElementTable.push_back(
this);
276 fIndexInTable = theElementTable.size() - 1;
279 ComputeCoulombFactor();
280 ComputeLradTsaiFactor();
290void G4Element::ComputeCoulombFactor()
295 static const G4double k1 = 0.0083 , k2 = 0.20206 ,k3 = 0.0020 , k4 = 0.0369 ;
297 G4double az2 = (fine_structure_const*fZeff)*(fine_structure_const*fZeff);
300 fCoulomb = (k1*az4 + k2 + 1./(1.+az2))*az2 - (k3*az4 + k4)*az4;
305void G4Element::ComputeLradTsaiFactor()
311 static const G4double Lrad_light[] = {5.31 , 4.79 , 4.74 , 4.71} ;
312 static const G4double Lprad_light[] = {6.144 , 5.621 , 5.805 , 5.924} ;
320 if (iz <= 3) { Lrad = Lrad_light[iz] ; Lprad = Lprad_light[iz] ; }
321 else { Lrad = log184 - logZ3 ; Lprad = log1194 - 2*logZ3;}
323 fRadTsai = 4*alpha_rcl2*fZeff*(fZeff*(Lrad-fCoulomb) + Lprad);
328void G4Element::AddNaturalIsotopes()
337 const std::vector<G4String> elmnames =
339 if(
Z < (
G4int)elmnames.size()) { fSymbol = elmnames[
Z]; }
340 else { fSymbol = fName; }
343 fNumberOfIsotopes = 0;
344 for(
G4int i=0; i<
n; ++i) {
349 fRelativeAbundanceVector =
new G4double[fNumberOfIsotopes];
352 for(
G4int i=0; i<
n; ++i) {
356 std::ostringstream strm;
357 strm << fSymbol <<
N;
358 (*theIsotopeVector)[idx] =
new G4Isotope(strm.str(),
Z,
N, 0.0, 0);
359 fRelativeAbundanceVector[idx] = x;
364 if(xsum != 0.0 && xsum != 1.0) {
365 for(
G4int i=0; i<idx; ++i) { fRelativeAbundanceVector[i] /= xsum; }
367 fNaturalAbundance =
true;
374 if (i<0 || i>=fNbOfAtomicShells) {
376 ed <<
"Invalid argument " << i <<
" in for G4Element " << fName
377 <<
" with Z= " << fZeff
378 <<
" and Nshells= " << fNbOfAtomicShells;
382 return fAtomicShells[i];
389 if (i<0 || i>=fNbOfAtomicShells) {
391 ed <<
"Invalid argument " << i <<
" for G4Element " << fName
392 <<
" with Z= " << fZeff
393 <<
" and Nshells= " << fNbOfAtomicShells;
394 G4Exception(
"G4Element::GetNbOfShellElectrons()",
"mat016",
398 return fNbOfShellElectrons[i];
405 return &theElementTable;
412 return theElementTable.size();
420 for(
auto J : theElementTable)
422 if(J->GetName() == elementName)
430 G4cout <<
"\n---> warning from G4Element::GetElement(). The element: "
431 << elementName <<
" does not exist in the table. Return NULL pointer."
441 std::ios::fmtflags mode = flux.flags();
442 flux.setf(std::ios::fixed,std::ios::floatfield);
443 G4long prec = flux.precision(3);
446 <<
" Element: " << element->fName <<
" (" << element->fSymbol <<
")"
447 <<
" Z = " << std::setw(4) << std::setprecision(1) << element->fZeff
448 <<
" N = " << std::setw(5) << std::setprecision(1)
450 <<
" A = " << std::setw(6) << std::setprecision(3)
451 << (element->fAeff)/(g/mole) <<
" g/mole";
453 for(
G4int i = 0; i < element->fNumberOfIsotopes; i++)
455 flux <<
"\n ---> " << (*(element->theIsotopeVector))[i]
456 <<
" abundance: " << std::setw(6) << std::setprecision(3)
457 << (element->fRelativeAbundanceVector[i]) / perCent <<
" %";
460 flux.precision(prec);
461 flux.setf(mode,std::ios::floatfield);
478 flux <<
"\n***** Table : Nb of elements = " << ElementTable.size()
481 for(
auto i : ElementTable)
494 flux <<
"\n***** Vector : Nb of elements = " << ElementVector.size()
497 for(
auto i : ElementVector)
std::vector< G4Element * > G4ElementTable
std::vector< const G4Element * > G4ElementVector
std::ostream & operator<<(std::ostream &flux, const G4Element *element)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
std::vector< G4Isotope * > G4IsotopeVector
G4double G4Log(G4double x)
G4GLOB_DLL std::ostream G4cout
static G4int GetNumberOfElectrons(G4int Z, G4int SubshellNb)
static G4double GetBindingEnergy(G4int Z, G4int SubshellNb)
static G4int GetNumberOfShells(G4int Z)
static G4ElementTable * GetElementTable()
static size_t GetNumberOfElements()
void AddIsotope(G4Isotope *isotope, G4double RelativeAbundance)
G4Element(const G4String &name, const G4String &symbol, G4double Zeff, G4double Aeff)
G4int GetNbOfShellElectrons(G4int index) const
static G4Element * GetElement(const G4String &name, G4bool warning=true)
G4double GetAtomicShell(G4int index) const
G4int GetNumberOfNistIsotopes(G4int Z) const
const std::vector< G4String > & GetNistElementNames() const
G4int GetNistFirstIsotopeN(G4int Z) const
static G4NistManager * Instance()
G4double GetIsotopeAbundance(G4int Z, G4int N) const