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 machine_at</title> |
---|
6 | <meta name="keywords" content="machine_at"> |
---|
7 | <meta name="description" content="MACHINE_AT - Returns the optics function as a structure"> |
---|
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> > <a href="index.html">at</a> > machine_at.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/at <img alt=">" border="0" src="../../right.png"></a></td></tr></table>--> |
---|
19 | |
---|
20 | <h1>machine_at |
---|
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>MACHINE_AT - Returns the optics function as a structure</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 varargout = machine_at(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">MACHINE_AT - Returns the optics function as a structure |
---|
31 | optics = machine_at([THERING, DP, ELEMENTS, SPECIFIC_OPTICS]) |
---|
32 | optics = machine_at(SPECIFIC_OPTICS) |
---|
33 | |
---|
34 | Essentially takes what twissring returns and restructures it so that its easier to use. |
---|
35 | |
---|
36 | Defaults to loading THERING from global, DP = 0, uses all elements and |
---|
37 | calculates the dispersion. |
---|
38 | SPECIFIC_OPTICS is a string that defines which particular element to |
---|
39 | return. Eg. if SPECIFIC_OPTICS = 'betax', then MACHINE_AT will only |
---|
40 | return those numbers. |
---|
41 | |
---|
42 | Other options are 'file' which will allow one to export the optical |
---|
43 | functions to an xls spreadsheet and 'line' to specify if the THERING used |
---|
44 | is actually a transfer line. If using the transfer line then the user |
---|
45 | must also provide the initial conditions as specified by TWISSLINE. |
---|
46 | |
---|
47 | Written by Eugene Tan (28/05/04) |
---|
48 | |
---|
49 | Change History |
---|
50 | 1. Added export of element names as well 14/11/06 |
---|
51 | 2. Added export to xls option. 12/05/05</pre></div> |
---|
52 | |
---|
53 | <!-- crossreference --> |
---|
54 | <h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2> |
---|
55 | This function calls: |
---|
56 | <ul style="list-style-image:url(../../matlabicon.gif)"> |
---|
57 | </ul> |
---|
58 | This function is called by: |
---|
59 | <ul style="list-style-image:url(../../matlabicon.gif)"> |
---|
60 | <li><a href="fittunedisp2.html" class="code" title="function varargout = fittunedisp2(newtunes_disp, quadfam1, quadfam2, quadfam3, dispind, varargin)">fittunedisp2</a> FITTUNEDISP2 - Fits the linear tunes and the dispersion of model using 3 quadrupole families.</li></ul> |
---|
61 | <!-- crossreference --> |
---|
62 | |
---|
63 | |
---|
64 | <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2> |
---|
65 | <div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function varargout = machine_at(varargin)</a> |
---|
66 | 0002 <span class="comment">%MACHINE_AT - Returns the optics function as a structure</span> |
---|
67 | 0003 <span class="comment">% optics = machine_at([THERING, DP, ELEMENTS, SPECIFIC_OPTICS])</span> |
---|
68 | 0004 <span class="comment">% optics = machine_at(SPECIFIC_OPTICS)</span> |
---|
69 | 0005 <span class="comment">%</span> |
---|
70 | 0006 <span class="comment">% Essentially takes what twissring returns and restructures it so that its easier to use.</span> |
---|
71 | 0007 <span class="comment">%</span> |
---|
72 | 0008 <span class="comment">% Defaults to loading THERING from global, DP = 0, uses all elements and</span> |
---|
73 | 0009 <span class="comment">% calculates the dispersion.</span> |
---|
74 | 0010 <span class="comment">% SPECIFIC_OPTICS is a string that defines which particular element to</span> |
---|
75 | 0011 <span class="comment">% return. Eg. if SPECIFIC_OPTICS = 'betax', then MACHINE_AT will only</span> |
---|
76 | 0012 <span class="comment">% return those numbers.</span> |
---|
77 | 0013 <span class="comment">%</span> |
---|
78 | 0014 <span class="comment">% Other options are 'file' which will allow one to export the optical</span> |
---|
79 | 0015 <span class="comment">% functions to an xls spreadsheet and 'line' to specify if the THERING used</span> |
---|
80 | 0016 <span class="comment">% is actually a transfer line. If using the transfer line then the user</span> |
---|
81 | 0017 <span class="comment">% must also provide the initial conditions as specified by TWISSLINE.</span> |
---|
82 | 0018 <span class="comment">%</span> |
---|
83 | 0019 <span class="comment">% Written by Eugene Tan (28/05/04)</span> |
---|
84 | 0020 <span class="comment">%</span> |
---|
85 | 0021 <span class="comment">% Change History</span> |
---|
86 | 0022 <span class="comment">% 1. Added export of element names as well 14/11/06</span> |
---|
87 | 0023 <span class="comment">% 2. Added export to xls option. 12/05/05</span> |
---|
88 | 0024 |
---|
89 | 0025 |
---|
90 | 0026 nspec_opt = 0; |
---|
91 | 0027 exportfile = 0; |
---|
92 | 0028 transferline = 0; |
---|
93 | 0029 tdin = []; |
---|
94 | 0030 <span class="keyword">for</span> i=1:nargin |
---|
95 | 0031 <span class="keyword">if</span> ischar(varargin{i}) && strcmpi(varargin{i},<span class="string">'file'</span>) |
---|
96 | 0032 exportfile = 1; |
---|
97 | 0033 <span class="keyword">elseif</span> ischar(varargin{i}) && strcmpi(varargin{i},<span class="string">'line'</span>) |
---|
98 | 0034 transferline = 1; |
---|
99 | 0035 <span class="keyword">elseif</span> isstruct(varargin{i}) |
---|
100 | 0036 <span class="comment">% Of all inputs there is only one struct type and that is for</span> |
---|
101 | 0037 <span class="comment">% twissline.</span> |
---|
102 | 0038 tdin = varargin{i}; |
---|
103 | 0039 <span class="keyword">else</span> |
---|
104 | 0040 <span class="keyword">if</span> ischar(varargin{i}) |
---|
105 | 0041 nspec_opt = nspec_opt + 1; |
---|
106 | 0042 spec_opt{nspec_opt} = varargin{i}; |
---|
107 | 0043 <span class="keyword">end</span> |
---|
108 | 0044 <span class="keyword">end</span> |
---|
109 | 0045 <span class="keyword">end</span> |
---|
110 | 0046 |
---|
111 | 0047 args = 0; |
---|
112 | 0048 args = args + 1; |
---|
113 | 0049 <span class="keyword">if</span> nargin >= args && ~ischar(varargin{args}) && ~isstruct(varargin{args}) |
---|
114 | 0050 line_ring = varargin{args}; |
---|
115 | 0051 <span class="keyword">else</span> |
---|
116 | 0052 <span class="keyword">global</span> THERING |
---|
117 | 0053 line_ring = THERING; |
---|
118 | 0054 <span class="keyword">end</span> |
---|
119 | 0055 |
---|
120 | 0056 args = args + 1; |
---|
121 | 0057 <span class="keyword">if</span> nargin >= args && ~ischar(varargin{args}) && ~isstruct(varargin{args}) |
---|
122 | 0058 dp = varargin{args}; |
---|
123 | 0059 <span class="keyword">else</span> |
---|
124 | 0060 dp = 0; |
---|
125 | 0061 <span class="keyword">end</span> |
---|
126 | 0062 |
---|
127 | 0063 args = args + 1; |
---|
128 | 0064 <span class="keyword">if</span> nargin >= args && ~ischar(varargin{args}) && ~isstruct(varargin{args}) |
---|
129 | 0065 elements = varargin{args}; |
---|
130 | 0066 <span class="keyword">else</span> |
---|
131 | 0067 elements = 1:length(line_ring)+1; |
---|
132 | 0068 <span class="keyword">end</span> |
---|
133 | 0069 |
---|
134 | 0070 <span class="comment">% Check that input struct supplied of 'line' is used</span> |
---|
135 | 0071 <span class="keyword">if</span> transferline |
---|
136 | 0072 <span class="keyword">if</span> isempty(tdin) |
---|
137 | 0073 error(<span class="string">'User must provide the twiss data input structure'</span>); |
---|
138 | 0074 <span class="keyword">end</span> |
---|
139 | 0075 TD = twissline(line_ring, dp, tdin, elements, <span class="string">'chrom'</span>, 1e-6); |
---|
140 | 0076 <span class="keyword">else</span> |
---|
141 | 0077 TD = twissring(line_ring, dp, elements, <span class="string">'chrom'</span>, 1e-6); |
---|
142 | 0078 <span class="keyword">end</span> |
---|
143 | 0079 |
---|
144 | 0080 <span class="comment">% Group element names into a cell array</span> |
---|
145 | 0081 <span class="keyword">for</span> i=1:length(elements) |
---|
146 | 0082 <span class="comment">% Circular indexing</span> |
---|
147 | 0083 iind = mod(elements(i)-1,length(line_ring))+1; |
---|
148 | 0084 elemnames{i,1} = line_ring{iind}.FamName; |
---|
149 | 0085 <span class="keyword">if</span> isfield(line_ring{iind},<span class="string">'Length'</span>) |
---|
150 | 0086 elemLeff(i,1) = line_ring{iind}.Length; |
---|
151 | 0087 <span class="keyword">else</span> |
---|
152 | 0088 elemLeff(i,1) = 0; |
---|
153 | 0089 <span class="keyword">end</span> |
---|
154 | 0090 <span class="keyword">end</span> |
---|
155 | 0091 optics.elemnames = elemnames; |
---|
156 | 0092 optics.elemLeff = elemLeff; |
---|
157 | 0093 |
---|
158 | 0094 temp = cat(1, TD.beta); |
---|
159 | 0095 optics.betax = temp(:,1); |
---|
160 | 0096 optics.betay = temp(:,2); |
---|
161 | 0097 |
---|
162 | 0098 temp = cat(1, TD.alpha); |
---|
163 | 0099 optics.alphax = temp(:,1); |
---|
164 | 0100 optics.alphay = temp(:,2); |
---|
165 | 0101 |
---|
166 | 0102 temp = cat(2, TD.Dispersion); |
---|
167 | 0103 optics.etax = temp(1,:)'; |
---|
168 | 0104 optics.etapx = temp(2,:)'; |
---|
169 | 0105 optics.etay = temp(3,:)'; |
---|
170 | 0106 optics.etapy = temp(4,:)'; |
---|
171 | 0107 |
---|
172 | 0108 temp = cat(2, TD.ClosedOrbit); |
---|
173 | 0109 optics.x = temp(1,:)'; |
---|
174 | 0110 optics.px = temp(2,:)'; |
---|
175 | 0111 optics.y = temp(3,:)'; |
---|
176 | 0112 optics.py = temp(4,:)'; |
---|
177 | 0113 |
---|
178 | 0114 temp = cat(1,TD.mu); |
---|
179 | 0115 optics.nux = temp(:,1)/(2*pi); |
---|
180 | 0116 optics.nuy = temp(:,2)/(2*pi); |
---|
181 | 0117 |
---|
182 | 0118 optics.spos = cat(1,TD.SPos); |
---|
183 | 0119 |
---|
184 | 0120 <span class="keyword">if</span> nspec_opt >= 1 |
---|
185 | 0121 varargout{1} = optics.(spec_opt{1}); |
---|
186 | 0122 <span class="keyword">else</span> |
---|
187 | 0123 varargout{1} = optics; |
---|
188 | 0124 <span class="keyword">end</span> |
---|
189 | 0125 |
---|
190 | 0126 <span class="keyword">if</span> exportfile |
---|
191 | 0127 [filename pathname] = uiputfile(<span class="string">'*.xls'</span>,<span class="string">'Excel spreadsheet'</span>); |
---|
192 | 0128 entrystr = fieldnames(optics); |
---|
193 | 0129 temp = optics.(entrystr{1}); |
---|
194 | 0130 <span class="keyword">for</span> i=2:length(entrystr) |
---|
195 | 0131 temp = cat(2,temp,optics.(entrystr{i})); |
---|
196 | 0132 <span class="keyword">end</span> |
---|
197 | 0133 xlswrite([pathname filename],entrystr',<span class="string">'opticalparam'</span>,<span class="string">'A1'</span>); |
---|
198 | 0134 xlswrite([pathname filename],temp,<span class="string">'opticalparam'</span>,<span class="string">'A2'</span>); |
---|
199 | 0135 <span class="keyword">end</span></pre></div> |
---|
200 | <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> |
---|
201 | </body> |
---|
202 | </html> |
---|