Home > pubtools > atdynap.m

atdynap

PURPOSE ^

ATDYNAP Compute the dynamic aperture

SYNOPSIS ^

function [xx,zz]=atdynap(ring,nt,dpp,rfrac)

DESCRIPTION ^

ATDYNAP        Compute the dynamic aperture


[XX,ZZ]=ATDYNAP(RING,NTURNS,DPP,RFRAC)

XX,ZZ :    limit of the dynamic aperture (betatron amplitudes in m)
RING :        Structure for tracking
NTURNS:    Number of turns
DPP :        Off-momentum value (default: 0)
RFRAC :    Resolution of the grid for checking the stability
            as a fraction of the maximum stable amplitude
            (default: 0.02)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [xx,zz]=atdynap(ring,nt,dpp,rfrac)
0002 %ATDYNAP        Compute the dynamic aperture
0003 %
0004 %
0005 %[XX,ZZ]=ATDYNAP(RING,NTURNS,DPP,RFRAC)
0006 %
0007 %XX,ZZ :    limit of the dynamic aperture (betatron amplitudes in m)
0008 %RING :        Structure for tracking
0009 %NTURNS:    Number of turns
0010 %DPP :        Off-momentum value (default: 0)
0011 %RFRAC :    Resolution of the grid for checking the stability
0012 %            as a fraction of the maximum stable amplitude
0013 %            (default: 0.02)
0014 
0015 np=5;
0016 rlist=0:0.001:0.1;
0017 if nargin < 4, rfrac=0.02; end
0018 if nargin < 3, dpp=0.0; end
0019 
0020 if isnumeric(dpp)
0021 clorb=[findorbit4(ring,dpp);dpp;0];
0022 else
0023    clorb=findorbit6(ring);
0024 end
0025 
0026 t1=linspace(0,pi,2*np+3);
0027 xpmax=ascan(ring,nt,clorb,0,rlist);
0028 zmax=ascan(ring,nt,clorb,0.5*pi,rlist);
0029 xmmax=ascan(ring,nt,clorb,pi,rlist);
0030 %
0031 % x1=[xpmax*ones(1,np+2) xmmax*ones(1,np+1)];
0032 % z1=zmax*ones(1,2*np+3);
0033 % tlist=atan2(sin(t1).*z1,cos(t1).*x1)';
0034 %
0035 % rr=NaN(2*np+3,1);
0036 % rr(1)=xpmax;
0037 % rr(np+2)=zmax;
0038 % rr(2*np+3)=xmmax;
0039 % for i=[2:np+1 np+3:2*np+2]
0040 %    rr(i)=ascan(ring,nt,clorb,tlist(i),rlist);
0041 % end
0042 % xx=rr.*cos(tlist);
0043 % zz=rr.*sin(tlist);
0044 slist=0.5:rfrac:2;
0045 xx=NaN(2*np+3,1);
0046 zz=xx;
0047 for i=1:np+3
0048    [xx(i),zz(i)]=bscan(ring,nt,clorb,...
0049       xpmax*cos(t1(i))*slist,zmax*sin(t1(i))*slist);
0050 end
0051 for i=np+4:2*np+3
0052    [xx(i),zz(i)]=bscan(ring,nt,clorb,...
0053       xmmax*cos(t1(i))*slist,zmax*sin(t1(i))*slist);
0054 end
0055 
0056 function rmax=ascan(ring,nt,clorb,theta,rlist)
0057 for rr=rlist
0058    rin=clorb+[rr*cos(theta);0;rr*sin(theta);0;0;0];
0059    [dummy,lost]=ringpass(ring,rin,nt,'KeepLattice'); %#ok<ASGLU>
0060    if lost, break; end
0061    rmax=rr;
0062 end
0063 fprintf('theta: %g, r: %g\n',theta,rmax);
0064 
0065 function [xmax,zmax]=bscan(ring,nt,clorb,xlist,zlist)
0066 xmax = 0.0;
0067 zmax = 0.0;
0068 for i=1:length(xlist)
0069    rin=clorb+[xlist(i);0;zlist(i);0;0;0];
0070    [dummy,lost]=ringpass(ring,rin,nt,'KeepLattice'); %#ok<ASGLU>
0071    if lost, break; end
0072    xmax=xlist(i);
0073    zmax=zlist(i);
0074 end
0075 fprintf('xm: %g, zm: %g\n',xmax,zmax);

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