Currently the hybrid mode works by switching from GC to GO at the moment when ENDCOND_MAX_RHO. The wall collision check now calculates the distance to the nearest wall element, so we can improve this scheme.
I suggest that in hybrid mode we check for close wall elements if any of those are within distance 1.1 R_larmor. If true, we switch to GO. The close elements are those which belong to any of the octree cells that are within distance 1.1 R_larmor from the guiding center position. Now the problem is in determining which cells fulfill this condition. I think the easiest way is to just include all cells where any of the points P, P+R_x, P-R_x, P+R_y, ... belong.
Currently the hybrid mode works by switching from GC to GO at the moment when ENDCOND_MAX_RHO. The wall collision check now calculates the distance to the nearest wall element, so we can improve this scheme.
I suggest that in hybrid mode we check for close wall elements if any of those are within distance 1.1 R_larmor. If true, we switch to GO. The close elements are those which belong to any of the octree cells that are within distance 1.1 R_larmor from the guiding center position. Now the problem is in determining which cells fulfill this condition. I think the easiest way is to just include all cells where any of the points P, P+R_x, P-R_x, P+R_y, ... belong.