desy-ml / cheetah

Fast and differentiable particle accelerator optics simulation for reinforcement learning and optimisation applications.
https://cheetah-accelerator.readthedocs.io
GNU General Public License v3.0
35 stars 14 forks source link

Transfer map inaccuracy for fringe field effect for dipole element #259

Closed zihan-zh closed 1 month ago

zihan-zh commented 2 months ago

There is a missing coefficient in the fringe field effect calculation for dipole magnets in the current implementation. According to the formula 18.16 in Bmad manual, a coefficient of 2 should be implemented into the phi value calc in Dipole._transfer_map_enter and Dipole._transfer_map_exit.

cr-xu commented 2 months ago

I believe this is due to different naming conventions. We used the OCELOT parameters where gap(cheetah, ocelot) = 2 * hgap (MAD, BMAD), See https://github.com/desy-ml/cheetah/blob/3038c7b51b40a7dd36c4a2c105dbd030c86da743/cheetah/accelerator/dipole.py#L31)

cr-xu commented 2 months ago

So the actual issue is the incorrect converter class... This should be fixed: https://github.com/desy-ml/cheetah/blob/3038c7b51b40a7dd36c4a2c105dbd030c86da743/cheetah/converters/bmad.py#L148