source: MML/trunk/machine/SOLEIL/LT2/updateatindex.m @ 5

Last change on this file since 5 was 4, checked in by zhangj, 11 years ago

Initial import--MML version from SOLEIL@2013

File size: 2.8 KB
Line 
1function updateatindex
2%UPDATEATINDEX - Updates the AT indices in the MiddleLayer with the present AT lattice (THERING)
3
4%
5% Adapted by Laurent S. Nadolski
6
7global THERING
8
9%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10% Append Accelerator Toolbox information %
11%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12
13% Since changes in the AT model could change the AT indexes, etc,
14% It's best to regenerate all the model indices whenever a model is loaded
15
16% Sort by family first (findcells is linear and slow)
17Indices = atindex(THERING);
18
19AO = getao;
20
21% BPMS
22try
23    ifam = 'BPMx';
24    AO.(ifam).AT.ATType = 'X';
25    AO.(ifam).AT.ATIndex = Indices.BPM(:); % findcells(THERING,'FamName','BPM')';
26    AO.(ifam).Position = findspos(THERING, AO.(ifam).AT.ATIndex)';
27
28    ifam = 'BPMz';
29    AO.(ifam).AT.ATType = 'Z';
30    AO.(ifam).AT.ATIndex = Indices.BPM(:); % findcells(THERING,'FamName','BPM')';
31    AO.(ifam).Position = findspos(THERING, AO.(ifam).AT.ATIndex)';
32catch
33    warning('BPM family not found in the model.');
34end
35
36% CORRECTORS
37try
38    %% HORIZONTAL CORRECTORS
39    ifam = ('CH');
40    AO.(ifam).AT.ATType  = ifam;
41    AO.(ifam).AT.ATIndex = Indices.(ifam)(:);
42    AO.(ifam).AT.ATIndex = AO.(ifam).AT.ATIndex(AO.(ifam).ElementList);   %not all correctors used
43    AO.(ifam).Position   = findspos(THERING, AO.(ifam).AT.ATIndex(:,1))';
44
45    %% VERTICAL CORRECTORS
46    ifam = ('CV');
47    AO.(ifam).AT.ATType  = ifam;
48    AO.(ifam).AT.ATIndex = Indices.(ifam)(:);
49    AO.(ifam).AT.ATIndex = AO.(ifam).AT.ATIndex(AO.(ifam).ElementList);   %not all correctors used
50    AO.(ifam).Position   = findspos(THERING, AO.(ifam).AT.ATIndex(:,1))';
51catch
52    warning('Corrector family not found in the model.');
53end
54
55
56% QUADRUPOLES
57try
58    ifam = 'QP';
59    AO.(ifam).AT.ATType  = 'QUAD';
60    AO.(ifam).AT.ATIndex = eval(['Indices.' ifam '(:)']);
61    AO.(ifam).AT.ATIndex = AO.(ifam).AT.ATIndex;
62    AO.(ifam).Position   = findspos(THERING, AO.(ifam).AT.ATIndex(:,1))';
63catch
64    warning('%s family not found in the model.', ifam);
65end
66
67% BEND
68
69try
70    ifam = ('BEND');
71    AO.(ifam).AT.ATType  = ifam;
72    ATIndex = Indices.(ifam)(:);
73    AO.(ifam).AT.ATIndex = buildatindex(AO.(ifam).FamilyName, sort(ATIndex));
74    AO.(ifam).Position   = findspos(THERING, AO.(ifam).AT.ATIndex(:,1))';
75catch
76    warning('BEND family not found in the model.');
77end
78
79setao(AO);
80
81% Set TwissData at the start of TL1
82try
83    % BTS twiss parameters at the input
84    TwissData.alpha = [0 0]';
85    TwissData.beta  = [6.0 6.0]';
86    TwissData.mu    = [-1.8 1.5]';
87    TwissData.ClosedOrbit = [0 0 0 0]';
88    TwissData.dP = 0;
89    TwissData.dL = 0;
90    TwissData.Dispersion  = [0 0 0 0]';
91
92    setpvmodel('TwissData', '', TwissData);  % Same as, THERING{1}.TwissData = TwissData;
93
94catch
95    warning('Setting the twiss data parameters in the MML failed.');
96end
Note: See TracBrowser for help on using the repository browser.