Hello. Have a look at this if-block if(1-tEtot/theTarget.GetMass()>0.001) { theTarget.SetTotalEnergy(tEtot); } The if-statement could be put as Etot<0.999*theTarget.GetMass() and when theTarget.SetTotalEnergy(tEtot) is called inline void SetTotalEnergy( const G4double en ) { totalEnergy = en; kineticEnergy = totalEnergy - mass; } it will set totalEnergy less than mass and negative kineticEnergy which could possibly affect low energy neutron transport at low temperatures. I have not checked if this behaviour really appears during the simulation but it would be better this way: if(tEtot<theTarget.GetMass()) { theTarget.SetKineticEnergy(0); }
The bug is certainly there, but actually does not cause a round-off error. The conditional in the if statement is incorrect: it should be tEtot/theTarget.GetMass() - 1 > 0.001 . This way the relativistic energy is chosen at higher energies while the classical energy is chosen at lower energies. I believe the classical energy is used to maintain precision at low energies, as the sqrt would reduce the number of significant digits. A fix has been submitted.