atQuantDiff creates a quantum diffusion element ELEM=ATQUANTDIFF(FAMNAME,DIFFMAT) uses the given diffusion matrix FAMNAME: family name DIFFMAT: Diffusion matrix ELEM=ATQUANTDIFF(FAMNANE,RING) computes the diffusion matrix of the ring FAMNAME: family name RING: lattice without radiation ELEM=ATQUANTDIFF(FAMNANE,RING,'orbit0',orbit) computes the diffusion matrix of the ring without computing the closed orbit orbit: closed orbit at beginning of the ring (this option is useful for the islands) The optional field Seed can be added. In that case, the seed of the random number generator is set at the first turn. ELEM=ATQUANTDIFF(FAMNANE,RING,'Seed',4) See also quantumDiff
0001 function elem=atQuantDiff(fname,varargin) 0002 %atQuantDiff creates a quantum diffusion element 0003 % 0004 %ELEM=ATQUANTDIFF(FAMNAME,DIFFMAT) uses the given diffusion matrix 0005 % FAMNAME: family name 0006 % DIFFMAT: Diffusion matrix 0007 % 0008 %ELEM=ATQUANTDIFF(FAMNANE,RING) computes the diffusion matrix of the ring 0009 % FAMNAME: family name 0010 % RING: lattice without radiation 0011 % 0012 %ELEM=ATQUANTDIFF(FAMNANE,RING,'orbit0',orbit) computes the diffusion 0013 % matrix of the ring without computing the closed orbit 0014 % orbit: closed orbit at beginning of the ring 0015 % (this option is useful for the islands) 0016 % 0017 % The optional field Seed can be added. In that case, the seed of the 0018 % random number generator is set at the first turn. 0019 % ELEM=ATQUANTDIFF(FAMNANE,RING,'Seed',4) 0020 % 0021 %See also quantumDiff 0022 0023 [rsrc,arg,method]=decodeatargs({[],'QuantDiffPass'},varargin); 0024 [method,rsrc]=getoption(rsrc,'PassMethod',method); 0025 [cl,rsrc]=getoption(rsrc,'Class','QuantDiff'); 0026 [orb,rsrc]=getoption(rsrc,'orbit0',[]); 0027 if iscell(arg) 0028 [ring2,radindex]=atradon(arg); 0029 if ~isempty(orb) 0030 dmat=quantumDiff(ring2,radindex,orb); 0031 else 0032 dmat=quantumDiff(ring2,radindex); 0033 end 0034 else 0035 dmat=arg; 0036 end 0037 elem=atbaselem(fname,method,'Class',cl,'Lmatp',lmatp(dmat),rsrc{:}); 0038 0039 function lmatp = lmatp(dmat) 0040 %lmat does Cholesky decomp of dmat unless diffusion is 0 in 0041 %vertical. Then do chol on 4x4 hor-long matrix and put 0's 0042 %in vertical 0043 try 0044 lmat66 = chol(dmat); 0045 catch 0046 lm=[chol(dmat([1 2 5 6],[1 2 5 6])) zeros(4,2);zeros(2,6)]; 0047 lmat66=lm([1 2 5 6 3 4],[1 2 5 6 3 4]); 0048 end 0049 lmatp=lmat66'; 0050 end 0051 end