Home > ALS > StorageRing > ffdeltasp.m

ffdeltasp

PURPOSE ^

[DelHCM, DelVCM, DelQF, DelQD] = ffdeltasp(Sector, Gap, LongitudinalGap, GeV)

SYNOPSIS ^

function [DelHCM, DelVCM, DelQF, DelQD] = ffdeltasp(Sector, Gap, LongitudinalGap, GeV)

DESCRIPTION ^

 [DelHCM, DelVCM, DelQF, DelQD] = ffdeltasp(Sector, Gap, LongitudinalGap, GeV)

 Inputs:
   Sector (column vector)
   Gap and LongitudinalGap must have the same number of columns
   Sector, Gap, and LongitudinalGap must have the same number of rows

 Defaults:
   if 0 or 1 inputs, then Gap=getid and LongitudinalGap=getepu
   if 2 inputs, then LongitudinalGap = zeros(size(Gap))

 Outputs
   Each column corresponds to the sum of all the sectors
   DelHCM, DelVCM, DelQF, DelQD are sized to the full family size
   Note:  if Sector has more than one element then HCM, VCM, QF, QD and their
          associated lists correspond to only the last element.  It does not make
          sense to sum corrections from different sectors.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [DelHCM, DelVCM, DelQF, DelQD] = ffdeltasp(Sector, Gap, LongitudinalGap, GeV)
0002 % [DelHCM, DelVCM, DelQF, DelQD] = ffdeltasp(Sector, Gap, LongitudinalGap, GeV)
0003 %
0004 % Inputs:
0005 %   Sector (column vector)
0006 %   Gap and LongitudinalGap must have the same number of columns
0007 %   Sector, Gap, and LongitudinalGap must have the same number of rows
0008 %
0009 % Defaults:
0010 %   if 0 or 1 inputs, then Gap=getid and LongitudinalGap=getepu
0011 %   if 2 inputs, then LongitudinalGap = zeros(size(Gap))
0012 %
0013 % Outputs
0014 %   Each column corresponds to the sum of all the sectors
0015 %   DelHCM, DelVCM, DelQF, DelQD are sized to the full family size
0016 %   Note:  if Sector has more than one element then HCM, VCM, QF, QD and their
0017 %          associated lists correspond to only the last element.  It does not make
0018 %          sense to sum corrections from different sectors.
0019 
0020 % Revision History:
0021 %
0022 % 2003-02-25, Christoph Steier
0023 %        Added quadrupole feed forward for EPU in sector 11 and longitudinal dipole feed forward
0024 % 2005-12-21, Greg Portmann
0025 %        Changed for new middle layer.  Copies srcontrol5 for tune correction.
0026 
0027 
0028 HCMelem = dev2elem('HCM', family2dev('HCM'));
0029 VCMelem = dev2elem('VCM', family2dev('VCM'));
0030 
0031 
0032 if nargin < 1
0033     Sector = [];
0034 end
0035 if isempty(Sector)
0036     Sector = family2dev('ID');
0037 end
0038 if nargin < 2
0039     Gap = [];
0040 end
0041 if isempty(Gap)
0042     Gap = getsp('ID', Sector);
0043 end
0044 if nargin < 3
0045     LongitudinalGap = [];
0046 end
0047 if isempty(LongitudinalGap)
0048     LongitudinalGap = getepu(Sector);
0049 end
0050 if nargin < 4
0051     GeV = [];
0052 end
0053 if isempty(GeV)
0054     GeV = getenergy('Production');  % was getenergy, changed by GJP 2/13/2007
0055 end
0056 
0057 
0058 if size(Sector,2) == 1
0059     Sector = elem2dev('ID', Sector);
0060 end
0061 if size(Sector,1) ~= size(Gap,1)
0062     error('Rows of Sector & Gap must equal.');
0063 end
0064 if any(size(Gap) ~= size(LongitudinalGap))
0065     error('Sector and LongitudinalGap must be the same size');
0066 end
0067 
0068 
0069 
0070 % Initialize
0071 HCMDeviceList = family2dev('HCM');
0072 VCMDeviceList = family2dev('VCM');
0073 DelHCM = zeros(size(HCMDeviceList,1), size(Gap,2));
0074 DelVCM = zeros(size(VCMDeviceList,1), size(Gap,2));
0075 HCM    = zeros( 4, size(Gap,2));
0076 VCM    = zeros( 4, size(Gap,2));
0077 
0078 
0079 for i = 1:size(Sector,1);
0080     if any(Sector(i,1) == [4 6 11])
0081         if Sector(i,2) == 1
0082             HCMlist1 = [
0083                 Sector(i,1)-1  8;
0084                 Sector(i,1)-1 10;
0085                 Sector(i,1)-1  2;  % ???
0086                 Sector(i,1)    7]; % ???
0087 
0088             VCMlist1 = [
0089                 Sector(i,1)-1  8;
0090                 Sector(i,1)-1 10;
0091                 Sector(i,1)-1  2;  % ???
0092                 Sector(i,1)    7]; % ???
0093         else
0094             HCMlist1 = [
0095                 Sector(i,1)-1 10;
0096                 Sector(i,1)    1;
0097                 Sector(i,1)-1  2;  % ???
0098                 Sector(i,1)    7]; % ???
0099 
0100             VCMlist1 = [
0101                 Sector(i,1)-1 10;
0102                 Sector(i,1)    1;
0103                 Sector(i,1)-1  2;  % ???
0104                 Sector(i,1)    7]; % ???
0105         end
0106     else
0107         HCMlist1 = [
0108             Sector(i,1)-1 8;
0109             Sector(i,1)   1;
0110             Sector(i,1)-1 2;
0111             Sector(i,1)   7];
0112 
0113         VCMlist1 = [
0114             Sector(i,1)-1 8;
0115             Sector(i,1)   1;
0116             Sector(i,1)-1 2;
0117             Sector(i,1)   7];
0118     end
0119 
0120     iHCM = findrowindex(HCMlist1, HCMDeviceList);
0121     iVCM = findrowindex(VCMlist1, VCMDeviceList);
0122 
0123 
0124     % Read the vertical FF table
0125     [tableHCM, tableVCM, tableQ] = fftable(Sector(i,1), GeV);
0126     if (Sector(i) == 4) | (Sector(i) == 11)
0127         [GapsLongitudinal, Gaps, HCMtable1, HCMtable2, VCMtable1, VCMtable2] = fftableepu(Sector(i,1), GeV);
0128         %[GapsLongitudinal, Gaps, HCMtable1, HCMtable2, VCMtable1, VCMtable2] = fftableepu;
0129     end
0130 
0131     for j = 1:size(Gap,2)
0132         % just to make table1 work without errors
0133         tmpgap = Gap(i,j);
0134         if tmpgap >= tableHCM(1,1)
0135             tmpgap = tableHCM(1,1);
0136         end
0137         if tmpgap <= tableHCM(size(tableHCM,1),1)
0138             tmpgap = tableHCM(size(tableHCM,1),1);
0139         end
0140 
0141         HCM(1:2,j) = [
0142             interp1(tableHCM(:,1), tableHCM(:,2), tmpgap);
0143             interp1(tableHCM(:,1), tableHCM(:,3), tmpgap)];
0144 
0145         VCM(1:2,j) = [
0146             interp1(tableVCM(:,1), tableVCM(:,2), tmpgap);
0147             interp1(tableVCM(:,1), tableVCM(:,3), tmpgap)];
0148 
0149 
0150         % Read the longitudinal FF table
0151         if (Sector(i) == 4) | (Sector(i) == 11)
0152             % just to make table1 work without errors
0153             tmpgap = Gap(i,j);
0154             if tmpgap >= Gaps(1)
0155                 tmpgap = Gaps(1);
0156             end
0157             if tmpgap <= Gaps(end)
0158                 tmpgap = Gaps(end);
0159             end
0160 
0161             tmpLongitudinalGap = LongitudinalGap(i,j);
0162             if tmpLongitudinalGap < GapsLongitudinal(1)
0163                 tmpLongitudinalGap = GapsLongitudinal(1);
0164             end
0165             if tmpLongitudinalGap > GapsLongitudinal(end)
0166                 tmpLongitudinalGap = GapsLongitudinal(end);
0167             end
0168 
0169             hcm1 = interp2(GapsLongitudinal, Gaps, HCMtable1, tmpLongitudinalGap, tmpgap);
0170             hcm2 = interp2(GapsLongitudinal, Gaps, HCMtable2, tmpLongitudinalGap, tmpgap);
0171             vcm1 = interp2(GapsLongitudinal, Gaps, VCMtable1, tmpLongitudinalGap, tmpgap);
0172             vcm2 = interp2(GapsLongitudinal, Gaps, VCMtable2, tmpLongitudinalGap, tmpgap);
0173 
0174             HCM(:,j) = HCM(:,j) + [hcm1;hcm2;0;0];
0175             VCM(:,j) = VCM(:,j) + [vcm1;vcm2;0;0];
0176         end
0177 
0178         DelHCM(iHCM,j) = DelHCM(iHCM,j) + HCM(:,j);
0179         DelVCM(iVCM,j) = DelVCM(iVCM,j) + VCM(:,j);
0180     end
0181 end
0182 
0183 
0184 
0185 % Tune feed forward
0186 if nargout >= 3
0187     [DelQF, DelQD] = ffdeltaquad(Sector, Gap, GeV);
0188 end
0189 
0190 
0191 
0192 
0193

Generated on Thu 02-Aug-2007 13:16:07 by m2html © 2003