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