Trouble running simulation in non-uniform electric field

Please fill out the following information to help in answering your question, and also see tips for posting code snippets. If you don’t provide this information it will take more time to help with your problem!

_Geant4 Version:_v11.1.2
_Operating System:_Windows 10
_Compiler/Version:_Visual Studio 17 2022
_CMake Version:_3.26.3


Hello! I’m just getting into Geant4, and currently trying to simulate electrons in an air gap discharge. At the start I used a uniform electric field in my simulation, and it worked perfectly fine. Then I tried to impelment a non-uniform field in my simulation. I generated my field data through COMSOL, and imported it into my simulation via modified codes from the Purge Magnet example. At first everything seemed fine. The field was imported successfully, and could be properly visualized. But when I tried to run the simulation, it just didn’t work. I tried several different electric field layouts. Sometimes the simulation seemingly froze and nothing appeared in the command window. Sometimes I got a warning message like the one below. Could someone enlighten me on this situation?
-------- WWWW ------- G4Exception-START -------- WWWW -------
*** G4Exception : GeomField0003
issued by : G4ChordFinder::FindNextChord()
Exceeded maximum number of trials= 75
Current sagita dist= -nan
Max sagita dist= 0.25
Step sizes (actual and proposed):
Last trial = 1e-73
Next trial = 1e-74
Proposed for chord = 2e-73

*** This is just a warning message. ***
-------- WWWW -------- G4Exception-END --------- WWWW -------

Hello. In the case of the exception which you report, it seems that the integration accuracy required (requested) cannot be achieved, as the size of the trial step was 1e-73 (millimeters). One reason could be that the electric field is discontinuous - potentially at its edge (between the region which is included and the region outside it.)
Could you use “/event/verbose 1” first to see in which event the problem occurs, and then “/tracking/verbose 1” to print out information about the tracks – it would give a first idea where the problem is occurring.

There may be a problem with the integrator - but I suggest first to check that the evaluation of the electric field provides finite and reasonable values. ( Test it with sample points, but also add some printing in the field evaluation method to report the position (with high precision g4cout.precision(9); ) then run the simulation to see whether the values appear reasonable in general (no NaNs, values which are not huge etc) and how they behave before the warning and when the program is no longer responding.

(You may need to redirect the output to a file and look at it with a program like ‘less’ or an editor if it’s not too large. ) If you can share sample parts of the output, such the last 30-50 lines before a warning, it could enable me to help better.

After this it may be necessary to provide you with a modified version of one or two classes, with additional printing to help debug the problem. Alternatively, if you can share a sample field which fails in Purging Magnet I can investigate myself.

Best regards,
John Apostolakis