calc_SMD_layer_td.m 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 diagonal S-matrix of a homogeneous layer for a 2D set of
  17. % wavevector projections
  18. %% input:
  19. % xno, yno: numbers of Fourier harmonics in x and y dimensions
  20. % kx0, ky0: zero order wavevector projections
  21. % kgx, kgy: wavevector steps in x and y dimensions
  22. % kh: layer thickness multiplied by the vacuum wavenumber
  23. % eps: layer permittivity
  24. %% output:
  25. % SMD: diagonal interface S-matrix of size (2*no,2,2), where no = xno*yno
  26. % block SMD(:,1,1) corresponds to refelection from below to below
  27. % block SMD(:,2,2) corresponds to refelection from above to above
  28. % block SMD(:,2,1) corresponds to transmission from below to above
  29. % block SMD(:,1,2) corresponds to transmission from above to below
  30. % central harmonic index is ind_0 = (ceil(xno/2)-1)*yno+ceil(yno/2)
  31. % first (no) components of the S-matrix correspond to the TE polarization,
  32. % and indeces from (no+1) to (2*no) correspond to the TM polarization
  33. %% implementation:
  34. function [SMD] = calc_SMD_layer_td(xno, yno, kx0, ky0, kgx, kgy, kh, eps)
  35. no = xno*yno;
  36. SMD = zeros(2*no,2,2);
  37. % wavevector projections
  38. kx = kx0 + kgx*(linspace(1,xno,xno) - ceil(xno/2));
  39. ky = ky0 + kgy*(linspace(1,yno,yno) - ceil(yno/2));
  40. [kkx,kky] = meshgrid(kx,ky);
  41. kkx = reshape(kkx,1,[]);
  42. kky = reshape(kky,1,[]);
  43. kkxy = kkx.^2 + kky.^2;
  44. kz = sqrt(eps - kkxy);
  45. ind = angle(kz) < -1e-12;
  46. kz(ind) = -kz(ind);
  47. SMD(:,2,1) = exp((1i*kh)*kz);
  48. SMD(:,1,2) = SMD(:,2,1);
  49. end
  50. %
  51. % end of calc_SMD_layer_td
  52. %