1
0

demo_fmm.m 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. %{
  2. Copyright © 2020 Alexey A. Shcherbakov. All rights reserved.
  3. This file is part of GratingFMM.
  4. GratingFMM is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 2 of the License, or
  7. (at your option) any later version.
  8. GratingFMM is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GratingFMM. If not, see <https://www.gnu.org/licenses/>.
  14. %}
  15. %% demonstration script for the collinear 1D grating Fourier Modal Method calculations
  16. clc;
  17. format long;
  18. %% initialization
  19. wl = 1; % wavelength in micrometers
  20. wv = 2*pi/wl; % wavevector
  21. pol = 'TM'; % polarization, "TE" or "TM"
  22. % grating parameters
  23. gp = 1.5; % grating period
  24. gh = 0.5; % grating depth
  25. % dimensionless parameters
  26. kg = wl/gp;
  27. kh = wv*gh;
  28. % permittivities
  29. eps_sub = 1.5^2; % substrate permittivity
  30. eps_gr = 3.17^2; %grating permittivity
  31. eps_sup = 1; % superstrate permittivity
  32. % method parameters
  33. no = 15; % number of Fourier modes
  34. ind0 = ceil(no/2); % index of the zero harmonic (0th order diffraction)
  35. % incidence
  36. theta = 10; % angle of incidence
  37. kx0 = sin(theta*pi/180); % incidence wavevector projection
  38. V_inc = zeros(no,2); % matrix of incident field amplitudes
  39. % second index indicates wether the amplitudes are in the substrate (1) in the superstrate (2)
  40. V_inc(ind0,2) = 1; % plane wave coming from the superstrate
  41. %% scattering matrix calculation
  42. % calculate Fourier image matrix of the dielectric permittivity function
  43. % for a lamellar grating with filling factor 0.4
  44. FM = calc_emn_lam(no,0.4,eps_gr,eps_sup); % lamellar grating
  45. % scattering matrix of the grating
  46. SM = fmm(no,kx0,kg,kh,eps_sub,eps_sup,FM,pol);
  47. %% diffraction of a plane wave example
  48. V_dif = zeros(no,2); % allocate a vector of diffracted field amplitudes
  49. % apply the calculated scattering matrix to the incident vector:
  50. V_dif(:,1) = SM(:,:,1,1)*V_inc(:,1) + SM(:,:,1,2)*V_inc(:,2); % diffraction to the substrate
  51. V_dif(:,2) = SM(:,:,2,1)*V_inc(:,1) + SM(:,:,2,2)*V_inc(:,2); % diffraction to the superstrate
  52. % check the power conservation
  53. b = fmm_balance(no,V_inc,V_dif,kx0,kg,eps_sub,eps_sup,pol);
  54. disp(b); % precicision of the power conservation
  55. % calculate the vector of diffraction efficiencies
  56. V_eff = fmm_efficiency(no,V_inc,V_dif,kx0,kg,eps_sub,eps_sup,pol);
  57. disp(V_eff(ind0,1)); % 0th order power transmission coefficient
  58. disp(V_eff(ind0,2)); % 0th order power reflection coefficient