-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpwem2d.m
97 lines (85 loc) · 2.56 KB
/
pwem2d.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
function WN = pwem2d(DEV,SYM,BETA,PQ,MODE)
% WN = pwem2d(DEV,GRID,RES,PQ,MODE) Plane Wave Expansion Method
%
% INPUT ARGUMENTS
% ============================================================================
% DEV Device structure containing the following
% .ER 2D Array describing permittivity of unit cell
% .UR 2D Array describing permeability of unit cell
% .T1 Reciprocal lattice vector
% .T2 Reciprocal lattice vector
% .LATTICE Lattice constant a
%
% SYM Key points of symmetry (for IBZ). Can be used with N points of
% symmetry.
% .NP Number of points to be used in band diagram calculation
% .POINTS Array containing all symmetry points
%
% BETA 2-by-? Array of BLOCH wave vectors
%
% PQ Number of harmonics along P,Q,and R
% .P
% .Q
%
% MODE Mode structure containing
% .EM Electromagnetic mode 'E' or 'H'
%
% OUTPUT ARGUMENTS
% ============================================================================
% WN Normalized frequency
% DETERMINE GRID SIZE
[Nx,Ny] = size(DEV.ER);
% DETERMINE TOTAL NUMBER OF HARMONICS
M = PQ.P * PQ.Q;
% EXTRACT BLOCH WAVE VECTORS
bx = BETA(1,:);
by = BETA(2,:);
NBX = length(bx);
NBY = length(by);
% COMPUTE CONVOLUTION MATRICES
ERC = convmat(DEV.ER,PQ.P,PQ.Q);
URC = convmat(DEV.UR,PQ.P,PQ.Q);
% COMPUTE HARMONIC AXES
p = [ -floor(PQ.P/2) : +floor(PQ.P/2) ];
q = [ -floor(PQ.Q/2) : +floor(PQ.Q/2) ];
% INITIALIZE NORMALIZED FREQUENCY ARRAYS
if (MODE.EM == 'E')
WNE = zeros(M,NBX);
elseif (MODE.EM == 'H')
WNH = zeros(M,NBX);
end
% SOLVE PROBLEM
for nbeta = 1 : NBX
KX = bx(nbeta) - 2*pi*p/DEV.LATTICE;
KY = by(nbeta) - 2*pi*q/DEV.LATTICE;
[KY,KX] = meshgrid(KY,KX);
KX = diag(sparse(KX(:)));
KY = diag(sparse(KY(:)));
if (MODE.EM == 'E')
% Build eigen-value problem
A = KX/URC*KX + KY/URC*KY;
B = ERC;
% Solve eigen-value problem
[K0] = eig(A,B);
% Record normalized frequencies
K0 = sort(K0);
K0 = (DEV.LATTICE/(2*pi))*real(sqrt(K0));
WNE(:,nbeta) = K0;
elseif (MODE.EM == 'H')
% Build eigen-value problem
A = KX/ERC*KX + KY/ERC*KY;
B = URC;
% Solve eigen-value problem
[K0] = eig(A,B);
% Record normalized frequencies
K0 = sort(K0);
K0 = (DEV.LATTICE/(2*pi))*real(sqrt(K0));
WNH(:,nbeta) = K0;
end
end
if (MODE.EM == 'E')
WN = WNE;
elseif (MODE.EM == 'H')
WN = WNH;
end
end