Suspected bug in void G4Element::AddIsotope(G4Isotope* isotope, G4double abundance)

Hello,
I believe there is a bug in void G4Element::AddIsotope(G4Isotope* isotope, G4double abundance). There is a piece of code trying to prevent the addition of an isotope with a different z. There are two problems with this code (line 151 of source/materials/src/G4Element.cc).

  • the comparison
    if ( fNumberOfIsotopes < (G4int)theIsotopeVector->size() )
    should be
    if ( fNumberOfIsotopes <= (G4int)theIsotopeVector->size() )
    otherwise the check is not performed on the last isotope

  • The error message should not be
    ed << "Fail to add Isotope Z= " << iz << " to G4Element " << fName
    << " with different Z= " << fZeff << fNeff;
    but rather
    ed << "Fail to add Isotope Z= " << iz << " to G4Element " << fName
    << " with different Z= " << fZeff << " and abundance " << abundance;

since there is no blank between fZeff and fNeff and moreover fNeff is defined only when the last isotope is added, otherwise is 0.

Have a nice day and stay creative…
The TMX Coder

Hello,

thank you for this comment. Can you demonstrate this bug in some simple example, for example in one of existing Geant4 examples?

VI