Bug: electrons travel outside of world volume


I’m not sure if this is correct section for posting this, but I don’t know what causes this bug, perhaps physical models are involved.

I was working with “chem5” example and discovered that under some conditions electrons ignored boundary between “World” and “OutOfWorld” regions and kept travelling out of world volume for awhile. This bug appeard to me both in 10.5.p01 and 10.6 versions.

How to reproduce the bug:

  1. Use chem5 example of 10.6 version of Geant4.
  2. Go to DetectorConstruction.cc file and make world volume be spheroid with semiaxis of 5 micrometers along XY and 1 micrometer along Z.
  3. Go to PrimaryGeneratorAction.cc file (or beam.in) and make primary particles be electrons with coordinates (-0.0024, -0.0019, 0.00023), energy of 884 keV and momentum direction of (0.,0.,1.)
  4. Add “SteppingAction” to chem5 project (to check with it if any particles appear outside of world volume). So you need to put SteppingAction.hh in “include” folder and SteppingAction.cc in “src” folder. You also need to activate this SteppingAction in “ActionInitialization.cc” file by adding line “SetUserAction(new SteppingAction())” at the end.
  5. Add to SteppingAction.cc file condition that checks if particle is inside world volume using particle’s coordinates and equation for spheroid.

If you execute this changed version of chem5 you will also see a lot of exception messages:
issued by : G4DNAMolecularDissociation::DecayIt()
The decayed product is outside of the volume : World

Modified versions of files are attached, so you can paste them in chem5 project without making 1-5 actions listed above. (!)Can’t attach “beam.in” file, attaching “beam.txt” instead, you need to rename it to “beam.in”.

beam.txt (285 Bytes) ActionInitialization.cc (3.5 KB) DetectorConstruction.cc (5.2 KB) PrimaryGeneratorAction.cc (3.8 KB) SteppingAction.cc (1.4 KB) SteppingAction.hh (263 Bytes)

Update: the problem also exists in “dnaphysics” example. To reproduce the bug in dnaphysics:

  1. Replace world volume with spheroid in DetectorConstruction.cc:
    G4Ellipsoid* solidWorld = new G4Ellipsoid(“World”, 5 * um, 5 * um, 1 * um);
  2. Replace source with electrons in beam.in:
    /gun/particle e-
    /gun/energy 884 keV
    /gun/direction 0 0 1
    /gun/position -0.0024 -0.0019 0.00023 mm
  3. Add a check if any particle is in World volume in SteppingAction.cc:
    You can copy it from SteppingAction.cc file that was attached to previous post or make it yourself using equation of spheroid:
    (x^2 + y^2) / r_xy^2 + z^2 / r_z^2 = 1,
    where (x,y,z) - coordinates of the surface of spheroid and r_xy, r_z - its semi-axis.

Example of how the program works using “/tracking/verbose 1”:
* G4Track Information: Particle = e-, Track ID = 1, Parent ID = 0

Step#    X(mm)    Y(mm)    Z(mm) KinE(MeV)  dE(MeV) StepLeng TrackLeng  NextVolume ProcName
    0  -0.0024  -0.0019  0.00023     0.884        0        0         0       World initStep
    1  -0.0024  -0.0019 0.000247     0.884        0 1.73e-05  1.73e-05       World e-_G4DNAElastic
    2  -0.0024  -0.0019 0.000996     0.884 1.08e-05 0.000749  0.000766       World e-_G4DNAIonisation
    3  -0.0024  -0.0019 0.000996     0.884        0        0  0.000766  OutOfWorld Transportation

You can check using calculator that starting coordinates of primary particle (-0.0024, -0.0019, 0.000247) are inside of world volume and final coordinates (-0.0024, -0.0019, 0.000996) are clearly outside of it. Ionisation (e-_G4DNAIonisation) process also occured outside of world volume.

I would appreciate if someone from devs would confirm this as a bug and give some tips how to handle it.

See problem report on ellipsoid:

Thank you for the reply. So we are waiting for the next patch then…