source: MML/trunk/mml/doc_html/mml/steptune.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 steptune</title>
6  <meta name="keywords" content="steptune">
7  <meta name="description" content="STEPTUNE - Step the tune">
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; steptune.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&nbsp;<img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
19
20<h1>steptune
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>STEPTUNE - Step the tune</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 [DelQuad, ActuatorFamily] = steptune(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">STEPTUNE - Step the tune
31  [DelQuad, QuadFamily] = steptune(DeltaTune, TuneResponseMatrix);
32
33  Step change in storage ring tune using the default tune correctors (findmemberof('Tune Corrector'))</pre></div>
34
35<!-- crossreference -->
36<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
37This function calls:
38<ul style="list-style-image:url(../matlabicon.gif)">
39<li><a href="findmemberof.html" class="code" title="function  FamilyName = findmemberof(MemberString, Field)">findmemberof</a>  FINDMEMBEROF - Finds all family members</li><li><a href="getsp.html" class="code" title="function [SP, tout, DataTime, ErrorFlag] = getsp(Family, varargin)">getsp</a>  GETSP - Gets setpoint channels</li><li><a href="gettuneresp.html" class="code" title="function [TuneMatrix, FileName] = gettuneresp(varargin)">gettuneresp</a>  GETTUNERESP - Loads the tune response vector (or matrix) for multiple quadrupole families</li><li><a href="setsp.html" class="code" title="function ErrorFlag = setsp(Family, varargin)">setsp</a>      SETSP - Makes an absolute setpoint change to the 'Setpoint' field</li></ul>
40This function is called by:
41<ul style="list-style-image:url(../matlabicon.gif)">
42<li><a href="settune.html" class="code" title="function [DelQuad, ActuatorFamily] = settune(varargin)">settune</a>      SETTUNE - Set the tune</li></ul>
43<!-- crossreference -->
44
45
46<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
47<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [DelQuad, ActuatorFamily] = steptune(varargin)</a>
480002 <span class="comment">%STEPTUNE - Step the tune</span>
490003 <span class="comment">%  [DelQuad, QuadFamily] = steptune(DeltaTune, TuneResponseMatrix);</span>
500004 <span class="comment">%</span>
510005 <span class="comment">%  Step change in storage ring tune using the default tune correctors (findmemberof('Tune Corrector'))</span>
520006
530007 <span class="comment">%  INPUTS</span>
540008 <span class="comment">%  1.             | Change in Horizontal Tune |</span>
550009 <span class="comment">%     DeltaTune = |                           |</span>
560010 <span class="comment">%                 | Change in Vertical Tune   |</span>
570011 <span class="comment">%  2. TuneResponseMatrix - Tune response matrix {Default: findmemberof('Tune Corrector')}</span>
580012 <span class="comment">%  3. ActuatorFamily -  Quadrupole to vary, ex {'Q7', 'Q9'} {Default: findmemberof('Tune Corrector')}</span>
590013 <span class="comment">%  4. Optional override of the units:</span>
600014 <span class="comment">%     'Physics'  - Use physics  units</span>
610015 <span class="comment">%     'Hardware' - Use hardware units</span>
620016 <span class="comment">%  5. Optional override of the mode:</span>
630017 <span class="comment">%     'Online'    - Set/Get data online</span>
640018 <span class="comment">%     'Model'     - Set/Get data on the simulated accelerator using AT</span>
650019 <span class="comment">%     'Simulator' - Set/Get data on the simulated accelerator using AT</span>
660020 <span class="comment">%     'Manual'    - Set/Get data manually</span>
670021 <span class="comment">%</span>
680022 <span class="comment">%</span>
690023 <span class="comment">%  OUTPUTS</span>
700024 <span class="comment">%  1. DelQuad</span>
710025 <span class="comment">%  2. QuadFamily - Families used (cell array)</span>
720026 <span class="comment">%</span>
730027 <span class="comment">%  ALGORITHM</span>
740028 <span class="comment">%     SVD method</span>
750029 <span class="comment">%  DelQuad = inv(TuneResponseMatrix) * DeltaTune</span>
760030
770031 <span class="comment">%</span>
780032 <span class="comment">%  Written by Gregory J. Portmann</span>
790033 <span class="comment">%  Modified by Laurent S. Nadolski</span>
800034 <span class="comment">%   06/01/06 - Introduction of ActuatorFamily as a input</span>
810035
820036 <span class="comment">% Initialize</span>
830037
840038 UnitsFlag = {};
850039 ModeFlag = {};
860040 <span class="keyword">for</span> i = length(varargin):-1:1
870041     <span class="keyword">if</span> strcmpi(varargin{i},<span class="string">'physics'</span>)
880042         UnitsFlag = varargin(i);
890043         varargin(i) = [];
900044     <span class="keyword">elseif</span> strcmpi(varargin{i},<span class="string">'hardware'</span>)
910045         UnitsFlag = varargin(i);
920046         varargin(i) = [];
930047     <span class="keyword">elseif</span> strcmpi(varargin{i},<span class="string">'Simulator'</span>) | strcmpi(varargin{i},<span class="string">'Model'</span>)
940048         ModeFlag = varargin(i);
950049         varargin(i) = [];
960050     <span class="keyword">elseif</span> strcmpi(varargin{i},<span class="string">'online'</span>)
970051         ModeFlag = varargin(i);
980052         varargin(i) = [];
990053     <span class="keyword">elseif</span> strcmpi(varargin{i},<span class="string">'manual'</span>)
1000054         ModeFlag = varargin(i);
1010055         varargin(i) = [];
1020056     <span class="keyword">end</span>       
1030057 <span class="keyword">end</span>
1040058
1050059 <span class="keyword">if</span> length(varargin) &gt;= 1
1060060     DeltaTune = varargin{1};
1070061 <span class="keyword">else</span>
1080062     DeltaTune = [];   
1090063 <span class="keyword">end</span>
1100064 <span class="keyword">if</span> isempty(DeltaTune)
1110065     answer = inputdlg({<span class="string">'Change the horizontal tune by'</span>, <span class="string">'Change the vertical tune by'</span>},<span class="string">'STEPTUNE'</span>,1,{<span class="string">'0'</span>,<span class="string">'0'</span>});
1120066     <span class="keyword">if</span> isempty(answer)
1130067         <span class="keyword">return</span>
1140068     <span class="keyword">end</span>
1150069     DeltaTune(1,1) = str2num(answer{1});
1160070     DeltaTune(2,1) = str2num(answer{2});
1170071 <span class="keyword">end</span>
1180072
1190073 DeltaTune = DeltaTune(:);
1200074 <span class="keyword">if</span> size(DeltaTune,1) ~= 2
1210075     error(<span class="string">'Input must be a 2x1 column vector.'</span>);
1220076 <span class="keyword">end</span>
1230077 <span class="keyword">if</span> DeltaTune(1)==0 &amp;&amp; DeltaTune(2)==0
1240078     <span class="keyword">return</span>
1250079 <span class="keyword">end</span>
1260080
1270081 <span class="keyword">if</span> length(varargin) &gt;= 2
1280082     TuneResponseMatrix = varargin{2};
1290083 <span class="keyword">else</span>
1300084     TuneResponseMatrix = [];   
1310085 <span class="keyword">end</span>
1320086 <span class="keyword">if</span> isempty(TuneResponseMatrix)
1330087     TuneResponseMatrix = <a href="gettuneresp.html" class="code" title="function [TuneMatrix, FileName] = gettuneresp(varargin)">gettuneresp</a>(UnitsFlag{:});
1340088 <span class="keyword">end</span>
1350089 <span class="keyword">if</span> isempty(TuneResponseMatrix)
1360090     error(<span class="string">'The tune response matrix must be an input or available in one of the default response matrix files.'</span>);
1370091 <span class="keyword">end</span>
1380092
1390093 <span class="comment">% User ActuatorFamily</span>
1400094 <span class="keyword">if</span> length(varargin) &gt;= 3
1410095     ActuatorFamily = varargin{3};
1420096 <span class="keyword">else</span>
1430097     ActuatorFamily = <a href="findmemberof.html" class="code" title="function  FamilyName = findmemberof(MemberString, Field)">findmemberof</a>(<span class="string">'Tune Corrector'</span>)';
1440098     <span class="keyword">if</span> isempty(ActuatorFamily)
1450099         ActuatorFamily = {<span class="string">'QF'</span>,<span class="string">'QD'</span>};
1460100     <span class="keyword">end</span>
1470101 <span class="keyword">end</span>
1480102
1490103 <span class="comment">% It's probably wise to check the .Units fields</span>
1500104
1510105 <span class="comment">% 1. SVD Tune Correction</span>
1520106 <span class="comment">% Decompose the tune response matrix:</span>
1530107 [U, S, V] = svd(TuneResponseMatrix, <span class="string">'econ'</span>);
1540108 <span class="comment">% TuneResponseMatrix = U*S*V'</span>
1550109 <span class="comment">%</span>
1560110 <span class="comment">% The V matrix columns are the singular vectors in the quadrupole magnet space</span>
1570111 <span class="comment">% The U matrix columns are the singular vectors in the TUNE space</span>
1580112 <span class="comment">% U'*U=I and V*V'=I</span>
1590113 <span class="comment">%</span>
1600114 <span class="comment">% TUNECoef is the projection onto the columns of TuneResponseMatrix*V(:,Ivec) (same space as spanned by U)</span>
1610115 <span class="comment">% Sometimes it's interesting to look at the size of these coefficients with singular value number.</span>
1620116 TUNECoef = diag(diag(S).^(-1)) * U' * DeltaTune;
1630117 <span class="comment">%</span>
1640118 <span class="comment">% Convert the vector TUNECoef back to coefficents of TuneResponseMatrix</span>
1650119 DelQuad = V * TUNECoef;
1660120
1670121
1680122 <span class="comment">% 2. Square matrix solution</span>
1690123 <span class="comment">% DelQuad = inv(TuneResponseMatrix) * DeltaTune;</span>
1700124
1710125
1720126 <span class="comment">% 3. Least squares solution</span>
1730127 <span class="comment">% DelQuad = inv(TuneResponseMatrix'*TuneResponseMatrix)*TuneResponseMatrix' * DeltaTune;</span>
1740128 <span class="comment">%</span>
1750129 <span class="comment">% see Matlab help for &quot;Matrices and Linear Algebra&quot; to see what this does</span>
1760130 <span class="comment">% If overdetermined, then &quot;\&quot; is least squares</span>
1770131 <span class="comment">%</span>
1780132 <span class="comment">% If underdetermined (like more than 2 quadrupole families), then only the</span>
1790133 <span class="comment">% columns with the 2 biggest norms will be keep.  The rest of the quadupole</span>
1800134 <span class="comment">% families with have zero effect.  Hence, constraints would have to be added for</span>
1810135 <span class="comment">% this method to work.</span>
1820136 <span class="comment">% DelQuad = TuneResponseMatrix \ DeltaTune;</span>
1830137
1840138
1850139
1860140 <span class="comment">% Make the setpoint change</span>
1870141 SP = <a href="getsp.html" class="code" title="function [SP, tout, DataTime, ErrorFlag] = getsp(Family, varargin)">getsp</a>(ActuatorFamily, UnitsFlag{:}, ModeFlag{:});
1880142
1890143 <span class="keyword">if</span> iscell(SP)
1900144     <span class="keyword">for</span> i = 1:length(SP)
1910145         SP{i} = SP{i} + DelQuad(i);
1920146     <span class="keyword">end</span>
1930147 <span class="keyword">else</span>
1940148     SP = SP + DelQuad;
1950149 <span class="keyword">end</span>
1960150
1970151 <a href="setsp.html" class="code" title="function ErrorFlag = setsp(Family, varargin)">setsp</a>(ActuatorFamily, SP, UnitsFlag{:}, ModeFlag{:});
1980152</pre></div>
199<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>
200</body>
201</html>
Note: See TracBrowser for help on using the repository browser.