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);
98 if(fNeff < 1.0) fNeff = 1.0;
102 ed <<
"Failed to create G4Element " << name
103 <<
" with Z= " << zeff <<
" N= " << fNeff
104 <<
" N < Z is not allowed" <<
G4endl;
109 fAtomicShells =
new G4double[fNbOfAtomicShells];
110 fNbOfShellElectrons =
new G4int[fNbOfAtomicShells];
112 AddNaturalIsotopes();
114 for (
G4int i=0;i<fNbOfAtomicShells;i++)
119 ComputeDerivedQuantities();
129 : fName(name),fSymbol(symbol)
131 InitializePointers();
133 size_t n = size_t(nIsotopes);
137 ed <<
"Failed to create G4Element " << name
138 <<
" <" << symbol <<
"> with " << nIsotopes
143 fRelativeAbundanceVector =
new G4double[nIsotopes];
153 if (theIsotopeVector == 0) {
155 ed <<
"Failed to add Isotope to G4Element " << fName
156 <<
" with Z= " << fZeff <<
" N= " << fNeff;
163 if ( fNumberOfIsotopes < (
G4int)theIsotopeVector->size() ) {
165 if (fNumberOfIsotopes==0) { fZeff =
G4double(iz); }
168 ed <<
"Failed to add Isotope Z= " << iz <<
" to G4Element " << fName
169 <<
" with different Z= " << fZeff << fNeff;
174 fRelativeAbundanceVector[fNumberOfIsotopes] = abundance;
175 (*theIsotopeVector)[fNumberOfIsotopes] = isotope;
180 ed <<
"Failed to add Isotope Z= " << iz <<
" to G4Element " << fName
181 <<
" - more isotopes than declared.";
187 if ( fNumberOfIsotopes == (
G4int)theIsotopeVector->size() ) {
190 for (
G4int i=0; i<fNumberOfIsotopes; i++) {
191 fAeff += fRelativeAbundanceVector[i]*(*theIsotopeVector)[i]->GetA();
192 wtSum += fRelativeAbundanceVector[i];
194 if(wtSum > 0.0) { fAeff /= wtSum; }
195 fNeff = fAeff/(g/mole);
198 for(
G4int i=0; i<fNumberOfIsotopes; ++i) {
199 fRelativeAbundanceVector[i] /= wtSum;
204 fAtomicShells =
new G4double[fNbOfAtomicShells];
205 fNbOfShellElectrons =
new G4int[fNbOfAtomicShells];
207 for (
G4int j = 0; j < fNbOfAtomicShells; j++ )
212 ComputeDerivedQuantities();
218void G4Element::InitializePointers()
220 theIsotopeVector =
nullptr;
221 fRelativeAbundanceVector =
nullptr;
222 fAtomicShells =
nullptr;
223 fNbOfShellElectrons =
nullptr;
224 fIonisation =
nullptr;
225 fNumberOfIsotopes = 0;
226 fNaturalAbundance =
false;
232 fNbOfAtomicShells = 0;
245 : fZeff(0), fNeff(0), fAeff(0)
247 InitializePointers();
254 if (theIsotopeVector) {
delete theIsotopeVector; }
255 if (fRelativeAbundanceVector) {
delete [] fRelativeAbundanceVector; }
256 if (fAtomicShells) {
delete [] fAtomicShells; }
257 if (fNbOfShellElectrons) {
delete [] fNbOfShellElectrons; }
258 if (fIonisation) {
delete fIonisation; }
261 theElementTable[fIndexInTable] = 0;
266void G4Element::ComputeDerivedQuantities()
271 theElementTable.push_back(
this);
272 fIndexInTable = theElementTable.size() - 1;
275 ComputeCoulombFactor();
276 ComputeLradTsaiFactor();
279 if (fIonisation) {
delete fIonisation; }
286void G4Element::ComputeCoulombFactor()
291 static const G4double k1 = 0.0083 , k2 = 0.20206 ,k3 = 0.0020 , k4 = 0.0369 ;
293 G4double az2 = (fine_structure_const*fZeff)*(fine_structure_const*fZeff);
296 fCoulomb = (k1*az4 + k2 + 1./(1.+az2))*az2 - (k3*az4 + k4)*az4;
301void G4Element::ComputeLradTsaiFactor()
307 static const G4double Lrad_light[] = {5.31 , 4.79 , 4.74 , 4.71} ;
308 static const G4double Lprad_light[] = {6.144 , 5.621 , 5.805 , 5.924} ;
316 if (iz <= 3) { Lrad = Lrad_light[iz] ; Lprad = Lprad_light[iz] ; }
317 else { Lrad = log184 - logZ3 ; Lprad = log1194 - 2*logZ3;}
319 fRadTsai = 4*alpha_rcl2*fZeff*(fZeff*(Lrad-fCoulomb) + Lprad);
324void G4Element::AddNaturalIsotopes()
332 const std::vector<G4String> elmnames =
334 if(Z < (
G4int)elmnames.size()) { fSymbol = elmnames[Z]; }
335 else { fSymbol = fName; }
338 fNumberOfIsotopes = 0;
339 for(
G4int i=0; i<
n; ++i) {
342 theIsotopeVector =
new G4IsotopeVector((
unsigned int)fNumberOfIsotopes,0);
343 fRelativeAbundanceVector =
new G4double[fNumberOfIsotopes];
346 for(
G4int i=0; i<
n; ++i) {
350 std::ostringstream strm;
351 strm << fSymbol << N;
352 (*theIsotopeVector)[idx] =
new G4Isotope(strm.str(), Z, N, 0.0, 0);
353 fRelativeAbundanceVector[idx] = x;
358 if(xsum != 0.0 && xsum != 1.0) {
359 for(
G4int i=0; i<idx; ++i) { fRelativeAbundanceVector[i] /= xsum; }
361 fNaturalAbundance =
true;
368 if (i<0 || i>=fNbOfAtomicShells) {
370 ed <<
"Invalid argument " << i <<
" in for G4Element " << fName
371 <<
" with Z= " << fZeff
372 <<
" and Nshells= " << fNbOfAtomicShells;
376 return fAtomicShells[i];
383 if (i<0 || i>=fNbOfAtomicShells) {
385 ed <<
"Invalid argument " << i <<
" for G4Element " << fName
386 <<
" with Z= " << fZeff
387 <<
" and Nshells= " << fNbOfAtomicShells;
388 G4Exception(
"G4Element::GetNbOfShellElectrons()",
"mat016",
392 return fNbOfShellElectrons[i];
399 return &theElementTable;
406 return theElementTable.size();
414 for (
size_t J=0; J<theElementTable.size(); ++J)
416 if (theElementTable[J]->
GetName() == elementName)
417 return theElementTable[J];
422 G4cout <<
"\n---> warning from G4Element::GetElement(). The element: "
423 << elementName <<
" does not exist in the table. Return NULL pointer."
433 std::ios::fmtflags mode = flux.flags();
434 flux.setf(std::ios::fixed,std::ios::floatfield);
435 G4long prec = flux.precision(3);
438 <<
" Element: " << element->fName <<
" (" << element->fSymbol <<
")"
439 <<
" Z = " << std::setw(4) << std::setprecision(1) << element->fZeff
440 <<
" N = " << std::setw(5) << std::setprecision(1)
442 <<
" A = " << std::setw(6) << std::setprecision(3)
443 << (element->fAeff)/(g/mole) <<
" g/mole";
445 for (
G4int i=0; i<element->fNumberOfIsotopes; i++)
447 <<
"\n ---> " << (*(element->theIsotopeVector))[i]
448 <<
" abundance: " << std::setw(6) << std::setprecision(3)
449 << (element->fRelativeAbundanceVector[i])/perCent <<
" %";
451 flux.precision(prec);
452 flux.setf(mode,std::ios::floatfield);
469 flux <<
"\n***** Table : Nb of elements = " << ElementTable.size()
472 for (
size_t i=0; i<ElementTable.size(); i++) flux << ElementTable[i]
std::vector< G4Element * > G4ElementTable
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)
const G4String & GetName() const
G4int GetNbOfShellElectrons(G4int index) const
G4double GetAtomicShell(G4int index) const
static G4Element * GetElement(G4String name, G4bool warning=true)
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