forked from ankrh/BPM-Matlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExample15.m
58 lines (50 loc) · 2.44 KB
/
Example15.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
P = BPMmatlab.model;
% This example shows that the mode finder can correctly find the LPlm
% labels even of modes of nonstandard radially symmetric refractive index
% distributions.
%
% The refractive index is chosen to approximate that of Figure 3 of
% https://www.rp-photonics.com/lp_modes.html. In the plot on the RP
% photonics site, the black curves correspond to the LP01 and LP02 modes,
% the red to the LP11 and LP12 modes, the green to the LP21 modes and the
% blue to the LP31 modes. Good agreement is seen between the modes found in
% the mode finder of BPM-Matlab and the modes on the RP site. Also, the
% LPlm labels found by BPM-Matlab (shown in the figure titles of the
% plotted modes) are correct. Interestingly, we see the LP01 mode exhibit a
% local minimum at the core center, a feature that is never present in the
% LP0m modes of step-index core fibers.
%
% Plotting of the refractive index is added to the RI function for
% visualization.
%
% The beam propagator is not run in this example.
%% General and solver-related settings
P.name = mfilename;
%% Resolution-related parameters (check for convergence)
P.Lx_main = 50e-6; % [m] x side length of main area
P.Ly_main = 50e-6; % [m] y side length of main area
P.Nx_main = 150; % x resolution of main area
P.Ny_main = 150; % y resolution of main area
P.padfactor = 1.25; % How much absorbing padding to add on the sides of the main area (1 means no padding, 2 means the absorbing padding on both sides is of thickness Lx_main/2)
P.dz_target = 1e-6; % [m] z step size to aim for
P.alpha = 3e14; % [1/m^3] "Absorption coefficient" per squared unit length distance out from edge of main area
%% Problem definition
P.lambda = 800e-9; % [m] Wavelength
P.n_background = 1.44; % [] (may be complex) Background refractive index, (in this case, the cladding)
P.n_0 = 1.443; % [] reference refractive index
P = initializeRIfromFunction(P,@calcRI);
%% Mode finder
P = findModes(P,15);
%% USER DEFINED RI FUNCTIONS
function n = calcRI(X,Y,n_background,nParameters)
% n may be complex
n = n_background*ones(size(X)); % Start by setting all pixels to n_background
R = sqrt(X.^2 + Y.^2);
n(R < 12e-6) = n_background + 0.0042*exp(-((R(R < 12e-6) - 3e-6)/3.5e-6).^2) + 0.001*exp(-((R(R < 12e-6) - 6e-6)/2e-6).^2);
figure(201);clf;
imagesc(X(1:end,1),Y(1,1:end),n.');
axis equal tight xy;colorbar;
xlabel('x [m]');ylabel('y [m]');
title('Radially symmetric refractive index');
drawnow;
end