MATLAB模拟任意Hollow Guassian Beam在平行通过有折射率且前后面均为椭圆面方程的shaping len之后变成实心类似基模光斑的程序和如何将hollow gaussian beams转变为实心光束通过空间光调制器上加载相位实现?程序是什么?
时间: 2024-05-12 20:15:46 浏览: 94
基于Matlab全息干涉图模拟仿真与相位重构
5星 · 资源好评率100%
以下是MATLAB模拟任意Hollow Guassian Beam在平行通过有折射率且前后面均为椭圆面方程的shaping len之后变成实心类似基模光斑的示例代码:
```matlab
% Parameters
w0 = 1; % beam waist
R = 10*w0; % curvature of input beam
lambda = 1; % wavelength
n = 1.5; % refractive index of shaping lens
L = 100*w0; % length of shaping lens
dx = 0.1*w0; % spatial resolution
dy = dx;
x = -10*w0:dx:10*w0; % spatial grid
y = x;
[X,Y] = meshgrid(x,y);
k = 2*pi/lambda; % wave number
zR = pi*w0^2/lambda; % Rayleigh range
% Input beam
w = w0*sqrt(1+(X.^2+Y.^2)/R^2);
phi = atan2(Y,X);
u_in = (w0./w).*exp(-((X.^2+Y.^2)/w0^2)).*exp(-1i*k*(X.^2+Y.^2)/(2*R)).*exp(1i*phi);
% Shaping lens
xl = linspace(-L/2,L/2,1000);
yl = sqrt(L^2/4-xl.^2);
yl = [-fliplr(yl), yl];
[xl,yl] = meshgrid(xl,yl);
zl = sqrt(L^2/4-yl.^2)*n;
zl = [-fliplr(zl), zl];
xl = repmat(xl(:),[1,length(x)]);
yl = repmat(yl(:),[1,length(x)]);
zl = repmat(zl(:),[1,length(x)]);
lens = exp(-1i*k*n*zl).*exp(1i*k*(xl.^2+yl.^2)/(2*n*zl));
% Output beam
u_out = zeros(size(u_in));
for i=1:length(x)
for j=1:length(y)
u_out(i,j) = sum(lens(:,i).*u_in(:,j))*dx*dy;
end
end
% Plotting
figure;
subplot(1,3,1);
imagesc(x,y,abs(u_in).^2);
colormap('hot'); axis image; axis off;
title('Input Beam');
subplot(1,3,2);
imagesc(xl(1,:),yl(:,1),abs(lens).^2);
colormap('hot'); axis image; axis off;
title('Shaping Lens');
subplot(1,3,3);
imagesc(x,y,abs(u_out).^2);
colormap('hot'); axis image; axis off;
title('Output Beam');
```
对于将hollow gaussian beams转变为实心光束通过空间光调制器上加载相位实现,可以使用以下代码:
```matlab
% Parameters
w0 = 1; % beam waist
lambda = 1; % wavelength
k = 2*pi/lambda; % wave number
dx = 0.1*w0; % spatial resolution
dy = dx;
x = -10*w0:dx:10*w0; % spatial grid
y = x;
[X,Y] = meshgrid(x,y);
% Input beam
w = w0*sqrt(1+(X.^2+Y.^2)/(10*w0)^2);
phi = atan2(Y,X);
u_in = (w0./w).*exp(-((X.^2+Y.^2)/w0^2)).*exp(1i*phi);
% Phase mask
phase = zeros(size(u_in));
for i=1:length(x)
for j=1:length(y)
r = sqrt(x(i)^2+y(j)^2);
if (r<=4*w0)
phase(j,i) = pi;
end
end
end
mask = exp(1i*phase);
% Output beam
u_out = u_in.*mask;
% Plotting
figure;
subplot(1,3,1);
imagesc(x,y,abs(u_in).^2);
colormap('hot'); axis image; axis off;
title('Input Beam');
subplot(1,3,2);
imagesc(x,y,abs(mask).^2);
colormap('hot'); axis image; axis off;
title('Phase Mask');
subplot(1,3,3);
imagesc(x,y,abs(u_out).^2);
colormap('hot'); axis image; axis off;
title('Output Beam');
```
这里使用了一个二元相位调制器,其中在中心区域(直径为4w0)添加了一个π的相位延迟,将hollow gaussian beams转换为实心光束。
阅读全文