Skip to content

Allow duplicate element names in MAD-X parser - #146

Open
austin-hoover wants to merge 4 commits into
PyORBIT-Collaboration:mainfrom
austin-hoover:madx-parser
Open

austin-hoover wants to merge 4 commits into
PyORBIT-Collaboration:mainfrom
austin-hoover:madx-parser

Conversation

@austin-hoover

Copy link
Copy Markdown
Contributor

MAD-X allows a single element definition to be repeated in a LINE definition. For example:

SCH_B02: Sextupole, L=LSH2, K2:=KSH2;
BPM_B02: Monitor;
KDHTB2:=0.0;
DMCH_B02: HKICKER, L=0.0, KICK=KDHTB2;
QSC_B02: MULTIPOLE, KNL:={0,KSC_B02,0};
SSXC_B02: MULTIPOLE, KSL:={0,0,KSSB2_8};
QB2: Line = (DDMCH_X02, DMCH_B02, QSC_B02, SSXC_B02, DDMCH_X02a, BPM_B02, DDMCH_X02b, Q2U, BPM_B02, QTH_B02, Q2D, SCH_B02);

This will output:

...
ssxc_b02, at = 18.92687188;
bpm_b02, at = 19.11879438;
bpm_b02, at = 19.23008388;
qth_b02, at = 19.48008388;
...

When it is read by orbit.teapot.TEAPOT_Lattice, the parser ignores the repeated element. See the SNS AR example here:

sns-ring-madx.zip

MAD-X tunes are 6.23, 6.16, and lattice length is 248.0098418.

Old output:

{'Ekin [GeV]': 1.2999999999999996,
 'alpha x': 0.06789673569066759,
 'alpha y': 0.002402281876774005,
 'beta x [m]': 11.433116314710075,
 'beta y [m]': 15.056203017824776,
 'dispersion prime x': 0.005737171344151361,
 'dispersion prime y': 0.0,
 'dispersion x [m]': -0.12422795506639159,
 'dispersion y [m]': 0.0,
 'eta': -0.1388907500980499,
 'fractional tune x': 0.22590630069001874,
 'fractional tune y': 0.15526948263492443,
 'frequency [Hz]': 1097951.0103074508,
 'gamma transition': 5.2104862428362155,
 'gamma x [m^-1]': 0.0878684288088322,
 'gamma y [m^-1]': 0.06641819121157827,
 'mass [GeV]': 0.938272029,
 'momentum [GeV/c]': 2.0321189127115566,
 'momentum compaction': 0.03683354278126075,
 'period [sec]': 9.107874491776984e-07,
 'transition energy [GeV]': 3.9505814701425224}
length = 247.89855230430024

New output with the modified parser:

{'Ekin [GeV]': 1.2999999999999996,
 'alpha x': 0.04170263505574618,
 'alpha y': 0.03250788492204014,
 'beta x [m]': 11.484241377667265,
 'beta y [m]': 14.711577053277404,
 'dispersion prime x': 0.0029994494463154594,
 'dispersion prime y': 0.0,
 'dispersion x [m]': -0.09888446210253576,
 'dispersion y [m]': 0.0,
 'eta': -0.13892488592900948,
 'fractional tune x': 0.2301327537383606,
 'fractional tune y': 0.16037073821882294,
 'frequency [Hz]': 1097458.3265571904,
 'gamma transition': 5.212902355810395,
 'gamma x [m^-1]': 0.08722727754065196,
 'gamma y [m^-1]': 0.06804550993797799,
 'mass [GeV]': 0.938272029,
 'momentum [GeV/c]': 2.0321189127115566,
 'momentum compaction': 0.03679940695030118,
 'period [sec]': 9.111963304675772e-07,
 'transition energy [GeV]': 3.952848441365099}
length = 248.00984180430024

@austin-hoover

Copy link
Copy Markdown
Contributor Author

Note: in this case there appears to be an error with the MADX lattice definition: BPM_B02 is repeated when defining the beam line. I'm not sure what the default PyORBIT behavior should be in this case. Should we allow duplicate element names?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant