Tracking issues in CSBEND elements in the presence of errors

Moderators: michael_borland, soliday

Post Reply
GPenn
Posts: 38
Joined: 28 Aug 2018, 09:46

Tracking issues in CSBEND elements in the presence of errors

Post by GPenn » 19 Dec 2019, 15:33

Sorry for the poor timing of this post. I see several problems with the tracking in CSBEND elements that include error terms. I've been tracking particle through bends using specific errors, rather than only looking at rms quantities.

First, ETILT does not seem to work properly. This seems related to Zhe's post at
viewtopic.php?f=19&t=914
When the rotation angle phi<<1, my best fit for how to set the parameters is to make
ETILT=-phi*sqrt(3)/2
Note the - sign. On the other hand, rotations of 2 pi have no impact, as expected. Maybe in csbend.c, the convertFromCSBendCoords and convertToCSBendCoords routines are reversed? Another symptom is that the vertical displacement of a particle is proportional to (1+delta), where delta is the momentum offset. It should scale like 1/(1+delta). An example figure is below, where the CSBEND element is between s=1 and s=2. The rest is drifts. I see the same issue when using REFERENCE_CORRECTION=1, and for rectangular bend magnets (E1=E1=angle/2 where angle is the bending angle).
etilt_y.pdf
(6.61 KiB) Downloaded 266 times
Also, there is an error when the CSBEND element is displaced horizontally using DX. The final position of the particles is not consistent with taking away the displacement of the CSBEND and instead first shifting the particles in the opposite direction, then displacing everything back at the end. The error scales linearly with DX. However, the final angle x' is exactly the same in all cases. Again, the same effect is seen using REFERENCE_CORRECTION=1 and for rectangular bend magnets. Figure is below.
dx_x.pdf
(6.64 KiB) Downloaded 266 times
Finally, whenever using REFERENCE_CORRECTION=1, it seems that the value of FSE_DIPOLE is ignored. I cannot tell if it's simply acting like FSE_DIPOLE=0, or if it's recalculating the reference orbit for the actual bending strength rather than the nominal value. This one I didn't include an example for, but it's very obvious especially for a plain dipole with just an FSE_DIPOLE term.

For the other two cases, the simulations and more extensive plots are in the zip file. I'm using the most recent version of elegant, version 2019.4.0, using the pre-compiled Mac binaries from the website. These errors were in earlier versions too.

Thanks,
Gregg
Attachments
Penn_Dec19.zip
(373.48 KiB) Downloaded 254 times

michael_borland
Posts: 1797
Joined: 19 May 2008, 09:33
Location: Argonne National Laboratory
Contact:

Re: Tracking issues in CSBEND elements in the presence of errors

Post by michael_borland » 03 Jan 2020, 14:14

Gregg,

Sorry I didn't get to this sooner.

For the first item, I'm pretty sure the ETILT works as it should. For example, I should get the same results if I use the TILT parameter with the opposite sign. When I try this, the vertical trajectory in the simulation using ETILT=A agrees with the vertical floor coordinate in the simulation using TILT=-A. The change in the horizontal coordinate (trajectory or floor coordinate) also agrees.

As for calls to convertFromCSBendCoords() and convertToCSBendCoords() being reversed: these routines are only used to prepare data for secondary calculations or output. In cases where the particle will continue to be tracked, they are used in pairs, so the order wouldn't introduce an error in the tracking. (I do think there is an error using these for the slice analysis feature, however. I'll follow up on that.)

As for the DX feature, please note that in order to correctly model it with displacements at the start and end of the element, you have to modify the final displacement to account for the bending angle. That's because the DX, DY, DX, and ETILT values are applied at the entrance of the dipole. Did you include that?

I'll look into the FSE_DIPOLE and REFERENCE_CORRECTION issue.

--Michael

michael_borland
Posts: 1797
Joined: 19 May 2008, 09:33
Location: Argonne National Laboratory
Contact:

Re: Tracking issues in CSBEND elements in the presence of errors

Post by michael_borland » 03 Jan 2020, 14:24

Gregg,

I checked the use of convertFromCSBendCoords and convertToCSBendCoords. They seem to be used correctly. They are used to put particles back in the lab frame prior to ancilliary calculations or output, so we use convertFromCSBendCoords first, then convertToCSBendCoords.

--Michael

michael_borland
Posts: 1797
Joined: 19 May 2008, 09:33
Location: Argonne National Laboratory
Contact:

Re: Tracking issues in CSBEND elements in the presence of errors

Post by michael_borland » 06 Jan 2020, 12:47

Gregg,

You are correct about the issue with FSE_DIPOLE when REFERENCE_CORRECTION=1: the code was using the reference trajectory with the dipole error. The bug fix will appear in the next version. For those who build from source, the corrected code is attached.

Thanks for bringing the bug to my attention!

--Michael
Attachments
csbend.c
(211.48 KiB) Downloaded 192 times

GPenn
Posts: 38
Joined: 28 Aug 2018, 09:46

Re: Tracking issues in CSBEND elements in the presence of errors

Post by GPenn » 06 Jan 2020, 18:23

Thank you for looking into this, Mike.

For the DX issue, the fact that a shift in x means different things at the entrance and exit makes sense. I hadn't taken that into account. The difference is very close to DX*(1-cos(angle)). Is that why there is also a change in the 't' coordinate? Because it could end up inside where the nominal magnet is supposed to be.

I think I am now clear on the sign conventions for ETILT and TILT. In the manual for CSBEND, the only difference in the description is that TILT is called the 'rotation', and ETILT is called the 'error rotation', so it's not obvious that they are supposed to go in opposite directions. I was assuming that if TILT and ETILT were both 1.e-3, that means the magnet was supposed to be rotated by 1 mrad but was actually rotated by twice that amount, but that configuration would actually correspond to someone forgetting to rotate it at all.

Anyway, I still think there is something strange about off-momentum trajectories in a bend with ETILT. I am including another attempt at making a comparison. I will post the full files in a separate message. I think you will also see something if you repeat what you did with looking at the floor coordinates but with an off-momentum particle. What I did in the attached files is look at 3 cases: a dipole with a tilt of -0.01 rad, a horizontal kicker (actually a quad with K1=0 and a negative hkick) with a tilt of -0.01 rad, and a dipole with an etilt of +0.01 rad. You can see that the dipole with a tilt labels the on-momentum particle as being the reference orbit, but it's really getting a kick in the +y direction. Higher energy particles do not get kicked as much, which shows up as a negative yp. The HKICK does not have any effect on the coordinate system, so a nominal energy particle has a yp of 0.1 mrad, and particles with higher energy get kicked less. But the difference from the nominal momentum is almost exactly the same as for the case of a tilted dipole. For a dipole with an etilt, the nominal momentum trajectory matches the HKICK example. However, higher energy particles get more of a vertical kick instead of having a straighter trajectory, which does not make sense.

In the file csbend.c there are some references to a notebook, is that something I could take a look at to better understand the code?

Thanks,
Gregg
tilt_yp.pdf
(6.39 KiB) Downloaded 207 times
hktilt_yp.pdf
(6.75 KiB) Downloaded 206 times
etilt_yp.pdf
(6.7 KiB) Downloaded 197 times

GPenn
Posts: 38
Joined: 28 Aug 2018, 09:46

Re: Tracking issues in CSBEND elements in the presence of errors

Post by GPenn » 06 Jan 2020, 18:25

I am attaching the set of files for the figures in the previous message.

One thing in csbend.c that looks suspicious to me is there are a few places with the line
ttilt = tilt + etilt;
and I assume that ttilt is supposed to be the total tilt. But with the sign conventions as they are, maybe it should be ttilt=tilt-etilt?

-Gregg
Attachments
Tilts.zip
(179.5 KiB) Downloaded 194 times

michael_borland
Posts: 1797
Joined: 19 May 2008, 09:33
Location: Argonne National Laboratory
Contact:

Re: Tracking issues in CSBEND elements in the presence of errors

Post by michael_borland » 07 Jan 2020, 08:59

Gregg,
For the DX issue, the fact that a shift in x means different things at the entrance and exit makes sense. I hadn't taken that into account. The difference is very close to DX*(1-cos(angle)). Is that why there is also a change in the 't' coordinate? Because it could end up inside where the nominal magnet is supposed to be.
Yes, that's why the time coordinate changes as well.

You are right that something was inconsistent in the interpretations of ETILT and TILT. I responded to this on another of your posts
viewtopic.php?f=13&t=1016#p4246 and included revised code (still not 100% tested, but seems right). The basic problem was that I was using inconsistent sign conventions for ETILT. That's been fixed in the revised code I uploaded at the link above.

Thanks again for your help in identifying this issue.

--Michael

GPenn
Posts: 38
Joined: 28 Aug 2018, 09:46

Re: Tracking issues in CSBEND elements in the presence of errors

Post by GPenn » 07 Jan 2020, 19:27

The revised code works great. Now putting ETILT and TILT with the same sign gives completely consistent behavior including for off-momentum particles.

I have one final question just to make sure I'm interpreting things correctly. It looks like in the CSBEND element, FSE and ETILT do not impact quadrupole or sextupole fields, although higher order multipoles are adjusted. I haven't checked all the combinations (I've been using F1 and F2 instead of K1 and K2 for example) but that's how it looks to me.

michael_borland
Posts: 1797
Joined: 19 May 2008, 09:33
Location: Argonne National Laboratory
Contact:

Re: Tracking issues in CSBEND elements in the presence of errors

Post by michael_borland » 07 Jan 2020, 21:50

Gregg,

My tests show that the quadrupole field tilts with the bending field regardless of how I specify it. See attached.
varyEtiltFocusing.png
--Michael
Attachments
csbendEtilt.zip
(2.34 KiB) Downloaded 196 times

GPenn
Posts: 38
Joined: 28 Aug 2018, 09:46

Re: Tracking issues in CSBEND elements in the presence of errors

Post by GPenn » 09 Jan 2020, 18:57

Thanks Mike,

That clarifies things a lot. I think the problem is simply that I'm comparing elegant to a model that is too simplistic. It's harder than I thought to account for the difference between the physical centerline of the magnet and the reference orbit when there is an error in the tilt. I'm sure you know all about that!

-Gregg

Post Reply