fmm_kxz.m 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 grating vectors for 1D grating (periodicity in x direction)
  17. % and plane wave propagation constants in homogeneous media below and
  18. % above the grating (substrate and superstrate)
  19. %% input:
  20. % no: number of Fourier harmonics
  21. % kx0, ky0: wavevector projections of an incident plane wave
  22. % kg: wavelength-to-period ratio
  23. % eps1: permittivity of a medium below the grating (substrate)
  24. % eps2: permittivity of a medium above the grating (superstrate)
  25. %% output:
  26. % kz1: row of propagation constants in the substrate
  27. % kz2: row of propagation constants in the superstrate
  28. % kx: row of grating vectors in x-direction
  29. % kxy: row of grating vectors in xy plane
  30. %% implementation:
  31. function [kz1, kz2, kx, kxy] = fmm_kxz(no, kx0, ky0, kg, eps1, eps2)
  32. ind = linspace(1,no,no);
  33. kx = kx0 + kg*(ind - ceil(no/2));
  34. kxy = kx.^2 + ky0^2;
  35. kz1 = sqrt(eps1 - kxy);
  36. kz2 = sqrt(eps2 - kxy);
  37. ind = angle(kz1) < -1e-12;
  38. kz1(ind) = -kz1(ind);
  39. ind = angle(kz2) < -1e-12;
  40. kz2(ind) = -kz2(ind);
  41. kxy = sqrt(kxy);
  42. end
  43. %
  44. % end of fmm_kxz
  45. %