0001 function [xx,zz]=atdynap(ring,nt,dpp,rfrac)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
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
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
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');
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');
0071 if lost, break; end
0072 xmax=xlist(i);
0073 zmax=zlist(i);
0074 end
0075 fprintf('xm: %g, zm: %g\n',xmax,zmax);