Problem 1911 - possible round off error in G4Nucleus::GetThermalNucleus
Summary: possible round off error in G4Nucleus::GetThermalNucleus
Status: RESOLVED FIXED
Alias: None
Product: Geant4
Classification: Unclassified
Component: processes/hadronic/util (show other problems)
Version: 10.2
Hardware: All All
: P5 trivial
Assignee: dennis.herbert.wright
URL:
Depends on:
Blocks:
 
Reported: 2016-11-14 11:36 CET by Artem Zontikov
Modified: 2016-12-06 00:21 CET (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this problem.
Description Artem Zontikov 2016-11-14 11:36:27 CET

    
Comment 1 Artem Zontikov 2016-11-14 11:37:27 CET
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);
}
Comment 2 dennis.herbert.wright 2016-12-06 00:21:26 CET
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.