-
Notifications
You must be signed in to change notification settings - Fork 1
/
fmmtdno.m
124 lines (108 loc) · 4.7 KB
/
fmmtdno.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
%{
Copyright © 2020 Alexey A. Shcherbakov. All rights reserved.
This file is part of GratingFMM.
GratingFMM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
GratingFMM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GratingFMM. If not, see <https://www.gnu.org/licenses/>.
%}
%% description:
% calculation of a grating S-matrix by the Fourier Modal Method
% in the case of the diffraction by 2D gratings being periodic two
% dimensions of the Cartesian coordinates
%% input:
% no1, no2: numbers of Fourier harmonics
% kx0, ky0: incident plane wave x and y projections (Bloch wavevector projections)
% kg1, kg2: wavelength-to-period ratios
% psi: angle between periodicity directions (first direction is supposed
% to be parallel to axis X)
% kh: grating depth multiplied by the vacuum wavenumber
% eps1: permittivity of the substrate
% eps2: permittivity of the superstrate
% FE: Fourier matrix of the grating profile
%% output:
% SM: scattering matrix of size (2*no,2*no,2,2) where no = xno*yno
% is the total number of Fourier harmonics
% block SM(:,:,1,1) corresponds to refelection from substrate to substrate
% block SM(:,:,2,2) corresponds to refelection from superstrate to superstrate
% block SM(:,:,2,1) corresponds to transmission from substrate to superstrate
% block SM(:,:,1,2) corresponds to transmission from superstrate to substrate
% first (no) components in each of the two first dimensions of the S-matrix
% correspond to the TE polarization, and indeces from (no+1) to (2*no)
% correspond to the TM polarization
% central harmonic index is ind_0 = (ceil(xno/2)-1)*yno+ceil(yno/2)
% for example, an ampitude of the TE-polarized transmitted wave to i-th diffraction order
% from the substrate to the superstrate under the TM plane wave illumination
% with unit amplitude is SM(ind_0+i, no+ind_0, 2, 1)
%% implementation
function [SM, beta, TS, TC, EV, HV] = fmmtdno(no1, no2, kx0, ky0, kg1, kg2, psi, kh, eps1, eps2, FE)
no = no1*no2;
ib1 = 1:no;
ib2 = no+1:2*no;
ib3 = 2*no+1:3*no;
ib4 = 3*no+1:4*no;
% wavevector projections
[kz1, kz2, kx, ky, kxy] = fmmtdno_kxyz(no1, no2, kx0, ky0, kg1, kg2, psi, eps1, eps2);
ME = toeplitz2(FE{1,1},no1,no2);
MU = toeplitz2(FE{1,2},no1,no2);
% solve the eigenvalue problem:
EV = zeros(2*no,2*no);
HV = zeros(2*no,2*no);
% matrix for the electric field
EV(ib1,ib1) = ((kx').*MU).*ky;
EV(ib1,ib2) = -((kx').*MU).*kx;
EV(2*no*no+1:2*no+1:end) = EV(2*no*no+1:2*no+1:end) + 1;
EV(ib2,ib1) = ((ky').*MU).*ky;
EV(no+1:2*no+1:2*no*no) = EV(no+1:2*no+1:2*no*no) - 1;
EV(ib2,ib2) = -((ky').*MU).*kx;
% matrix for the magnetic field
HV(2*no*no+no+1:2*no+1:end) = HV(2*no*no+no+1:2*no+1:end) + kx.*ky;
HV(1:2*no+1:2*no*no) = -HV(2*no*no+no+1:2*no+1:end);
HV(ib1,ib2) = -ME;
HV(2*no*no+1:2*no+1:end) = HV(2*no*no+1:2*no+1:end) + kx.^2;
HV(ib2,ib1) = ME;
HV(no+1:2*no+1:2*no*no) = HV(no+1:2*no+1:2*no*no) - ky.^2;
% solve the eigenvalue problem for the electric field
[EV,MB] = eig(EV*HV);
beta = transpose(sqrt(diag(MB))); % row of eigenvalues
ind = angle(beta) < -1e-7; % check the branch of the square root
beta(ind) = -beta(ind);
% calculate the magnetic field amplitude eigen vectors
HV = (HV*EV).*(1./beta);
% calculate T-matrices
TS = fmmtd_calc_T(no,EV,HV,kx,ky,kxy,kz1,eps1); % substrate-grating T-matrix
TC = fmmtd_calc_T(no,EV,HV,kx,ky,kxy,kz2,eps2); % grating-cover T-matrix
% combine T-matrices
bexp = exp((1i*kh)*beta);
M1 = zeros(4*no,4*no);
M2 = zeros(4*no,4*no);
M1([ib1,ib2],[ib1,ib2]) = TS([ib3,ib4],[ib1,ib2]);
M1([ib3,ib4],[ib3,ib4]) = TC([ib1,ib2],[ib3,ib4]);
M1(ib1,ib3) = TS(ib3,ib3).*bexp(ib1);
M1(ib2,ib3) = TS(ib4,ib3).*bexp(ib1);
M1(ib1,ib4) = TS(ib3,ib4).*bexp(ib2);
M1(ib2,ib4) = TS(ib4,ib4).*bexp(ib2);
M1(ib3,ib1) = TC(ib1,ib1).*bexp(ib1);
M1(ib4,ib1) = TC(ib2,ib1).*bexp(ib1);
M1(ib3,ib2) = TC(ib1,ib2).*bexp(ib2);
M1(ib4,ib2) = TC(ib2,ib2).*bexp(ib2);
M2([ib1,ib2],[ib1,ib2]) = TS([ib1,ib2],[ib1,ib2]);
M2([ib3,ib4],[ib3,ib4]) = TC([ib3,ib4],[ib3,ib4]);
M2(ib1,ib3) = TS(ib1,ib3).*bexp(ib1);
M2(ib2,ib3) = TS(ib2,ib3).*bexp(ib1);
M2(ib1,ib4) = TS(ib1,ib4).*bexp(ib2);
M2(ib2,ib4) = TS(ib2,ib4).*bexp(ib2);
M2(ib3,ib1) = TC(ib3,ib1).*bexp(ib1);
M2(ib4,ib1) = TC(ib4,ib1).*bexp(ib1);
M2(ib3,ib2) = TC(ib3,ib2).*bexp(ib2);
M2(ib4,ib2) = TC(ib4,ib2).*bexp(ib2);
% S-matrix
SM = M2S(M1/M2);
end
%%% END OF FILE %%%