demo_fmmnc.m 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 non-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. % grating parameters
  22. gp = 1.5; % grating period
  23. gh = 0.5; % grating depth
  24. % dimensionless parameters
  25. kg = wl/gp;
  26. kh = wv*gh;
  27. % permittivities
  28. eps_sub = 1.5^2; % substrate permittivity
  29. eps_gr = 3.17^2; % grating permittivity
  30. eps_sup = 1; % superstrate permittivity
  31. % method parameters
  32. no = 15; % number of Fourier modes
  33. ind0 = ceil(no/2); % index of the zero harmonic (0th order diffraction)
  34. % incidence
  35. theta = 10; % angle of incidence (angle between the direction of incidence
  36. % and the vertical axis being perpendicular to the grating plane)
  37. phi = 0; % turn angle in the grating plane,
  38. % phi = 0 corresponds to the case of collinear diffraction
  39. % incidence wavevector projections:
  40. kx0 = sin(theta*pi/180)*cos(phi*pi/180);
  41. ky0 = sin(theta*pi/180)*sin(phi*pi/180);
  42. V_inc = zeros(2*no,2); % matrix of incident field amplitudes
  43. % first index indicates different Fourier harmonics, first (no) correspond
  44. % to the TE polarization; second (no) correspond to the TM polarization
  45. % second index indicates wether the amplitudes are in the substrate (1) in the superstrate (2)
  46. V_inc(1*no+ind0,2) = 1; % "TM" polarized plane wave (0-th harmonic) incoming from the superstrate
  47. %% scattering matrix calculation
  48. % calculate Fourier image matrix of the dielectric permittivity function
  49. % for a lamellar grating with filling factor 0.4
  50. FM = calc_emn_lam(no,0.4,eps_gr,eps_sup);
  51. % scattering matrix of the grating
  52. SM = fmmnc(no,kx0,ky0,kg,kh,eps_sub,eps_sup,FM);
  53. %% diffraction of a plane wave example
  54. V_sca = zeros(2*no,2); % allocate a vector of diffracted field amplitudes
  55. % apply the calculated scattering matrix to the incident vector:
  56. V_sca(:,1) = SM(:,:,1,1)*V_inc(:,1) + SM(:,:,1,2)*V_inc(:,2); % diffraction to the substrate
  57. V_sca(:,2) = SM(:,:,2,1)*V_inc(:,1) + SM(:,:,2,2)*V_inc(:,2); % diffraction to the superstrate
  58. % check the power conservation
  59. b = fmmnc_balance(no,V_inc,V_sca,kx0,ky0,kg,eps_sub,eps_sup);
  60. disp(b); % precicision of the power conservation
  61. % calculate the vector of diffraction efficiencies:
  62. V_eff = fmmnc_efficiency(no,V_inc,V_sca,kx0,ky0,kg,eps_sub,eps_sup);
  63. disp(V_eff(0*no+ind0,1)); % zero order power transmission to TE
  64. disp(V_eff(0*no+ind0,2)); % zero order power reflection to TE
  65. disp(V_eff(1*no+ind0,1)); % zero order power transmission to TM
  66. disp(V_eff(1*no+ind0,2)); % zero order power reflection to TM