| Summary: | nan-producing operation in ionization models | ||
|---|---|---|---|
| Product: | Geant4 | Reporter: | dennis.herbert.wright |
| Component: | processes/electromagnetic | Assignee: | Michel.Maire |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | 7.1 | ||
| Hardware: | PC | ||
| OS: | Linux | ||
Bug fixed and commited Bug fixed and commited Bug fixed and commited |
On both Linux and Sun, I encountered program aborts which I traced back to a NAN-producing operation in G4BraggModel::SampleSecondaries and G4BetheBlochModel::SampleSecondaries. The problem is in the lines: G4double cost = deltaKinEnergy * (energy + electron_mass_c2) / (deltaMomentum * totMomentum); G4double sint = sqrt(1.0 - cost*cost); cost is occaisionally > 1 by a small amount, causing the argument of sqrt to be negative. My temporary fix was to protect the calculation of cost by taking the std::min of the calculated value and 1.0. The same problem also occurs in G4BraggIonModel and G4MollerBhabhaModel.