✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。
🍎个人主页:Matlab王者助手
🍊个人信条:日日行 不怕千万里
⛄ 内容介绍
光学实验的计算机仿真不仅在科学与工程计算方面发挥着重要作用,而且在光学教学方面也引起了广大教育工作者的广泛关注.使用不同工具编写的各种光学实验仿真应用软件大量涌现,掀起了光学实验仿真的热潮.
⛄ 部分代码
%% solve the mode in the waveguide
close all;clear;clc;tic;
profile on;
profile clear;
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%% fiber information %%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
n_core=1.46; % core index
NA=0.12; % Numerical Aperture
n_clad=sqrt(n_core^2-NA^2); % clad index
n_eff=(n_clad+n_core)/2; % estimated propagating index
n_air=n_clad;
r_clad=25;
r_core=2.952;
r_air=50;
lambda=1.550; % wavelength in um
BCs=4;% 1 Dirichelet 2 Newmann 3 Anaytical 4 Transparent
tolerance=1e-4; % How accuate you want the effective index to be? The smaller the tolerance, the more accurate the answer would be.
field='ex'; % The polarization of the light. 'ex', 'ey' or 'scalar'
N1=201; % number of points between -r_clad and r_clad
N2=201; % number of points between r_clad and r_air
%% Analysis Window Discretization
vx=[-r_air N2 -r_core 2*N1+1 r_core N2 r_air];
vy=vx;
index=[n_core,n_clad,n_air];
radius=[r_core,r_clad,r_air];
[X,Y,Index]=fiber(vx,vy,index,radius);
% plot index profile
figure
h=surf(X,Y,Index);
set(h,'edgecolor','none')
set(gcf,'renderer','painters');
view(0,90)
colorbar;
axis equal;
%% Initial guess of wavefunction distriution
r=sqrt(X.^2+Y.^2);
V=2*pi*r_core*NA/lambda;
w0=5;
E0=exp(-r.^2/w0^2);
% plot initial field
figure
h=surf(X,Y,abs(E0).^2);
set(h,'edgecolor','none')
set(gcf,'renderer','painters');
view(0,0)
%% Mode calculation
E=E0;
n_out=[1 1 1 1]; % the index outside the boundary
[n_eff,E]=SVMODES(lambda,n_eff,X,Y,Index,E,BCs,field,tolerance);
n_eff
figure
surf(X,Y,abs(E).^2);
view(0,0);
shading interp;
figure
n=round(size(E,1)/2);
plot(X(1,:),abs(E(n,:)).^2);
toc;
profile report;
⛄ 运行结果
⛄ 参考文献
[1]曲伟娟. 基于Matlab的光学实验仿真[D]. 西北工业大学, 2004.
[2]钟可君, 张海林. 基于Matlab GUI设计的光学实验仿真[J]. 实验室研究与探索, 2010(10):3.