Quad curvature correction in bending magnets#1067
Conversation
|
Some tests are failing because of small deviations introduced by the new tracking. Please ignore that for the moment, I will adapt the tests if the modification proves successful. |
|
A few other points appear when looking into that:
|
|
I ran my scripts again, and I see several issues: I will take a step back and verify that in AT the new integrator give identical results as the old one in the absence of K1. |
|
I confirm a problem with the new sector bend, with the following code all particles are lost which is nit the case in the previous implementation |
|
Very strange: the added term has Note that I will use you script to further check. |
BndSymplectic4Pass seems to be fine at first sight |
|
I see problems with |
Do you? It looked fine for me providing the FringeFields are correctly set (full, or dipole-only in XSuite). |
|
A bug in Note: if K == 0, Now for K != 0, it's up to you ! |
Great thanks! May have to wait until next week (after the restart) before getting back it it though |
f852135 to
a471c14
Compare
|
I confirm that now in the absence of K1, the master and this banch give the same results. Anything I can try? |
|
@swhite2401 : I reproduced your test setup and here are my findings, taking into account these 2 problems in Xsuite:
For sector magnets (ExactSectorBendPass) with K1 == 0.0
For sector magnets (ExactSectorBendPass) with K1 != 0.0
For rectangular magnets (ExactRectangularBendPass)Agreement only with K1 == 0.0 and face_angle == 0.5*bending_angle. There is clearly a problem there. For sector magnets (BndMPoleSymplectic4Pass)No result yet, I have to compare with the Xsuite "drift-kick-drift-expanded" model. |
|
@lfarv, thanks for the summary, sorry I had forgotten about this charge issue... I agree with your findings! |
|
@lfarv see issue #1076 from @gubaidulinvadim maybe it could be integrated in there? |
|
@lfarv we had a discussion with CERN colleagues yesterday and made some prgress see below.
They agree on that and will fix this
We could not reproduce this, for us the sector bend agrees well for all face angles
Here there is some subtelties related to X0ref, to match XSuite and AT. Without running rbendtune (X0ref=0): xs_sbend[0].rbend_shift += xs_sbend[0]._x0_in With running rbendtune (X0ref!=0): xs_sbend[0].rbend_shift += xs_sbend[0]._x0_in - at_sbend[0].X0ref
|
|
Remaining issue: B0, A0: They include these components in the multipole fringe field calculation, while we have the skip_b0 option activated. When using dipole fringe only I get agreement with A0 but not B0 (as expected) dx: this is strange we get agreement only with paralell faces, there is something fishy there either for us or for them...do we neglect the change in dipole length when applying a horizontal offset in a sector bend? X0ref: we apply the shift only on the body of the magnet while it seem that rbendshift applies an offset on everything including edges (I checked this by using parallel faces and turning off multipole fringe, in this case the 2 codes agree) I think this is all... there are so many cases I am getting confused myself with all these tests.... but we are slowly converging! |
|
@swhite2401 : very nice, we are progressing. In the meantime, I made some additional tests: For sector magnets (BndMPoleSymplectic4Pass)Perfect agreement with the For quadrupoles (StrMPoleSymplectic4Pass)Perfect agreement with the For quadrupoles (ExactMultipolePass)Perfect agreement with the So I found no additional problems compared to your list above. |
Great! Just for my understanding, I would have expected this to match with kick-drift-kick-exact, why do you need to bend in a multipole? |
Sorry, it's a typo, you are right! |
You are right. it should be applied to the whole magnet. I just pushed a correction for that. Let me know what you find. |
You introduced a bug in xsuite.py, the keyword for fringe in xsuite is "suppressed" and not "suppress" |
|
Other problem, in ExactRectangular bend the case where FringeBend*=1 and QuandBend*=0 now translates to 'linear' instead of 'dipole-only'. |
|
So it is strange now... some things that used to work don't anymore.... are you sure X0ref is correctly handle? Don't you need to change rbendtune() as well? |
corrected
Yes, here is what is happening at the moment: according to the doc: So 1 should indeed translate to "linear". But at the moment, the AT exact methods ignore the value of FringeBend* and always use another method (Forest), even when specifying 0. In the future, this will be method 4, and 1 will be indeed the "linear" method (this is how I tested the agreement with Xsuite). For the time being, don't specify I'm presently working to implement all 4 methods on all the dipole passmethods. |
|
Still I still get strange results: For me the reference particle is np.zeros(6) before rbendtune() it already exists at zero, so why is rbendtune() moving it to some other coordinates? ... maybe I miss someting? In any case not running rbendtune in this case I get perfect agreement using: I would have think that running rbendtune and shifting the xsuite element by the same amount... so something is strange....and clearly the problem lies there |
|
@swhite: you magnet has K1 == 0. So Similarly, if K1 == 0, the Xsuite result should be independent of |
|
@swhite2401: I checked that before iterating, |
I agree, I did not expect this! This is why I am surprised, but maybe I am doing something wrong.... let me check and get back to you... |
|
This new release makes 3 changes:
|
|
A comment on This looks like a problem in transformations. dx works perfectly on straight magnets ! |
atelem.to_file() serializes all element attributes including PolynomA, PolynomB and MaxOrder into atparams. These were then passed twice to Multipole.from_at() — once explicitly and once via **atparams — causing a TypeError. Fix by popping PolynomA, PolynomB and MaxOrder from atparams before the call, so only the values recomputed from KickAngle are used.
|
@lfarv I am having a look back and here is a summary of the present situation: Multipole: all looks good SBEND is ok for any value of FringeQuad*, face angles or K1, dy as long as dx, B0 and A0 are equal to zero RBEND Few questions / remarks come: |
I don't see that: even in that case, I see a strong disagreement as soon as the entrance/exit angles are not half the bending angle |
|
@swhite2401 : after another review, my conclusions on RBEND are different from yours: With faceangles == 0.5*bendingangleEverything works, including
Here is my test dipole: elem = at.Dipole('D', 2.0, 1.0, k=1.0, PassMethod='ExactRectangularBendPass',
EntranceAngle=0.5, ExitAngle=0.5,
FullGap=0.1, FringeInt1=0.65, FringeInt2=0.65,
FringeQuadEntrance=1, FringeQuadExit=1,
NumIntSteps=1000)Here is the translated Xsuite element: With faceangles != 0.5*bendinganglenothing works |




This adds another term to the bending magnets to try and cancel a difference of tracking of combined bending-focusing magnets between AT and Xsuite.
The so-called "K1h" term of the Hamiltonian is included in:
A successful comparison is necessary before accepting this term. @swhite2401 and @kandre2, can you look at that ?