MethodicalAcceleratorDesign / MAD-X

MAD-X repository
Other
49 stars 39 forks source link

bv issue in crab cavities #910

Closed rdemaria closed 4 years ago

rdemaria commented 4 years ago

After a recent check on LHC we found the bv flag for the crab cavities is applied in the wrong way.

The reason is that the bv flag needs to invert the kick in px and energy, but not in py. The implementation however applies the bv flag before applying the tilt attribute instead at the end.

RF multipoles are not yet re-checked (to be followed up)

ldeniau commented 4 years ago

Could you please provide a minimal example with the expected results (in a comment or so), I would like to compare with PTC and MAD-NG...

rdemaria commented 4 years ago

I put two examples: one with crab cavities and one with rf-multipoles. They give the same kick with bv=1, but they give opposite kicks with bv=-1

job_rfm.madx.txt job_cc.madx.txt

I cannot tell (yet?) which one is correct. It is possibly a matter of conventions, but I am not convinced either. Certainly it is not good they behave differently.

rdemaria commented 4 years ago

Probably it is also good if the rfmultipoles behave as multipoles when the frequency is 0 and behave as the cavity.

ldeniau commented 4 years ago

RFmultipole should normally behave as a multipole when the voltage is zero, and in this case, frequency and phases are ignored as they should in your example, so I am surprised by the output...

rdemaria commented 4 years ago

I am thinking a bit more about the issue. Beside the fact the rf-multipoles are always straight, if the kick is magnetic it should behave as multipole, if electric it should be the other way. In case of RF cavity the kick is indeed a mix of the two, therefore it is not possible to determine the effect on a particle going in one direction by knowing the effect in the other direction. The kick therefore does not carry an information of the field direction, contrary to the mulitpoles. Re-reading the paper from Andrea and myself we did not write explicitly the type of convention. According to the paper, the map is simply P M^-1 P. This means that when reflecting the sequence the strength of the element should not flipped. I think the problem then reduces to understand why crab cavities (which is a special case of rf-multipole) behave differently than the rf-multipole.

tpersson commented 4 years ago

I had a look at the paper and I think the RF-multipoles are doing the correct thing. In the crabcavity there is an addtional multiplication of the bv flag of the voltage in this line: rfv = bvk * node_value('volt ')

Removing bvk from there and the results from the crabcavities and the rfmultipole seem to be identical (the code is also almost identical).

I will make PR shortly.

tpersson commented 4 years ago

Fixed in #919