ATBEAM generates a particle distribution according to a sigma matrix PARTICLES=ATBEAM(NP,SIGMA) Generate a particle distribution according to a sigma matrix PARTICLES=ATBEAM(NP,SIGMA,ORBIT) adds a center of mass to the distribution% INPUTS 1. NP number of particles 2. SIGMA beam matrix (2x2, 4x4, 6x6) 3. ORBIT closed orbit OUPUTS 1. PARTICLES particle distribution NOTES 1. random generator is randn See also atsigma
0001 function particle_dist = atbeam(np,sigma,orbit) 0002 %ATBEAM generates a particle distribution according to a sigma matrix 0003 % PARTICLES=ATBEAM(NP,SIGMA) Generate a particle distribution according to a sigma matrix 0004 % PARTICLES=ATBEAM(NP,SIGMA,ORBIT) adds a center of mass to the distribution% 0005 % 0006 % INPUTS 0007 % 1. NP number of particles 0008 % 2. SIGMA beam matrix (2x2, 4x4, 6x6) 0009 % 3. ORBIT closed orbit 0010 % 0011 % OUPUTS 0012 % 1. PARTICLES particle distribution 0013 % 0014 % NOTES 0015 % 1. random generator is randn 0016 % 0017 % See also atsigma 0018 0019 % 0020 %See also ATPLOTBEAM, ATSIGMA 0021 0022 % ampl=sqrt(-2*log(rand(3,np))); 0023 % phase=2*pi()*rand(3,np); 0024 % v=[ampl.*cos(phase);ampl.*sin(phase)]; 0025 v=randn(size(sigma,1),np); 0026 try 0027 l=chol(sigma); 0028 catch 0029 a=[chol(sigma([1 2 5 6],[1 2 5 6])) zeros(4,2);zeros(2,6)]; 0030 l=a([1 2 5 6 3 4],[1 2 5 6 3 4]); 0031 end 0032 if nargin < 3 0033 particle_dist=l'*v; 0034 else 0035 particle_dist=orbit(:,ones(1,np)) + l'*v; 0036 end 0037 end