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

'tracking_method' unexpectedly changes from Bmad_standard to runge_kutta for quad with x_offset + superimposed hkicker #1177

Closed weiyuanlou closed 3 weeks ago

weiyuanlou commented 2 months ago

Compare 3 cases:

Case 1: A quad q1 has an hkicker superimposed onto it. The quad q1 is also given an x_offset in the lattice BEFORE the use statement. When Tao runs, tracking_method of many elements becomes runge_kutta ( see image below ). To test, run tao using the attached files. bug.zip

Case 2: The x_offset of q1 is given in tao. The tracking_method remains Bmad_Standard as expected. To test, uncomment the x_offset line in lat.bmad, and call Script.tao.

The difference between case 1 and case 2 is unexpected.

Case 3: Comment out the superimposed kicker, and all tracking_method stays Bmad_standard, regardless of the x_offset being applied in the lattice or in Tao.

Overall observation: a quad with (1) x_offset given in lattice + (2) a kicker superimposed seems to cause the tracking method to change from Bmad_standard to runge_kutta for the PIPE and several downstream elements on the pipe. The kicker KEY also changes to EM_FIELD. However the other kicker on the other quad (q2) with no x_offset is un-affected. If the x_offset is given after Tao runs, no problem is seen.

image

DavidSagan commented 1 month ago

When elements are superimposed upon one another, Bmad cannot, except for a few special cases, handle misalignments of the elements. So when there are misalignments, a EM_Field element is created and the tracking method is set to Runge_Kutta. What Bmad should do Is prevent you from misaligning in case 2. I will work on a fix.

weiyuanlou commented 1 month ago

Ah I see. I guess it would would if I use the hkick attribute of the quad instead of superimposing a hkicker onto it?

DavidSagan commented 1 month ago

Yes better is to use the hkick attribute of the quad.