source: ETALON/simulations/Smith_Purcell_infinite_width.m @ 1

Last change on this file since 1 was 1, checked in by delerue, 12 years ago

Code from Mrie added.

File size: 7.2 KB
Line 
1%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3%  Computation of the SPM radiation using the surface current model
4%           M. Labat - Decembre 2011
5
6%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7
8clear all
9
10%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11%%% Input parameters %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12 %%% Electron beam
13Ee=100;                         % [MeV]
14Qe=0.6*1e-9;                      % [C] Charge   
15x_0=2e-3;                       % [m] Bunch height
16sigma_x=0.5e-3;                   % [m] Bucnh size
17sigma_y=1.1e-3;                   % [m] Bucnh size
18sigma_t=3.3/2.35*1e-12;          % [s] Bunch length --> SOLEIL
19%sigma_t=2/2.35*1e-15;           % [s] Bunch length --> LOA
20prof=1;                         % [1: gaussian / 2: other] Bunch profile   
21
22 %%% Gratings
23N_gratings=1;               % Number of gratings
24l=zeros(1,N_gratings);      % [m] Grating period
25Ng1=zeros(1,N_gratings);    % [-] Number of periods
26L1=zeros(1,N_gratings);     % [m] Grating length
27h1=zeros(1,N_gratings);     % [m] Tooth depth
28d1=zeros(1,N_gratings);     % [m] Tooth width
29F1=zeros(1,N_gratings);     % [-] Number of facets
30R1=zeros(1,N_gratings);
31
32    %%% Grating 1 parameters
33l(1)=1*1e-3;                % [m] Grating period --> SOLEIL
34%l(1)=1*1e-6;                % [m] Grating period --> LOA
35Ng(1)=40;                 % [-] Number of periods
36alpha1(1)=30*pi/180;        % [rad] Blaze angle
37    %%% Grating 2 parameters
38%l(2)=2*1e-3;                % [m] Grating period --> SOLEIL
39l(2)=5*1e-6;                % [m] Grating period --> LOA
40Ng(2)=2000;                 % [-] Number of periods
41alpha1(2)=20*pi/180;        % [rad] Blaze angle
42    %%% Grating 3 parameters
43l(3)=1*1e-3;               % [m] Grating period --> SOLEIL
44%l(3)=5*1e-6;                % [m] Grating period --> LOA
45Ng(3)=40;                 % [-] Number of periods
46alpha1(3)=30*pi/180;        % [rad] Blaze angle
47
48 %%% Detection
49theta_min=1*pi/9;           % [rad]
50theta_max=pi;               % [rad]
51phi=0;                      % [rad]
52
53%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
54%%% Variable definition %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
55 %%% Constants
56c=3e8;                  % [m/s]
57q=1.6e-19;              % [C]
58E0=0.511;               % [MeV] Electron rest energy
59Ne=Qe/q                             % [-] Nb of electrons
60gamma=Ee/E0;                        % [-]
61beta=sqrt(1-1/power(gamma,2));      % [-]
62v=beta*c;                           % [m]
63
64 %%% Time coordinates
65dt=sigma_t/20;          % Time sample
66Dt=sigma_t*100;         % Time window
67Nt=Dt/dt;
68t_0=Dt/2;                           % [s] Beam position in time
69for i=1:Nt
70    t(i)=i*dt;
71end
72
73if (prof==1)
74    rho = exp(-0.5*power((t-t_0)/sigma_t,2));     % gaussian profile
75else
76    rho=t*0;
77end;
78
79 %%% Electron beam Fourier transform
80m = length(rho);                % Window length
81n = pow2(nextpow2(m));          % Transform length
82TF_rho_tot = fft(rho,n);            % DFT
83for i=1:round(n/2)
84    nu(i)=i/(n*dt);
85    TF_rho(i)=TF_rho_tot(i);
86    nu_tot(i)=i/(n*dt);
87end
88for i=(round(n/2)+1):n
89    nu_tot(i)=(i-n)/(n*dt);
90end
91lambda_V=c./nu;
92Np=length(lambda_V);
93lambda_Vtot=c./nu_tot;
94TF_rho_norm=abs(TF_rho);
95TF_rho_norm=TF_rho_norm/max(TF_rho_norm);
96
97
98
99for j=1:N_gratings
100for ii=1:Np   
101   
102%%% Radiation parameters
103nh=1;                   % [-] Order of the radiation
104lambda=lambda_V(ii);    % [m]
105theta=acos(1/beta-nh*lambda/l(j))
106theta_V(j,ii)=acos(1/beta-nh*lambda/l(j));
107omega=2*pi*c/lambda;    % [1/s]
108
109%%% Calculation of lambda_e
110lambda_e=lambda/(2*pi)*1/(sqrt(1+power(gamma*beta*sin(theta)*sin(phi),2))/(gamma*beta*c));
111
112%%% Calculation of the grating parameters
113L=Ng(j)*l(j);                   % [m] Grating length
114l1=l(j)*power(cos(alpha1(j)),1);         % [m] Length of facet 1
115    % ? % power(cos(alpha1(j)),2);
116alpha2=pi/2+alpha1(j);          % [rad]
117l2=l(j)-l1;                     % [m] Length of facet 2
118h=abs(l1*tan(alpha1(j)));       % [m] Tooth heigth
119x=h/lambda_e;
120
121%%%
122kx=2*pi*sin(theta)*cos(phi)/lambda;
123ky=2*pi*sin(theta)*sin(phi)/lambda;
124
125tau1=2*pi*nh*cos(alpha1)-kx*l(j)*sin(alpha1(j));
126tau2=2*pi*nh*cos(alpha2)-kx*l(j)*sin(alpha2);
127
128eps1=2*pi*nh*l1/l(j)-kx*h;
129eps2=2*pi*nh*l2/l(j);
130
131a2t=(1/lambda_e*sin(alpha2)*(cos(eps2)*exp(-x)-cos(kx*h))+tau2*(sin(eps2)*exp(-x)+sin(kx*h)))/(power(1/lambda_e*sin(alpha2),2)+power(tau2,2));
132b2t=(1/lambda_e*sin(alpha2)*(sin(eps2)*exp(-x)+sin(kx*h))-tau2*(cos(eps2)*exp(-x)-cos(kx*h)))/(power(1/lambda_e*sin(alpha2),2)+power(tau2,2));
133   
134a1=(1/lambda_e*sin(alpha1(j))*(cos(eps1)-exp(-x))+tau1*sin(eps1))/(power(1/lambda_e*sin(alpha1(j)),2)+power(tau1,2));
135b1=(1/lambda_e*sin(alpha1(j))*sin(eps1)-tau1*(cos(eps1)-exp(-x)))/(power(1/lambda_e*sin(alpha1(j)),2)+power(tau1,2));
136
137a2=a2t*cos(2*pi*l1/l(j))-b2t*sin(2*pi*l1/l(j));
138b2=b2t*cos(2*pi*l1/l(j))+a2t*sin(2*pi*l1/l(j));
139
140as=a1*sin(alpha1(j))+a2*sin(alpha2);
141bs=b1*sin(alpha1(j))+b2*sin(alpha2);
142ac=a1*cos(alpha1(j))+a2*cos(alpha2);
143bc=b1*cos(alpha1(j))+b2*cos(alpha2);
144a111=(power(as,2)+power(bs,2))*power(cos(theta)*cos(phi),2);
145a112=(power(as,2)+power(bs,2))*power(ky*lambda_e,2)*power(cos(theta)*cos(phi),2);
146a113=(power(ac,2)+power(bc,2))*power(sin(theta),2);
147a114=-2*(as*ac+bs*bc)*sin(theta)*cos(theta)*cos(phi);
148a115=2*(as*bc-bs*ac)*ky*lambda_e*sin(theta)*cos(theta)*sin(phi);
149
150a211=power(as,2)+power(bs,2);
151a212=power(sin(phi),2)*(1+power(kx*lambda_e,2));
152
153aa1t=a111+a112+a113+a114+a115;
154aa2t=a211*a212;
155
156R2=aa1t+aa2t;
157R2_V(ii)=R2;
158%R2=0;
159%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
160
161
162%%% Calculation of W1
163W1=2*pi*power(q,2)*power(nh,2)*power(beta,3)/(power(l(j),2)*power(1-beta*cos(theta),3))*exp(-2*x_0/lambda_e)*L*R2;
164    % ? % *1e-7;
165    % ? % *power(beta,2);
166    % ? % *power(q*Ne,2);
167
168%%% Calculation of S_inc
169S_inc=Ne*0.5*exp(2*power(sigma_x/lambda_e,2)-2*x_0/lambda_e)*erfc(-x_0/(sqrt(2)*sigma_x)+sqrt(2)*sigma_x/lambda_e);
170
171%%% Calculation of S_coh
172S_coh_X=power(0.5*exp(0.5*power(sigma_x/lambda_e,2)-x_0/lambda_e)*erfc(-x_0/(sqrt(2)*sigma_x)+sigma_x/(sqrt(2)*lambda_e)),2);
173S_coh_Y=power(exp(-0.5*power(ky*sigma_y,2)),2);
174S_coh_Z=power(TF_rho_norm,2);
175S_coh=power(Ne,2)*S_coh_X*S_coh_Y*S_coh_Z;
176
177%%% Calculation of W
178if (theta>theta_min)&&(theta<theta_max)
179    W_inc(j,ii)=W1*S_inc/(L*0.01)                 % [J/sr/cm]
180    W(j,ii)=W1*(S_inc+S_coh(ii))/(L*0.01)   % [J/sr/cm]
181else
182    W_inc(j,ii)=0;
183    W(j,ii)=0;
184end
185
186end
187
188end
189
190figure(1)
191subplot(2,1,1)
192plot(t*1e12,rho)
193xlabel('Time (s)')
194ylabel('Power')
195title('{\bf Time sample}')
196grid on
197
198subplot(2,1,2)
199semilogx(lambda_V,TF_rho_norm)
200xlabel('Wavelength [m]')
201ylabel('TF_rho')
202title('{\bf Bunch profile Fourier Transform}')
203grid on
204%xlim([1e-6 1e-3])
205
206
207figure(2)
208subplot(2,1,1)
209loglog(lambda_V,W(1,:),'*');%,lambda_V,W(2,:),'*',lambda_V,W(3,:),'*');
210hold on
211loglog(lambda_V,W_inc(1,:));%,lambda_V,W_inc(2,:),lambda_V,W_inc(3,:));
212%xlim([200*1e-6 40000*1e-6])
213xlabel('Wavelength [m]')
214ylabel('W [J/sr/cm]')
215%ylim ([1e-10 1e-0])
216legend('g1','g2','g3',3)
217grid on
218hold off
219
220subplot(2,1,2)
221plot(theta_V(1,:)*180/pi,W(1,:),'*');%,theta_V(2,:),W(2,:),theta_V(3,:),W(3,:));
222%xlim([0 3.15])
223xlabel('Angle [degrees]')
224ylabel('W [J/sr]')
225grid on
226%ylim ([1e-20 1e-3])
227
228figure(3)
229plot(theta_V(1,:)*180/pi,R2_V(:),'*');
230xlabel('Angle [degres]')
231ylabel('R2')
232grid on
233
234
Note: See TracBrowser for help on using the repository browser.