Strange trajectories within custom magnetic field

FLUKA: 4-5.1
Flair: 3.4-5.2

Dear all,

I am trying to calculate electron trajectories within a halbach cylinder dipole (inner radius 1cm, height 7cm). I calculated the magnetic field via a python script and imported it to Flair following the instructions in this post:

The field seems good, but electron trajectories look unrealistic. For example, an electron of 50 MeV seemingly passes through the entire 7cm cylinder, which contains a fairly constant field of 1.2T.

I tried calculating a 50 MeV trajectory in a custom script with the same field, and electrons hit the cylinder way before the exit. I also tried creating in Fluka a constant field of 0.7T inside the cylinder, just to overcompensate for the fringe fields, and Fluka correctly calculates that 50 MeV should hit the edge at the exit.

I am not sure why electrons don’t bend enough in the 1.2T field but do in the 0.7T one. It might be something wrong with the way I imported the field…or completely misunderstanding physics.

I attach the flair file, the B-field input file “field.inp”, and also the txt file in (x,y,z,Bx,By,Bz) which I used to create field.inp

Any ideas would be greatly appreciated!

Thank you,

Simon

Input files

field.inp (289.1 KB)

total_grid.txt (640.9 KB)

magnetic_field.flair (4.7 KB)

Hello Simon,

this is an excellent question. The tracking algorithm typically is very smart when following particles in magnetic fields, but you encountered a corner case.

When in magnetic field, the radius of curvature is calculated locally. Since the first point you encounter has very little magnetic field intensity, the radius of curvature is enormous. Therefore, the tracking tries to perform a huge step. Along this step, the magnetic fields increases dramatically, but the code could not realize it.

To circumvent this problem, you need to specify that in this region the step size has to be forcefully decreased. To do so, you can use this card for instance:

STEPSIZE                   0.1       VAC                                        

With this option on, I manage to steer the electron in the magnet, as seen in the trajectory.

Let me know if you have any other questions!

Cheers,
Daniele

2 Likes

Dear Daniele,

this is very interesting, and makes sense! Indeed decreasing the stepsize solved the issue.

Thank you for the quick reply…
and for saving my sanity

All the best,
Simon