Home > at > linepass1turn.m

linepass1turn

PURPOSE ^

LINEPASS1TURN - Track particle forward or backwards in one turn of the ring

SYNOPSIS ^

function [x, ATindex, LostBeam] = linepass1turn(x0, Family0, DeviceList0, Family, DeviceList)

DESCRIPTION ^

LINEPASS1TURN - Track particle forward or backwards in one turn of the ring
  [x, ATIndex] = linepass1turn(x0, Family, DeviceList)
  [x, ATIndex] = linepass1turn(x0, ATIndex)

  INPUTS
  1. x0 - 6-component column vector {Default: [.001 0 .001 0 0]'}
          Initial particle launch condition at the start of the ring (see ringpass)
          AT units are meters & radians.
  2. Location to measure turns: Family / DeviceList  {Default: 'BPMx'}
                                  or
                                ATIndex

     NOTE: Family can be a MiddlyLayer family or AT family.
           If using at AT family, then DeviceList is an index array (see family2atindex).   

  OUTPUTS
  1. x - Single turn data (6 x BPM Number)
  2. ATIndex - AT index vector 

  EXAMPLES
  1. Get the starting coordinates for a kick at HCM[7 1]
     x = linepass1turn([.001 0 .001 0 0 0]', HCM, [7 1], 1);

  See also getturns

  Note: this function is still under development!!!

  Written by Greg Portmann

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [x, ATindex, LostBeam] = linepass1turn(x0, Family0, DeviceList0, Family, DeviceList)
0002 %LINEPASS1TURN - Track particle forward or backwards in one turn of the ring
0003 %  [x, ATIndex] = linepass1turn(x0, Family, DeviceList)
0004 %  [x, ATIndex] = linepass1turn(x0, ATIndex)
0005 %
0006 %  INPUTS
0007 %  1. x0 - 6-component column vector {Default: [.001 0 .001 0 0]'}
0008 %          Initial particle launch condition at the start of the ring (see ringpass)
0009 %          AT units are meters & radians.
0010 %  2. Location to measure turns: Family / DeviceList  {Default: 'BPMx'}
0011 %                                  or
0012 %                                ATIndex
0013 %
0014 %     NOTE: Family can be a MiddlyLayer family or AT family.
0015 %           If using at AT family, then DeviceList is an index array (see family2atindex).
0016 %
0017 %  OUTPUTS
0018 %  1. x - Single turn data (6 x BPM Number)
0019 %  2. ATIndex - AT index vector
0020 %
0021 %  EXAMPLES
0022 %  1. Get the starting coordinates for a kick at HCM[7 1]
0023 %     x = linepass1turn([.001 0 .001 0 0 0]', HCM, [7 1], 1);
0024 %
0025 %  See also getturns
0026 %
0027 %  Note: this function is still under development!!!
0028 %
0029 %  Written by Greg Portmann
0030 
0031 
0032 global THERING
0033 if isempty(THERING)
0034     error('THERING is not defined.');
0035 end
0036 
0037 
0038 % AT units meters & radians
0039 if nargin < 1
0040     x0 = [];
0041 end
0042 if isempty(x0)
0043     % 1 mm starting offset
0044     x0 = [.001 0, 0.001, 0, 0, 0]';
0045 end
0046 
0047 x0 = x0(:);
0048 if size(x0,1) == 4
0049     x0 = [x0; 0; 0];
0050 elseif size(x0,1) ~= 6
0051     error('x0 must be a 4x1 or 6x1 vector.');
0052 end
0053 
0054 if nargin < 2
0055     Family0 = [];
0056 end
0057 if isempty(Family0)
0058     Family0 = 'BPMx';
0059 end
0060 if nargin < 3
0061     DeviceList0 = [];
0062 end
0063 
0064 if nargin < 4
0065     Family = [];
0066 end
0067 if isempty(Family)
0068     Family = 'BPMx';
0069 end
0070 if nargin < 5
0071     DeviceList  = [];
0072 end
0073 
0074 
0075 % Get AT index
0076 if ischar(Family0)
0077     ATindex0 = family2atindex(Family0, DeviceList0);
0078     % Watch for split magnets
0079     if size(ATindex0,2) > 1
0080         ATindex0 = ATindex0(:,1);
0081     end
0082     if ischar(Family)
0083         ATindex = family2atindex(Family, DeviceList);
0084         % Watch for split magnets
0085         if size(ATindex,2) > 1
0086             ATindex = ATindex(:,1);
0087         end
0088     else
0089         % AT index was input directly
0090         ATindex = Family;
0091     end
0092 else
0093     % AT index was input directly
0094     ATindex0 = Family0;
0095     ATindex = DeviceList0;
0096 end
0097 
0098 if any(size(ATindex0) ~= [1 1])
0099     error('DeviceList0 must be one location.');
0100 end
0101 
0102 
0103 ATindex = ATindex(:)';
0104 if isempty(ATindex)
0105     error('AT index empty.');
0106 end
0107 
0108 
0109 % Propagrate single turn data around the ring
0110 % xAllBPMs (6 x BPM Number)
0111 
0112 % Find forward and backward BPMs
0113 iForward  = find(ATindex >= ATindex0);
0114 iBackward = find(ATindex < ATindex0);
0115 
0116 x = [];
0117 if ~isempty(iForward)
0118     Index = ATindex(iForward) - ATindex0 + 1;
0119     x = linepass(THERING([ATindex0:ATindex(iForward(end))]), x0, Index);
0120 end
0121 
0122 if ~isempty(iBackward)
0123     if x0(5)~=0 | x0(6)~=0
0124         fprintf('   WARNING: x0(5) & x0(6) must be zero for propagating backwards in the ring to work correctly.\n');
0125     end
0126     
0127     x0neg = x0;
0128     x0neg([2 4]) = -x0neg([2 4]);
0129 
0130     IndexBack = [ATindex(iBackward):ATindex0]-1;
0131     IndexBack(1) = [];
0132     
0133     %Index = ATindex0-IndexBack;
0134     ATIndexBack = ATindex(iBackward);
0135     Index = ATindex0 - ATIndexBack + 1;
0136     Index = Index(end:-1:1);
0137 
0138     xb = linepass(THERING(IndexBack(end:-1:1)), x0neg, Index);
0139     xb([2 4],:) = -xb([2 4],:);
0140 
0141 
0142     x = [xb(:,end:-1:1) x];
0143 end
0144

Generated on Fri 18-May-2007 17:13:39 by m2html © 2003