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

Fix Bmad collimator length on import #249

Closed jank324 closed 2 months ago

jank324 commented 2 months ago

Description

Changes in interpretation of Bmad ecollimator and rcollimator in Cheetah from a lengthless Aperture element to a Drift + Aperture sequence.

Motivation and Context

This was a bug found in the LCLS import that led to a Twiss mismatch. See #248.

Types of changes

Checklist

Note: We are using a maximum length of 88 characters per line.

cr-xu commented 2 months ago

I have only one minor concern: I guess when you have a real aperture with non-length, the beam should be smaller than some threshold over the whole length. Would it make more sense to convert it to [Aperture_start, Drift, Aperture_end]?

Edit: looking at the Bmad manual it happens only at the "exit end" by default

image
jank324 commented 2 months ago

I have only one minor concern: I guess when you have a real aperture with non-length, the beam should be smaller than some threshold over the whole length. Would it make more sense to convert it to [Aperture_start, Drift, Aperture_end]?

Edit: looking at the Bmad manual it happens only at the "exit end" by default

image

I was thinking about the same thing. In the end, only an infinite number of apertures would be truly correct. But this quick fix worked well enough to fix the mismatch I had. We can think about adding more options or even a Collimator element at a later date if this is not enough.