source: MML/trunk/at/doc_html/at/atphysics/findm66.html @ 4

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

Initial import--MML version from SOLEIL@2013

File size: 9.7 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 findm66</title>
6  <meta name="keywords" content="findm66">
7  <meta name="description" content="FINDM66 numerically finds the 6x6 transfer matrix of an accelerator lattice">
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; <a href="index.html">atphysics</a> &gt; findm66.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/atphysics&nbsp;<img alt=">" border="0" src="../../right.png"></a></td></tr></table>-->
19
20<h1>findm66
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>FINDM66 numerically finds the 6x6 transfer matrix of an accelerator lattice</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 [M66, varargout] = findm66(RING, 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">FINDM66 numerically finds the 6x6 transfer matrix of an accelerator lattice
31  by differentiation of LINEPASS near the closed orbit
32  FINDM66 uses FINDORBIT6 to search for the closed orbit in 6-d
33  In order for this to work the ring MUST have a CAVITY element
34
35 M66 = FINDM66(RING)finds full one-turn 6-by-6
36    matrix at the entrance of the first element
37
38 [M66,T] = FINDM66(RING,REFPTS) in addition to M finds
39    6-by-6 transfer matrixes  between entrances of
40    the first element and each element indexed by REFPTS.
41    T is 6-by-6-by-length(REFPTS) 3 dimentional array.
42   
43    REFPTS is an array of increasing indexes that  select elements
44    from the range 1 to length(RING)+1.
45    See further explanation of REFPTS in the 'help' for FINDSPOS
46    When REFPTS is a vector FINDM44 is a 6-by-6-by-length(REFPTS) array
47    so that the set of indexes (:,:,i) selects the 6-by-6
48    matrix at the i-th reference point
49   
50    Note:
51    When REFPTS= [ 1 2 .. ] the fist point is the entrance of the first element
52    and T(:,:,1) - identity matrix
53    When REFPTS= [  .. length(RING)+1] the last point is the exit of the last element
54    and the entrance of the first element after 1 turn: T(:,:, ) = M
55
56 [M66, T, orbit] = FINDM66(RING, REFPTS) in addition returns the closed orbit
57    found in the process of lenearization
58
59 See also <a href="findm44.html" class="code" title="function [M44, varargout]  = findm44(LATTICE,DP,varargin)">findm44</a></pre></div>
60
61<!-- crossreference -->
62<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
63This function calls:
64<ul style="list-style-image:url(../../matlabicon.gif)">
65<li><a href="findorbit6.html" class="code" title="function orbit = findorbit6(RING,varargin);">findorbit6</a>   FINDORBIT6 finds closed orbit in the full 6-d phase space</li></ul>
66This function is called by:
67<ul style="list-style-image:url(../../matlabicon.gif)">
68<li><a href="ohmienvelope.html" class="code" title="function [ENVELOPE, RMSDP, RMSBL] = ohmienvelope(RING,RADELEMINDEX,varargin)">ohmienvelope</a>      OHMIENVELOPE calculates equilibrium beam envelope in a</li></ul>
69<!-- crossreference -->
70
71
72<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
73<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [M66, varargout] = findm66(RING, varargin);</a>
740002 <span class="comment">%FINDM66 numerically finds the 6x6 transfer matrix of an accelerator lattice</span>
750003 <span class="comment">%  by differentiation of LINEPASS near the closed orbit</span>
760004 <span class="comment">%  FINDM66 uses FINDORBIT6 to search for the closed orbit in 6-d</span>
770005 <span class="comment">%  In order for this to work the ring MUST have a CAVITY element</span>
780006 <span class="comment">%</span>
790007 <span class="comment">% M66 = FINDM66(RING)finds full one-turn 6-by-6</span>
800008 <span class="comment">%    matrix at the entrance of the first element</span>
810009 <span class="comment">%</span>
820010 <span class="comment">% [M66,T] = FINDM66(RING,REFPTS) in addition to M finds</span>
830011 <span class="comment">%    6-by-6 transfer matrixes  between entrances of</span>
840012 <span class="comment">%    the first element and each element indexed by REFPTS.</span>
850013 <span class="comment">%    T is 6-by-6-by-length(REFPTS) 3 dimentional array.</span>
860014 <span class="comment">%</span>
870015 <span class="comment">%    REFPTS is an array of increasing indexes that  select elements</span>
880016 <span class="comment">%    from the range 1 to length(RING)+1.</span>
890017 <span class="comment">%    See further explanation of REFPTS in the 'help' for FINDSPOS</span>
900018 <span class="comment">%    When REFPTS is a vector FINDM44 is a 6-by-6-by-length(REFPTS) array</span>
910019 <span class="comment">%    so that the set of indexes (:,:,i) selects the 6-by-6</span>
920020 <span class="comment">%    matrix at the i-th reference point</span>
930021 <span class="comment">%</span>
940022 <span class="comment">%    Note:</span>
950023 <span class="comment">%    When REFPTS= [ 1 2 .. ] the fist point is the entrance of the first element</span>
960024 <span class="comment">%    and T(:,:,1) - identity matrix</span>
970025 <span class="comment">%    When REFPTS= [  .. length(RING)+1] the last point is the exit of the last element</span>
980026 <span class="comment">%    and the entrance of the first element after 1 turn: T(:,:, ) = M</span>
990027 <span class="comment">%</span>
1000028 <span class="comment">% [M66, T, orbit] = FINDM66(RING, REFPTS) in addition returns the closed orbit</span>
1010029 <span class="comment">%    found in the process of lenearization</span>
1020030 <span class="comment">%</span>
1030031 <span class="comment">% See also findm44</span>
1040032
1050033 FULL = 0;
1060034 <span class="keyword">switch</span> nargin
1070035     
1080036     <span class="keyword">case</span> 2
1090037       REFPTS = varargin{1};
1100038    <span class="keyword">case</span> 1
1110039        REFPTS = 1;
1120040     <span class="keyword">otherwise</span>
1130041      error(<span class="string">'Too many input arguments'</span>)
1140042 <span class="keyword">end</span>
1150043
1160044
1170045 NE = length(RING);
1180046 NR = length(REFPTS);
1190047
1200048 <span class="comment">% See if step size for numerical differentiation</span>
1210049 <span class="comment">% is set globally. Otherwise use 1e-7</span>
1220050 <span class="keyword">global</span> NUMDIFPARAMS
1230051 <span class="comment">% Transverse</span>
1240052 <span class="keyword">if</span> isfield(NUMDIFPARAMS,<span class="string">'XYStep'</span>)
1250053     dt = NUMDIFPARAMS.XYStep';
1260054 <span class="keyword">else</span>
1270055     dt =  1e-8;
1280056 <span class="keyword">end</span>
1290057 <span class="comment">% Longitudinal</span>
1300058 <span class="keyword">if</span> isfield(NUMDIFPARAMS,<span class="string">'DPStep'</span>)
1310059     dl = NUMDIFPARAMS.DPStep';
1320060 <span class="keyword">else</span>
1330061     dl =  1e-8;
1340062 <span class="keyword">end</span>
1350063
1360064
1370065 <span class="comment">% Calculate closed orbit in 6 dimensions (MUST have cavity in the ring)</span>
1380066 reforbit = <a href="findorbit6.html" class="code" title="function orbit = findorbit6(RING,varargin);">findorbit6</a>(RING,REFPTS);
1390067 <span class="comment">% Build a diagonal matrix of initial conditions</span>
1400068 D6 = [dt*eye(4),zeros(4,2);zeros(2,4), dl*eye(2)];
1410069 <span class="comment">% Add to the orbit_in</span>
1420070 RIN = reforbit(:,1)*ones(1,12) + [D6, -D6];
1430071
1440072 <span class="keyword">if</span> nargout &lt;= 1 <span class="comment">% Whole ring , NO REFPTS</span>
1450073     <span class="comment">% Propagate through the ring</span>
1460074     ROUT = ringpass(RING,RIN);
1470075     <span class="comment">% Calculate numerical derivative</span>
1480076     M66 = [(ROUT(:,1:4)-ROUT(:,7:10))./(2*dt), (ROUT(:,5:6)-ROUT(:,11:12))./(2*dl)];
1490077    <span class="keyword">return</span>
1500078 <span class="keyword">else</span>                   
1510079     <span class="comment">% Calculate matrixes at all REFPTS. Use linepass</span>
1520080     <span class="comment">% Need to include the exit of the RING to REFPTS array</span>
1530081     <span class="keyword">if</span>(REFPTS(NR)~=NE+1)
1540082         REFPTS = [REFPTS NE+1];
1550083         NR1 = NR+1;
1560084     <span class="keyword">else</span>
1570085         NR1 = NR;
1580086     <span class="keyword">end</span>
1590087     TMAT = linepass(RING,RIN,REFPTS);
1600088     <span class="comment">% Reshape, so that the otcome at each REFPTS is a separate page in a 3-dim array</span>
1610089     TMAT3 = reshape(TMAT,6,12,NR1);
1620090     varargout{1} = [(TMAT3(:,1:4,1:NR)-TMAT3(:,7:10,1:NR))/(2*dt), (TMAT3(:,5:6,1:NR)-TMAT3(:,11:12,1:NR))/(2*dl)];
1630091     M66 = [(TMAT3(:,1:4,NR1)-TMAT3(:,7:10,NR1))/(2*dt), (TMAT3(:,5:6,NR1)-TMAT3(:,11:12,NR1))/(2*dl)];
1640092 <span class="keyword">end</span>
1650093
1660094 <span class="comment">% Return closed orbit if requested</span>
1670095 <span class="keyword">if</span> nargout == 3
1680096    varargout{2} = reforbit;
1690097 <span class="keyword">end</span></pre></div>
170<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> &copy; 2003</address>
171</body>
172</html>
Note: See TracBrowser for help on using the repository browser.