fmmtd_efficiency.m 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. %% description:
  16. % calculate a matrix of diffraction efficiencies in case of the
  17. % diffraction by 2D gratings being periodic in x and y dimensions
  18. %% input:
  19. % xno, yno: numbers of Fourier harmonics in x and y dimensions
  20. % V_inc: incident field amplitude matrix of size (2*no,2)
  21. % V_dif: diffracted field amplitude matrix of size (2*no,2)
  22. % kx0, ky0: incident plane wave wavevector x and y projections (Bloch wavevector projections)
  23. % kgx, kgy: wavelength-to-period ratios (grating vectors)
  24. % eps1, eps2: substrate and superstrate permittivities
  25. %% output:
  26. % V_eff: efficiency matrix of size (2*no,2) if the if the incident field has
  27. % propagating harmonics, otherwise (if the incident field is purely evanescent)
  28. % the matrix of partial powers carried by each diffraction order
  29. % first index of V_inc, V_dif, V_eff indicates diffraction harmonics
  30. % with indices 1:no being TE orders and no+1:2*no being TM orders
  31. % (0-th order index is ind_0 = (ceil(xno/2)-1)*yno+ceil(yno/2))
  32. % second index of V_inc, V_dif, V_eff indicates whether the diffraction orders
  33. % are in the substrate (V(:,1)) or in the superstrate (V(:,2))
  34. %% implementation
  35. function [V_eff] = fmmtd_efficiency(xno, yno, V_inc, V_dif, kx0, ky0, kgx, kgy, eps1, eps2)
  36. no = xno*yno;
  37. ib1 = 1:no; ib2 = no+1:2*no;
  38. [kz1, kz2] = fmmtd_kxyz(xno, yno, kx0, ky0, kgx, kgy, eps1, eps2);
  39. kz1 = transpose(kz1);
  40. kz2 = transpose(kz2);
  41. P_inc = sum( abs(V_inc(ib1,1).^2).*real(kz1) + abs(V_inc(ib1,2).^2).*real(kz2) ) ...
  42. + sum( abs(V_inc(ib2,1).^2).*real(kz1/eps1) + abs(V_inc(ib2,2).^2).*real(kz2/eps2) );
  43. V_eff = zeros(2*no,2);
  44. V_eff(ib1,1) = abs(V_dif(ib1,1).^2).*real(kz1);
  45. V_eff(ib1,2) = abs(V_dif(ib1,2).^2).*real(kz2);
  46. V_eff(ib2,1) = abs(V_dif(ib2,1).^2).*real(kz1/eps1);
  47. V_eff(ib2,2) = abs(V_dif(ib2,2).^2).*real(kz2/eps2);
  48. if abs(P_inc) > 1e-15
  49. V_eff = (1/P_inc)*V_eff;
  50. else
  51. V_eff = 0.5*V_eff;
  52. end
  53. end
  54. %
  55. % END
  56. %