Problem 1888

Summary: Photon stuck in infinite loop when traveling almost perpendicular to the surface normal
Product: Geant4 Reporter: Juan Pablo Yanez <j.p.yanez>
Component: processes/opticalAssignee: gum
Status: RESOLVED FIXED    
Severity: normal    
Priority: P4    
Version: 10.2   
Hardware: PC   
OS: Linux   
Attachments: Patch to add a tolerance to the Done condition

Description Juan Pablo Yanez 2016-09-09 06:59:24 CEST
Created attachment 412 [details]
Patch to add a tolerance to the Done condition

The photon is traveling almost perpendicular to an acrylic surface, but still approaching it. The reflection angle is calculated, but due to the numerical precision of the machine (I suppose), the resulting angle does not meet the condition of (NewMomentum*theGlobalNormal >= 0). The product is of order 10^-8, but negative. The calculation sits in a loop, that you can only exit if you meet the condition stated above. Since the condition is never met, the program stays in that loop. 

The problem was replicated in multiple systems.

Adding a tolerance solves the issue.
Comment 1 Juan Pablo Yanez 2016-09-09 07:01:18 CEST
EDIT: Photon path is almost perpendicular to the surface normal (parallel to the surface).
Comment 2 gum 2016-10-04 01:26:30 CEST
Thank you for the bug-report and for providing a fix. This is tagged as op-V10-02-02 and will be in the next public release (10.3)