You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import cpymad.madx
import pysixtrack
# code from help(pysixtrack.Line.apply_madx_errors) with minimal madx sequence
madx = cpymad.madx.Madx()
madx.input('''
!----EXAMPLE----------------------------------------------------------------
MQ1: Quadrupole, K1:=KQ1, L=1.0;
MQ2: Quadrupole, K1:=KQ2, L=1.0;
KQ1 = 0.02;
KQ2 = -0.02;
testseq: SEQUENCE, l = 20.0;
MQ1, at = 5;
MQ2, at=18;
ENDSEQUENCE;
!---the usual stuff
BEAM, PARTICLE=PROTON, ENERGY=7000.0, EXN=2.2e-6, EYN=2.2e-6;
USE, SEQUENCE=testseq;
Select, flag=makethin, pattern="MQ1", slice=2;
makethin, sequence=testseq;
use, sequence=testseq;
!---misalign collimator
select, flag = error, clear;
select, flag = error, pattern = "MQ1";
ealign, dx := 0.01, dy :=0.01;
select, flag = error, clear;
select, flag = error, pattern = "MQ2";
ealign, dx := 0.02, dy :=0.02;
select, flag = error, full;
!---/EXAMPLE----------------------------------------------------------------
''')
seq = madx.sequence.testseq
madx.command.esave(file='lattice_errors.err')
madx.command.readtable(file='lattice_errors.err', table="errors")
errors = madx.table.errors
pysixtrack_line = pysixtrack.Line.from_madx_sequence(seq, install_apertures=True)
pysixtrack_line.apply_madx_errors(errors)
print('\n')
print('Line content:')
for name,element in zip(pysixtrack_line.element_names,pysixtrack_line.elements):
print("{0:30} : {1}".format(name,element))
The example generates a MAD-X sequence with misaligned quadrupoles and transfers everything to pysixtrack. In the end it outputs the line (element_names and elements).
MQ1 is sliced into multiple slices, MQ2 is a single multipole.
You can see that the DX and DY misalignments of the multi-slice quadrupole are assigned to the start marker and twice to the first slice while the single slice quadrupole is misaligned properly.
The text was updated successfully, but these errors were encountered:
I looked a little into this and the problem seems to be the use of element vs element_name apply_madx_errors(): element_name -> element add_offset_error_to(element): element -> idx_el
However, the intermittent element is not unique for slices and any kind of marker, so the first marker gets every offset for markers the first multipole slice gets every offset for similar multipoles, etc.
The following example assumes #34 is fixed:
The example generates a MAD-X sequence with misaligned quadrupoles and transfers everything to pysixtrack. In the end it outputs the line (element_names and elements).
MQ1 is sliced into multiple slices, MQ2 is a single multipole.
You can see that the DX and DY misalignments of the multi-slice quadrupole are assigned to the start marker and twice to the first slice while the single slice quadrupole is misaligned properly.
The text was updated successfully, but these errors were encountered: