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 ohmienvelope</title> |
---|
6 | <meta name="keywords" content="ohmienvelope"> |
---|
7 | <meta name="description" content="OHMIENVELOPE calculates equilibrium beam envelope in a"> |
---|
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> > ohmienvelope.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>ohmienvelope |
---|
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>OHMIENVELOPE calculates equilibrium beam envelope in a</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 [ENVELOPE, RMSDP, RMSBL] = ohmienvelope(RING,RADELEMINDEX,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">OHMIENVELOPE calculates equilibrium beam envelope in a |
---|
31 | circular accelerator using Ohmi's beam envelope formalism [1] |
---|
32 | [1] K.Ohmi et al. Phys.Rev.E. Vol.49. (1994) |
---|
33 | |
---|
34 | [ENVELOPE, RMSDP, RMSBL] = ONMIENVELOPE(RING,RADELEMINDEX,REFPTS) |
---|
35 | |
---|
36 | ENVELOPE is a structure with fields |
---|
37 | Sigma - [SIGMA(1); SIGMA(2)] - RMS size [m] along |
---|
38 | the principal axis of a tilted ellips |
---|
39 | Assuming normal distribution exp(-(Z^2)/(2*SIGMA)) |
---|
40 | Tilt - Tilt angle of the XY ellips [rad] |
---|
41 | Positive Tilt corresponds to Corkscrew (right) |
---|
42 | rotatiom of XY plane around s-axis |
---|
43 | R - 6-by-6 equilibrium envelope matrix R |
---|
44 | |
---|
45 | RMSDP - RMS momentum spread |
---|
46 | RMSBL - RMS bunch length[m]</pre></div> |
---|
47 | |
---|
48 | <!-- crossreference --> |
---|
49 | <h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2> |
---|
50 | This function calls: |
---|
51 | <ul style="list-style-image:url(../../matlabicon.gif)"> |
---|
52 | <li><a href="findelemm66.html" class="code" title="function M66 = findelemm66(ELEM, MethodName, orbit_in);">findelemm66</a> FINDELEMM66 numerically finds the 6x6 transfer matrix of an element</li><li><a href="findm66.html" class="code" title="function [M66, varargout] = findm66(RING, varargin);">findm66</a> FINDM66 numerically finds the 6x6 transfer matrix of an accelerator lattice</li><li><a href="findmpoleraddiffmatrix.html" class="code" title="">findmpoleraddiffmatrix</a> FINDMPOLERADDIFFMATIRX calculates radiation diffusion matrix of a multipole element</li></ul> |
---|
53 | This function is called by: |
---|
54 | <ul style="list-style-image:url(../../matlabicon.gif)"> |
---|
55 | </ul> |
---|
56 | <!-- crossreference --> |
---|
57 | |
---|
58 | |
---|
59 | <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2> |
---|
60 | <div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [ENVELOPE, RMSDP, RMSBL] = ohmienvelope(RING,RADELEMINDEX,varargin)</a> |
---|
61 | 0002 <span class="comment">%OHMIENVELOPE calculates equilibrium beam envelope in a</span> |
---|
62 | 0003 <span class="comment">% circular accelerator using Ohmi's beam envelope formalism [1]</span> |
---|
63 | 0004 <span class="comment">% [1] K.Ohmi et al. Phys.Rev.E. Vol.49. (1994)</span> |
---|
64 | 0005 <span class="comment">%</span> |
---|
65 | 0006 <span class="comment">% [ENVELOPE, RMSDP, RMSBL] = ONMIENVELOPE(RING,RADELEMINDEX,REFPTS)</span> |
---|
66 | 0007 <span class="comment">%</span> |
---|
67 | 0008 <span class="comment">% ENVELOPE is a structure with fields</span> |
---|
68 | 0009 <span class="comment">% Sigma - [SIGMA(1); SIGMA(2)] - RMS size [m] along</span> |
---|
69 | 0010 <span class="comment">% the principal axis of a tilted ellips</span> |
---|
70 | 0011 <span class="comment">% Assuming normal distribution exp(-(Z^2)/(2*SIGMA))</span> |
---|
71 | 0012 <span class="comment">% Tilt - Tilt angle of the XY ellips [rad]</span> |
---|
72 | 0013 <span class="comment">% Positive Tilt corresponds to Corkscrew (right)</span> |
---|
73 | 0014 <span class="comment">% rotatiom of XY plane around s-axis</span> |
---|
74 | 0015 <span class="comment">% R - 6-by-6 equilibrium envelope matrix R</span> |
---|
75 | 0016 <span class="comment">%</span> |
---|
76 | 0017 <span class="comment">% RMSDP - RMS momentum spread</span> |
---|
77 | 0018 <span class="comment">% RMSBL - RMS bunch length[m]</span> |
---|
78 | 0019 |
---|
79 | 0020 NumElements = length(RING); |
---|
80 | 0021 |
---|
81 | 0022 [MRING, MS, orbit] = <a href="findm66.html" class="code" title="function [M66, varargout] = findm66(RING, varargin);">findm66</a>(RING,1:NumElements+1); |
---|
82 | 0023 |
---|
83 | 0024 B = cell(1,NumElements); <span class="comment">% B{i} is the diffusion matrix of the i-th element</span> |
---|
84 | 0025 BATEXIT = B; <span class="comment">% BATEXIT{i} is the cumulative diffusion matrix from</span> |
---|
85 | 0026 <span class="comment">% element 0 to the end of the i-th element</span> |
---|
86 | 0027 M = B; <span class="comment">% 6-by-6 transfer matrix of the i-th element</span> |
---|
87 | 0028 |
---|
88 | 0029 <span class="comment">% calculate Radiation-Diffusion matrix B for elements with radiation</span> |
---|
89 | 0030 <span class="keyword">for</span> i = RADELEMINDEX |
---|
90 | 0031 B{i} = <a href="findmpoleraddiffmatrix.html" class="code" title="">findmpoleraddiffmatrix</a>(RING{i},orbit(:,i)); |
---|
91 | 0032 <span class="keyword">end</span> |
---|
92 | 0033 |
---|
93 | 0034 <span class="comment">% Calculate 6-by-6 linear transfer matrix in each element</span> |
---|
94 | 0035 <span class="comment">% near the equilibrium orbit</span> |
---|
95 | 0036 <span class="keyword">for</span> i = 1:NumElements |
---|
96 | 0037 ELEM = RING{i}; |
---|
97 | 0038 M{i} = <a href="findelemm66.html" class="code" title="function M66 = findelemm66(ELEM, MethodName, orbit_in);">findelemm66</a>(ELEM,ELEM.PassMethod,orbit(:,i)); |
---|
98 | 0039 <span class="comment">% Set Radiation-Diffusion matrix B to 0 in elements without radiation</span> |
---|
99 | 0040 <span class="keyword">if</span> isempty(B{i}) |
---|
100 | 0041 B{i} = zeros(6,6); |
---|
101 | 0042 <span class="keyword">end</span> |
---|
102 | 0043 <span class="keyword">end</span> |
---|
103 | 0044 <span class="comment">% Calculate cumulative Radiation-Diffusion matrix for the ring</span> |
---|
104 | 0045 BCUM = zeros(6,6); <span class="comment">% Cumulative diffusion matrix of the entire ring</span> |
---|
105 | 0046 |
---|
106 | 0047 <span class="keyword">for</span> i = 1:NumElements |
---|
107 | 0048 BCUM = M{i}*BCUM*M{i}' + B{i}; |
---|
108 | 0049 BATEXIT{i} = BCUM; |
---|
109 | 0050 <span class="keyword">end</span> |
---|
110 | 0051 <span class="comment">% ------------------------------------------------------------------------</span> |
---|
111 | 0052 <span class="comment">% Equation for the moment matrix R is</span> |
---|
112 | 0053 <span class="comment">% R = MRING*R*MRING' + BCUM;</span> |
---|
113 | 0054 <span class="comment">% We rewrite it in the form of Lyapunov equation to use MATLAB's LYAP function</span> |
---|
114 | 0055 <span class="comment">% AA*R + R*BB = -CC</span> |
---|
115 | 0056 <span class="comment">% where</span> |
---|
116 | 0057 <span class="comment">% AA = inv(MRING)</span> |
---|
117 | 0058 <span class="comment">% BB = -MRING'</span> |
---|
118 | 0059 <span class="comment">% CC = -inv(MRING)*BCUM</span> |
---|
119 | 0060 <span class="comment">% -----------------------------------------------------------------------</span> |
---|
120 | 0061 AA = inv(MRING); |
---|
121 | 0062 BB = -MRING'; |
---|
122 | 0063 CC = -inv(MRING)*BCUM; |
---|
123 | 0064 |
---|
124 | 0065 R = lyap(AA,BB,CC); <span class="comment">% Envelope matrix at the rinng entrance</span> |
---|
125 | 0066 |
---|
126 | 0067 RMSDP = sqrt(R(5,5)); <span class="comment">% R.M.S. energy spread</span> |
---|
127 | 0068 RMSBL = sqrt(R(6,6)); <span class="comment">% R.M.S. bunch lenght</span> |
---|
128 | 0069 |
---|
129 | 0070 <span class="keyword">if</span> nargin == 2 <span class="comment">% no REFPTS</span> |
---|
130 | 0071 ENVELOPE.R = R; |
---|
131 | 0072 <span class="keyword">elseif</span> nargin == 3 |
---|
132 | 0073 REFPTS = varargin{1}; |
---|
133 | 0074 |
---|
134 | 0075 REFPTSX = REFPTS; |
---|
135 | 0076 <span class="comment">% complete REFPTS with 1 and NumElements+1 if necessary</span> |
---|
136 | 0077 <span class="keyword">if</span> REFPTS(1)~=1 |
---|
137 | 0078 REFPTSX = [1 REFPTS]; |
---|
138 | 0079 <span class="keyword">end</span> |
---|
139 | 0080 <span class="keyword">if</span> REFPTS(end)~= NumElements+1 |
---|
140 | 0081 REFPTSX = [REFPTSX NumElements+1]; |
---|
141 | 0082 <span class="keyword">end</span> |
---|
142 | 0083 <span class="comment">% Now REFPTS has at least 2 ponts and the first one is the ring entrance</span> |
---|
143 | 0084 |
---|
144 | 0085 NRX = length(REFPTSX); |
---|
145 | 0086 ENVELOPE = struct(<span class="string">'Sigma'</span>,num2cell(zeros(2,NRX),1),<span class="keyword">...</span> |
---|
146 | 0087 <span class="string">'Tilt'</span>,0,<span class="string">'R'</span>,zeros(6)); |
---|
147 | 0088 |
---|
148 | 0089 ENVELOPE(1).R = R; |
---|
149 | 0090 |
---|
150 | 0091 <span class="keyword">for</span> i=2:NRX |
---|
151 | 0092 ELEM = REFPTSX(i); |
---|
152 | 0093 ENVELOPE(i).R = MS(:,:,ELEM)*R*MS(:,:,ELEM)'+BATEXIT{ELEM-1}; |
---|
153 | 0094 <span class="keyword">end</span> |
---|
154 | 0095 |
---|
155 | 0096 |
---|
156 | 0097 <span class="keyword">if</span> REFPTS(1)~=1 |
---|
157 | 0098 ENVELOPE = ENVELOPE(2:end); |
---|
158 | 0099 <span class="keyword">end</span> |
---|
159 | 0100 <span class="keyword">if</span> REFPTS(end)~= NumElements+1 |
---|
160 | 0101 ENVELOPE = ENVELOPE(1:end-1); |
---|
161 | 0102 <span class="keyword">end</span> |
---|
162 | 0103 |
---|
163 | 0104 <span class="keyword">else</span> |
---|
164 | 0105 error(<span class="string">'Too many input arguments'</span>); |
---|
165 | 0106 <span class="keyword">end</span> |
---|
166 | 0107 |
---|
167 | 0108 <span class="keyword">for</span> i=1:length(ENVELOPE) |
---|
168 | 0109 [U,DR] = eig(ENVELOPE(i).R([1 3],[1 3])); |
---|
169 | 0110 ENVELOPE(i).Tilt = asin((U(2,1)-U(1,2))/2); |
---|
170 | 0111 ENVELOPE(i).Sigma(1) = sqrt(DR(1,1)); |
---|
171 | 0112 ENVELOPE(i).Sigma(2) = sqrt(DR(2,2)); |
---|
172 | 0113 <span class="keyword">end</span></pre></div> |
---|
173 | <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> |
---|
174 | </body> |
---|
175 | </html> |
---|