-
Notifications
You must be signed in to change notification settings - Fork 1
/
GaussianBeam_2D.m
146 lines (105 loc) · 4.51 KB
/
GaussianBeam_2D.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%% last update 15 March 2021, LNEV %%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all
close all
clc
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Parameters %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Power=1; % light power [Watt]
rmax = 5; Nr = 50; % rmax is the last point of the r vector and Nr is number of point of this vector [mm]
zmax = 2*rmax; Nz = 81; % same for z [mm]
FOI = 10; % angle of the beam FOI
w0=0.1; % waist of the Gaussian beam
z0=2; % z position of the waist
zcut = 5; % 2D xy-plot at z=zcut
xscale=[-1 1]*rmax; % ploting scale
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
r = logspace(-3,log10(rmax),Nr);
r = sort([0 r]);
z = logspace(-2,log10(zmax),Nz);
if isempty(find(z==zcut))
z=sort([z zcut ]);
end
[Z,R] = meshgrid(z,r);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%% Gaussian beam calculus %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ll=pi*w0*tan(FOI*pi/180);
zr=pi*w0^2./ll;
w=w0*sqrt(1+((Z-z0)/zr).^2);
L = Power*2/pi/w0^2 * (w0./w).^2 .* exp(-2*R.^2./w.^2) ;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%% indexes and values for plotting %%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
idz=find(z==zcut);
idxL=find(abs(r-xscale(1))==min(abs(r-xscale(1))) ) ;
idxR=find(abs(r-xscale(2))==min(abs(r-xscale(2))) ) ;
M=max( [ max(L(:,end)) max(L(idxL,:)) max(L(idxR,:)) ] ) ;
m=max(L(:,idz));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
figure('position',[50 50 1400 1000],'color','w')
%figure('position',[-3500 300 1400 1000],'color','w')
FS=15;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
subplot(2,2,1,'fontsize',FS)
hold on; grid on; box on;
pcolor(+r,z,squeeze(L)' )
pcolor(-r,z,squeeze(L)' )
plot(xscale,[1 1]*z(idz),'r--')
v=sort(logspace(log10(M), log10(m),3));
contour(+r,z,squeeze(L)',v,'showtext','off','linecolor','m','linewidth',1)
contour(-r,z,squeeze(L)',v,'showtext','off','linecolor','m','linewidth',1)
plot(+squeeze(w(1,:))',z,'w','linewidth',2)
plot(-squeeze(w(1,:))',z,'w','linewidth',2)
colormap(jet)
colorbar
shading flat
xlim(xscale)
ylim([0 2*xscale(end)])
m=150*Power/max(z)^2;
caxis([0 m])
xlabel('r (mm)')
ylabel('z (mm)')
title(strcat('FOI = ',num2str(FOI,'%.0f'),'deg @y=0mm' ))
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Nphi=50;
phi=linspace(0,2*pi,Nphi);
[PHI,RR] = meshgrid(phi,r);
Lp= repmat(L(:,:,1),[1 1 Nphi]);
X=RR.*cos(PHI);
Y=RR.*sin(PHI);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
subplot(2,2,2,'fontsize',FS)
hold on; grid on; box on;
pcolor(X,Y,squeeze(Lp(:,idz,:) ))
colormap(jet); colorbar; shading flat
xlim(xscale)
ylim(xscale)
axis equal
xlabel('r (mm)')
ylabel('r (mm)')
title(strcat('@z=',num2str(z(idz)),'mm'))
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
subplot(2,2,3,'fontsize',FS)
hold on; grid on; box on;
plot(+r,L(:,idz)/max(L(:,idz)) , 'r.-' )
plot(-r,L(:,idz)/max(L(:,idz)) , 'r.-' )
xlim(xscale)
xlabel('r (mm)')
ylabel('Amplitude (norm. u.)')
title(strcat('@z=',num2str(z(idz)), 'mm'))
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% here, I just check that the integral (the power) is constant over z
s = squeeze( trapz(r,2*pi*R.*squeeze(L),1) ) ;
subplot(2,2,4,'fontsize',FS)
hold on; grid on; box on;
plot(z,s,'ro-')
xlabel('z (mm)')
ylabel('Power (W)')
title(strcat('Total integral, P=', num2str(Power),'W'))