source: MML/trunk/at/doc_html/at/atphysics/findrespm.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: 12.1 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 findrespm</title>
6  <meta name="keywords" content="findrespm">
7  <meta name="description" content="FINDRESPM computes the change in the closed orbit due to parameter perturbations">
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; findrespm.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>findrespm
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>FINDRESPM computes the change in the closed orbit due to parameter perturbations</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 C = findrespm(RING, OBSINDEX, PERTURB, PVALUE, 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">FINDRESPM computes the change in the closed orbit due to parameter perturbations
31 Two calling syntax options
32 1. FINDRESPM(RING, OBSINDEX, PERTURBINDEX, PVALUE, 'FIELD', M, N, ORBITFUNCTION, ARGS)
33 2. !!! not implemented yet FINDRESPM(RING, OBSINDEX, PERTURBGROUP, PVALUE, ORBITFUNCTION, ARGS)
34
35 RING      - ring lattice
36 OBSINDEX  - indexes of elements where the orbit is observed (at the entrance)
37 PERTURBINDEX  - Integer indexes of elements whose parameters are perturbed
38                 used with syntax 1 only.
39             
40 PERTURBGROUP  - cell array of AT paramgroups. See ATPARAMGROUP
41               used with syntax 2 only
42
43 PVALUE    - amount of peturbation
44             (Numeric array or scalar if all perturbations are the same magnitude)
45 
46 FIELD,M,N are only use with syntax 1.
47
48 FIELD     - field name of the parameter to perturb (string)
49
50 M,N       - index in the matrix, if the field is a matrix
51             For example to perturb the quadrupole field in a
52             multipole element
53             FIELD = 'PolynomB', M = 1, N = 2
54
55 ORBITFUNCTION  - specifies which of the FINDORBIT functions is used
56             
57             'findorbit4' (default)
58             'findsyncorbit'
59             'findorbit6'
60             
61 ARGS - additioanl arguments may passsed to some of the FINDORBIT functions
62             findorbit4     - constant momentum error dP
63             findsyncorbit  - fixed orbit lengthening dCT
64             
65
66 Returns a 1-by-4 cell array of O-by-P matrixes
67 where O = length(OBSINDEX) and P = length(PERTURB)
68 one for each of the close orbit components: X, PX, Y, PY
69 See also ATPARAMGROUP, <a href="findorbit.html" class="code" title="function [orbit, varargout]  = findorbit(RING,D, varargin);">FINDORBIT</a>, <a href="findorbit4.html" class="code" title="function orbit = findorbit4(RING,dP,varargin);">FINDORBIT4</a>, <a href="findorbit6.html" class="code" title="function orbit = findorbit6(RING,varargin);">FINDORBIT6</a>, <a href="findsyncorbit.html" class="code" title="function [orbit, varargout] = findsyncorbit(RING,dCT,varargin);">FINDSYNCORBIT</a></pre></div>
70
71<!-- crossreference -->
72<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
73This function calls:
74<ul style="list-style-image:url(../../matlabicon.gif)">
75<li><a href="findorbit4.html" class="code" title="function orbit = findorbit4(RING,dP,varargin);">findorbit4</a>        FINDORBIT4 finds closed orbit in the 4-d transverse phase</li><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><li><a href="findsyncorbit.html" class="code" title="function [orbit, varargout] = findsyncorbit(RING,dCT,varargin);">findsyncorbit</a>   FINDSYNCORBIT finds closed orbit, synchronous with the RF cavity</li></ul>
76This function is called by:
77<ul style="list-style-image:url(../../matlabicon.gif)">
78</ul>
79<!-- crossreference -->
80
81
82<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
83<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function C = findrespm(RING, OBSINDEX, PERTURB, PVALUE, varargin)</a>
840002 <span class="comment">%FINDRESPM computes the change in the closed orbit due to parameter perturbations</span>
850003 <span class="comment">% Two calling syntax options</span>
860004 <span class="comment">% 1. FINDRESPM(RING, OBSINDEX, PERTURBINDEX, PVALUE, 'FIELD', M, N, ORBITFUNCTION, ARGS)</span>
870005 <span class="comment">% 2. !!! not implemented yet FINDRESPM(RING, OBSINDEX, PERTURBGROUP, PVALUE, ORBITFUNCTION, ARGS)</span>
880006 <span class="comment">%</span>
890007 <span class="comment">% RING      - ring lattice</span>
900008 <span class="comment">% OBSINDEX  - indexes of elements where the orbit is observed (at the entrance)</span>
910009 <span class="comment">% PERTURBINDEX  - Integer indexes of elements whose parameters are perturbed</span>
920010 <span class="comment">%                 used with syntax 1 only.</span>
930011 <span class="comment">%</span>
940012 <span class="comment">% PERTURBGROUP  - cell array of AT paramgroups. See ATPARAMGROUP</span>
950013 <span class="comment">%               used with syntax 2 only</span>
960014 <span class="comment">%</span>
970015 <span class="comment">% PVALUE    - amount of peturbation</span>
980016 <span class="comment">%             (Numeric array or scalar if all perturbations are the same magnitude)</span>
990017 <span class="comment">%</span>
1000018 <span class="comment">% FIELD,M,N are only use with syntax 1.</span>
1010019 <span class="comment">%</span>
1020020 <span class="comment">% FIELD     - field name of the parameter to perturb (string)</span>
1030021 <span class="comment">%</span>
1040022 <span class="comment">% M,N       - index in the matrix, if the field is a matrix</span>
1050023 <span class="comment">%             For example to perturb the quadrupole field in a</span>
1060024 <span class="comment">%             multipole element</span>
1070025 <span class="comment">%             FIELD = 'PolynomB', M = 1, N = 2</span>
1080026 <span class="comment">%</span>
1090027 <span class="comment">% ORBITFUNCTION  - specifies which of the FINDORBIT functions is used</span>
1100028 <span class="comment">%</span>
1110029 <span class="comment">%             'findorbit4' (default)</span>
1120030 <span class="comment">%             'findsyncorbit'</span>
1130031 <span class="comment">%             'findorbit6'</span>
1140032 <span class="comment">%</span>
1150033 <span class="comment">% ARGS - additioanl arguments may passsed to some of the FINDORBIT functions</span>
1160034 <span class="comment">%             findorbit4     - constant momentum error dP</span>
1170035 <span class="comment">%             findsyncorbit  - fixed orbit lengthening dCT</span>
1180036 <span class="comment">%</span>
1190037 <span class="comment">%</span>
1200038 <span class="comment">% Returns a 1-by-4 cell array of O-by-P matrixes</span>
1210039 <span class="comment">% where O = length(OBSINDEX) and P = length(PERTURB)</span>
1220040 <span class="comment">% one for each of the close orbit components: X, PX, Y, PY</span>
1230041 <span class="comment">% See also ATPARAMGROUP, FINDORBIT, FINDORBIT4, FINDORBIT6, FINDSYNCORBIT</span>
1240042
1250043
1260044 O = length(OBSINDEX);
1270045 P = length(PERTURB);
1280046 C = {zeros(O,P),zeros(O,P),zeros(O,P),zeros(O,P)};
1290047
1300048 <span class="keyword">if</span> length(PVALUE) ~= P
1310049     PVALUE = PVALUE(ones(1,P(1)));
1320050 <span class="keyword">end</span>
1330051   
1340052
1350053 <span class="keyword">if</span> isnumeric(PERTURB)   <span class="comment">% syntax option 1</span>
1360054                         <span class="comment">% Integer indexes of perturbed elements.</span>
1370055                         <span class="comment">% More fields must be supplied.</span>
1380056                         <span class="comment">% setfield will be used to make perturbations</span>
1390057 <span class="keyword">if</span> nargin &lt; 7
1400058     error(<span class="string">'Incorrect number of inputs'</span>);
1410059 <span class="keyword">end</span>
1420060
1430061 <span class="keyword">if</span> ~ischar(varargin{1}) <span class="comment">% Check that the FIELD argument is a string</span>
1440062     error(<span class="string">'The 5-th argument FIELD must be a string'</span>);
1450063 <span class="keyword">end</span>
1460064     
1470065 <span class="keyword">if</span> ~isnumeric(varargin{2}) | length(varargin{2})&gt;1 <span class="comment">% Check that the M argument is a scalar</span>
1480066     error(<span class="string">'The 6-th argument FIELD must be a scalar'</span>);
1490067 <span class="keyword">end</span>
1500068 M = varargin{2}(1);
1510069
1520070 <span class="keyword">if</span> ~isnumeric(varargin{3}) | length(varargin{3})&gt;1 <span class="comment">% Check that the M argument is a scalar</span>
1530071     error(<span class="string">'The 7-th argument FIELD must be a scalar'</span>);
1540072 <span class="keyword">end</span>
1550073 N = varargin{3}(1);
1560074
1570075 <span class="keyword">if</span> nargin &gt; 7
1580076     ORBITFUNCTION = varargin{4};
1590077 <span class="keyword">else</span>
1600078     ORBITFUNCTION = <span class="string">'findorbit4'</span>;
1610079 <span class="keyword">end</span>
1620080     
1630081   
1640082 <span class="keyword">switch</span> ORBITFUNCTION
1650083 <span class="keyword">case</span> <span class="string">'findorbit4'</span> 
1660084     orbit_function_handle = @<a href="findorbit4.html" class="code" title="function orbit = findorbit4(RING,dP,varargin);">findorbit4</a>;
1670085     <span class="keyword">if</span> nargin == 9
1680086         orbit_function_args   = {varargin{5}, OBSINDEX};
1690087     <span class="keyword">else</span>
1700088         orbit_function_args   = {0, OBSINDEX};
1710089     <span class="keyword">end</span>
1720090 <span class="keyword">case</span> <span class="string">'findsyncorbit'</span>
1730091     orbit_function_handle = @<a href="findsyncorbit.html" class="code" title="function [orbit, varargout] = findsyncorbit(RING,dCT,varargin);">findsyncorbit</a>;
1740092     <span class="keyword">if</span> nargin == 9
1750093         orbit_function_args   = {varargin{5}, OBSINDEX};
1760094     <span class="keyword">else</span>
1770095         orbit_function_args   = {0, OBSINDEX};
1780096     <span class="keyword">end</span>
1790097 <span class="keyword">case</span> <span class="string">'findorbit6'</span>
1800098     orbit_function_handle = @<a href="findorbit6.html" class="code" title="function orbit = findorbit6(RING,varargin);">findorbit6</a>;
1810099     orbit_function_args   = {OBSINDEX};
1820100 <span class="keyword">otherwise</span> 
1830101     error([<span class="string">'Unknown FINDORBIT function: '</span>,ORBITFUNCTION]);
1840102 <span class="keyword">end</span>
1850103
1860104 <span class="comment">%ORBIT = findorbit4(RING,0,OBSINDEX);</span>
1870105
1880106
1890107 ORBIT = feval(orbit_function_handle,RING,orbit_function_args{:});
1900108
1910109 mn = {M,N};
1920110 <span class="keyword">for</span> i = 1:P
1930111     oldvalue = getfield(RING{PERTURB(i)},varargin{1},mn);
1940112     RING{PERTURB(i)} = setfield(RING{PERTURB(i)},varargin{1},mn,oldvalue+PVALUE(i));
1950113     ORBITPLUS  = feval(orbit_function_handle,RING,orbit_function_args{:});
1960114     RING{PERTURB(i)} = setfield(RING{PERTURB(i)},varargin{1},mn,oldvalue);
1970115     DORBIT = (ORBITPLUS - ORBIT);
1980116     C{1}(:,i) = DORBIT(1,:);
1990117     C{2}(:,i) = DORBIT(2,:);
2000118     C{3}(:,i) = DORBIT(3,:);
2010119     C{4}(:,i) = DORBIT(4,:);
2020120 <span class="keyword">end</span>
2030121 <span class="keyword">end</span></pre></div>
204<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>
205</body>
206</html>
Note: See TracBrowser for help on using the repository browser.