At Lattice Manipulation

A lattice in AT is a cell array.

Each cell is a structure. Suppose the lattice structure is called lat. We access the fifth element with

lat{5}

For creating the elements themselves, we use lattice creation functions. For example atsextupole('s3',0.4,3.0903) will create

s3 =
FamName: 'S4'
Length: 0.4000
PolynomB: [0 0 3.0903]
PolynomA: [0 0 0]
MaxOrder: 2
NumIntSteps: 10
PassMethod: 'StrMPoleSymplectic4Pass'
BetaCode: 'SX'
Energy: 6.0400e+09

Suppose we have a number of lattice elements: some drifts d1,d2, d3, bends, b1, b2, b3, quadrupoles q1, q2, q3, sextupoles s1, s2, s3, and an rf cavity rfcav. We can put these elements together with the syntax:

lat = {d1 b1 d2 b2 q1 d1 s2 rfcav …}

One can define parts of a lattice. Say
cell1 = {d1 b1 d2}
cell2 = {d1 q1 d2}

We combine these together with the syntax

cell12 = [cell1 cell2]

To find specific elements, we can use the function findcells. e.g.
markers_ler=findcells(LOW_EMIT_RING,'Class','Marker')

The available classes are:
"Bend", "Quadrupole", "Sextupole", "RFCavity", "Marker"

what remains is to get the dipoles right
esrf{14}

ans =

FamName: 'B1H'
Length: 2.1573
PolynomA: [0 0 0]
PolynomB: [0 0 0]
MaxOrder: 1
NumIntSteps: 10
BendingAngle: 0.0923
EntranceAngle: 0.0491
ExitAngle: 0.0432
K: 0
PassMethod: 'BndMPoleSymplectic4E2Pass'
Class: 'Bend'
BetaCode: 'DI'
FullGap: 0
FringeInt: 0
Energy: 6.0400e+09

ee{14}

ans =

FamName: 'B1IN'
Length: 0.0491
KickAngle: 2.3366e+03
PassMethod: 'CorrectorPass'
Class: 'Corrector'

Another useful command is atindex.
E.g.
atindex(esrf)

ans =

SDHI: [1x32 double]
BPM: [1x224 double]
SD1U: [1x32 double]
S4: [1x32 double]
SD2U: [1x32 double]
QF2: [1x32 double]
SD2D: [1x32 double]
SDA: [1x64 double]
S6: [1x32 double]
SD3U: [1x32 double]
QD3: [1x32 double]
SD3D: [1x32 double]
B1H: [1x32 double]
B1S: [1x32 double]
SDBD: [1x64 double]
SD4U: [1x64 double]
QD4: [1x64 double]
SD4D: [1x64 double]
S13: [1x32 double]
SD5U: [1x64 double]
QF5: [1x64 double]
SD5D: [1x32 double]
X27: [1x32 double]
S19: [1x32 double]
S5PU: [1x32 double]
S20: [1x32 double]
B2S: [1x32 double]
B2H: [1x32 double]
SD6U: [1x32 double]
QD6: [1x32 double]
SD6D: [1x32 double]
S22: [1x32 double]
SD7U: [1x32 double]
QF7: [1x32 double]
SD7D: [1x32 double]
S24: [1x32 double]
SD8D: [1x32 double]
SDLO: [1x32 double]
CAV: [103 206 309 412 515 618 721 824 927 1030 1133 1236 1339 1442 1545 1648]

Another important function is ringpara:

ringpara(esrf)
ringpara(esrf)

AT Ring Parmater Summary
Energy: 6.04000 [GeV]
Circumference: 844.39037 [m]
Revolution time: 2816.58311 [ns] (0.35504 [MHz])
Betatron tune H: 36.43963 (156.08566 [kHz])
V: 13.39005 (138.48417 [kHz])
Momentum Compaction Factor: 0.00018
Chromaticity H: +2.65702
V: +5.22811
Synchrotron Integral 1: 0.15000 [m]
2: 0.26036 [m^-1]
3: 0.01097 [m^-2]
4: -0.00019 [m^-1]
5: 0.00002 [m^-1]
Damping Partition H: 1.00072
V: 1.00000
E: 1.99928
Radiation Loss: 4880.64612 [keV]
Natural Energy Spread: 1.06202e-03
Natural Emittance: 3.99081e+00 [nm]
Radiation Damping H: 6.96629 [ms]
V: 6.97127 [ms]
E: 3.48689 [ms]
Slip factor : -0.00018

Assuming cavities Voltage: 9000.00000 [kV]
Frequency: 352.19980 [MHz]
Harmonic Number: 992
Synchronous Phase: 2.56843 [rad] (147.16006 [deg])
Linear Energy Acceptance: 4.01312 %
Synchrotron Tune: 0.00593 (2.10376 kHz or 168.76 turns)
Bunch Length: 4.27858 [mm], 14.27180 [ps]

Emitty from Dy: 0.00000 [nm]

ans =

E0: 6.0400e+09
R: 134.3889
alphac: 1.7764e-04
U0: 4.8806e+06
sigma_E: 0.0011
emittx: 3.9908e-09
T0: 2.8166e-06
integrals: [0.1500 0.2604 0.0110 -1.8647e-04 1.9432e-05]
dampingalpha: [143.5485 143.4458 286.7889]
dampingtime: [0.0070 0.0070 0.0035]
dampingJ: [1.0007 1 1.9993]
tunes: [36.4396 13.3901]
chroms: [2.6570 5.2281]
etac: -1.7763e-04
nus: 0.0059
phi_s: 2.5684
harm: 992
bunchlength: 0.0043
delta_max: 0.0401
emitty_d: 0

In addition there is atsummary:

atsummary

AT Lattice Summary
Energy: 6.04000 [GeV]
Gamma: 11819.98260
Circumference: 844.39037 [m]
Revolution time: 2816.58311 [ns] (0.35504 [MHz])
Betatron tune H: 36.43963 (12937.52993 [kHz])
V: 13.39005 (4754.00571 [kHz])
Momentum Compaction Factor: 0.00018
Chromaticity H: +2.65904
V: +5.22788
Synchrotron Integral 1: 0.24797 [m]
2: 0.26036 [m^-1]
3: 0.01097 [m^-2]
4: 0.00083 [m^-1]
5: 0.00003 [m^-1]
6: 0.00000 [m^-1]
Damping Partition H: 0.99680
V: 1.00000
E: 2.00320
Radiation Loss: 4878.51377 [keV]
Natural Energy Spread: 1.06124e-03
Natural Emittance: 6.37619e-09 [mrad]
Radiation Damping H: 6.98767 [ms]
V: 6.96530 [ms]
E: 3.47708 [ms]
Slip factor : -0.00018

Assuming cavities Voltage: 562.50000 [kV]
Frequency: 352.19980 [MHz]
Harmonic Number: 992.00000
Overvoltage factor: 0.11530
Synchronous Phase: 1.57080 [rad] (90.00000 [deg])
Linear Energy Acceptance: 5.20567 %
Synchrotron Tune: 0.00335 (1.19066 kHz or 149.09 turns)
Bunch Length: 3.77566 [mm]

ans =

e0: 6.0400
circumference: 844.3904
revTime: 2.8166e-06
revFreq: 3.5504e+05
gamma: 1.1820e+04
beta: 1.0000
tunes: [36.4396 13.3901]
chromaticity: [2.6590 5.2279]
compactionFactor: 1.7758e-04
integrals: [0.2480 0.2604 0.0110 8.3356e-04 3.0910e-05 0]
damping: [0.9968 1 2.0032]
radiation: 0.0049
naturalEnergySpread: 0.0011
naturalEmittance: 6.3762e-09
radiationDamping: [0.0070 0.0070 0.0035]
etac: -1.7757e-04
harmon: 992.0000
overvoltage: 0.1153
syncphase: 1.5708 + 2.8500i
energyacceptance: 0.0521 - 0.0521i
synctune: 0.0034 + 0.0034i
bunchlength: 0.0038 - 0.0038i

To construct a lattice we use the lattice creation functions:
Here is the ESRF lattice (still not totally correct)
(in the function esrflat.m)

RP=atringparam('EsrfMB',6.03e9,16);
SDHI=atdrift('SDHI',3.0526);
BPM=atmonitor('BPM');
SD1U=atdrift('SD1U',0.667);
S4=atsextupole('S4',0.4,3.04942);
SD2U=atdrift('SD2U',0.128295);
QF2=atquadrupole('QF2',0.943410,0.39100749);
SD2D=atdrift('SD2D',0.095295);
SDA=atdrift('SDA',0.083);
S6=atsextupole('S6',0.40000000,-4.055060);
SD3U=atdrift('SD3U',0.13316500);
QD3=atquadrupole('QD3',0.53367000,-0.60355343);
SD3D=atdrift('SD3D',1.0554150);
B1H=atrbend('B1H',2.1573,0.0923,0,'BndMPoleSymplectic4E2Pass'); % need to get this right still…
B1S=atrbend('B1S',0.2927,0.0059,0,'BndMPoleSymplectic4E2Pass');
SDBD=atdrift('SDBD',0.95475000);
SD4U=atdrift('SD4U',0.10594500);
QD4=atquadrupole('QD4',0.42211000,-0.60152556);
SD4D=atdrift('SD4D',0.13894500);
S13=atsextupole('S13',0.4000000,-2.2975000);
SD5U=atdrift('SD5U',0.22019000);
QF5=atquadrupole('QF5',0.5196200,0.73458675);
SD5D=atdrift('SD5D',0.10719000);
d27=atdrift('d27', 0.1830000);
S19=atsextupole('S19',0.400000,11.328457);
S5PU=atdrift('S5PU',.29019000);
S20=atsextupole('S20',0.4000000,-10.666945);
B2S=atrbend('B2S',0.2927,0.0058500000,0,'BndMPoleSymplectic4E2Pass');
B2H=atrbend('B2H',2.1573,0.092324800,0,'BndMPoleSymplectic4E2Pass');
SD6U=atdrift('SD6U',1.0627450);
QD6=atquadrupole('QD6',0.51901000,-0.81881205);
SD6D=atdrift('SD6D',0.14049500);
S22=atsextupole('S22',0.4000000,-2.4975900);
SD7U=atdrift('SD7U',0.10484000);
QF7=atquadrupole('QF7',0.92432000,0.68156653);
SD7D=atdrift('SD7D',0.13784000);
S24=atsextupole('S24',0.40000000,3.5249000);
SD8D=atdrift('SD8D',0.66700000);
SDLO=atdrift('SDLO',3.0526000);
CAV=atrfcavity('CAV',0,0.56250000e6,3.5220e+08,992/16,0.60400000E+10);

esrflat={SDHI BPM SD1U S4 SD2U QF2 SD2D BPM SDA S6…
SD3U QD3 SD3D B1H B1S SDBD…
BPM SD4U QD4 SD4D S13 SD5U QF5 SD5D BPM d27…
S19 S5PU QF5 SD5U S20 SD4D QD4 SD4U BPM SDBD…
B2S B2H SD6U QD6 SD6D S22 …
SDA BPM SD7U QF7 SD7D S24 SD8D BPM SDLO SDLO…
BPM SD8D S24 SD7D QF7 SD7U BPM SDA S22 SD6D…
QD6 SD6U B1H B1S SDBD BPM …
SD4U QD4 SD4D S20 SD5U QF5 SD5D BPM d27 S19 …
S5PU QF5 SD5U S13 SD4D QD4 SD4U BPM SDBD…
B2S B2H SD3D QD3 SD3U S6 SDA …
BPM SD2D QF2 SD2U S4 SD1U BPM SDHI CAV}';

We can read in a lattice file to create a cell structure. We may want to add errors. We may want to split elements.

esrf= build_simple(1,'s13s20thick.str');

And then there is Accelerator Markup Language:
http://www.lns.cornell.edu/~dcs/aml/

This uses XML. In the end, we create the cell structure. We have all the elements in there. We want to be able to manipulate them.

We can act on individual elements, or on the lattice as a whole.

Now let us misalign this sextupole by 1mm horizontally and vertically
sext4ma=atshiftelem(sext4,.001,.001)

This creates the new element sext4ma with non-zero T1 and T2:
sext4ma.T1

ans =

1.0e-03 *

-1.0000
0
-1.0000
0
0
0
Another interesting function is atelem:

function elemstruct = atelem(ELEM,varargin)
%ATELEM makes a new AT element structure from another element,
% standard AT type, or a template on file. Existing fields are overridden
% with new values. New fields are added and initialized.
%
% NEWELEM = ATELEM(ELEM,'Field1','Value1','Field2', 'Value2', …)
% ELEM can be 1) another element structure
% 2) One of the standard AT types
% 'drift'
% 'quadrupole'
% 'sextupole'
% …
% 3) name of a function that returns a template element structure
%
% Accelerator Toolbox, Version 1.3, 2004-01-26

working with the output of atlinopt, we get arrays, and can use arrayfun()
working with lattice structures themselves, we have cell arrrays and can use cellfun()

The functions in the lattice folder are
atelem.m attiltelem.m insertelem0.m readmad.m setshift.m
atgetcells.m buildlat.m insertindrift.m restoreparamgroup.m settags.m
atindex.m combinebypassmethod.m isatelem.m reverse.m settilt.m
atparamgroup.m combinelinear45.m isatlattice.m rmelem0.m splitdrift.m
atsetshift.m findcells.m mergedrift.m saveparamgroup.m splitelem.m
atsettilt.m findtags.m mkparamgroup.m setcellstruct.m
atshiftelem.m getcellstruct.m mvelem.m setparamgroup.m
—-

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License