bmad-sim / bmad-ecosystem

Bmad simulation ecosystem for simulating high energy storage rings.
https://www.classe.cornell.edu/bmad/
12 stars 15 forks source link

strange focusing in cartesian map wiggler #779

Closed jeu8 closed 9 months ago

jeu8 commented 9 months ago

When I look at the focusing from a Cartesian map wiggler, there is a kink when switching from hyper-xy to hyper-x as kx increases above kz.

I attached the file I was using to get this plot. I was using an overlay to ensure the k's were chosen consistently and to make sure a main wiggling field (By) of 2.4T. When switching between hyper-xy and hyper-x. the overly has to change slightly.

Also, The lattice rotates the wiggler from horizontal wiggling to vertical, so the matrix elements are swapped.

kx_kz.zip non-bending plane focusing zoom corrected

DavidSagan commented 9 months ago

@jeu8 I expected a lattice with a single wiggler element. So I am confused as to what the situation is here.

jeu8 commented 9 months ago

This is just looking at the first wiggler element

DavidSagan commented 9 months ago

To make sure we are on the same page, can you post a lattice with just that single element (with patches and overlay as needed)? Thanks.

jeu8 commented 9 months ago

Here is a lattice with just the wiggler

wigg.zip

DavidSagan commented 9 months ago

@jeu8 Since the wiggler is tilted, the focusing/defocusing will be in the horizontal plane so it is M21 that you want to plot. Yes?

jeu8 commented 9 months ago

Correct. The plot is mislabeled, here is a corrected one

corrected plot

DavidSagan commented 9 months ago

@jeu8 The issue here is that there are higher order effects that are important. To see this use a lattice with a weakened wiggler:

parameter[geometry] = Open            
parameter[p0c]                      = 1.49769343514647E8
parameter[particle]                 = Electron

beginning[beta_a]    = 1.41620593343558
beginning[alpha_a]   = -2.39715487083063E-15
beginning[beta_b]    = 0.279954474013848
beginning[alpha_b]   = -1.36130763996354E-13

particle_start[x]  = -1.4426502192572E-29
particle_start[px] = 1.34746055861515E-15
particle_start[y]  = -4.25363938008239E-15
particle_start[py] = 5.49377071864153E-7

kz = 28
ky = 3
kx = sqrt(kz^2 + ky^2)  ! Gives positive k21. Use sqrt(kz^2 - ky^2) to get negative.

PI: Patch, Y_PITCH = -0.180909582657665
WIGGHALFREV: Wiggler, cartesian_map = {
      master_parameter  = POLARITY,
      field_scale       = 1,
      r0                = (0, 0, 0),
      ele_anchor_pt     = Beginning,
      field_type        = Magnetic,
      term = {2, kx, ky, kz, 0, 0, 0, Y}
    }, L = 2.0196, field_calc = FieldMap,
    TILT = 1.5707963267949, B_MAX = 2.40000401303407, DS_STEP = 1E-3, tracking_method = Symp_Lie_Bmad

WIGGTEST: line = (WIGGHALFREV)
use, WIGGTEST

You will see a positive m21 and if you set kx = sqrt(kz^2 - ky^2), m21 switches sign. I can also see the higher order effects in the orbit within the wiggler. With the lattice above the orbit is a sine wave. With larger strength coefficient A the orbit gets distorted.