Demo of using atfastring for fast tracking The ESRF lattice is loaded, cavity is set, and then the fast ring is created. An electron is tracked through the full lattice and fast ring and the tracking time and tracking results are compared.
0001 % Demo of using atfastring for fast tracking 0002 % The ESRF lattice is loaded, cavity is set, and then the fast ring is 0003 % created. 0004 % An electron is tracked through the full lattice and fast ring and 0005 % the tracking time and tracking results are compared. 0006 0007 clear all 0008 clc 0009 echo on 0010 0011 %load esrf ring 0012 ring=esrf; 0013 0014 % indcav=findcells(ring,'Class','RFCavity'); 0015 % cav=ring(indcav(1)); 0016 % ring(indcav(:))=[]; 0017 % ring=[cav;ring]; 0018 0019 % set RF cavity 0020 ring=atsetcavity(ring,8e6,0,992); 0021 0022 %Now, create fastring and fastringrad from ring. 0023 [fastring,fastringrad]=atfastring(ring); 0024 0025 0026 %Set an initial condition for tracking 0027 z0=[1e-5,0,0,0,1e-3,0]'; 0028 0029 %Now, track with full ring and with fast ring and time the computation. 0030 tic 0031 z1=ringpass(ring,z0,500); 0032 toc 0033 0034 tic 0035 z1fast=ringpass(fastring,z0,500); 0036 toc 0037 0038 0039 % Check tunes and chromaticity: 0040 [p,t,c]=atlinopt(ring,0,1); 0041 [pf,tf,cf]=atlinopt(fastring,0,1); 0042 0043 t 0044 tf 0045 c 0046 cf 0047 0048 % Now compare the horizontal and transverse tracking results. 0049 plot(1:length(z1),z1(1,:),'r',1:length(z1fast),z1fast(1,:),'b'); 0050 legend('full ring','fast ring'); 0051 xlabel('turns'); 0052 ylabel('x (m)'); 0053 0054 figure 0055 plot(z1(5,:),'r'); 0056 hold on 0057 plot(z1fast(5,:),'b'); 0058 legend('full ring','fast ring'); 0059 xlabel('turns'); 0060 ylabel('delta'); 0061 0062 0063 % figure 0064 % hold on 0065 % plot(z1fastrad(5,:),'-k');