Home > lattice > atfastring.m

atfastring

PURPOSE ^

ATFASTRING Generate simplified AT structures

SYNOPSIS ^

function [newring,newringrad] = atfastring(ring0,varargin)

DESCRIPTION ^

ATFASTRING Generate simplified AT structures

 The given ring structure is modified so that cavities are moved to the
 beginning and the rest of the ring is replaced by a linear 6x6 transfer
 matrix followed by a non-linear element providing tune shifts with
 amplitude and momentum.

   [FASTRING,FASTRINGRAD]=ATFASTRING(RING)

RING:          original AT structure, with no RF and no radiation.

FASTRING:      Structure containing unchanged cavities moved to the
               beginning, a linear 6x6 matrix and a  non-linear element
               simulating linear chromaticities and tune shift with
               amplitudes

FASTRINGRAD:   Structure containing unchanged cavities moved to the
               beginning, a diffusion element, a linear 6x6 transfer
               matrix and a non-linear element simulating linear
               chromaticities and tune shift with amplitudes

   [FASTRING,FASTRINGRAD]=ATFASTRING(RING,REFPTS)

 The ring is split at the specified locations, and each section is
 transformed in the same way as previously described

[FASTRING,FASTRINGRAD]=ATFASTRING(RING,'Plot') plots the tune shifts with amplitude

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [newring,newringrad] = atfastring(ring0,varargin)
0002 %ATFASTRING Generate simplified AT structures
0003 %
0004 % The given ring structure is modified so that cavities are moved to the
0005 % beginning and the rest of the ring is replaced by a linear 6x6 transfer
0006 % matrix followed by a non-linear element providing tune shifts with
0007 % amplitude and momentum.
0008 %
0009 %   [FASTRING,FASTRINGRAD]=ATFASTRING(RING)
0010 %
0011 %RING:          original AT structure, with no RF and no radiation.
0012 %
0013 %FASTRING:      Structure containing unchanged cavities moved to the
0014 %               beginning, a linear 6x6 matrix and a  non-linear element
0015 %               simulating linear chromaticities and tune shift with
0016 %               amplitudes
0017 %
0018 %FASTRINGRAD:   Structure containing unchanged cavities moved to the
0019 %               beginning, a diffusion element, a linear 6x6 transfer
0020 %               matrix and a non-linear element simulating linear
0021 %               chromaticities and tune shift with amplitudes
0022 %
0023 %   [FASTRING,FASTRINGRAD]=ATFASTRING(RING,REFPTS)
0024 %
0025 % The ring is split at the specified locations, and each section is
0026 % transformed in the same way as previously described
0027 %
0028 %[FASTRING,FASTRINGRAD]=ATFASTRING(RING,'Plot') plots the tune shifts with amplitude
0029 
0030 global GLOBVAL
0031 
0032 [doplot,varargin]=getflag(varargin,'Plot');
0033 split=getargs(varargin,{[]});
0034 if nargin < 2
0035     split=[];
0036 end
0037 if islogical(split)
0038     iend=[find(split) length(ring0)+1];
0039 else
0040     iend=[split length(ring0)+1];
0041 end
0042 ibeg=[1 iend(1:end-1)];
0043 
0044 xm=0.001;
0045 zm=0.0005;
0046 GLOBVAL.E0=atenergy(ring0);
0047 [lindata,tunes,xsi]=atlinopt(ring0,0); %#ok<ASGLU>
0048 gamma=(1+lindata.alpha.*lindata.alpha)./lindata.beta;
0049 
0050 ringv=arrayfun(@rearrange,ibeg,iend,'UniformOutput',false);
0051 ring=cat(1,ringv{:});
0052 markers=atgetcells(ring,'FamName','xbeg|xend');
0053 ringrad=atradon(ring);
0054 
0055 orbit4=zeros(6,sum(markers));
0056 orbit4(1:5,:)=findsyncorbit(ring,0,markers);
0057 orbit4=num2cell(orbit4,1);
0058 r1=detuning(ring,gamma,xm,zm,orbit4(:,1));
0059 
0060 orbit6=num2cell(findorbit6(ringrad,markers),1);
0061 
0062 counter=0;
0063 [rv,rvrad]=cellfun(@rebuild,ringv,orbit4(1:2:end),orbit6(1:2:end),...
0064     orbit4(2:2:end),orbit6(2:2:end),'UniformOutput',false);
0065 nonlin_elem=atbaselem('NonLinear','DeltaQPass',...
0066     'Betax',lindata.beta(1),'Betay',lindata.beta(2),...
0067     'Alphax',lindata.alpha(1),'Alphay',lindata.alpha(2),...
0068     'Qpx',xsi(1),'Qpy',xsi(2),...
0069     'A1',r1(1),'A2',r1(2),'A3',r1(4),...
0070     'T1',-orbit4{end},'T2',orbit4{end});
0071 nonlin_elemrad=atbaselem('NonLinear','DeltaQPass',...
0072     'Betax',lindata.beta(1),'Betay',lindata.beta(2),...
0073     'Alphax',lindata.alpha(1),'Alphay',lindata.alpha(2),...
0074     'Qpx',xsi(1),'Qpy',xsi(2),...
0075     'A1',r1(1),'A2',r1(2),'A3',r1(4),...
0076     'T1',-orbit6{end},'T2',orbit6{end});
0077 newring=cat(1,rv{:},nonlin_elem);
0078 newringrad=cat(1,rvrad{:},nonlin_elemrad);
0079 
0080     function rg=rearrange(i1,i2)
0081         slice=ring0(i1:i2-1);
0082         cav=atgetcells(slice,'Frequency') | atgetcells(slice,'Class','RingParam');
0083         rg=[slice(cav);atmarker('xbeg');slice(~cav);atmarker('xend')];
0084     end
0085     function [rg,rgrad]=rebuild(slice,o4b,o6b,o4e,o6e)
0086         counter=counter+1;
0087         cc=num2str(counter);
0088 %       m1=atmarker(['xbeg' cc]);
0089 %       m2=atmarker(['xend' cc]);
0090         i1=find(atgetcells(slice,'FamName','xbeg'),1);
0091         dipoles=atgetcells(slice,'BendingAngle');
0092         theta=atgetfieldvalues(slice(dipoles),'BendingAngle');
0093         lendp=atgetfieldvalues(slice(dipoles),'Length');
0094         s=diff(findspos(slice,[1 length(slice)+1]));
0095         I2=sum(abs(theta.*theta./lendp));
0096         
0097         m66norad=symplectify(findm66(slice(i1:end),[],o4b));
0098         lin_elem=atM66(['Linear_' cc],m66norad,'T1',-o4b,'T2',o4e,'Length',s,'I2',I2);
0099         rg=[slice(1:i1-1);lin_elem];
0100         
0101         [slicerad,radindex]=atradon(slice);
0102         diff_elem=atQuantDiff(['Diffusion_' cc],quantumDiff(slicerad,radindex,o6b));
0103         m66rad=findm66(slicerad(i1:end),[],o6b);
0104         lin_elemrad=atM66(['Linear_' cc],m66rad,'T1',-o6b,'T2',o6e,'Length',s,'I2',I2);
0105         rgrad=[slicerad(1:i1-1);lin_elemrad;diff_elem];
0106     end
0107     function r=detuning(ring,gamma,xm,zm,orbit)
0108         x2=linspace(0,xm.*xm,10);
0109         z2=linspace(0,zm.*zm,10);
0110         [nuxx,nuzx]=atnuampl(ring,sqrt(x2),1,orbit);
0111         [nuxz,nuzz]=atnuampl(ring,sqrt(z2),3,orbit);
0112         if doplot
0113             tune0=floor([nuxx(1);nuzz(1)]);
0114             subplot(2,1,1);
0115             plot(x2,[nuxx;nuzx]-tune0(:,ones(1,10)));
0116             subplot(2,1,2);
0117             plot(z2,[nuxz;nuzz]-tune0(:,ones(1,10)));
0118         end
0119         rx=([nuxx-nuxx(1);nuzx-nuzx(1)]*x2')./(x2([1 1],:)*x2')/gamma(1);
0120         rz=([nuxz-nuxz(1);nuzz-nuzz(1)]*z2')./(z2([1 1],:)*z2')/gamma(2);
0121         r=2*[rx;rz];
0122     end
0123 end

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