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 findrespm</title> |
---|
6 | <meta name="keywords" content="findrespm"> |
---|
7 | <meta name="description" content="FINDRESPM computes the change in the closed orbit due to parameter perturbations"> |
---|
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">at</a> > <a href="index.html">atphysics</a> > findrespm.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 at/atphysics <img alt=">" border="0" src="../../right.png"></a></td></tr></table>--> |
---|
19 | |
---|
20 | <h1>findrespm |
---|
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>FINDRESPM computes the change in the closed orbit due to parameter perturbations</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 C = findrespm(RING, OBSINDEX, PERTURB, PVALUE, 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">FINDRESPM computes the change in the closed orbit due to parameter perturbations |
---|
31 | Two calling syntax options |
---|
32 | 1. FINDRESPM(RING, OBSINDEX, PERTURBINDEX, PVALUE, 'FIELD', M, N, ORBITFUNCTION, ARGS) |
---|
33 | 2. !!! not implemented yet FINDRESPM(RING, OBSINDEX, PERTURBGROUP, PVALUE, ORBITFUNCTION, ARGS) |
---|
34 | |
---|
35 | RING - ring lattice |
---|
36 | OBSINDEX - indexes of elements where the orbit is observed (at the entrance) |
---|
37 | PERTURBINDEX - Integer indexes of elements whose parameters are perturbed |
---|
38 | used with syntax 1 only. |
---|
39 | |
---|
40 | PERTURBGROUP - cell array of AT paramgroups. See ATPARAMGROUP |
---|
41 | used with syntax 2 only |
---|
42 | |
---|
43 | PVALUE - amount of peturbation |
---|
44 | (Numeric array or scalar if all perturbations are the same magnitude) |
---|
45 | |
---|
46 | FIELD,M,N are only use with syntax 1. |
---|
47 | |
---|
48 | FIELD - field name of the parameter to perturb (string) |
---|
49 | |
---|
50 | M,N - index in the matrix, if the field is a matrix |
---|
51 | For example to perturb the quadrupole field in a |
---|
52 | multipole element |
---|
53 | FIELD = 'PolynomB', M = 1, N = 2 |
---|
54 | |
---|
55 | ORBITFUNCTION - specifies which of the FINDORBIT functions is used |
---|
56 | |
---|
57 | 'findorbit4' (default) |
---|
58 | 'findsyncorbit' |
---|
59 | 'findorbit6' |
---|
60 | |
---|
61 | ARGS - additioanl arguments may passsed to some of the FINDORBIT functions |
---|
62 | findorbit4 - constant momentum error dP |
---|
63 | findsyncorbit - fixed orbit lengthening dCT |
---|
64 | |
---|
65 | |
---|
66 | Returns a 1-by-4 cell array of O-by-P matrixes |
---|
67 | where O = length(OBSINDEX) and P = length(PERTURB) |
---|
68 | one for each of the close orbit components: X, PX, Y, PY |
---|
69 | See also ATPARAMGROUP, <a href="findorbit.html" class="code" title="function [orbit, varargout] = findorbit(RING,D, varargin);">FINDORBIT</a>, <a href="findorbit4.html" class="code" title="function orbit = findorbit4(RING,dP,varargin);">FINDORBIT4</a>, <a href="findorbit6.html" class="code" title="function orbit = findorbit6(RING,varargin);">FINDORBIT6</a>, <a href="findsyncorbit.html" class="code" title="function [orbit, varargout] = findsyncorbit(RING,dCT,varargin);">FINDSYNCORBIT</a></pre></div> |
---|
70 | |
---|
71 | <!-- crossreference --> |
---|
72 | <h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2> |
---|
73 | This function calls: |
---|
74 | <ul style="list-style-image:url(../../matlabicon.gif)"> |
---|
75 | <li><a href="findorbit4.html" class="code" title="function orbit = findorbit4(RING,dP,varargin);">findorbit4</a> FINDORBIT4 finds closed orbit in the 4-d transverse phase</li><li><a href="findorbit6.html" class="code" title="function orbit = findorbit6(RING,varargin);">findorbit6</a> FINDORBIT6 finds closed orbit in the full 6-d phase space</li><li><a href="findsyncorbit.html" class="code" title="function [orbit, varargout] = findsyncorbit(RING,dCT,varargin);">findsyncorbit</a> FINDSYNCORBIT finds closed orbit, synchronous with the RF cavity</li></ul> |
---|
76 | This function is called by: |
---|
77 | <ul style="list-style-image:url(../../matlabicon.gif)"> |
---|
78 | </ul> |
---|
79 | <!-- crossreference --> |
---|
80 | |
---|
81 | |
---|
82 | <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2> |
---|
83 | <div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function C = findrespm(RING, OBSINDEX, PERTURB, PVALUE, varargin)</a> |
---|
84 | 0002 <span class="comment">%FINDRESPM computes the change in the closed orbit due to parameter perturbations</span> |
---|
85 | 0003 <span class="comment">% Two calling syntax options</span> |
---|
86 | 0004 <span class="comment">% 1. FINDRESPM(RING, OBSINDEX, PERTURBINDEX, PVALUE, 'FIELD', M, N, ORBITFUNCTION, ARGS)</span> |
---|
87 | 0005 <span class="comment">% 2. !!! not implemented yet FINDRESPM(RING, OBSINDEX, PERTURBGROUP, PVALUE, ORBITFUNCTION, ARGS)</span> |
---|
88 | 0006 <span class="comment">%</span> |
---|
89 | 0007 <span class="comment">% RING - ring lattice</span> |
---|
90 | 0008 <span class="comment">% OBSINDEX - indexes of elements where the orbit is observed (at the entrance)</span> |
---|
91 | 0009 <span class="comment">% PERTURBINDEX - Integer indexes of elements whose parameters are perturbed</span> |
---|
92 | 0010 <span class="comment">% used with syntax 1 only.</span> |
---|
93 | 0011 <span class="comment">%</span> |
---|
94 | 0012 <span class="comment">% PERTURBGROUP - cell array of AT paramgroups. See ATPARAMGROUP</span> |
---|
95 | 0013 <span class="comment">% used with syntax 2 only</span> |
---|
96 | 0014 <span class="comment">%</span> |
---|
97 | 0015 <span class="comment">% PVALUE - amount of peturbation</span> |
---|
98 | 0016 <span class="comment">% (Numeric array or scalar if all perturbations are the same magnitude)</span> |
---|
99 | 0017 <span class="comment">%</span> |
---|
100 | 0018 <span class="comment">% FIELD,M,N are only use with syntax 1.</span> |
---|
101 | 0019 <span class="comment">%</span> |
---|
102 | 0020 <span class="comment">% FIELD - field name of the parameter to perturb (string)</span> |
---|
103 | 0021 <span class="comment">%</span> |
---|
104 | 0022 <span class="comment">% M,N - index in the matrix, if the field is a matrix</span> |
---|
105 | 0023 <span class="comment">% For example to perturb the quadrupole field in a</span> |
---|
106 | 0024 <span class="comment">% multipole element</span> |
---|
107 | 0025 <span class="comment">% FIELD = 'PolynomB', M = 1, N = 2</span> |
---|
108 | 0026 <span class="comment">%</span> |
---|
109 | 0027 <span class="comment">% ORBITFUNCTION - specifies which of the FINDORBIT functions is used</span> |
---|
110 | 0028 <span class="comment">%</span> |
---|
111 | 0029 <span class="comment">% 'findorbit4' (default)</span> |
---|
112 | 0030 <span class="comment">% 'findsyncorbit'</span> |
---|
113 | 0031 <span class="comment">% 'findorbit6'</span> |
---|
114 | 0032 <span class="comment">%</span> |
---|
115 | 0033 <span class="comment">% ARGS - additioanl arguments may passsed to some of the FINDORBIT functions</span> |
---|
116 | 0034 <span class="comment">% findorbit4 - constant momentum error dP</span> |
---|
117 | 0035 <span class="comment">% findsyncorbit - fixed orbit lengthening dCT</span> |
---|
118 | 0036 <span class="comment">%</span> |
---|
119 | 0037 <span class="comment">%</span> |
---|
120 | 0038 <span class="comment">% Returns a 1-by-4 cell array of O-by-P matrixes</span> |
---|
121 | 0039 <span class="comment">% where O = length(OBSINDEX) and P = length(PERTURB)</span> |
---|
122 | 0040 <span class="comment">% one for each of the close orbit components: X, PX, Y, PY</span> |
---|
123 | 0041 <span class="comment">% See also ATPARAMGROUP, FINDORBIT, FINDORBIT4, FINDORBIT6, FINDSYNCORBIT</span> |
---|
124 | 0042 |
---|
125 | 0043 |
---|
126 | 0044 O = length(OBSINDEX); |
---|
127 | 0045 P = length(PERTURB); |
---|
128 | 0046 C = {zeros(O,P),zeros(O,P),zeros(O,P),zeros(O,P)}; |
---|
129 | 0047 |
---|
130 | 0048 <span class="keyword">if</span> length(PVALUE) ~= P |
---|
131 | 0049 PVALUE = PVALUE(ones(1,P(1))); |
---|
132 | 0050 <span class="keyword">end</span> |
---|
133 | 0051 |
---|
134 | 0052 |
---|
135 | 0053 <span class="keyword">if</span> isnumeric(PERTURB) <span class="comment">% syntax option 1</span> |
---|
136 | 0054 <span class="comment">% Integer indexes of perturbed elements.</span> |
---|
137 | 0055 <span class="comment">% More fields must be supplied.</span> |
---|
138 | 0056 <span class="comment">% setfield will be used to make perturbations</span> |
---|
139 | 0057 <span class="keyword">if</span> nargin < 7 |
---|
140 | 0058 error(<span class="string">'Incorrect number of inputs'</span>); |
---|
141 | 0059 <span class="keyword">end</span> |
---|
142 | 0060 |
---|
143 | 0061 <span class="keyword">if</span> ~ischar(varargin{1}) <span class="comment">% Check that the FIELD argument is a string</span> |
---|
144 | 0062 error(<span class="string">'The 5-th argument FIELD must be a string'</span>); |
---|
145 | 0063 <span class="keyword">end</span> |
---|
146 | 0064 |
---|
147 | 0065 <span class="keyword">if</span> ~isnumeric(varargin{2}) | length(varargin{2})>1 <span class="comment">% Check that the M argument is a scalar</span> |
---|
148 | 0066 error(<span class="string">'The 6-th argument FIELD must be a scalar'</span>); |
---|
149 | 0067 <span class="keyword">end</span> |
---|
150 | 0068 M = varargin{2}(1); |
---|
151 | 0069 |
---|
152 | 0070 <span class="keyword">if</span> ~isnumeric(varargin{3}) | length(varargin{3})>1 <span class="comment">% Check that the M argument is a scalar</span> |
---|
153 | 0071 error(<span class="string">'The 7-th argument FIELD must be a scalar'</span>); |
---|
154 | 0072 <span class="keyword">end</span> |
---|
155 | 0073 N = varargin{3}(1); |
---|
156 | 0074 |
---|
157 | 0075 <span class="keyword">if</span> nargin > 7 |
---|
158 | 0076 ORBITFUNCTION = varargin{4}; |
---|
159 | 0077 <span class="keyword">else</span> |
---|
160 | 0078 ORBITFUNCTION = <span class="string">'findorbit4'</span>; |
---|
161 | 0079 <span class="keyword">end</span> |
---|
162 | 0080 |
---|
163 | 0081 |
---|
164 | 0082 <span class="keyword">switch</span> ORBITFUNCTION |
---|
165 | 0083 <span class="keyword">case</span> <span class="string">'findorbit4'</span> |
---|
166 | 0084 orbit_function_handle = @<a href="findorbit4.html" class="code" title="function orbit = findorbit4(RING,dP,varargin);">findorbit4</a>; |
---|
167 | 0085 <span class="keyword">if</span> nargin == 9 |
---|
168 | 0086 orbit_function_args = {varargin{5}, OBSINDEX}; |
---|
169 | 0087 <span class="keyword">else</span> |
---|
170 | 0088 orbit_function_args = {0, OBSINDEX}; |
---|
171 | 0089 <span class="keyword">end</span> |
---|
172 | 0090 <span class="keyword">case</span> <span class="string">'findsyncorbit'</span> |
---|
173 | 0091 orbit_function_handle = @<a href="findsyncorbit.html" class="code" title="function [orbit, varargout] = findsyncorbit(RING,dCT,varargin);">findsyncorbit</a>; |
---|
174 | 0092 <span class="keyword">if</span> nargin == 9 |
---|
175 | 0093 orbit_function_args = {varargin{5}, OBSINDEX}; |
---|
176 | 0094 <span class="keyword">else</span> |
---|
177 | 0095 orbit_function_args = {0, OBSINDEX}; |
---|
178 | 0096 <span class="keyword">end</span> |
---|
179 | 0097 <span class="keyword">case</span> <span class="string">'findorbit6'</span> |
---|
180 | 0098 orbit_function_handle = @<a href="findorbit6.html" class="code" title="function orbit = findorbit6(RING,varargin);">findorbit6</a>; |
---|
181 | 0099 orbit_function_args = {OBSINDEX}; |
---|
182 | 0100 <span class="keyword">otherwise</span> |
---|
183 | 0101 error([<span class="string">'Unknown FINDORBIT function: '</span>,ORBITFUNCTION]); |
---|
184 | 0102 <span class="keyword">end</span> |
---|
185 | 0103 |
---|
186 | 0104 <span class="comment">%ORBIT = findorbit4(RING,0,OBSINDEX);</span> |
---|
187 | 0105 |
---|
188 | 0106 |
---|
189 | 0107 ORBIT = feval(orbit_function_handle,RING,orbit_function_args{:}); |
---|
190 | 0108 |
---|
191 | 0109 mn = {M,N}; |
---|
192 | 0110 <span class="keyword">for</span> i = 1:P |
---|
193 | 0111 oldvalue = getfield(RING{PERTURB(i)},varargin{1},mn); |
---|
194 | 0112 RING{PERTURB(i)} = setfield(RING{PERTURB(i)},varargin{1},mn,oldvalue+PVALUE(i)); |
---|
195 | 0113 ORBITPLUS = feval(orbit_function_handle,RING,orbit_function_args{:}); |
---|
196 | 0114 RING{PERTURB(i)} = setfield(RING{PERTURB(i)},varargin{1},mn,oldvalue); |
---|
197 | 0115 DORBIT = (ORBITPLUS - ORBIT); |
---|
198 | 0116 C{1}(:,i) = DORBIT(1,:); |
---|
199 | 0117 C{2}(:,i) = DORBIT(2,:); |
---|
200 | 0118 C{3}(:,i) = DORBIT(3,:); |
---|
201 | 0119 C{4}(:,i) = DORBIT(4,:); |
---|
202 | 0120 <span class="keyword">end</span> |
---|
203 | 0121 <span class="keyword">end</span></pre></div> |
---|
204 | <hr><address>Generated on Mon 21-May-2007 15:26:45 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address> |
---|
205 | </body> |
---|
206 | </html> |
---|