Hello! I’m new with Geant4 and I’m building a simulation, where electrons/positrons start in the vacuum and travel to a spherical area with magnetic field inside.
For that purpose I have modified example B5, deleting all unnecessary components and adding magnetic field from a 3Dtable file. The field seems to work fine, however, I get my program crashed every time I try to use vis/scene/add/magneticfield. The error is SIGSEGV / Segmentation fault. Also, if I try to run the same in unmodified B5, it says “no field found”, while there obviously is one.
So, could anyone please help me with solving this error? Or maybe tell if vis/scene/add/magneticfield is just isn’t capable of local field visualisation and I should use some other methods?
Thanks in advance!
/vis/scene/add/magneticfield works fine for me with unmodified example B5 with the latest version of Geant4. What version of Geant4 are you using?
The command samples the field on a rectangular grid and if the grid spacing is too large it may miss the magnetic field. Look at the command guidance to see how to reduce the grid spacing. (By default it is not too small that it could overwhelm the graphics system and maybe it was larger in older versions of Geant4.)
As for the SIGSEGV, the command causes the vis manager to call your field algorithm at the sampling points, so that is where I would look for the problem. I would compile in DEBUG mode and use a debugger to tell me exactly where the SIGSEGV happened.
Thanks for the suggestion, I’ll try that now.
What for B5 - it seems I just messed it up a bit, now I checked it in a fresh build and it works just fine.