source: MML/trunk/mml/doc_html/mml/at/machine_at.html @ 4

Last change on this file since 4 was 4, checked in by zhangj, 10 years ago

Initial import--MML version from SOLEIL@2013

File size: 10.0 KB
Line 
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 &copy; 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> &gt;  <a href="../index.html">mml</a> &gt; <a href="index.html">at</a> &gt; machine_at.m</div>
16
17<!--<table width="100%"><tr><td align="left"><a href="../../index.html"><img alt="<" border="0" src="../../left.png">&nbsp;Master index</a></td>
18<td align="right"><a href="index.html">Index for mml/at&nbsp;<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>
55This function calls:
56<ul style="list-style-image:url(../../matlabicon.gif)">
57</ul>
58This 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>
660002 <span class="comment">%MACHINE_AT - Returns the optics function as a structure</span>
670003 <span class="comment">%  optics = machine_at([THERING, DP, ELEMENTS, SPECIFIC_OPTICS])</span>
680004 <span class="comment">%  optics = machine_at(SPECIFIC_OPTICS)</span>
690005 <span class="comment">%</span>
700006 <span class="comment">%  Essentially takes what twissring returns and restructures it so that its easier to use.</span>
710007 <span class="comment">%</span>
720008 <span class="comment">%  Defaults to loading THERING from global, DP = 0, uses all elements and</span>
730009 <span class="comment">%  calculates the dispersion.</span>
740010 <span class="comment">%  SPECIFIC_OPTICS is a string that defines which particular element to</span>
750011 <span class="comment">%  return. Eg. if SPECIFIC_OPTICS = 'betax', then MACHINE_AT will only</span>
760012 <span class="comment">%  return those numbers.</span>
770013 <span class="comment">%</span>
780014 <span class="comment">%  Other options are 'file' which will allow one to export the optical</span>
790015 <span class="comment">%  functions to an xls spreadsheet and 'line' to specify if the THERING used</span>
800016 <span class="comment">%  is actually a transfer line. If using the transfer line then the user</span>
810017 <span class="comment">%  must also provide the initial conditions as specified by TWISSLINE.</span>
820018 <span class="comment">%</span>
830019 <span class="comment">%  Written by Eugene Tan (28/05/04)</span>
840020 <span class="comment">%</span>
850021 <span class="comment">%  Change History</span>
860022 <span class="comment">%  1. Added export of element names as well 14/11/06</span>
870023 <span class="comment">%  2. Added export to xls option. 12/05/05</span>
880024
890025
900026 nspec_opt = 0;
910027 exportfile = 0;
920028 transferline = 0;
930029 tdin = [];
940030 <span class="keyword">for</span> i=1:nargin
950031     <span class="keyword">if</span> ischar(varargin{i}) &amp;&amp; strcmpi(varargin{i},<span class="string">'file'</span>)
960032         exportfile = 1;
970033     <span class="keyword">elseif</span> ischar(varargin{i}) &amp;&amp; strcmpi(varargin{i},<span class="string">'line'</span>)
980034         transferline = 1;
990035     <span class="keyword">elseif</span> isstruct(varargin{i})
1000036         <span class="comment">% Of all inputs there is only one struct type and that is for</span>
1010037         <span class="comment">% twissline.</span>
1020038         tdin = varargin{i};
1030039     <span class="keyword">else</span>
1040040         <span class="keyword">if</span> ischar(varargin{i})
1050041             nspec_opt = nspec_opt + 1;
1060042             spec_opt{nspec_opt} = varargin{i};
1070043         <span class="keyword">end</span>
1080044     <span class="keyword">end</span>
1090045 <span class="keyword">end</span>
1100046         
1110047 args = 0;
1120048 args = args + 1;
1130049 <span class="keyword">if</span> nargin &gt;= args &amp;&amp; ~ischar(varargin{args}) &amp;&amp; ~isstruct(varargin{args})
1140050     line_ring = varargin{args};
1150051 <span class="keyword">else</span>
1160052     <span class="keyword">global</span> THERING
1170053     line_ring = THERING;
1180054 <span class="keyword">end</span>
1190055
1200056 args = args + 1;
1210057 <span class="keyword">if</span> nargin &gt;= args &amp;&amp; ~ischar(varargin{args}) &amp;&amp; ~isstruct(varargin{args})
1220058     dp = varargin{args};
1230059 <span class="keyword">else</span>
1240060     dp = 0;
1250061 <span class="keyword">end</span>
1260062
1270063 args = args + 1;
1280064 <span class="keyword">if</span> nargin &gt;= args &amp;&amp; ~ischar(varargin{args}) &amp;&amp; ~isstruct(varargin{args})
1290065     elements = varargin{args};
1300066 <span class="keyword">else</span>
1310067     elements = 1:length(line_ring)+1;
1320068 <span class="keyword">end</span>
1330069
1340070 <span class="comment">% Check that input struct supplied of 'line' is used</span>
1350071 <span class="keyword">if</span> transferline
1360072     <span class="keyword">if</span> isempty(tdin)
1370073         error(<span class="string">'User must provide the twiss data input structure'</span>);
1380074     <span class="keyword">end</span>
1390075     TD = twissline(line_ring, dp, tdin, elements, <span class="string">'chrom'</span>, 1e-6);
1400076 <span class="keyword">else</span>
1410077     TD = twissring(line_ring, dp, elements, <span class="string">'chrom'</span>, 1e-6);
1420078 <span class="keyword">end</span>
1430079
1440080 <span class="comment">% Group element names into a cell array</span>
1450081 <span class="keyword">for</span> i=1:length(elements)
1460082     <span class="comment">% Circular indexing</span>
1470083     iind = mod(elements(i)-1,length(line_ring))+1;
1480084     elemnames{i,1} = line_ring{iind}.FamName;
1490085     <span class="keyword">if</span> isfield(line_ring{iind},<span class="string">'Length'</span>)
1500086         elemLeff(i,1) = line_ring{iind}.Length;
1510087     <span class="keyword">else</span>
1520088         elemLeff(i,1) = 0;
1530089     <span class="keyword">end</span>
1540090 <span class="keyword">end</span>
1550091 optics.elemnames = elemnames;
1560092 optics.elemLeff = elemLeff;
1570093
1580094 temp = cat(1, TD.beta);
1590095 optics.betax = temp(:,1);
1600096 optics.betay = temp(:,2);
1610097
1620098 temp = cat(1, TD.alpha);
1630099 optics.alphax = temp(:,1);
1640100 optics.alphay = temp(:,2);
1650101
1660102 temp = cat(2, TD.Dispersion);
1670103 optics.etax = temp(1,:)';
1680104 optics.etapx = temp(2,:)';
1690105 optics.etay = temp(3,:)';
1700106 optics.etapy = temp(4,:)';
1710107
1720108 temp = cat(2, TD.ClosedOrbit);
1730109 optics.x = temp(1,:)';
1740110 optics.px = temp(2,:)';
1750111 optics.y = temp(3,:)';
1760112 optics.py = temp(4,:)';
1770113
1780114 temp = cat(1,TD.mu);
1790115 optics.nux = temp(:,1)/(2*pi);
1800116 optics.nuy = temp(:,2)/(2*pi);
1810117
1820118 optics.spos = cat(1,TD.SPos);
1830119
1840120 <span class="keyword">if</span> nspec_opt &gt;= 1
1850121     varargout{1} = optics.(spec_opt{1});
1860122 <span class="keyword">else</span>
1870123     varargout{1} = optics;
1880124 <span class="keyword">end</span>
1890125
1900126 <span class="keyword">if</span> exportfile
1910127     [filename pathname] = uiputfile(<span class="string">'*.xls'</span>,<span class="string">'Excel spreadsheet'</span>);
1920128     entrystr = fieldnames(optics);
1930129     temp = optics.(entrystr{1});
1940130     <span class="keyword">for</span> i=2:length(entrystr)
1950131         temp = cat(2,temp,optics.(entrystr{i}));
1960132     <span class="keyword">end</span>
1970133     xlswrite([pathname filename],entrystr',<span class="string">'opticalparam'</span>,<span class="string">'A1'</span>);
1980134     xlswrite([pathname filename],temp,<span class="string">'opticalparam'</span>,<span class="string">'A2'</span>);
1990135 <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> &copy; 2003</address>
201</body>
202</html>
Note: See TracBrowser for help on using the repository browser.