1 | function 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 |
---|
29 | if nargin < 2 |
---|
30 | error('Must have at least two inputs (Family & Amps)'); |
---|
31 | end |
---|
32 | if nargin < 3 |
---|
33 | CMDevList = []; |
---|
34 | end |
---|
35 | if isempty(CMDevList) |
---|
36 | CMDevList = family2dev(CMfamily); |
---|
37 | end |
---|
38 | if (size(CMDevList,1) == 1) |
---|
39 | CMDevList = elem2dev(CMfamily, CMDevList); |
---|
40 | end |
---|
41 | |
---|
42 | |
---|
43 | % Response matrix |
---|
44 | if ~isempty(findstr(upper(CMfamily),'H')) || ~isempty(findstr(upper(CMfamily),'X')) |
---|
45 | Smat = getrespmat(gethbpmfamily, [], CMfamily, CMDevList, varargin{:}); |
---|
46 | elseif ~isempty(findstr(upper(CMfamily),'V')) || ~isempty(findstr(upper(CMfamily),'Y')) |
---|
47 | Smat = getrespmat(getvbpmfamily, [], CMfamily, CMDevList, varargin{:}); |
---|
48 | else |
---|
49 | error('Not sure if corrector family is horizontal or vertical.'); |
---|
50 | end |
---|
51 | |
---|
52 | |
---|
53 | if isempty(Amps) |
---|
54 | error('Amps is empty'); |
---|
55 | elseif all(size(Amps) == [1 1]) |
---|
56 | Amps = Amps * ones(size(CMDevList,1),1); |
---|
57 | elseif size(Amps,1) == size(CMDevList,1) |
---|
58 | % input OK |
---|
59 | else |
---|
60 | error('Rows of Amps must be equal to the rows of CMDevList or a scalar!'); |
---|
61 | end |
---|
62 | |
---|
63 | |
---|
64 | % Check for missing correctors |
---|
65 | [iFound, iNotFound] = findrowindex(CMDevList, family2dev(CMfamily,0)); |
---|
66 | if ~isempty(iNotFound) |
---|
67 | error(' Not all correctors found.\n'); |
---|
68 | end |
---|
69 | |
---|
70 | |
---|
71 | % Main |
---|
72 | for j = 1:size(Amps,2) |
---|
73 | for i = 1:size(CMDevList,1) |
---|
74 | mm(i,j) = Amps(i,j) * max(Smat(:,i)); |
---|
75 | end |
---|
76 | end |
---|
77 | |
---|