quantumDiff Compute the radiation-diffusion matrix DIFFMAT=QUANTUMDIFF(RING,RADINDEX) RING: Closed ring AT structure, containing radiative elements and RF cavity RADINDEX: Indices of elements where diffusion occurs, typically dipoles and quadrupoles. DIFFMAT=QUANTUMDIFF(ELEMS,RADINDEX,ORBIT0) ELEMS: AT structure RADINDEX: Indices of elements where diffusion occurs, typically dipoles and quadrupoles. ORBIT0: Initial 6-D closed orbit In this mode, ELEMS may be a section of a ring
0001 function DiffMat = quantumDiff(elems,radindex,orb0) 0002 %quantumDiff Compute the radiation-diffusion matrix 0003 % 0004 %DIFFMAT=QUANTUMDIFF(RING,RADINDEX) 0005 % 0006 % RING: Closed ring AT structure, containing radiative elements and 0007 % RF cavity 0008 % RADINDEX: Indices of elements where diffusion occurs, typically dipoles 0009 % and quadrupoles. 0010 % 0011 %DIFFMAT=QUANTUMDIFF(ELEMS,RADINDEX,ORBIT0) 0012 % 0013 % ELEMS: AT structure 0014 % RADINDEX: Indices of elements where diffusion occurs, typically dipoles 0015 % and quadrupoles. 0016 % ORBIT0: Initial 6-D closed orbit 0017 % 0018 % In this mode, ELEMS may be a section of a ring 0019 0020 NumElements=length(elems); 0021 0022 %[mring, ms, orbit] = findm66(ring,1:NumElements+1); 0023 if (nargin >= 3) 0024 orb=num2cell(linepass(elems, orb0, 1:NumElements),1)'; 0025 else 0026 orb=num2cell(findorbit6(elems, 1:NumElements),1)'; 0027 end 0028 0029 zr={zeros(6,6)}; 0030 B=zr(ones(NumElements,1)); % B{i} is the diffusion matrix of the i-th element 0031 0032 % calculate Radiation-Diffusion matrix B for elements with radiation 0033 B(radindex)=cellfun(@findmpoleraddiffmatrix,... 0034 elems(radindex),orb(radindex),'UniformOutput',false); 0035 0036 % Calculate cumulative Radiation-Diffusion matrix for the ring 0037 BCUM = zeros(6,6); 0038 % Batbeg{i} is the cumulative diffusion matrix from 0039 % 0 to the beginning of the i-th element 0040 Batbeg=[zr;cellfun(@cumulb,elems,orb,B,'UniformOutput',false)]; %#ok<NASGU> 0041 0042 DiffCum = BCUM; 0043 0044 DiffMat=(DiffCum+DiffCum')/2; 0045 0046 %Lmat=chol((DiffCum+DiffCum')/2); 0047 0048 function btx=cumulb(elem,orbit,b) 0049 % Calculate 6-by-6 linear transfer matrix in each element 0050 % near the equilibrium orbit 0051 m=findelemm66(elem,elem.PassMethod,orbit); 0052 % Cumulative diffusion matrix of the entire ring 0053 BCUM = m*BCUM*m' + b; 0054 btx=BCUM; 0055 end 0056 end 0057