running N03 with optimized math (SLC4, gcc 4.1.0, g++4 -O2 -funsafe-math-optimizations -fno-math-errno -msse3 -mfpmath=sse, 387) (see also bug 905) I got the following NAN Program received signal SIGFPE, Arithmetic exception. 0x00a80b9d in G4Transportation::AlongStepDoIt (this=0x9e81740, track=@0x9f7ede0, stepData=@0x9e30bf8) at src/G4Transportation.cc:480 480 deltaTime = stepLength/initialVelocity ; gdb) print stepLength $1 = 0 (gdb) print initialVelocity $2 = 0 (gdb) where #0 0x00a80b9d in G4Transportation::AlongStepDoIt (this=0x9e81740, track=@0x9f7ede0, stepData=@0x9e30bf8) at src/G4Transportation.cc:480 #1 0x00bf606f in G4SteppingManager::InvokeAlongStepDoItProcs (this=0x9e33720) at src/ G4SteppingManager2.cc:397 #2 0x00bf3406 in G4SteppingManager::Stepping (this=0x9e33720) at src/G4SteppingManager.cc:187 #3 0x00bfb97f in G4TrackingManager::ProcessOneTrack (this=0x9e30d18, apValueG4Track=0x9f7ede0) at src/G4TrackingManager.cc:120 # cured trivially with [lxcmsf2] /data/vin/geant4.8.1.p01/source > diff /afs/cern.ch/sw/geant4/releases/share/ geant4.8.1.p01/source/processes/transportation/src/G4Transportation.cc processes/transportation/ src/G4Transportation.cc 464c464,468 < if (fpDynamicParticle->GetDefinition()== fOpticalPhoton) --- > if ( float(stepLength)==0) > { > deltaTime = 0; > } > else if (fpDynamicParticle->GetDefinition()== fOpticalPhoton) I'm happy to report that after the this mod and the mods for bug-905, N03 runs fine for several 1000 events with NAN trapping enabled (other fpe-traps cannot be enabled due to math with DBL_MAX...).
I agree that a simple check in the time calculation for the case in which initial velocity is 0 could make the code a bit more robust. However it is a error for the G4Tranportation to be called if this is the case. Only processes that have an action in time can be called. So further investigation regarding why it was called is necessary - not just an extra protection. Best regards, John Apostolakis
A fix to protect against this condition has been included in patch 1 of Geant4 8.2
Need a protection in tracking to avoid calling AlongStep methods when the velocity is zero at the start of a step. Must check what class is responsible to ensure that particles with zero energy are Stopped.