Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4Element Class Reference

#include <G4Element.hh>

Public Member Functions

 G4Element (const G4String &name, const G4String &symbol, G4double Zeff, G4double Aeff)
 
 G4Element (const G4String &name, const G4String &symbol, G4int nbIsotopes)
 
void AddIsotope (G4Isotope *isotope, G4double RelativeAbundance)
 
virtual ~G4Element ()
 
const G4StringGetName () const
 
const G4StringGetSymbol () const
 
G4double GetZ () const
 
G4int GetZasInt () const
 
G4double GetN () const
 
G4double GetAtomicMassAmu () const
 
G4double GetA () const
 
G4bool GetNaturalAbundanceFlag () const
 
void SetNaturalAbundanceFlag (G4bool)
 
G4int GetNbOfAtomicShells () const
 
G4double GetAtomicShell (G4int index) const
 
G4int GetNbOfShellElectrons (G4int index) const
 
size_t GetNumberOfIsotopes () const
 
G4IsotopeVectorGetIsotopeVector () const
 
G4doubleGetRelativeAbundanceVector () const
 
const G4IsotopeGetIsotope (G4int iso) const
 
size_t GetIndex () const
 
G4double GetfCoulomb () const
 
G4double GetfRadTsai () const
 
G4IonisParamElmGetIonisation () const
 
 G4Element (__void__ &)
 
void SetName (const G4String &name)
 

Static Public Member Functions

static G4ElementTableGetElementTable ()
 
static size_t GetNumberOfElements ()
 
static G4ElementGetElement (G4String name, G4bool warning=true)
 

Friends

std::ostream & operator<< (std::ostream &, const G4Element *)
 
std::ostream & operator<< (std::ostream &, const G4Element &)
 
std::ostream & operator<< (std::ostream &, G4ElementTable)
 

Detailed Description

Definition at line 97 of file G4Element.hh.

Constructor & Destructor Documentation

G4Element::G4Element ( const G4String name,
const G4String symbol,
G4double  Zeff,
G4double  Aeff 
)

Definition at line 75 of file G4Element.cc.

77  : fName(name), fSymbol(symbol)
78 {
79  G4int iz = G4lrint(zeff);
80  if (iz < 1) {
82  ed << "Fail to create G4Element " << name
83  << " Z= " << zeff << " < 1 !";
84  G4Exception ("G4Element::G4Element()", "mat011", FatalException, ed);
85  }
86  if (std::abs(zeff - iz) > perMillion) {
88  ed << "G4Element Warning: " << name << " Z= " << zeff
89  << " A= " << aeff/(g/mole);
90  G4Exception("G4Element::G4Element()", "mat017", JustWarning, ed);
91  }
92 
93  InitializePointers();
94 
95  fZeff = zeff;
96  fAeff = aeff;
97  fNeff = fAeff/(g/mole);
98 
99  if(fNeff < 1.0) fNeff = 1.0;
100 
101  if (fNeff < zeff) {
103  ed << "Fail to create G4Element " << name
104  << " with Z= " << zeff << " N= " << fNeff
105  << " N < Z is not allowed" << G4endl;
106  G4Exception("G4Element::G4Element()", "mat012", FatalException, ed);
107  }
108 
109  fNbOfAtomicShells = G4AtomicShells::GetNumberOfShells(iz);
110  fAtomicShells = new G4double[fNbOfAtomicShells];
111  fNbOfShellElectrons = new G4int[fNbOfAtomicShells];
112 
113  AddNaturalIsotopes();
114 
115  for (G4int i=0;i<fNbOfAtomicShells;i++)
116  {
117  fAtomicShells[i] = G4AtomicShells::GetBindingEnergy(iz, i);
118  fNbOfShellElectrons[i] = G4AtomicShells::GetNumberOfElectrons(iz, i);
119  }
120  ComputeDerivedQuantities();
121 }
static constexpr double perMillion
Definition: G4SIunits.hh:334
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
static constexpr double g
Definition: G4SIunits.hh:183
int G4int
Definition: G4Types.hh:78
static G4double GetBindingEnergy(G4int Z, G4int SubshellNb)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
int G4lrint(double ad)
Definition: templates.hh:163
static G4int GetNumberOfElectrons(G4int Z, G4int SubshellNb)
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
static constexpr double mole
Definition: G4SIunits.hh:286
static G4int GetNumberOfShells(G4int Z)

Here is the call graph for this function:

G4Element::G4Element ( const G4String name,
const G4String symbol,
G4int  nbIsotopes 
)

Definition at line 128 of file G4Element.cc.

130  : fName(name),fSymbol(symbol)
131 {
132  InitializePointers();
133 
134  size_t n = size_t(nIsotopes);
135 
136  if(0 >= nIsotopes) {
138  ed << "Fail to create G4Element " << name
139  << " <" << symbol << "> with " << nIsotopes
140  << " isotopes";
141  G4Exception ("G4Element::G4Element()", "mat012", FatalException, ed);
142  } else {
143  theIsotopeVector = new G4IsotopeVector(n,0);
144  fRelativeAbundanceVector = new G4double[nIsotopes];
145  }
146 }
std::vector< G4Isotope * > G4IsotopeVector
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

G4Element::~G4Element ( )
virtual

Definition at line 253 of file G4Element.cc.

254 {
255  if (theIsotopeVector) { delete theIsotopeVector; }
256  if (fRelativeAbundanceVector) { delete [] fRelativeAbundanceVector; }
257  if (fAtomicShells) { delete [] fAtomicShells; }
258  if (fNbOfShellElectrons) { delete [] fNbOfShellElectrons; }
259  if (fIonisation) { delete fIonisation; }
260 
261  //remove this element from theElementTable
262  theElementTable[fIndexInTable] = 0;
263 }
G4Element::G4Element ( __void__ &  )

Definition at line 245 of file G4Element.cc.

246  : fZeff(0), fNeff(0), fAeff(0)
247 {
248  InitializePointers();
249 }

Member Function Documentation

void G4Element::AddIsotope ( G4Isotope isotope,
G4double  RelativeAbundance 
)

Definition at line 152 of file G4Element.cc.

153 {
154  if (theIsotopeVector == 0) {
156  ed << "Fail to add Isotope to G4Element " << fName
157  << " with Z= " << fZeff << " N= " << fNeff;
158  G4Exception ("G4Element::AddIsotope()", "mat013", FatalException, ed);
159  return;
160  }
161  G4int iz = isotope->GetZ();
162 
163  // filling ...
164  if ( fNumberOfIsotopes < (G4int)theIsotopeVector->size() ) {
165  // check same Z
166  if (fNumberOfIsotopes==0) { fZeff = G4double(iz); }
167  else if (G4double(iz) != fZeff) {
169  ed << "Fail to add Isotope Z= " << iz << " to G4Element " << fName
170  << " with different Z= " << fZeff << fNeff;
171  G4Exception ("G4Element::AddIsotope()", "mat014", FatalException, ed);
172  return;
173  }
174  //Z ok
175  fRelativeAbundanceVector[fNumberOfIsotopes] = abundance;
176  (*theIsotopeVector)[fNumberOfIsotopes] = isotope;
177  ++fNumberOfIsotopes;
178 
179  } else {
181  ed << "Fail to add Isotope Z= " << iz << " to G4Element " << fName
182  << " - more isotopes than declaired ";
183  G4Exception ("G4Element::AddIsotope()", "mat015", FatalException, ed);
184  return;
185  }
186 
187  // filled.
188  if ( fNumberOfIsotopes == (G4int)theIsotopeVector->size() ) {
189  G4double wtSum=0.0;
190  fAeff = 0.0;
191  for (G4int i=0; i<fNumberOfIsotopes; i++) {
192  fAeff += fRelativeAbundanceVector[i]*(*theIsotopeVector)[i]->GetA();
193  wtSum += fRelativeAbundanceVector[i];
194  }
195  if(wtSum > 0.0) { fAeff /= wtSum; }
196  fNeff = fAeff/(g/mole);
197 
198  if(wtSum != 1.0) {
199  for(G4int i=0; i<fNumberOfIsotopes; ++i) {
200  fRelativeAbundanceVector[i] /= wtSum;
201  }
202  }
203 
204  fNbOfAtomicShells = G4AtomicShells::GetNumberOfShells(iz);
205  fAtomicShells = new G4double[fNbOfAtomicShells];
206  fNbOfShellElectrons = new G4int[fNbOfAtomicShells];
207 
208  for ( G4int j = 0; j < fNbOfAtomicShells; j++ )
209  {
210  fAtomicShells[j] = G4AtomicShells::GetBindingEnergy(iz, j);
211  fNbOfShellElectrons[j] = G4AtomicShells::GetNumberOfElectrons(iz, j);
212  }
213  ComputeDerivedQuantities();
214  }
215 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
static constexpr double g
Definition: G4SIunits.hh:183
int G4int
Definition: G4Types.hh:78
static G4double GetBindingEnergy(G4int Z, G4int SubshellNb)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4int GetZ() const
Definition: G4Isotope.hh:91
static G4int GetNumberOfElectrons(G4int Z, G4int SubshellNb)
double G4double
Definition: G4Types.hh:76
static constexpr double mole
Definition: G4SIunits.hh:286
static G4int GetNumberOfShells(G4int Z)

Here is the call graph for this function:

Here is the caller graph for this function:

G4double G4Element::GetA ( ) const
inline

Definition at line 139 of file G4Element.hh.

139 {return fAeff;}

Here is the caller graph for this function:

G4double G4Element::GetAtomicMassAmu ( ) const
inline

Definition at line 136 of file G4Element.hh.

136 {return fNeff;}
G4double G4Element::GetAtomicShell ( G4int  index) const

Definition at line 367 of file G4Element.cc.

368 {
369  if (i<0 || i>=fNbOfAtomicShells) {
371  ed << "Invalid argument " << i << " in for G4Element " << fName
372  << " with Z= " << fZeff
373  << " and Nshells= " << fNbOfAtomicShells;
374  G4Exception("G4Element::GetAtomicShell()", "mat016", FatalException, ed);
375  return 0.0;
376  }
377  return fAtomicShells[i];
378 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

Here is the call graph for this function:

Here is the caller graph for this function:

G4Element * G4Element::GetElement ( G4String  name,
G4bool  warning = true 
)
static

Definition at line 412 of file G4Element.cc.

413 {
414  // search the element by its name
415  for (size_t J=0; J<theElementTable.size(); ++J)
416  {
417  if (theElementTable[J]->GetName() == elementName)
418  return theElementTable[J];
419  }
420 
421  // the element does not exist in the table
422  if (warning) {
423  G4cout << "\n---> warning from G4Element::GetElement(). The element: "
424  << elementName << " does not exist in the table. Return NULL pointer."
425  << G4endl;
426  }
427  return nullptr;
428 }
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
const G4String & GetName() const
Definition: G4Element.hh:127

Here is the call graph for this function:

Here is the caller graph for this function:

G4ElementTable * G4Element::GetElementTable ( )
static

Definition at line 398 of file G4Element.cc.

399 {
400  return &theElementTable;
401 }

Here is the caller graph for this function:

G4double G4Element::GetfCoulomb ( ) const
inline

Definition at line 191 of file G4Element.hh.

191 {return fCoulomb;}

Here is the caller graph for this function:

G4double G4Element::GetfRadTsai ( ) const
inline

Definition at line 195 of file G4Element.hh.

195 {return fRadTsai;}
size_t G4Element::GetIndex ( ) const
inline

Definition at line 182 of file G4Element.hh.

182 {return fIndexInTable;}

Here is the caller graph for this function:

G4IonisParamElm* G4Element::GetIonisation ( ) const
inline

Definition at line 199 of file G4Element.hh.

199 {return fIonisation;}

Here is the caller graph for this function:

const G4Isotope* G4Element::GetIsotope ( G4int  iso) const
inline

Definition at line 170 of file G4Element.hh.

171  {return (*theIsotopeVector)[iso];}

Here is the caller graph for this function:

G4IsotopeVector* G4Element::GetIsotopeVector ( ) const
inline

Definition at line 163 of file G4Element.hh.

163 {return theIsotopeVector;}

Here is the caller graph for this function:

G4double G4Element::GetN ( ) const
inline

Definition at line 135 of file G4Element.hh.

135 {return fNeff;}

Here is the caller graph for this function:

const G4String& G4Element::GetName ( ) const
inline

Definition at line 127 of file G4Element.hh.

127 {return fName;}

Here is the caller graph for this function:

G4bool G4Element::GetNaturalAbundanceFlag ( ) const
inline

Definition at line 262 of file G4Element.hh.

263 {
264  return fNaturalAbundance;
265 }

Here is the caller graph for this function:

G4int G4Element::GetNbOfAtomicShells ( ) const
inline

Definition at line 147 of file G4Element.hh.

147 {return fNbOfAtomicShells;}

Here is the caller graph for this function:

G4int G4Element::GetNbOfShellElectrons ( G4int  index) const

Definition at line 382 of file G4Element.cc.

383 {
384  if (i<0 || i>=fNbOfAtomicShells) {
386  ed << "Invalid argument " << i << " for G4Element " << fName
387  << " with Z= " << fZeff
388  << " and Nshells= " << fNbOfAtomicShells;
389  G4Exception("G4Element::GetNbOfShellElectrons()", "mat016",
390  FatalException, ed);
391  return 0;
392  }
393  return fNbOfShellElectrons[i];
394 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

Here is the call graph for this function:

Here is the caller graph for this function:

size_t G4Element::GetNumberOfElements ( )
static

Definition at line 405 of file G4Element.cc.

406 {
407  return theElementTable.size();
408 }

Here is the caller graph for this function:

size_t G4Element::GetNumberOfIsotopes ( ) const
inline

Definition at line 159 of file G4Element.hh.

159 {return fNumberOfIsotopes;}

Here is the caller graph for this function:

G4double* G4Element::GetRelativeAbundanceVector ( ) const
inline

Definition at line 167 of file G4Element.hh.

168  {return fRelativeAbundanceVector;}

Here is the caller graph for this function:

const G4String& G4Element::GetSymbol ( ) const
inline

Definition at line 128 of file G4Element.hh.

128 {return fSymbol;}

Here is the caller graph for this function:

G4double G4Element::GetZ ( ) const
inline

Definition at line 131 of file G4Element.hh.

131 {return fZeff;}
G4int G4Element::GetZasInt ( ) const
inline

Definition at line 132 of file G4Element.hh.

132 {return fZ;}

Here is the caller graph for this function:

void G4Element::SetName ( const G4String name)
inline

Definition at line 214 of file G4Element.hh.

214 {fName=name;}
const XML_Char * name
Definition: expat.h:151

Here is the caller graph for this function:

void G4Element::SetNaturalAbundanceFlag ( G4bool  val)
inline

Definition at line 267 of file G4Element.hh.

268 {
269  fNaturalAbundance = val;
270 }

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  flux,
const G4Element element 
)
friend

Definition at line 432 of file G4Element.cc.

433 {
434  std::ios::fmtflags mode = flux.flags();
435  flux.setf(std::ios::fixed,std::ios::floatfield);
436  G4long prec = flux.precision(3);
437 
438  flux
439  << " Element: " << element->fName << " (" << element->fSymbol << ")"
440  << " Z = " << std::setw(4) << std::setprecision(1) << element->fZeff
441  << " N = " << std::setw(5) << std::setprecision(1)
442  << G4lrint(element->fNeff)
443  << " A = " << std::setw(6) << std::setprecision(3)
444  << (element->fAeff)/(g/mole) << " g/mole";
445 
446  for (G4int i=0; i<element->fNumberOfIsotopes; i++)
447  flux
448  << "\n ---> " << (*(element->theIsotopeVector))[i]
449  << " abundance: " << std::setw(6) << std::setprecision(3)
450  << (element->fRelativeAbundanceVector[i])/perCent << " %";
451 
452  flux.precision(prec);
453  flux.setf(mode,std::ios::floatfield);
454  return flux;
455 }
static constexpr double perCent
Definition: G4SIunits.hh:332
long G4long
Definition: G4Types.hh:80
static constexpr double g
Definition: G4SIunits.hh:183
int G4int
Definition: G4Types.hh:78
static const double prec
Definition: RanecuEngine.cc:58
int G4lrint(double ad)
Definition: templates.hh:163
static constexpr double mole
Definition: G4SIunits.hh:286
std::ostream& operator<< ( std::ostream &  flux,
const G4Element element 
)
friend

Definition at line 459 of file G4Element.cc.

460 {
461  flux << &element;
462  return flux;
463 }
std::ostream& operator<< ( std::ostream &  flux,
G4ElementTable  ElementTable 
)
friend

Definition at line 467 of file G4Element.cc.

468 {
469  //Dump info for all known elements
470  flux << "\n***** Table : Nb of elements = " << ElementTable.size()
471  << " *****\n" << G4endl;
472 
473  for (size_t i=0; i<ElementTable.size(); i++) flux << ElementTable[i]
474  << G4endl << G4endl;
475 
476  return flux;
477 }
#define G4endl
Definition: G4ios.hh:61

The documentation for this class was generated from the following files: