Home > atphysics > ParameterSummaryFunctions > linopt.m

linopt

PURPOSE ^

LINOPT performs linear analysis of the COUPLED lattices

SYNOPSIS ^

function [LinData, varargout] = linopt(RING,DP,varargin);

DESCRIPTION ^

LINOPT performs linear analysis of the COUPLED lattices
   Notation is the same as in reference [3]


 LinData = LINOPT(RING,DP,REFPTS) is a MATLAB structure array with fields
    
   ElemIndex   - ordinal position in the RING 
   SPos        - longitudinal position [m]
   ClosedOrbit - closed orbit column vector with 
                 components x, px, y, py (momentums, NOT angles)                        
   Dispersion  - dispersion orbit position vector with 
                 components eta_x, eta_prime_x, eta_y, eta_prime_y
                 calculated with respect to the closed orbit with 
                 momentum deviation DP
   M44         - 4x4 transfer matrix M from the beginning of RING
                 to the entrance of the element for specified DP [2]
   A           - 2x2 matrix A in [3]
   B           - 2x2 matrix B in [3]
   C           - 2x2 matrix C in [3]            
   gamma       - gamma parameter of the transformation to eigenmodes 
   mu          - [ mux, muy] horizontal and vertical betatron phase
   beta        - [betax, betay] vector

   All values are specified at the entrance of each element specified in REFPTS. 
   REFPTS is an array of increasing indexes that  select elements 
   from the range 1 to length(LINE)+1. 
   See further explanation of REFPTS in the 'help' for FINDSPOS 

 [LinData,NU] = LINOPT() returns a vector of linear tunes
   [nu_u , nu_v] for two normal modes of linear motion [1] 

 [LinData,NU, KSI] = LINOPT() returns a vector of chromaticities ksi = d(nu)/(dP/P)
   [ksi_u , ksi_v] - derivatives of [nu_u , nu_v] 

 See also FINDSPOS TWISSRING TUNECHROM

   [1] D.Edwars,L.Teng IEEE Trans.Nucl.Sci. NS-20, No.3, p.885-888, 1973
   [2] E.Courant, H.Snyder
   [3] D.Sagan, D.Rubin Phys.Rev.Spec.Top.-Accelerators and beams, vol.2 (1999)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [LinData, varargout] = linopt(RING,DP,varargin);
0002 %LINOPT performs linear analysis of the COUPLED lattices
0003 %   Notation is the same as in reference [3]
0004 %
0005 %
0006 % LinData = LINOPT(RING,DP,REFPTS) is a MATLAB structure array with fields
0007 %
0008 %   ElemIndex   - ordinal position in the RING
0009 %   SPos        - longitudinal position [m]
0010 %   ClosedOrbit - closed orbit column vector with
0011 %                 components x, px, y, py (momentums, NOT angles)
0012 %   Dispersion  - dispersion orbit position vector with
0013 %                 components eta_x, eta_prime_x, eta_y, eta_prime_y
0014 %                 calculated with respect to the closed orbit with
0015 %                 momentum deviation DP
0016 %   M44         - 4x4 transfer matrix M from the beginning of RING
0017 %                 to the entrance of the element for specified DP [2]
0018 %   A           - 2x2 matrix A in [3]
0019 %   B           - 2x2 matrix B in [3]
0020 %   C           - 2x2 matrix C in [3]
0021 %   gamma       - gamma parameter of the transformation to eigenmodes
0022 %   mu          - [ mux, muy] horizontal and vertical betatron phase
0023 %   beta        - [betax, betay] vector
0024 %
0025 %   All values are specified at the entrance of each element specified in REFPTS.
0026 %   REFPTS is an array of increasing indexes that  select elements
0027 %   from the range 1 to length(LINE)+1.
0028 %   See further explanation of REFPTS in the 'help' for FINDSPOS
0029 %
0030 % [LinData,NU] = LINOPT() returns a vector of linear tunes
0031 %   [nu_u , nu_v] for two normal modes of linear motion [1]
0032 %
0033 % [LinData,NU, KSI] = LINOPT() returns a vector of chromaticities ksi = d(nu)/(dP/P)
0034 %   [ksi_u , ksi_v] - derivatives of [nu_u , nu_v]
0035 %
0036 % See also FINDSPOS TWISSRING TUNECHROM
0037 %
0038 %   [1] D.Edwars,L.Teng IEEE Trans.Nucl.Sci. NS-20, No.3, p.885-888, 1973
0039 %   [2] E.Courant, H.Snyder
0040 %   [3] D.Sagan, D.Rubin Phys.Rev.Spec.Top.-Accelerators and beams, vol.2 (1999)
0041 
0042  
0043 
0044 NE=length(RING);
0045 if(nargin==2)
0046    REFPTS= 1;
0047 else
0048    REFPTS=varargin{1};
0049 end
0050 
0051 NR=length(REFPTS);
0052   
0053 
0054 spos = findspos(RING,REFPTS);
0055 [M44, MS, orb] = findm44(RING,DP,REFPTS);
0056 
0057 LinData = struct('ElemIndex',num2cell(REFPTS),'SPos',num2cell(spos),...
0058     'ClosedOrbit',num2cell(orb,1),'M44',squeeze(num2cell(MS,[1 2]))');
0059 
0060 % Calculate A,B,C, gamma at the first element
0061 M =M44(1:2,1:2);
0062 N =M44(3:4,3:4);
0063 m =M44(1:2,3:4);
0064 n =M44(3:4,1:2);
0065 
0066 % 2-by-2 symplectic matrix
0067 S = [0 1; -1 0];
0068 H = m + S*n'*S';
0069 t = trace(M-N);
0070 
0071 g = sqrt(1 + sqrt(t*t/(t*t+4*det(H))))/sqrt(2);
0072 G = diag([g g]);
0073 C = -H*sign(t)/(g*sqrt(t*t+4*det(H)));
0074 A = G*G*M  -  G*(m*S*C'*S' + C*n) + C*N*S*C'*S';
0075 B = G*G*N  +  G*(S*C'*S'*m + n*C) + S*C'*S'*M*C;
0076 
0077 
0078    
0079 if REFPTS(1)==1 & NR>1
0080     START = 2;
0081     LinData(1).A=A;
0082     LinData(1).B=B;
0083     LinData(1).C=C;
0084     LinData(1).gamma=g;
0085     LinData(1).beta(1) = A(1,2)/sin(acos(trace(A/2)));
0086     LinData(1).beta(2) = B(1,2)/sin(acos(trace(B/2)));
0087 else
0088     START = 1;
0089 end
0090 
0091 
0092       
0093     
0094 
0095 
0096 % find  matrixes in all elements indexed by REFPTS
0097 for i=START:NR;
0098     M12 =LinData(i).M44(1:2,1:2);
0099     N12 =LinData(i).M44(3:4,3:4);
0100     m12 =LinData(i).M44(1:2,3:4);
0101     n12 =LinData(i).M44(3:4,1:2);
0102    
0103     g2 = sqrt(det(n12*C+G*N12));
0104     E12 = (G*M12-m12*S*C'*S')/g2;
0105     F12 = (n12*C+G*N12)/g2;
0106    
0107     LinData(i).gamma=g2;
0108     LinData(i).C=(M12*C+G*m12)*S*F12'*S';
0109     LinData(i).A=E12*A*S*E12'*S';
0110     LinData(i).B=F12*B*S*F12'*S';
0111     LinData(i).beta(1) = LinData(i).A(1,2)/sin(acos(trace(A/2)));
0112     LinData(i).beta(2) = LinData(i).B(1,2)/sin(acos(trace(B/2)));
0113  
0114 end
0115 
0116 
0117 
0118 if nargout > 1 
0119    cos_mu_x = trace(A)/2;
0120    cos_mu_y = trace(B)/2;
0121    varargout{1} = acos([cos_mu_x cos_mu_y])/2/pi;
0122 end
0123 
0124 if nargout == 3
0125     global NUMDIFPARAMS
0126 
0127     if isfield(NUMDIFPARAMS,'DPStep')
0128         dDP = NUMDIFPARAMS.DPStep';
0129     else
0130         dDP =  1e-8;
0131     end
0132     % Calculate tunes for DP+dDP
0133     [LD, TUNES] = linopt(RING,DP+dDP,1);
0134     varargout{2} = (TUNES - varargout{1})/dDP;
0135 end

Generated on Thu 24-Aug-2017 18:47:33 by m2html © 2005