1 | function setoperationalmode(ModeNumber) |
---|
2 | %SETOPERATIONALMODE - Switches between the various operational modes |
---|
3 | % setoperationalmode(ModeNumber) |
---|
4 | % |
---|
5 | % INPUTS |
---|
6 | % 1. ModeNumber = 1. 2.7391 GeV, multibunch |
---|
7 | % |
---|
8 | % 100. Laurent's Mode |
---|
9 | % |
---|
10 | % See also aoinit, updateatindex, LT1init |
---|
11 | |
---|
12 | % |
---|
13 | % Written by Laurent S. Nadolski |
---|
14 | |
---|
15 | global THERING |
---|
16 | |
---|
17 | % Check if the AO exists |
---|
18 | checkforao; |
---|
19 | |
---|
20 | |
---|
21 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
22 | % Accelerator Dependent Modes % |
---|
23 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
24 | if nargin < 1 |
---|
25 | ModeNumber = []; |
---|
26 | end |
---|
27 | if isempty(ModeNumber) |
---|
28 | ModeCell = {'2.7391 GeV, multibunch', ... |
---|
29 | 'Laurent''s Mode'}; |
---|
30 | [ModeNumber, OKFlag] = listdlg('Name','SOLEIL','PromptString','Select the Operational Mode:', 'SelectionMode','single', 'ListString', ModeCell, 'ListSize', [450 200]); |
---|
31 | if OKFlag ~= 1 |
---|
32 | fprintf(' Operational mode not changed\n'); |
---|
33 | return |
---|
34 | elseif ModeNumber == 2 |
---|
35 | ModeNumber = 100; % Laurent |
---|
36 | end |
---|
37 | end |
---|
38 | |
---|
39 | |
---|
40 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
41 | % Accelerator Data Structure % |
---|
42 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
43 | AD = getad; |
---|
44 | AD.Machine = 'SOLEIL'; % Will already be defined if setpathmml was used |
---|
45 | AD.MachineType = 'StorageRing'; % Will already be defined if setpathmml was used |
---|
46 | AD.SubMachine = 'Booster'; % Will already be defined if setpathmml was used |
---|
47 | AD.OperationalMode = ''; % Gets filled in later |
---|
48 | |
---|
49 | |
---|
50 | % Tune processor delay: delay required to wait |
---|
51 | % to have a fresh tune measurement after changing |
---|
52 | % a variable like the RF frequency. Setpv will wait |
---|
53 | % 2.2 * TuneDelay to be guaranteed a fresh data point. |
---|
54 | AD.BPMDelay = 0.25; % use [N, BPMDelay]=getbpmsaverages (AD.BPMDelay will disappear) |
---|
55 | AD.TuneDelay = 0.1; |
---|
56 | |
---|
57 | |
---|
58 | % SP-AM Error level |
---|
59 | % AD.ErrorWarningLevel = 0 -> SP-AM errors are Matlab errors {Default} |
---|
60 | % -1 -> SP-AM errors are Matlab warnings |
---|
61 | % -2 -> SP-AM errors prompt a dialog box |
---|
62 | % -3 -> SP-AM errors are ignored (ErrorFlag=-1 is returned) |
---|
63 | AD.ErrorWarningLevel = 0; |
---|
64 | |
---|
65 | %%%%%%%%%%%%%%%%%%%%% |
---|
66 | % Operational Modes % |
---|
67 | %%%%%%%%%%%%%%%%%%%%% |
---|
68 | |
---|
69 | % Mode setup variables (mostly path and file names) |
---|
70 | % AD.OperationalMode - String used in titles |
---|
71 | % ModeName - String used for mode directory name off DataRoot/MachineName |
---|
72 | % OpsFileExtension - string add to default file names |
---|
73 | |
---|
74 | if ModeNumber == 1 |
---|
75 | % Booster Nominal Lattice |
---|
76 | AD.OperationalMode = '2.7391 GeV, multibunch'; |
---|
77 | AD.Energy = 2.7391; % Make sure this is the same as bend2gev at the production lattice! |
---|
78 | ModeName = 'boosterreal'; |
---|
79 | OpsFileExtension = '_boosterreal'; |
---|
80 | |
---|
81 | % AT lattice |
---|
82 | %AD.ATModel = 'boostersteerer'; % lattice file |
---|
83 | AD.ATModel = 'boosterreal'; |
---|
84 | eval(AD.ATModel); %run model for compilersolamor2linb; |
---|
85 | |
---|
86 | switch2hw; |
---|
87 | |
---|
88 | elseif ModeNumber == 100 |
---|
89 | % User mode - High Tune, Top Off injection |
---|
90 | error('To be completed'); |
---|
91 | |
---|
92 | else |
---|
93 | error('Operational mode unknown'); |
---|
94 | end |
---|
95 | |
---|
96 | |
---|
97 | |
---|
98 | % Set the AD directory path |
---|
99 | setad(AD); |
---|
100 | MMLROOT = setmmldirectories(AD.Machine, AD.SubMachine, ModeName, OpsFileExtension); |
---|
101 | MMLDATAROOT = getmmldataroot; |
---|
102 | AD = getad; |
---|
103 | |
---|
104 | % SOLEIL specific path changes |
---|
105 | |
---|
106 | % Top Level Directories |
---|
107 | |
---|
108 | AD.Directory.DataRoot = fullfile(MMLDATAROOT, 'measdata', 'SOLEIL', 'Boosterdata', filesep); |
---|
109 | AD.Directory.OpsData = fullfile(MMLROOT, 'machine', 'SOLEIL', 'BoosterOpsData', filesep); |
---|
110 | AD.Directory.Lattice = fullfile(MMLROOT, 'machine', 'SOLEIL', 'Booster', 'Lattices', filesep); |
---|
111 | AD.Directory.Orbit = fullfile(MMLROOT, 'applications', 'orbit', filesep); |
---|
112 | |
---|
113 | % Data Archive Directories |
---|
114 | AD.Directory.BPMData = fullfile(AD.Directory.DataRoot, 'BPM', filesep); |
---|
115 | AD.Directory.TuneData = fullfile(AD.Directory.DataRoot, 'Tune', filesep); |
---|
116 | AD.Directory.ChroData = fullfile(AD.Directory.DataRoot, 'Chromaticity', filesep); |
---|
117 | AD.Directory.DispData = fullfile(AD.Directory.DataRoot, 'Dispersion', filesep); |
---|
118 | AD.Directory.ConfigData = fullfile(MMLROOT, 'machine', 'SOLEIL', 'Booster', 'MachineConfig', filesep); |
---|
119 | AD.Directory.BumpData = fullfile(AD.Directory.DataRoot, 'Bumps', filesep); |
---|
120 | AD.Directory.Archiving = fullfile(AD.Directory.DataRoot, 'ArchivingData', filesep); |
---|
121 | AD.Directory.TurnByTurnTune = fullfile(AD.Directory.DataRoot, 'BPM', 'turnbyturntune'); |
---|
122 | AD.Directory.Synchro = fullfile(MMLROOT, 'machine', 'SOLEIL', 'common', 'synchro', filesep); |
---|
123 | |
---|
124 | % STANDALONE matlab applications |
---|
125 | AD.Directory.Standalone = fullfile(MMLROOT, 'machine', 'SOLEIL', 'standalone_applications', filesep); |
---|
126 | |
---|
127 | % quick fix (dixit Alex) |
---|
128 | AD.Directory.Timing = fullfile(MMLROOT, 'machine', 'SOLEIL', 'LT1', 'LT1data', 'Timing', filesep); |
---|
129 | |
---|
130 | %Response Matrix Directories |
---|
131 | AD.Directory.BPMResponse = fullfile(AD.Directory.DataRoot, 'Response', 'BPM', filesep); |
---|
132 | AD.Directory.TuneResponse = fullfile(AD.Directory.DataRoot, 'Response', 'Tune', filesep); |
---|
133 | AD.Directory.ChroResponse = fullfile(AD.Directory.DataRoot, 'Response', 'Chrom', filesep); |
---|
134 | AD.Directory.DispResponse = fullfile(AD.Directory.DataRoot, 'Response', 'Disp', filesep); |
---|
135 | |
---|
136 | %Default Data File Prefix |
---|
137 | AD.Default.BPMArchiveFile = 'BPM'; %file in AD.Directory.BPM orbit data |
---|
138 | AD.Default.TuneArchiveFile = 'Tune'; %file in AD.Directory.Tune tune data |
---|
139 | AD.Default.ChroArchiveFile = 'Chro'; %file in AD.Directory.Chromaticity chromaticity data |
---|
140 | AD.Default.DispArchiveFile = 'Disp'; %file in AD.Directory.Dispersion dispersion data |
---|
141 | AD.Default.CNFArchiveFile = 'CNF'; %file in AD.Directory.CNF configuration data |
---|
142 | AD.Default.QUADArchiveFile = 'QuadBeta'; %file in AD.Directory.QUAD betafunction for quadrupoles |
---|
143 | |
---|
144 | %Default Response Matrix File Prefix |
---|
145 | AD.Default.BPMRespFile = 'BPMRespMat'; %file in AD.Directory.BPMResponse BPM response matrices |
---|
146 | AD.Default.TuneRespFile = 'TuneRespMat'; %file in AD.Directory.TuneResponse tune response matrices |
---|
147 | AD.Default.ChroRespFile = 'ChroRespMat'; %file in AD.Directory.ChroResponse chromaticity response matrices |
---|
148 | AD.Default.DispRespFile = 'DispRespMat'; %file in AD.Directory.DispResponse dispersion response matrices |
---|
149 | |
---|
150 | %Operational Files |
---|
151 | AD.OpsData.LatticeFile = 'GoldenLattice'; %Golden Lattice File (setup for users) |
---|
152 | AD.OpsData.PhysDataFile = 'GoldenPhysData'; |
---|
153 | %AD.OpsData.BPMGoldenFile = 'GoldenBPMOrbit'; |
---|
154 | %AD.OpsData.BPMOffsetFile = 'OffsetBPMOrbit'; |
---|
155 | AD.OpsData.BPMSigmaFile = 'BPMSigma'; |
---|
156 | %AD.OpsData.TuneFile = 'GoldenTune'; |
---|
157 | %AD.OpsData.ChroFile = 'GoldenChro'; |
---|
158 | %AD.OpsData.DispFile = 'GoldenDisp'; |
---|
159 | |
---|
160 | %Operational Response Files |
---|
161 | AD.OpsData.BPMRespFile = 'GoldenBPMResp'; |
---|
162 | AD.OpsData.TuneRespFile = 'GoldenTuneResp'; |
---|
163 | AD.OpsData.ChroRespFile = 'GoldenChroResp'; |
---|
164 | AD.OpsData.DispRespFile = 'GoldenDispResp'; |
---|
165 | AD.OpsData.RespFiles = {AD.OpsData.BPMRespFile, ... |
---|
166 | AD.OpsData.TuneRespFile, ... |
---|
167 | AD.OpsData.ChroRespFile, ... |
---|
168 | AD.OpsData.DispRespFile}; |
---|
169 | |
---|
170 | % Circumference |
---|
171 | AD.Circumference = findspos(THERING,length(THERING)+1); |
---|
172 | setad(AD); |
---|
173 | |
---|
174 | % Updates the AT indices in the MiddleLayer with the present AT lattice |
---|
175 | updateatindex; |
---|
176 | |
---|
177 | % Set the model energy |
---|
178 | setenergymodel(AD.Energy); |
---|
179 | |
---|
180 | |
---|
181 | % Momentum compaction factor |
---|
182 | MCF = getmcf('Model'); |
---|
183 | if isnan(MCF) |
---|
184 | AD.MCF = 0.0150; |
---|
185 | fprintf(' Model alpha calculation failed, middlelayer alpha set to %f\n', AD.MCF); |
---|
186 | else |
---|
187 | AD.MCF = MCF; |
---|
188 | fprintf(' Middlelayer alpha set to %f (AT model).\n', AD.MCF); |
---|
189 | end |
---|
190 | setad(AD); |
---|
191 | |
---|
192 | |
---|
193 | fprintf(' lattice files have changed or if the AT lattice has changed.\n'); |
---|
194 | fprintf(' Middlelayer setup for operational mode: %s\n', AD.OperationalMode); |
---|
195 | |
---|
196 | setad(orderfields(AD)); |
---|