fmm_efficiency.m 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. % collinear diffraction by 1D gratings
  18. %% input:
  19. % no: number of Fourier harmonics
  20. % V_inc: incident field amplitude matrix of size (no,2)
  21. % V_dif: diffracted field amplitude matrix of size (no,2)
  22. % kx0: incident plane wave wavevector x-projection (Bloch wavevector)
  23. % kg: wavelength-to-period ratio (grating vector)
  24. % eps1, eps2: substrate and superstrate permittivities
  25. % pol: polarization (either "TE" or "TM")
  26. %% output:
  27. % V_eff: efficiency matrix of size (no,2) if the if the incident field has
  28. % propagating harmonics, otherwise (if the incident field is purely evanescent)
  29. % the matrix of partial powers carried by each diffraction order
  30. % first index of V_inc, V_dif, V_eff indicates diffraction harmonics
  31. % (0-th order index is ind_0 = ceil(no/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] = fmm_efficiency(no, V_inc, V_dif, kx0, kg, eps1, eps2, pol)
  36. [kz1, kz2] = fmm_kxz(no, kx0, 0, kg, eps1, eps2);
  37. kz1 = transpose(kz1);
  38. kz2 = transpose(kz2);
  39. if (strcmp(pol,'TM'))
  40. kz1 = kz1/eps1;
  41. kz2 = kz2/eps2;
  42. end
  43. V_eff = zeros(no,2);
  44. P_inc = sum( abs(V_inc(:,1).^2).*real(kz1) + abs(V_inc(:,2).^2).*real(kz2) );
  45. V_eff(:,1) = abs(V_dif(:,1).^2).*real(kz1);
  46. V_eff(:,2) = abs(V_dif(:,2).^2).*real(kz2);
  47. if (abs(P_inc) > 1e-15)
  48. V_eff = V_eff/P_inc;
  49. end
  50. end
  51. %
  52. % END
  53. %