Created attachment 786 [details] /tracking/verbose 4 output N-14 recoil of 142keV when ranged out in a custom definition of Air, during an ionization step it gets kinetic energy NaN See the attached verbose tracking Search for 'BUG' which is marking the N-14 track after a few steps it reports kinetic energy nan Searching with the debugger when the N-14 energy is 0.104MeV, it calls the G4VEnergyLossProcess.hh:620 619│ << " " << theDEDXTable << G4endl; */ 620├─> G4double x = fFactor*(*theDEDXTable)[basedCoupleIndex]->LogVectorValue(e,loge); 621│ if(e < minKinEnergy) { x *= std::sqrt(e/minKinEnergy); } 622│ return x; 623│ } with basedCoupleIndex = 36, the table if full of nan all other indexes of basedCoupleIndex (total 77) seemed to be Ok, except this entry.
hello Vasilis, dedx table is used at each step of each charged particle, so having nan there is a significant problem. For me unclear several moments: - what is exact Geant4 version? - what is the application? - can such problem be reproduced in TestEm7 or Hadr01 examples? VI
Hi Vladimir, > For me unclear several moments: > - what is exact Geant4 version? Geant4 version Name: geant4-11-00 [MT] (10-December-2021) << in Multi-threaded mode >> > - what is the application? A simulation of a Firebrigade Helicopter with a NaI detector inside. In this simulation I was starting with a neutron source of 1MeV The N-14 recoil is produced by an elastic collision of a neutron in the cabin air. The air is custom defined (Wet Air) (not the standard G4_Air) as //+++ 43) Dry air near sea level +++ :MIXT DryAIR 0.00120479 4 G4_C 0.000124 G4_N 0.755268 G4_O 0.231781 G4_Ar 0.012827 //+++ 44) Water vapor +++ :MIXT_BY_NATOMS WVAP 0.0007562 2 H 2.0 O 1.0 //+++ 45) Wet air +++ :MIXT WAIR 0.0011993 2 WVAP 0.0072 DryAIR 0.9928 > - can such problem be reproduced in TestEm7 or Hadr01 examples? Honestly I din't try to reduce it, since is quite a complicated setup and I thought it would be faster to find the offending instruction with the help of the debugger. I could try to debug to find out who populated with NaN the table for that it would be helpful if you could provide me some hints where to look
I found the problem, two materials were defined as an mixture by atoms however having the atoms as fraction not as integers. The persistency/ascii/src/G4tgbMaterialMixtureByNoAtoms.cc was silently converting them int therefore all Zero and the AtomicDensityVector was filled with NaN leading to a NaN dEdx which probably needs to be protected either in the G4Material::AddElementByNumberOfAtoms to check for invalid entry maybe also in the G4tgbMaterialMixtureByNoAtoms or better to accept atoms fractions
Hi Vasilis, We do not check if number of atoms is >0, this should be fixed. I would think, 0 means that double value is provided instead of integer. Independently, I would advice to use 11.0patch03 and not 11.0. VI
I think a check would been great. Also it would be nice to accept floating point as fractions. Sometimes we have materials given in atom fraction + including some impurities
Different method should be used for fractions: AddElementByMassFraction(...), which is the main. What is not allowed is a mixture of two methods for the same material.
The fix includes FatalException if number of atoms <=0. It is integrated into the development version of Geant4 and will be available with the next public release. The patch to 11.0 will be also provided but unclear if such patch will be done and when. VI