source: MML/trunk/mml/at/doc_html/at/linepass1turn.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.3 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 linepass1turn</title>
6  <meta name="keywords" content="linepass1turn">
7  <meta name="description" content="LINEPASS1TURN - Track particle forward or backwards in one turn of the ring">
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">at</a> &gt; linepass1turn.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 at&nbsp;<img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
19
20<h1>linepass1turn
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>LINEPASS1TURN - Track particle forward or backwards in one turn of the ring</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 [x, ATindex, LostBeam] = linepass1turn(x0, Family0, DeviceList0, Family, DeviceList) </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">LINEPASS1TURN - Track particle forward or backwards in one turn of the ring
31  [x, ATIndex] = linepass1turn(x0, Family, DeviceList)
32  [x, ATIndex] = linepass1turn(x0, ATIndex)
33
34  INPUTS
35  1. x0 - 6-component column vector {Default: [.001 0 .001 0 0]'}
36          Initial particle launch condition at the start of the ring (see ringpass)
37          AT units are meters &amp; radians.
38  2. Location to measure turns: Family / DeviceList  {Default: 'BPMx'}
39                                  or
40                                ATIndex
41
42     NOTE: Family can be a MiddlyLayer family or AT family.
43           If using at AT family, then DeviceList is an index array (see family2atindex).   
44
45  OUTPUTS
46  1. x - Single turn data (6 x BPM Number)
47  2. ATIndex - AT index vector
48
49  EXAMPLES
50  1. Get the starting coordinates for a kick at HCM[7 1]
51     x = linepass1turn([.001 0 .001 0 0 0]', HCM, [7 1], 1);
52
53  See also <a href="getturns.html" class="code" title="function [xAllBPMs, ATindex, LostBeam] = getturns(x0, N, Family, DeviceList)">getturns</a>
54
55  Note: this function is still under development!!!
56
57  Written by Greg Portmann</pre></div>
58
59<!-- crossreference -->
60<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
61This function calls:
62<ul style="list-style-image:url(../matlabicon.gif)">
63<li><a href="family2atindex.html" class="code" title="function [ATIndexList, ErrorFlag] = family2atindex(Family, varargin);">family2atindex</a> FAMILY2ATINDEX - Returns the AT index for a given family</li></ul>
64This function is called by:
65<ul style="list-style-image:url(../matlabicon.gif)">
66</ul>
67<!-- crossreference -->
68
69
70<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
71<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [x, ATindex, LostBeam] = linepass1turn(x0, Family0, DeviceList0, Family, DeviceList)</a>
720002 <span class="comment">%LINEPASS1TURN - Track particle forward or backwards in one turn of the ring</span>
730003 <span class="comment">%  [x, ATIndex] = linepass1turn(x0, Family, DeviceList)</span>
740004 <span class="comment">%  [x, ATIndex] = linepass1turn(x0, ATIndex)</span>
750005 <span class="comment">%</span>
760006 <span class="comment">%  INPUTS</span>
770007 <span class="comment">%  1. x0 - 6-component column vector {Default: [.001 0 .001 0 0]'}</span>
780008 <span class="comment">%          Initial particle launch condition at the start of the ring (see ringpass)</span>
790009 <span class="comment">%          AT units are meters &amp; radians.</span>
800010 <span class="comment">%  2. Location to measure turns: Family / DeviceList  {Default: 'BPMx'}</span>
810011 <span class="comment">%                                  or</span>
820012 <span class="comment">%                                ATIndex</span>
830013 <span class="comment">%</span>
840014 <span class="comment">%     NOTE: Family can be a MiddlyLayer family or AT family.</span>
850015 <span class="comment">%           If using at AT family, then DeviceList is an index array (see family2atindex).</span>
860016 <span class="comment">%</span>
870017 <span class="comment">%  OUTPUTS</span>
880018 <span class="comment">%  1. x - Single turn data (6 x BPM Number)</span>
890019 <span class="comment">%  2. ATIndex - AT index vector</span>
900020 <span class="comment">%</span>
910021 <span class="comment">%  EXAMPLES</span>
920022 <span class="comment">%  1. Get the starting coordinates for a kick at HCM[7 1]</span>
930023 <span class="comment">%     x = linepass1turn([.001 0 .001 0 0 0]', HCM, [7 1], 1);</span>
940024 <span class="comment">%</span>
950025 <span class="comment">%  See also getturns</span>
960026 <span class="comment">%</span>
970027 <span class="comment">%  Note: this function is still under development!!!</span>
980028 <span class="comment">%</span>
990029 <span class="comment">%  Written by Greg Portmann</span>
1000030
1010031
1020032 <span class="keyword">global</span> THERING
1030033 <span class="keyword">if</span> isempty(THERING)
1040034     error(<span class="string">'THERING is not defined.'</span>);
1050035 <span class="keyword">end</span>
1060036
1070037
1080038 <span class="comment">% AT units meters &amp; radians</span>
1090039 <span class="keyword">if</span> nargin &lt; 1
1100040     x0 = [];
1110041 <span class="keyword">end</span>
1120042 <span class="keyword">if</span> isempty(x0)
1130043     <span class="comment">% 1 mm starting offset</span>
1140044     x0 = [.001 0, 0.001, 0, 0, 0]';
1150045 <span class="keyword">end</span>
1160046
1170047 x0 = x0(:);
1180048 <span class="keyword">if</span> size(x0,1) == 4
1190049     x0 = [x0; 0; 0];
1200050 <span class="keyword">elseif</span> size(x0,1) ~= 6
1210051     error(<span class="string">'x0 must be a 4x1 or 6x1 vector.'</span>);
1220052 <span class="keyword">end</span>
1230053
1240054 <span class="keyword">if</span> nargin &lt; 2
1250055     Family0 = [];
1260056 <span class="keyword">end</span>
1270057 <span class="keyword">if</span> isempty(Family0)
1280058     Family0 = <span class="string">'BPMx'</span>;
1290059 <span class="keyword">end</span>
1300060 <span class="keyword">if</span> nargin &lt; 3
1310061     DeviceList0 = [];
1320062 <span class="keyword">end</span>
1330063
1340064 <span class="keyword">if</span> nargin &lt; 4
1350065     Family = [];
1360066 <span class="keyword">end</span>
1370067 <span class="keyword">if</span> isempty(Family)
1380068     Family = <span class="string">'BPMx'</span>;
1390069 <span class="keyword">end</span>
1400070 <span class="keyword">if</span> nargin &lt; 5
1410071     DeviceList  = [];
1420072 <span class="keyword">end</span>
1430073
1440074
1450075 <span class="comment">% Get AT index</span>
1460076 <span class="keyword">if</span> ischar(Family0)
1470077     ATindex0 = <a href="family2atindex.html" class="code" title="function [ATIndexList, ErrorFlag] = family2atindex(Family, varargin);">family2atindex</a>(Family0, DeviceList0);
1480078     <span class="comment">% Watch for split magnets</span>
1490079     <span class="keyword">if</span> size(ATindex0,2) &gt; 1
1500080         ATindex0 = ATindex0(:,1);
1510081     <span class="keyword">end</span>
1520082     <span class="keyword">if</span> ischar(Family)
1530083         ATindex = <a href="family2atindex.html" class="code" title="function [ATIndexList, ErrorFlag] = family2atindex(Family, varargin);">family2atindex</a>(Family, DeviceList);
1540084         <span class="comment">% Watch for split magnets</span>
1550085         <span class="keyword">if</span> size(ATindex,2) &gt; 1
1560086             ATindex = ATindex(:,1);
1570087         <span class="keyword">end</span>
1580088     <span class="keyword">else</span>
1590089         <span class="comment">% AT index was input directly</span>
1600090         ATindex = Family;
1610091     <span class="keyword">end</span>
1620092 <span class="keyword">else</span>
1630093     <span class="comment">% AT index was input directly</span>
1640094     ATindex0 = Family0;
1650095     ATindex = DeviceList0;
1660096 <span class="keyword">end</span>
1670097
1680098 <span class="keyword">if</span> any(size(ATindex0) ~= [1 1])
1690099     error(<span class="string">'DeviceList0 must be one location.'</span>);
1700100 <span class="keyword">end</span>
1710101
1720102
1730103 ATindex = ATindex(:)';
1740104 <span class="keyword">if</span> isempty(ATindex)
1750105     error(<span class="string">'AT index empty.'</span>);
1760106 <span class="keyword">end</span>
1770107
1780108
1790109 <span class="comment">% Propagrate single turn data around the ring</span>
1800110 <span class="comment">% xAllBPMs (6 x BPM Number)</span>
1810111
1820112 <span class="comment">% Find forward and backward BPMs</span>
1830113 iForward  = find(ATindex &gt;= ATindex0);
1840114 iBackward = find(ATindex &lt; ATindex0);
1850115
1860116 x = [];
1870117 <span class="keyword">if</span> ~isempty(iForward)
1880118     Index = ATindex(iForward) - ATindex0 + 1;
1890119     x = linepass(THERING([ATindex0:ATindex(iForward(end))]), x0, Index);
1900120 <span class="keyword">end</span>
1910121
1920122 <span class="keyword">if</span> ~isempty(iBackward)
1930123     <span class="keyword">if</span> x0(5)~=0 | x0(6)~=0
1940124         fprintf(<span class="string">'   WARNING: x0(5) &amp; x0(6) must be zero for propagating backwards in the ring to work correctly.\n'</span>);
1950125     <span class="keyword">end</span>
1960126     
1970127     x0neg = x0;
1980128     x0neg([2 4]) = -x0neg([2 4]);
1990129
2000130     IndexBack = [ATindex(iBackward):ATindex0]-1;
2010131     IndexBack(1) = [];
2020132     
2030133     <span class="comment">%Index = ATindex0-IndexBack;</span>
2040134     ATIndexBack = ATindex(iBackward);
2050135     Index = ATindex0 - ATIndexBack + 1;
2060136     Index = Index(end:-1:1);
2070137
2080138     xb = linepass(THERING(IndexBack(end:-1:1)), x0neg, Index);
2090139     xb([2 4],:) = -xb([2 4],:);
2100140
2110141
2120142     x = [xb(:,end:-1:1) x];
2130143 <span class="keyword">end</span>
2140144</pre></div>
215<hr><address>Generated on Fri 18-May-2007 17:13:39 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> &copy; 2003</address>
216</body>
217</html>
Note: See TracBrowser for help on using the repository browser.