source: MML/trunk/machine/SOLEIL/LT1/updateatindex.m @ 17

Last change on this file since 17 was 17, checked in by zhangj, 10 years ago

To have a stable version on the server.

  • Property svn:executable set to *
File size: 2.3 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% CORRECTORS
22try
23    %% HORIZONTAL CORRECTORS
24    ifam = ('CH');
25    AO.(ifam).AT.ATType  = ifam;
26    AO.(ifam).AT.ATIndex = Indices.(ifam)(:);
27    AO.(ifam).AT.ATIndex = AO.(ifam).AT.ATIndex(AO.(ifam).ElementList);   %not all correctors used
28    AO.(ifam).Position   = findspos(THERING, AO.(ifam).AT.ATIndex(:,1))';
29
30    %% VERTICAL CORRECTORS
31    ifam = ('CV');
32    AO.(ifam).AT.ATType  = ifam;
33    AO.(ifam).AT.ATIndex = Indices.(ifam)(:);
34    AO.(ifam).AT.ATIndex = AO.(ifam).AT.ATIndex(AO.(ifam).ElementList);   %not all correctors used
35    AO.(ifam).Position   = findspos(THERING, AO.(ifam).AT.ATIndex(:,1))';
36catch
37    warning('Corrector family not found in the model.');
38end
39
40
41% QUADRUPOLES
42try
43    ifam = 'QP';
44    AO.(ifam).AT.ATType  = 'QUAD';
45    AO.(ifam).AT.ATIndex = eval(['Indices.' ifam '(:)']);
46    AO.(ifam).AT.ATIndex = reshape(AO.(ifam).AT.ATIndex,2,7)';
47    AO.(ifam).Position   = findspos(THERING, AO.(ifam).AT.ATIndex(:,1))';
48catch
49    warning('%s family not found in the model.',ifam);
50end
51
52% BEND
53
54try
55    ifam = ('BEND');
56    AO.(ifam).AT.ATType  = ifam;
57    ATIndex = Indices.(ifam)(:);
58    AO.(ifam).AT.ATIndex = buildatindex(AO.(ifam).FamilyName, sort(ATIndex));
59    AO.(ifam).Position   = findspos(THERING, AO.(ifam).AT.ATIndex(:,1))';
60catch
61    warning('BEND family not found in the model.');
62end
63
64setao(AO);
65
66% Set TwissData at the start of TL1
67try
68    % BTS twiss parameters at the input
69    TwissData.alpha = [0 0]';
70    TwissData.beta  = [8.1 8.1]';
71    TwissData.mu    = [0 0]';
72    TwissData.ClosedOrbit = [0 0 0 0]';
73    TwissData.dP = 0;
74    TwissData.dL = 0;
75    TwissData.Dispersion  = [0 0 0 0]';
76
77    setpvmodel('TwissData', '', TwissData);  % Same as, THERING{1}.TwissData = TwissData;
78
79catch
80    warning('Setting the twiss data parameters in the MML failed.');
81end
Note: See TracBrowser for help on using the repository browser.