Problem 1592

Summary: ERROR: Undefined side for valid surface normal to solid.
Product: Geant4 Reporter: Andrii Tykhonov <andrii.tykhonov>
Component: eventAssignee: asai
Status: RESOLVED INVALID    
Severity: critical    
Priority: P5    
Version: 9.6   
Hardware: All   
OS: All   

Description Andrii Tykhonov 2014-03-18 14:04:43 CET

    
Comment 1 Andrii Tykhonov 2014-03-18 14:11:51 CET
Dear Geant4 developers,

I get the following error (attached below) as I try to simulate particles with a *sphere* source. The problem seems to occur non-systematically, i.e. sometimes it works, sometimes not - possibly connected with the random generator seed (which is weird since I do not set seed manually anywhere in my code). Also, the problem may disappear if I alter the number of generated particles (for example 1000 instead of 10). 

Thank you for considering this,
Andrii




-----------------------------------------------------------
    *** Dump for solid - World_box ***
    ===================================================
 Solid type: G4Box
 Parameters: 
    half length X: 5000 mm 
    half length Y: 5000 mm 
    half length Z: 5000 mm 
-----------------------------------------------------------

-------- WWWW ------- G4Exception-START -------- WWWW -------
*** G4Exception : GeomSolids1002
      issued by : G4Box::DistanceToOut(p,v,..)
Undefined side for valid surface normal to solid.
Position:

p.x() = -1.794028531588482e+222 mm
p.y() = 2.000911471279191e+222 mm
p.z() = 1.272145737498265e+222 mm

Direction:

v.x() = -nan
v.y() = -nan
v.z() = -nan

Proposed distance :

snxt = 9e+99 mm

*** This is just a warning message. ***
-------- WWWW -------- G4Exception-END --------- WWWW -------
Comment 2 Gabriele Cosmo 2014-03-18 14:46:55 CET
We need more information about your application in order to understand what is going wrong.
The information provided by G4Box is the effect of something which inherently going wrong (NaN reported as direction vector?).
Are you using General Particle Source (G4GeneralParticleSource)  as particle generator ?
Can you please give more details ?
Comment 3 Andrii Tykhonov 2014-03-18 15:56:55 CET
Dear Gabriele,

Indeed we are using G4GeneralParticleSource. Below please find the details of how it is invoked. I should note that we are using GDML geometry with many tessellated objects. Removing some of the objects from the geometry leads to more rare occurrences (or complete absence) of the error. The main problem is that it is very hard to trace this bug. As I said before, it occurs non-systematically (it may happen that completely the same code on the same machine runs okay in one moment of time and fails in the other...).

Thank you,
Andrii


...
particleSource = new G4GeneralParticleSource();
particleSource->SetNumberOfParticles(n_particle);
particleSource->SetParticleDefinition(particle);
...
posDist = new G4SPSPosDistribution();
posDist = particleSource->GetCurrentSource()->GetPosDist();
angDist = new G4SPSAngDistribution();
angDist = particleSource->GetCurrentSource()->GetAngDist();
...

posDist->SetPosDisType("Surface");  
posDist->SetPosDisShape("Sphere"); 
posDist->SetCentreCoords(G4ThreeVector(0., 0., 0.)); // center of the world
posDist->SetRadius(r0);

angDist->SetAngDistType("iso");  
angDist->SetMinTheta(0. * rad);
angDist->SetMaxTheta(pi/2. * rad);    
angDist->SetMinPhi(0.*rad);
angDist->SetMaxPhi(twopi *rad);
Comment 4 Gabriele Cosmo 2014-03-18 16:03:01 CET
Thanks. I'm forwarding the problem report to event category for inspection.
The error you see reported from the geometry is likely the effect of wrong primary generation.
Comment 5 asai 2014-03-18 16:45:58 CET
Hi, 

Thank you for reporting this issue.

> posDist->SetPosDisType("Surface");  
> posDist->SetPosDisShape("Sphere"); 
> posDist->SetCentreCoords(G4ThreeVector(0., 0., 0.)); // center of the world
> posDist->SetRadius(r0);

Could you please double-check "r0" is smaller than the half width of the world volume?

Makoto
Comment 6 Andrii Tykhonov 2014-03-19 10:31:24 CET
Dear Makoto,



Indeed, there's a problem with r0:

...
r0:             2.9733e+222
world size z  : 2000
world size x/y: 2000
...


This is due to the following part of the code:

  G4double r0 = dVertexRadius;
  if (r0 < 1){
    r0 = std::max(0.5*PayLoadSizeXY,0.5*PayLoadSizeZ)+50.; //mm
  }


"dVertexRadius" was not initialized anywhere in the code. That explains the "randomness" of the bug, because for each run dVertexRadius was assigned to some random variable according to where it was allocated in the memory. 

So, the problem is solved. 
Thanks a lot for your time!
Andrii
Comment 7 asai 2014-03-19 10:50:21 CET
Thank you for confirming it. Let me close this incident.
Makoto