1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
---|
2 | "http://www.w3.org/TR/REC-html40/loose.dtd"> |
---|
3 | <html> |
---|
4 | <head> |
---|
5 | <title>Description of stepchro</title> |
---|
6 | <meta name="keywords" content="stepchro"> |
---|
7 | <meta name="description" content="STEPCHRO - Incremental change in the chromaticity (Delta Tune / Delta RF)"> |
---|
8 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
---|
9 | <meta name="generator" content="m2html © 2003 Guillaume Flandin"> |
---|
10 | <meta name="robots" content="index, follow"> |
---|
11 | <link type="text/css" rel="stylesheet" href="../m2html.css"> |
---|
12 | </head> |
---|
13 | <body> |
---|
14 | <a name="_top"></a> |
---|
15 | <div><a href="../index.html">Home</a> > <a href="index.html">mml</a> > stepchro.m</div> |
---|
16 | |
---|
17 | <!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td> |
---|
18 | <td align="right"><a href="index.html">Index for mml <img alt=">" border="0" src="../right.png"></a></td></tr></table>--> |
---|
19 | |
---|
20 | <h1>stepchro |
---|
21 | </h1> |
---|
22 | |
---|
23 | <h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2> |
---|
24 | <div class="box"><strong>STEPCHRO - Incremental change in the chromaticity (Delta Tune / Delta RF)</strong></div> |
---|
25 | |
---|
26 | <h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2> |
---|
27 | <div class="box"><strong>function [DelSext, ActuatorFamily] = stepchro(varargin) </strong></div> |
---|
28 | |
---|
29 | <h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2> |
---|
30 | <div class="fragment"><pre class="comment">STEPCHRO - Incremental change in the chromaticity (Delta Tune / Delta RF) |
---|
31 | [DelSext, SextFamily] = stepchro(DeltaChromaticity, ChroResponseMatrix) |
---|
32 | |
---|
33 | Step change in storage ring chromaticity using the default chromaticty correctors (findmemberof('Chromaticity Corrector')) |
---|
34 | |
---|
35 | INPUTS |
---|
36 | 1. | Change in Horizontal Chromaticity | |
---|
37 | DeltaChromaticity = | | |
---|
38 | | Change in Vertical Chromaticity | |
---|
39 | 2. ChroResponseMatrix - Chromaticity response matrix {Default: getchroresp} |
---|
40 | 3. ActuatorFamily - Sextupoles to vary, ex {'S9', 'S10'} {Default: findmemberof('Chromaticity Corrector')'} |
---|
41 | 4. Optional override of the units: |
---|
42 | 'Physics' - Use physics units |
---|
43 | 'Hardware' - Use hardware units |
---|
44 | 5. Optional override of the mode: |
---|
45 | 'Online' - Set/Get data online |
---|
46 | 'Model' - Set/Get data on the simulated accelerator using AT |
---|
47 | 'Simulator' - Set/Get data on the simulated accelerator using AT |
---|
48 | 'Manual' - Set/Get data manually |
---|
49 | |
---|
50 | |
---|
51 | OUTPUTS |
---|
52 | 1. DelSext |
---|
53 | 2. SextFamily - Families used (cell array) |
---|
54 | |
---|
55 | ALGORITHM |
---|
56 | SVD method |
---|
57 | DelSext = inv(CHROMATICITY_RESP_MATRIX) * DeltaChromaticity |
---|
58 | |
---|
59 | NOTES |
---|
60 | 1. Beware of what units you are working in. The default units for chromaticity |
---|
61 | are physics units. This is an exception to the normal middle layer convention. |
---|
62 | Hardware units for "chromaticity" is in tune change per change in RF frequency. |
---|
63 | Since this is an unusual unit to work with, the default units for chromaticity |
---|
64 | is physics units. Note that goal chromaticity is also stored in physics units. |
---|
65 | 2. The actuator family comes from findmemberof('Chromaticity Corrector') or 'SF','SD' if empty |
---|
66 | |
---|
67 | EXAMPLES |
---|
68 | 1. use default families |
---|
69 | stepchro([1 0.5]) |
---|
70 | 2. use 10 families |
---|
71 | Sfam = {'S1','S2','S3','S4','S5','S6','S7','S8','S9','S10'}; |
---|
72 | B = measchroresp('Model','Display',Sfam); |
---|
73 | stepchro([1 0.5],'Model',B,Sfam) |
---|
74 | |
---|
75 | See Also <a href="setchro.html" class="code" title="function [DelSext, ActuatorFamily] = setchro(varargin)">setchro</a></pre></div> |
---|
76 | |
---|
77 | <!-- crossreference --> |
---|
78 | <h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2> |
---|
79 | This function calls: |
---|
80 | <ul style="list-style-image:url(../matlabicon.gif)"> |
---|
81 | <li><a href="findmemberof.html" class="code" title="function FamilyName = findmemberof(MemberString, Field)">findmemberof</a> FINDMEMBEROF - Finds all family members</li><li><a href="getchroresp.html" class="code" title="function [ChromaticityMatrix, FileName] = getchroresp(varargin)">getchroresp</a> GETCHRORESP - Loads the chromaticity response vector (or matrix) for multiple sextupole families</li><li><a href="getsp.html" class="code" title="function [SP, tout, DataTime, ErrorFlag] = getsp(Family, varargin)">getsp</a> GETSP - Gets setpoint channels</li><li><a href="setsp.html" class="code" title="function ErrorFlag = setsp(Family, varargin)">setsp</a> SETSP - Makes an absolute setpoint change to the 'Setpoint' field</li></ul> |
---|
82 | This function is called by: |
---|
83 | <ul style="list-style-image:url(../matlabicon.gif)"> |
---|
84 | <li><a href="setchro.html" class="code" title="function [DelSext, ActuatorFamily] = setchro(varargin)">setchro</a> SETCHRO - Measures then sets the chromaticity</li></ul> |
---|
85 | <!-- crossreference --> |
---|
86 | |
---|
87 | |
---|
88 | <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2> |
---|
89 | <div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [DelSext, ActuatorFamily] = stepchro(varargin)</a> |
---|
90 | 0002 <span class="comment">%STEPCHRO - Incremental change in the chromaticity (Delta Tune / Delta RF)</span> |
---|
91 | 0003 <span class="comment">% [DelSext, SextFamily] = stepchro(DeltaChromaticity, ChroResponseMatrix)</span> |
---|
92 | 0004 <span class="comment">%</span> |
---|
93 | 0005 <span class="comment">% Step change in storage ring chromaticity using the default chromaticty correctors (findmemberof('Chromaticity Corrector'))</span> |
---|
94 | 0006 <span class="comment">%</span> |
---|
95 | 0007 <span class="comment">% INPUTS</span> |
---|
96 | 0008 <span class="comment">% 1. | Change in Horizontal Chromaticity |</span> |
---|
97 | 0009 <span class="comment">% DeltaChromaticity = | |</span> |
---|
98 | 0010 <span class="comment">% | Change in Vertical Chromaticity |</span> |
---|
99 | 0011 <span class="comment">% 2. ChroResponseMatrix - Chromaticity response matrix {Default: getchroresp}</span> |
---|
100 | 0012 <span class="comment">% 3. ActuatorFamily - Sextupoles to vary, ex {'S9', 'S10'} {Default: findmemberof('Chromaticity Corrector')'}</span> |
---|
101 | 0013 <span class="comment">% 4. Optional override of the units:</span> |
---|
102 | 0014 <span class="comment">% 'Physics' - Use physics units</span> |
---|
103 | 0015 <span class="comment">% 'Hardware' - Use hardware units</span> |
---|
104 | 0016 <span class="comment">% 5. Optional override of the mode:</span> |
---|
105 | 0017 <span class="comment">% 'Online' - Set/Get data online</span> |
---|
106 | 0018 <span class="comment">% 'Model' - Set/Get data on the simulated accelerator using AT</span> |
---|
107 | 0019 <span class="comment">% 'Simulator' - Set/Get data on the simulated accelerator using AT</span> |
---|
108 | 0020 <span class="comment">% 'Manual' - Set/Get data manually</span> |
---|
109 | 0021 <span class="comment">%</span> |
---|
110 | 0022 <span class="comment">%</span> |
---|
111 | 0023 <span class="comment">% OUTPUTS</span> |
---|
112 | 0024 <span class="comment">% 1. DelSext</span> |
---|
113 | 0025 <span class="comment">% 2. SextFamily - Families used (cell array)</span> |
---|
114 | 0026 <span class="comment">%</span> |
---|
115 | 0027 <span class="comment">% ALGORITHM</span> |
---|
116 | 0028 <span class="comment">% SVD method</span> |
---|
117 | 0029 <span class="comment">% DelSext = inv(CHROMATICITY_RESP_MATRIX) * DeltaChromaticity</span> |
---|
118 | 0030 <span class="comment">%</span> |
---|
119 | 0031 <span class="comment">% NOTES</span> |
---|
120 | 0032 <span class="comment">% 1. Beware of what units you are working in. The default units for chromaticity</span> |
---|
121 | 0033 <span class="comment">% are physics units. This is an exception to the normal middle layer convention.</span> |
---|
122 | 0034 <span class="comment">% Hardware units for "chromaticity" is in tune change per change in RF frequency.</span> |
---|
123 | 0035 <span class="comment">% Since this is an unusual unit to work with, the default units for chromaticity</span> |
---|
124 | 0036 <span class="comment">% is physics units. Note that goal chromaticity is also stored in physics units.</span> |
---|
125 | 0037 <span class="comment">% 2. The actuator family comes from findmemberof('Chromaticity Corrector') or 'SF','SD' if empty</span> |
---|
126 | 0038 <span class="comment">%</span> |
---|
127 | 0039 <span class="comment">% EXAMPLES</span> |
---|
128 | 0040 <span class="comment">% 1. use default families</span> |
---|
129 | 0041 <span class="comment">% stepchro([1 0.5])</span> |
---|
130 | 0042 <span class="comment">% 2. use 10 families</span> |
---|
131 | 0043 <span class="comment">% Sfam = {'S1','S2','S3','S4','S5','S6','S7','S8','S9','S10'};</span> |
---|
132 | 0044 <span class="comment">% B = measchroresp('Model','Display',Sfam);</span> |
---|
133 | 0045 <span class="comment">% stepchro([1 0.5],'Model',B,Sfam)</span> |
---|
134 | 0046 <span class="comment">%</span> |
---|
135 | 0047 <span class="comment">% See Also setchro</span> |
---|
136 | 0048 |
---|
137 | 0049 <span class="comment">%</span> |
---|
138 | 0050 <span class="comment">% Written by Gregory J. Portmann</span> |
---|
139 | 0051 <span class="comment">% Modifed by Laurent S. Nadolski</span> |
---|
140 | 0052 <span class="comment">% add ActuatorFamily as optional input</span> |
---|
141 | 0053 |
---|
142 | 0054 ModeFlag = {}; |
---|
143 | 0055 UnitsFlag = {<span class="string">'Physics'</span>}; |
---|
144 | 0056 |
---|
145 | 0057 <span class="keyword">for</span> i = length(varargin):-1:1 |
---|
146 | 0058 <span class="keyword">if</span> strcmpi(varargin{i},<span class="string">'Physics'</span>) |
---|
147 | 0059 UnitsFlag = varargin(i); |
---|
148 | 0060 varargin(i) = []; |
---|
149 | 0061 <span class="keyword">elseif</span> strcmpi(varargin{i},<span class="string">'Hardware'</span>) |
---|
150 | 0062 UnitsFlag = varargin(i); |
---|
151 | 0063 varargin(i) = []; |
---|
152 | 0064 <span class="keyword">elseif</span> strcmpi(varargin{i},<span class="string">'Simulator'</span>) | strcmpi(varargin{i},<span class="string">'Model'</span>) |
---|
153 | 0065 ModeFlag = varargin(i); |
---|
154 | 0066 varargin(i) = []; |
---|
155 | 0067 <span class="keyword">elseif</span> strcmpi(varargin{i},<span class="string">'Online'</span>) |
---|
156 | 0068 ModeFlag = varargin(i); |
---|
157 | 0069 varargin(i) = []; |
---|
158 | 0070 <span class="keyword">elseif</span> strcmpi(varargin{i},<span class="string">'Manual'</span>) |
---|
159 | 0071 ModeFlag = varargin(i); |
---|
160 | 0072 varargin(i) = []; |
---|
161 | 0073 <span class="keyword">end</span> |
---|
162 | 0074 <span class="keyword">end</span> |
---|
163 | 0075 |
---|
164 | 0076 |
---|
165 | 0077 <span class="keyword">if</span> length(varargin) >= 1 |
---|
166 | 0078 DeltaChrom = varargin{1}; |
---|
167 | 0079 <span class="keyword">else</span> |
---|
168 | 0080 DeltaChrom = []; |
---|
169 | 0081 <span class="keyword">end</span> |
---|
170 | 0082 <span class="keyword">if</span> isempty(DeltaChrom) |
---|
171 | 0083 answer = inputdlg({<span class="string">'Change the horizontal chromaticity by'</span>, <span class="string">'Change the vertical chromaticity by'</span>},<span class="string">'STEPCHRO'</span>,1,{<span class="string">'0'</span>,<span class="string">'0'</span>}); |
---|
172 | 0084 <span class="keyword">if</span> isempty(answer) |
---|
173 | 0085 <span class="keyword">return</span> |
---|
174 | 0086 <span class="keyword">end</span> |
---|
175 | 0087 DeltaChrom(1,1) = str2num(answer{1}); |
---|
176 | 0088 DeltaChrom(2,1) = str2num(answer{2}); |
---|
177 | 0089 <span class="keyword">end</span> |
---|
178 | 0090 DeltaChrom = DeltaChrom(:); |
---|
179 | 0091 <span class="keyword">if</span> size(DeltaChrom,1) ~= 2 |
---|
180 | 0092 error(<span class="string">'Input must be a 2x1 column vector.'</span>); |
---|
181 | 0093 <span class="keyword">end</span> |
---|
182 | 0094 <span class="keyword">if</span> DeltaChrom(1)==0 && DeltaChrom(2)==0 |
---|
183 | 0095 <span class="keyword">return</span> |
---|
184 | 0096 <span class="keyword">end</span> |
---|
185 | 0097 |
---|
186 | 0098 <span class="keyword">if</span> length(varargin) >= 2 |
---|
187 | 0099 ChroResponseMatrix = varargin{2}; |
---|
188 | 0100 <span class="keyword">else</span> |
---|
189 | 0101 ChroResponseMatrix = []; |
---|
190 | 0102 <span class="keyword">end</span> |
---|
191 | 0103 <span class="keyword">if</span> isempty(ChroResponseMatrix) |
---|
192 | 0104 ChroResponseMatrix = <a href="getchroresp.html" class="code" title="function [ChromaticityMatrix, FileName] = getchroresp(varargin)">getchroresp</a>(UnitsFlag{:}); |
---|
193 | 0105 <span class="keyword">end</span> |
---|
194 | 0106 <span class="keyword">if</span> isempty(ChroResponseMatrix) |
---|
195 | 0107 error(<span class="string">'The chromaticity response matrix must be an input or available in one of the default response matrix files.'</span>); |
---|
196 | 0108 <span class="keyword">end</span> |
---|
197 | 0109 |
---|
198 | 0110 <span class="keyword">if</span> length(varargin) >= 3 |
---|
199 | 0111 ActuatorFamily = varargin{3}; |
---|
200 | 0112 <span class="keyword">else</span> |
---|
201 | 0113 ActuatorFamily = <a href="findmemberof.html" class="code" title="function FamilyName = findmemberof(MemberString, Field)">findmemberof</a>(<span class="string">'Chromaticity Corrector'</span>)'; |
---|
202 | 0114 <span class="keyword">if</span> isempty(ActuatorFamily) |
---|
203 | 0115 ActuatorFamily = {<span class="string">'S9'</span>,<span class="string">'S10'</span>}; |
---|
204 | 0116 <span class="keyword">end</span> |
---|
205 | 0117 <span class="keyword">end</span> |
---|
206 | 0118 |
---|
207 | 0119 <span class="comment">% 1. SVD Tune Correction</span> |
---|
208 | 0120 <span class="comment">% Decompose the chromaticity response matrix:</span> |
---|
209 | 0121 [U, S, V] = svd(ChroResponseMatrix, <span class="string">'econ'</span>); |
---|
210 | 0122 <span class="comment">% ChroResponseMatrix = U*S*V'</span> |
---|
211 | 0123 <span class="comment">%</span> |
---|
212 | 0124 <span class="comment">% The V matrix columns are the singular vectors in the sextupole magnet space</span> |
---|
213 | 0125 <span class="comment">% The U matrix columns are the singular vectors in the chromaticity space</span> |
---|
214 | 0126 <span class="comment">% U'*U=I and V*V'=I</span> |
---|
215 | 0127 <span class="comment">%</span> |
---|
216 | 0128 <span class="comment">% CHROCoef is the projection onto the columns of ChroResponseMatrix*V(:,Ivec) (same space as spanned by U)</span> |
---|
217 | 0129 <span class="comment">% Sometimes it's interesting to look at the size of these coefficients with singular value number.</span> |
---|
218 | 0130 CHROCoef = diag(diag(S).^(-1)) * U' * DeltaChrom; |
---|
219 | 0131 <span class="comment">%</span> |
---|
220 | 0132 <span class="comment">% Convert the vector CHROCoef back to coefficents of ChroResponseMatrix</span> |
---|
221 | 0133 DelSext = V * CHROCoef; |
---|
222 | 0134 |
---|
223 | 0135 |
---|
224 | 0136 <span class="comment">% 2. Square matrix solution</span> |
---|
225 | 0137 <span class="comment">%DelSext = inv(ChroResponseMatrix) * DeltaChrom;</span> |
---|
226 | 0138 |
---|
227 | 0139 |
---|
228 | 0140 SP = <a href="getsp.html" class="code" title="function [SP, tout, DataTime, ErrorFlag] = getsp(Family, varargin)">getsp</a>(ActuatorFamily, UnitsFlag{:}, ModeFlag{:}); |
---|
229 | 0141 |
---|
230 | 0142 <span class="keyword">if</span> iscell(SP) |
---|
231 | 0143 <span class="keyword">for</span> i = 1:length(SP) |
---|
232 | 0144 SP{i} = SP{i} + DelSext(i); |
---|
233 | 0145 <span class="keyword">end</span> |
---|
234 | 0146 <span class="keyword">else</span> |
---|
235 | 0147 SP = SP + DelSext; |
---|
236 | 0148 <span class="keyword">end</span> |
---|
237 | 0149 |
---|
238 | 0150 |
---|
239 | 0151 <a href="setsp.html" class="code" title="function ErrorFlag = setsp(Family, varargin)">setsp</a>(ActuatorFamily, SP, UnitsFlag{:}, ModeFlag{:}); |
---|
240 | 0152</pre></div> |
---|
241 | <hr><address>Generated on Mon 21-May-2007 15:29:18 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address> |
---|
242 | </body> |
---|
243 | </html> |
---|