Problem 1221

Summary: Infinite loop (no convergence) in G4GoudsmitSaundersonMscModel
Product: Geant4 Reporter: Andreas <zog>
Component: processes/electromagneticAssignee: Vladimir.Ivantchenko
Status: RESOLVED FIXED    
Severity: normal    
Priority: P3    
Version: 9.4   
Hardware: All   
OS: All   
Attachments: Root script showing the convergence issues with an example

Description Andreas 2011-06-10 22:50:29 CEST
Created attachment 121 [details]
Root script showing the convergence issues with an example

Hello,

In the class G4GoudsmitSaundersonMscModel under certain conditions the exit conditions for the following infinite loop can never be met (around line 200 in G4GoudsmitSaundersonMscModel.cxx)

  do
    {  
      logx0=std::log(1.+1./x0);
      x1 = x0-(x0*((1.+x0)*logx0-1.0)-g1/2.)/( (1.+2.*x0)*logx0-2.0);
      delta = std::abs( x1 - x0 );    
      x0 = x1;
    } while (delta > 1.0e-12);

Adding a simple check into the code, which aborts the loop after a certain amount of loops is not possible, since for certain input values (which I do see in my simulation) the code can diverge instead of converge.

Attached is a small ROOT script, which shows a case where convergence is not reached and a case where we have divergence. Both values are obtained from my simulations.

Thanks,
Andreas
Comment 1 Vladimir.Ivantchenko 2011-06-14 13:05:40 CEST
Thanks for the report. The protection is added, so the loop is finite and exit condition is improved.

VI