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 findsyncorbit</title> |
---|
6 | <meta name="keywords" content="findsyncorbit"> |
---|
7 | <meta name="description" content="FINDSYNCORBIT finds closed orbit, synchronous with the RF cavity"> |
---|
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> > findsyncorbit.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>findsyncorbit |
---|
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>FINDSYNCORBIT finds closed orbit, synchronous with the RF cavity</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 [orbit, varargout] = findsyncorbit(RING,dCT,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">FINDSYNCORBIT finds closed orbit, synchronous with the RF cavity |
---|
31 | and momentum deviation dP (first 5 components of the phase space vector) |
---|
32 | by numerically solving for a fixed point |
---|
33 | of the one turn map M calculated with LINEPASS |
---|
34 | |
---|
35 | (X, PX, Y, PY, dP2, CT2 ) = M (X, PX, Y, PY, dP1, CT1) |
---|
36 | |
---|
37 | under constraints CT2 - CT1 = dCT = C(1/Frev - 1/Frev0) and dP2 = dP1 , where |
---|
38 | Frev0 = Frf0/HarmNumber is the design revolution frequency |
---|
39 | Frev = (Frf0 + dFrf)/HarmNumber is the imposed revolution frequency |
---|
40 | |
---|
41 | IMPORTANT!!! FINDSYNCORBIT imposes a constraint (CT2 - CT1) and |
---|
42 | dP2 = dP1 but no constraint on the value of dP1, dP2 |
---|
43 | The algorithm assumes time-independent fixed-momentum ring |
---|
44 | to reduce the dimensionality of the problem. |
---|
45 | To impose this artificial constraint in FINDSYNCORBIT |
---|
46 | PassMethod used for any element SHOULD NOT |
---|
47 | 1. change the longitudinal momentum dP (cavities , magnets with radiation) |
---|
48 | 2. have any time dependence (localized impedance, fast kickers etc). |
---|
49 | |
---|
50 | |
---|
51 | FINDSYNCORBIT(RING,dCT) is 5x1 vector - fixed point at the |
---|
52 | entrance of the 1-st element of the RING (x,px,y,py,dP) |
---|
53 | |
---|
54 | FINDSYNCORBIT(RING,dCT,REFPTS) is 5-by-Length(REFPTS) |
---|
55 | array of column vectors - fixed points (x,px,y,py,dP) |
---|
56 | at the entrance of each element indexed in REFPTS array. |
---|
57 | REFPTS is an array of increasing indexes that select elements |
---|
58 | from the range 1 to length(RING)+1. |
---|
59 | See further explanation of REFPTS in the 'help' for FINDSPOS |
---|
60 | |
---|
61 | FINDSYNCORBIT(RING,dCT,REFPTS,GUESS) - same as above but the search |
---|
62 | for the fixed point starts at the initial condition GUESS |
---|
63 | Otherwise the search starts from [0 0 0 0 0 0]'. |
---|
64 | GUESS must be a 6-by-1 vector; |
---|
65 | |
---|
66 | [ORBIT, FIXEDPOINT] = FINDSYNCORBIT( ... ) |
---|
67 | The optional second return parameter is |
---|
68 | a 6-by-1 vector of initial conditions |
---|
69 | on the close orbit at the entrance to the RING. |
---|
70 | |
---|
71 | See also <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>.</pre></div> |
---|
72 | |
---|
73 | <!-- crossreference --> |
---|
74 | <h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2> |
---|
75 | This function calls: |
---|
76 | <ul style="list-style-image:url(../../matlabicon.gif)"> |
---|
77 | </ul> |
---|
78 | This function is called by: |
---|
79 | <ul style="list-style-image:url(../../matlabicon.gif)"> |
---|
80 | <li><a href="findrespm.html" class="code" title="function C = findrespm(RING, OBSINDEX, PERTURB, PVALUE, varargin)">findrespm</a> FINDRESPM computes the change in the closed orbit due to parameter perturbations</li></ul> |
---|
81 | <!-- crossreference --> |
---|
82 | |
---|
83 | |
---|
84 | <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2> |
---|
85 | <div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [orbit, varargout] = findsyncorbit(RING,dCT,varargin);</a> |
---|
86 | 0002 <span class="comment">%FINDSYNCORBIT finds closed orbit, synchronous with the RF cavity</span> |
---|
87 | 0003 <span class="comment">% and momentum deviation dP (first 5 components of the phase space vector)</span> |
---|
88 | 0004 <span class="comment">% by numerically solving for a fixed point</span> |
---|
89 | 0005 <span class="comment">% of the one turn map M calculated with LINEPASS</span> |
---|
90 | 0006 <span class="comment">%</span> |
---|
91 | 0007 <span class="comment">% (X, PX, Y, PY, dP2, CT2 ) = M (X, PX, Y, PY, dP1, CT1)</span> |
---|
92 | 0008 <span class="comment">%</span> |
---|
93 | 0009 <span class="comment">% under constraints CT2 - CT1 = dCT = C(1/Frev - 1/Frev0) and dP2 = dP1 , where</span> |
---|
94 | 0010 <span class="comment">% Frev0 = Frf0/HarmNumber is the design revolution frequency</span> |
---|
95 | 0011 <span class="comment">% Frev = (Frf0 + dFrf)/HarmNumber is the imposed revolution frequency</span> |
---|
96 | 0012 <span class="comment">%</span> |
---|
97 | 0013 <span class="comment">% IMPORTANT!!! FINDSYNCORBIT imposes a constraint (CT2 - CT1) and</span> |
---|
98 | 0014 <span class="comment">% dP2 = dP1 but no constraint on the value of dP1, dP2</span> |
---|
99 | 0015 <span class="comment">% The algorithm assumes time-independent fixed-momentum ring</span> |
---|
100 | 0016 <span class="comment">% to reduce the dimensionality of the problem.</span> |
---|
101 | 0017 <span class="comment">% To impose this artificial constraint in FINDSYNCORBIT</span> |
---|
102 | 0018 <span class="comment">% PassMethod used for any element SHOULD NOT</span> |
---|
103 | 0019 <span class="comment">% 1. change the longitudinal momentum dP (cavities , magnets with radiation)</span> |
---|
104 | 0020 <span class="comment">% 2. have any time dependence (localized impedance, fast kickers etc).</span> |
---|
105 | 0021 <span class="comment">%</span> |
---|
106 | 0022 <span class="comment">%</span> |
---|
107 | 0023 <span class="comment">% FINDSYNCORBIT(RING,dCT) is 5x1 vector - fixed point at the</span> |
---|
108 | 0024 <span class="comment">% entrance of the 1-st element of the RING (x,px,y,py,dP)</span> |
---|
109 | 0025 <span class="comment">%</span> |
---|
110 | 0026 <span class="comment">% FINDSYNCORBIT(RING,dCT,REFPTS) is 5-by-Length(REFPTS)</span> |
---|
111 | 0027 <span class="comment">% array of column vectors - fixed points (x,px,y,py,dP)</span> |
---|
112 | 0028 <span class="comment">% at the entrance of each element indexed in REFPTS array.</span> |
---|
113 | 0029 <span class="comment">% REFPTS is an array of increasing indexes that select elements</span> |
---|
114 | 0030 <span class="comment">% from the range 1 to length(RING)+1.</span> |
---|
115 | 0031 <span class="comment">% See further explanation of REFPTS in the 'help' for FINDSPOS</span> |
---|
116 | 0032 <span class="comment">%</span> |
---|
117 | 0033 <span class="comment">% FINDSYNCORBIT(RING,dCT,REFPTS,GUESS) - same as above but the search</span> |
---|
118 | 0034 <span class="comment">% for the fixed point starts at the initial condition GUESS</span> |
---|
119 | 0035 <span class="comment">% Otherwise the search starts from [0 0 0 0 0 0]'.</span> |
---|
120 | 0036 <span class="comment">% GUESS must be a 6-by-1 vector;</span> |
---|
121 | 0037 <span class="comment">%</span> |
---|
122 | 0038 <span class="comment">% [ORBIT, FIXEDPOINT] = FINDSYNCORBIT( ... )</span> |
---|
123 | 0039 <span class="comment">% The optional second return parameter is</span> |
---|
124 | 0040 <span class="comment">% a 6-by-1 vector of initial conditions</span> |
---|
125 | 0041 <span class="comment">% on the close orbit at the entrance to the RING.</span> |
---|
126 | 0042 <span class="comment">%</span> |
---|
127 | 0043 <span class="comment">% See also FINDORBIT, FINDORBIT4, FINDORBIT6.</span> |
---|
128 | 0044 <span class="comment">%</span> |
---|
129 | 0045 <span class="keyword">if</span> ~iscell(RING) |
---|
130 | 0046 error(<span class="string">'First argument must be a cell array'</span>); |
---|
131 | 0047 <span class="keyword">end</span> |
---|
132 | 0048 |
---|
133 | 0049 d = 1e-9; <span class="comment">% step size for numerical differentiation</span> |
---|
134 | 0050 max_iterations = 20; |
---|
135 | 0051 J = zeros(5); |
---|
136 | 0052 |
---|
137 | 0053 <span class="keyword">if</span> nargin==4 |
---|
138 | 0054 <span class="keyword">if</span> isnumeric(varargin{2}) & all(eq(size(varargin{2}),[6,1])) |
---|
139 | 0055 Ri=varargin{2}; |
---|
140 | 0056 <span class="keyword">else</span> |
---|
141 | 0057 error(<span class="string">'The last argument GUESS must be a 6-by-1 vector'</span>); |
---|
142 | 0058 <span class="keyword">end</span> |
---|
143 | 0059 <span class="keyword">else</span> |
---|
144 | 0060 Ri = zeros(6,1); |
---|
145 | 0061 <span class="keyword">end</span> |
---|
146 | 0062 |
---|
147 | 0063 D5 = d*eye(5); |
---|
148 | 0064 <span class="comment">%B5 = zeros(5,5);</span> |
---|
149 | 0065 RMATi = zeros(6,6); |
---|
150 | 0066 theta5 = [0 0 0 0 dCT]'; |
---|
151 | 0067 |
---|
152 | 0068 |
---|
153 | 0069 |
---|
154 | 0070 <span class="comment">%Fist iteration</span> |
---|
155 | 0071 RMATi= Ri*ones(1,6) + [D5 zeros(5,1); zeros(1,6)]; |
---|
156 | 0072 RMATf = linepass(RING,RMATi); |
---|
157 | 0073 Rf = RMATf(:,6); |
---|
158 | 0074 <span class="comment">% compute the transverse part of the Jacobian</span> |
---|
159 | 0075 J5 = [RMATf([1:4,6],1:5)-RMATf([1:4,6],6)*ones(1,5)]/d; |
---|
160 | 0076 |
---|
161 | 0077 <span class="comment">% Replace matrix inversion with \</span> |
---|
162 | 0078 <span class="comment">%B5 = inv(diag([1 1 1 1 0]) - J5);</span> |
---|
163 | 0079 <span class="comment">% Ri_next = Ri + [B5* (Rf([1:4,6])-[Ri(1:4);0]-theta5) ; 0];</span> |
---|
164 | 0080 Ri_next = Ri + [(diag([1 1 1 1 0]) - J5)\(Rf([1:4,6])-[Ri(1:4);0]-theta5) ; 0]; |
---|
165 | 0081 change = norm(Ri_next - Ri); |
---|
166 | 0082 Ri = Ri_next; |
---|
167 | 0083 |
---|
168 | 0084 itercount = 1; |
---|
169 | 0085 |
---|
170 | 0086 |
---|
171 | 0087 <span class="keyword">while</span> (change>eps) & (itercount < max_iterations) |
---|
172 | 0088 |
---|
173 | 0089 RMATi= Ri*ones(1,6) + [D5 zeros(5,1); zeros(1,6)]; |
---|
174 | 0090 RMATf = linepass(RING,RMATi,<span class="string">'reuse'</span>); |
---|
175 | 0091 |
---|
176 | 0092 Rf = RMATf(:,6); |
---|
177 | 0093 <span class="comment">% compute the transverse part of the Jacobian</span> |
---|
178 | 0094 J5 = [RMATf([1:4,6],1:5)-RMATf([1:4,6],6)*ones(1,5)]/d; |
---|
179 | 0095 <span class="comment">% Replace matrix inversion with \</span> |
---|
180 | 0096 <span class="comment">%B5 = inv(diag([1 1 1 1 0]) - J5);</span> |
---|
181 | 0097 <span class="comment">%Ri_next = Ri + [B5*(Rf([1:4,6])-[Ri(1:4);0]-theta5); 0];</span> |
---|
182 | 0098 Ri_next = Ri + [(diag([1 1 1 1 0]) - J5)\(Rf([1:4,6])-[Ri(1:4);0]-theta5); 0]; |
---|
183 | 0099 change = norm(Ri_next - Ri); |
---|
184 | 0100 Ri = Ri_next; |
---|
185 | 0101 itercount = itercount+1; |
---|
186 | 0102 |
---|
187 | 0103 <span class="keyword">end</span>; |
---|
188 | 0104 |
---|
189 | 0105 |
---|
190 | 0106 <span class="keyword">if</span>(nargin<3) | (varargin{1}==(length(RING)+1)) |
---|
191 | 0107 <span class="comment">% return only the fixed point at the entrance of RING{1}</span> |
---|
192 | 0108 orbit=Ri(1:5,1); |
---|
193 | 0109 <span class="keyword">else</span> <span class="comment">% 3-rd input argument - vector of reference points along the Ring</span> |
---|
194 | 0110 <span class="comment">% is supplied - return orbit</span> |
---|
195 | 0111 orb6 = linepass(RING,Ri,varargin{1},<span class="string">'reuse'</span>); |
---|
196 | 0112 orbit = orb6(1:5,:); |
---|
197 | 0113 <span class="keyword">end</span> |
---|
198 | 0114 |
---|
199 | 0115 <span class="keyword">if</span> nargout==2 |
---|
200 | 0116 varargout{1}=Ri; |
---|
201 | 0117 <span class="keyword">end</span></pre></div> |
---|
202 | <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> |
---|
203 | </body> |
---|
204 | </html> |
---|