| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 | %{Copyright © 2020 Alexey A. Shcherbakov. All rights reserved.This file is part of GratingFMM.GratingFMM is free software: you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe 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 ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with GratingFMM. If not, see <https://www.gnu.org/licenses/>.%}%% demonstration script for the 2D grating Fourier Modal Method calculationsclc;%format long;%% initializationwl = 1; % wavelength in micrometersphi = 0;theta = 0.001; % for normal incidence take a small non-zero valuekx0 = sin(theta*pi/180)*cos(phi*pi/180); % incidence wavevector horizontal projection (dimensionless) (Bloch wavevector)ky0 = sin(theta*pi/180)*sin(phi*pi/180); % incidence wavevector horizontal projection (dimensionless) (Bloch wavevector)gpx = 0.72; % grating period in x dimensiongpy = 0.72; % grating period it y dimensiongh = 0.5; % grating depthwv = 2*pi/wl; % wavevector  % dimensionless variableskgx = wl/gpx;kgy = wl/gpy;kh = wv*gh;xno = 15; % number of Fourier modesyno = 15; % number of Fourier modesno = xno*yno;ixy = (ceil(xno/2)-1)*yno+ceil(yno/2);eps_sub = 1.5; % substrate permittivityeps_gr = 3.17^2; % get_epsAu_Drude(wl); %grating permittivityeps_sup = 1; % superstrate permittivity	%% S-matrix calculation	% calculate Fourier image matrix of the dielectric permittivity function	% for a 2D lamellar grating with filling factors 0.5,0.5FE = calc_emntd_lam(xno,yno,0.5,0.5,eps_gr,eps_sup);	% scattering matrix of the gratingSM = fmmtd(xno,yno,kx0,ky0,kgx,kgy,kh,eps_sub,eps_sup,FE);%% diffraction of a plane wave example	% incident field amplitude vectorV_inc = zeros(2*no,2);V_inc((ceil(xno/2)-1)*yno+ceil(yno/2),2) = 1; % TE polarized plane wave (0-th harmonic) coming from the superstrate	% define diffracted amplitude vectorV_dif = zeros(2*no,2);	% calculate diffraction vectorV_dif(:,1) = SM(:,:,1,1)*V_inc(:,1) + SM(:,:,1,2)*V_inc(:,2); % diffraction to the substrateV_dif(:,2) = SM(:,:,2,1)*V_inc(:,1) + SM(:,:,2,2)*V_inc(:,2); % diffraction to the superstrateV_eff = fmmtd_efficiency(xno,yno,V_inc,V_dif,kx0,ky0,kgx,kgy,eps_sub,eps_sup);disp("efficiency:");disp(V_eff(ixy,1)); % 0th order power transmission coefficientdisp(V_eff(ixy,2)); % 0th order power reflection coefficient	% calculate the power balanceb = fmmtd_balance(xno,yno,V_inc,V_dif,kx0,ky0,kgx,kgy,eps_sub,eps_sup);disp("balance:");disp(b);
 |