-
Notifications
You must be signed in to change notification settings - Fork 1
/
epsSpher_f.m
113 lines (75 loc) · 2.92 KB
/
epsSpher_f.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
function[n,eps]=epsSpher_f(x,y,z,Rx,Ry,Rz,n1,n2,AbsorbingBoundaryCondition)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%% Optical index definition %%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[X,Y,Z]=meshgrid(x,y,z);
x0=0;y0=0;z0=0;
idXYZ = ((X-x0)/Rx).^2 + ((Y-y0)/Ry).^2 + ((Z-z0)/Rz).^2 < 1 ; %% elipse
n = n2*idXYZ + n1*(1-idXYZ); %% ridge optical index
%eps(Y<=0)=4+0i; %% substrate optical index
if AbsorbingBoundaryCondition==1
LOSS=1e-4;
n(:,:,1) = n(:,:,1) + LOSS*i;
n(:,:,end) = n(:,:,end) + LOSS*i;
n(1,:,2:end-1) = n(1,:,2:end-1) + LOSS*i;
n(end,:,2:end-1) = n(end,:,2:end-1) + LOSS*i;
n(2:end-1,1,2:end-1) = n(2:end-1,1,2:end-1) + LOSS*i;
n(2:end-1,end,2:end-1) = n(2:end-1,end,2:end-1) + LOSS*i;
end
eps=n.^2;
break
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
figure('Name','Optical index','position',[10 -50 1600 800])
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
subplot(2,3,1,'fontsize',15)
hold on;grid on;
pcolor(x*1e6,z*1e6,squeeze(n(round(end/2),:,:))')
colormap(cool)
colorbar
%xlim([-1 1]*Dx/2*1e6)
%ylim([-1 1]*Dz/2*1e6)
xlabel('x (um)')
ylabel('z (um)')
title(strcat('n-xz @y=0um'))
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
subplot(2,3,4,'fontsize',15)
hold on;grid on;
pcolor(y*1e6,z*1e6,squeeze(n(:,round(end/2),:))')
colormap(cool)
colorbar
%xlim([-1 1]*Dx/2*1e6)
%ylim([-1 1]*Dz/2*1e6)
xlabel('y (um)')
ylabel('z (um)')
title(strcat('n-yz @x=0um'))
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
subplot(2,3,2,'fontsize',15)
hold on;grid on;
idz=find(z>0);
idz=idz(1);
pcolor(x*1e6,y*1e6,squeeze(n(:,:,idz)))
colormap(cool)
colorbar
%xlim([-1 1]*Dy/2*1e6)
%ylim([-1 1]*Dy/2*1e6)
xlabel('x (um)')
ylabel('y (um)')
title(strcat('n-xy @z=',num2str(z(idz)*1e6,'%.2f'),'um'))
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
subplot(2,3,5,'fontsize',15)
hold on;grid on;view (-38, 20);
slice(x*1e6,y*1e6,z*1e6,n,[0],[0],[0])
xlabel('x (nm)')
ylabel('y (nm)')
zlabel('z (nm)')
title(strcat('n'))
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
subplot(2,3,3,'fontsize',15)
hold on;grid on;
plot(z*1e6,squeeze(n(round(end/2),round(end/2),:)) ,'b.-')
plot(z*1e6,squeeze(n(round(end/2),end,:)) ,'r.-')
xlabel('z (nm)')
ylabel('Optical index')
title(strcat('n-z @y=0um and \color{blue}x=0um ; \color{red}x=',num2str(x(end)*1e6),'um'))