ascot4fusion / ascot5

ASCOT5 is a high-performance orbit-following code for fusion plasma physics and engineering
https://ascot4fusion.github.io/ascot5/
GNU Lesser General Public License v3.0
31 stars 9 forks source link

Segfault in markergen rhoto5d #108

Open miekkasarki opened 5 months ago

miekkasarki commented 5 months ago

I'm having an issue with the function a5.markergen.rhoto5d(), after running an AFSI simulation for a 3-D stellarator case (via a5.afsi.thermal() function), I can generate well the markers (alpha-particles) only when running this on a Mac (Sonoma 14.5) but every time I try to run it on a linux machine it crashes with the error "Segmentation fault (core dumped)", I've tried three different linux systems all with the same result. Is there any way to diagnose what could be going wrong? I'm using ASCOT 5.5.4, and installing with conda (h5cc wrapper using gcc (conda-forge gcc 12.3.0-7) 12.3.0 ). Thanks!

From @lcarbajal-t1e

miekkasarki commented 5 months ago

Just noting that (in case if you're in a hurry) rhoto5d is not needed to generate alpha particles. You can sample markers directly from the fusion distribution and, if you need importance sampling for the wall loads, just pick ones that have rho > some_value. For practical purposes this is quite close to what rhoto5d would provide.

In any case this segfault should be fixed. I'm fairly certain this is stellarator specific as it has not been tested for stellarators. My guess is that it is this line where the segfault is coming from (though this is the only part I'm fairly sure should work for stellarators): https://github.com/ascot4fusion/ascot5/blob/20656e3623bf0ef3b644d3107e7a7e356373466b/a5py/routines/markergen.py#L262

Could you test that by replicating that function call in a separate script? Just replace self._ascot with the Ascot object (a5). You could also try running valgrind to locate the segfault, but that might mean you'd have to use smaller distribution grid resolution for it to complete within a reasonable time.

Can you confirm that the magnetic field data covers the entire (R,z) grid you are using in the distribution?