source: MML/trunk/mml/amp2mm.m @ 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: 2.1 KB
Line 
1function mm = amp2mm(CMfamily, Amps, CMDevList, varargin)
2%AMPS2MM - Returns the maximum millimeter orbit change per change in corrector
3%  mm = amps2mm(CMFamily, Amps, CMDevList, varargin)
4%
5%  INPUTS
6%  1. CMFamily - Corrector magnet family name (ex. 'HCM', 'VCM')
7%  2. Amps - Change in corrector magnet strength
8%  3. CMDevList - Corrector magnet device list
9%  4. varargin - Inputs sent to getrespmat function call
10%
11%  OUTPUTS
12%  1. mm - Maximum change in orbit produces by a change in
13%          corrector strength of Amps.
14%
15%  NOTES
16%  1. mm and Amps happen to be the hardware units for the ALS.  This function
17%     actually works in whatever the hardware units are for the middlelayer.
18%
19%  ALGORITHM
20%  Based on the response matrix, mm = R * Amps, the maximum change in the
21%  orbit due to a corrector change can be found.
22%
23%  See also mm2amp
24%
25%  Written by Greg Portmann
26
27
28% Input checking
29if nargin < 2
30    error('Must have at least two inputs (Family & Amps)');
31end
32if nargin < 3
33    CMDevList = [];
34end
35if isempty(CMDevList)
36    CMDevList = family2dev(CMfamily);
37end
38if (size(CMDevList,1) == 1)
39    CMDevList = elem2dev(CMfamily, CMDevList);
40end
41
42
43% Response matrix
44if ~isempty(findstr(upper(CMfamily),'H')) || ~isempty(findstr(upper(CMfamily),'X'))
45    Smat = getrespmat(gethbpmfamily, [], CMfamily, CMDevList, varargin{:});
46elseif ~isempty(findstr(upper(CMfamily),'V')) || ~isempty(findstr(upper(CMfamily),'Y'))
47    Smat = getrespmat(getvbpmfamily, [], CMfamily, CMDevList, varargin{:});
48else
49    error('Not sure if corrector family is horizontal or vertical.');
50end
51
52
53if isempty(Amps)
54    error('Amps is empty');
55elseif all(size(Amps) == [1 1])
56    Amps = Amps * ones(size(CMDevList,1),1);
57elseif size(Amps,1) == size(CMDevList,1)
58    % input OK
59else
60    error('Rows of Amps must be equal to the rows of CMDevList or a scalar!');
61end
62
63
64% Check for missing correctors
65[iFound, iNotFound] = findrowindex(CMDevList, family2dev(CMfamily,0));
66if ~isempty(iNotFound)
67    error('   Not all correctors found.\n');
68end
69
70
71% Main
72for j = 1:size(Amps,2)
73    for i = 1:size(CMDevList,1)
74        mm(i,j) = Amps(i,j) * max(Smat(:,i));
75    end
76end
77
Note: See TracBrowser for help on using the repository browser.