FDFD Implementation

Transcription

FDFD Implementation
10/15/2015
Instructor
Dr. Raymond Rumpf
(915) 747‐6958
[email protected]
EE 5320
Computational Electromagnetics (CEM)
Lecture #14
Implementation of Finite‐
Difference Frequency‐Domain
 These notes may contain copyrighted material obtained under fair use rules. Distribution of these materials is strictly prohibited 
Lecture 14
Slide 1
Outline
•
•
•
•
•
•
Basic flow of FDFD
2× grid technique
Calculating grid parameters
Constructing your device on the grid
Walkthrough of the FDFD algorithm
Examples for benchmarking
Lecture 14
Slide 2
1
10/15/2015
Basic Flow of FDFD
Lecture 14
Slide 3
Block Diagram of FDFD Implementation
Dashboard
Source, device, learn, and grid
All hard‐coded numbers. No work.
No hard‐coded numbers. All work.
Calculate Grid
Nx, Ny, dx, dy, xa, ya
k x ,inc , k y ,inc , k x  m  , k y ,ref  m  , k y ,trn  m 
Build Wave Matrix A


  E   j H

  Ax  0
  H  j E
FDFD
Build Device on Grid
Calculate Wave Vector Components
Compute Source
Incorporate PML
b   QA  AQ  fsrc
Solve Ax = b
Post‐Process
RDE, TDE, REF, TRN, CON
Lecture 14
Slide 4
2
10/15/2015
Detailed FDFD Algorithm
1. Construct FDFD Problem
a. Define your problem
b. Calculate the grid parameters
c. Assign materials to the grid to build ER2 and UR2 arrays
4. Construct A
a. Construct diagonal materials matrices
b. Compute derivative matrices
c. Compute A
2. Handle PML and Materials
a. Compute sx and sy
b. Incorporate into r and r
c. Overlay onto 1× grids
5. Compute Source Vector, b
a. compute source field fsrc
b. compute Q
c. compute source vector b
3. Compute Wave Vector Components
a. Identify materials in reflected and transmitted regions: ref, trn, ref, trn, nref, ntrn
b. Compute incident wave vector: kinc
c. Compute transverse wave vector expansion: kx,m
d. Compute ky,ref and ky,trn
6. Solve Matrix Problem: e = A‐1b;
7. Post Process Data
a. Extract Eref and Etrn
b. Remove phase tilt
c. FFT the fields
d. Compute diffraction efficiencies
e. Compute reflectance & transmittance
f. Compute conservation of power
Lecture 14
Slide 5
2× Grid Technique
Lecture 14
Slide 6
3
10/15/2015
What is the 2× Grid Technique? (1 of 2)
This is the traditional approach for building devices on a Yee grid. It is very tedious and cumbersome to determine which field components reside in which material.
Device on 1× Grid
1× Grid
Device
Nx
Ny
dx
dy
VERY DIFFICULT STEP !!
Lecture 14
Slide 7
What is the 2× Grid Technique? (2 of 2)
The 2× grid technique simplifies how devices are built into the permittivity and permeability arrays.
Device on 2× Grid
2× Grid
Nx2
Ny2
dx2
dy2
=
=
=
=
2*Nx
2*Ny
dx/2
dy/2
easy
easy
easy
Device on 1× Grid
1× Grid
Device
Nx
Ny
dx
dy
Lecture 14
Slide 8
4
10/15/2015
Where is 2 Grid Used?
Dashboard
Source, device, learn, and grid
All hard‐coded numbers. No work.
No hard‐coded numbers. All work.
Calculate Grid
Calculate Wave Vector Components
k x ,inc , k y ,inc , k x  m  , k y ,ref  m  , k y ,trn  m 
Nx, Ny, dx, dy, xa, ya
2 Grid Only Used Here
FDFD
Build Device on Grid
Build Wave Matrix A


  E   j H

  Ax  0
  H  j E
Compute Source
b   QA  AQ  fsrc
Incorporate PML
Solve Ax = b
Post‐Process
RDE, TDE, REF, TRN, CON
Lecture 14
Slide 9
Recall the Yee Grid
2D Yee Grids
1D Yee Grid
z
Ez
Ex
Hx
Hy
z
Hy
x
Ex Mode
Lecture 14
Ex
z
Ey Mode
y
Ez
Hy
Ez Mode
Hx
Ey
3D Yee Grid
x
Hz
Ey
Hx
Ey
y
x
Ex
Hz
y
Hz Mode
Slide 10
5
10/15/2015
4×4 Yee Grid for the Ez Mode
i
j
Hx
Hy
Actual 2D Grid
Ez
x
y
Simplified Representation
• The field components are physically positioned at the edges of the cell.
• The simplified representation shows the fields inside the cells to convey more clearly which cell they are in.
j
i
Lecture 14
Slide 11
The 2× Grid
Due to the staggered nature of the Yee grid, we are effectively getting twice the resolution.
The Conventional 1× Grid
It now makes sense to talk about a grid that is at twice the resolution, the “2× grid.”
y
j
j
i
x
j
i
i
The 2× grid concept is useful because we can create devices (or PMLs) on the 2× grid without having to think about where the different field components are located. In a second step, we can easily pull off the values from the 2× grid where they exist for a particular field component.
Lecture 14
Hx
Hy
Ez
Slide 12
6
10/15/2015
2×1× (1 of 4): Define Grids
Suppose we wish to add a circle to our Yee grid. First, we define the standard 1x grid.
Second, we define a corresponding 2× grid.
Note: the 2× grid represents the same physical space, but with twice the number of points.
Lecture 14
Slide 13
2×1× (2 of 4): Build Device
Third, we construct a cylinder on the Fourth, if desired we could 2× grid without having to consider perform dielectric smoothing anything about the Yee grid.
on the 2× grid at this point.
Note: This is discussed more in Lecture 14 FDFD Extras.
Lecture 14
Slide 14
7
10/15/2015
2×1× (3 of 4): Grid Relation
Recall the relation between the 2× and 1× grids as well as the location of the field components.
Hx
Hy
Ez
Lecture 14
Slide 15
2×1× (4 of 4): Parse Onto 1× Grid
URyy
ERzz
URxx
Hx
Hy
Ez
Lecture 14
Slide 16
8
10/15/2015
MATLAB Code for Parsing Onto 1× Grid
ERxx = ER2(2:2:Nx2,1:2:Ny2,1:2:Nz2);
ERyy = ER2(1:2:Nx2,2:2:Ny2,1:2:Nz2);
ERzz = ER2(1:2:Nx2,1:2:Ny2,2:2:Nz2);
URxx = UR2(1:2:Nx2,2:2:Ny2,2:2:Nz2);
URyy = UR2(2:2:Nx2,1:2:Ny2,2:2:Nz2);
URzz = UR2(2:2:Nx2,2:2:Ny2,1:2:Nz2);
ERzz = ER2(1:2:Nx2,1:2:Ny2);
URxx = UR2(1:2:Nx2,2:2:Ny2);
URyy = UR2(2:2:Nx2,1:2:Ny2);
Ez Mode
ERxx = ER2(2:2:Nx2,1:2:Ny2);
ERyy = ER2(1:2:Nx2,2:2:Ny2);
Hz Mode
URzz = UR2(2:2:Nx2,2:2:Ny2);
Lecture 14
Slide 17
Calculating the Grid Parameters
Lecture 14
Slide 18
9
10/15/2015
Model Construction
Dirichlet boundary
20 cells
PML

periodic boundary
periodic boundary

20 cells
PML
Dirichlet boundary
Lecture 14
Slide 19
Calculate Initial Grid Resolution
Must resolve the minimum wavelength
 
min  0   max  n  x, y  
N
x
N   10
Note: If you are performing a parameter sweep over
frequency or wavelength, min(0) is the shortest
wavelength in the sweep.
y
Must resolve the minimum structural dimension
d 
 min
Nd
Nd  1
Initial grid resolution is the smallest number computed above
 x   y  min    ,  d 
Lecture 14
Slide 20
10
10/15/2015
“Snap” Grid to Critical Dimensions
Decide what dimensions along each axis are critical
initial grid
adjusted grid
critical dimension
 x and  y
critical dimension
 Typically this is a lattice constant or grating period along x
 Typically this is a film thickness along y
Compute how many grid cells comprise  and round UP
M x  ceil   x  x 
M y  ceil   y  y 
Adjust grid resolution to fit this dimension in grid EXACTLY
x   x M x
y   y M y
Lecture 14
Slide 21
Compute Total Grid Size
x
• Don’t forget to add cells for PML!
PML
• Must often add “space” between PML and device.
y
Note: This is particularly important when modeling devices with large evanescent fields.

Nx  x
x
Ny 
y
y
Make Nx odd.
Reason discussed later.
 2 N PML  2 N BUF
 
N BUF  ceil  max
 nbuff  y

Lecture 14
Buffer Space
Problem Space
Ny
Buffer Space



PML
Nx
Slide 22
11
10/15/2015
Compute 2× Grid Parameters
1× Grid
2× Grid
Nx2 = 2*Nx;
Ny2 = 2*Ny;
dx2 = dx/2;
dy2 = dy/2;
Lecture 14
Slide 23
Constructing a Device on the Grid
Lecture 14
Slide 24
12
10/15/2015
Reducing 3D Problems to 2D (1 of 2)
periodic boundary
periodic boundary
Absorbing boundary
Absorbing boundary
Lecture 14
Slide 25
Reducing 3D Problems to 2D (2 of 2)
n1,eff
n2,eff
Effective indices are best computed by modeling the vertical cross section as a slab waveguide.
n1,eff
n2,eff
A simple average index can also produce good results. Lecture 14
Slide 26
13
10/15/2015
Averaging At the Edges
Direct
Smoothed
Lecture 14
Slide 27
Building Rectangular Structures
nx6
nx2
nx3
nx4
nx5
 r1
r
r2
nx1
For rectangular structures, considering calculating start and stop indices.
Be very careful with how many ny1
points on the grid you fill in! ny2
ny3
ny4
% BUILD DEVICE
ER2 = er1*ones(Nx2,Ny2);
ER2(nx1:nx2,ny1:ny2) = er;
ER2(nx5:nx6,ny1:ny2) = er;
ER2(:,ny3:ny4)
= er;
ER2(:,ny4+1:Ny2)
= er2;
Lecture 14
d
ny2 = ny1 + round(d/dy2) – 1;
Without subtracting 1 here, filling in ny1
to ny2 would include an extra cell. This can introduce error into your results.
%fill everywhere with er1
%add tooth 1
%add tooth 2
%add substrate
%fill transmission region
Slide 28
14
10/15/2015
Oh Yeah, Metals!
Perfect Electric Conductors
 r  10000
or

  E1   f1 
 
    

   
 0 0 1 0 0   Em    0 

   
     


  EM   f M 
Em  0
Include Tangential Fields at Boundary (TM modes!)
Bad placement of metals
Ex
x
Hz E
y
Good placement of metals
y
Hz Mode
Lecture 14
Slide 29
Walkthrough of the
FDFD Algorithm
Lecture 14
Slide 30
15
10/15/2015
Input to the FDFD Algorithm
The FDFD algorithm requires the following information: •The materials on the 2× grid: ER2(nx,ny) and UR2(nx,ny)
•The grid resolution: dx and dy
•The size of the PML on the 1× grid: NYLO and NYHI
•The source wavelength, 0
•Angle of incidence, 
•Mode/polarization: ‘E’ or ‘H’
Lecture 14
Slide 31
(1) Determine the Material Properties in the Reflected and Transmitted Regions
If these parameters are not provided in the dashboard, or a dashboard does not exist, they can be pulled directly off of the grid.
 rref
rref
UR2(nx,ny)
ER2(nx,ny)
 rtrn
Lecture 14
rtrn
Slide 32
16
10/15/2015
(2) Compute the PML Parameters on 2× Grid
20 cells on Yee grid.
40 cells on 2 grid.
s y  x, y 
s x  x, y 
20 cells on Yee grid.
40 cells on 2 grid.
Lecture 14
Slide 33
(3) Incorporate the PML
We can incorporate the PML parameters into [μ] and [ε] as follows


  E  k0   r  H


  H  k0  r  E
 s y sz
 xx

 sx

 r    0


 0

0
sx sz
 yy
sy
0




0 


sx s y 
 zz
sz

0
 s y sz
 xx

 sx

 r    0


 0

0
s x sz
 yy
sy
0




0 


sx s y
 zz 
sz

0
For 2D simulations, sz = 1 and we have
 xx 
sy
sx
r
 xx 
sy
sx
r
s
 yy  x  r
sy
s
 yy  x  r
sy
 zz  sx s y r
 zz  sx s y  r
Lecture 14
Note: the PML is incorporated into the 2× grid.
% INCORPORATE PML
URxx = UR2./sx.*sy;
URyy = UR2.*sx./sy;
URzz = UR2.*sx.*sy;
ERxx = ER2./sx.*sy;
ERyy = ER2.*sx./sy;
ERzz = ER2.*sx.*sy;
Slide 34
17
10/15/2015
(4) Overlay Materials Onto 1× Grids
1× Grids
Field and materials assignments
I
H x , Ey
 xx ,  yy
Ez
 zz
III
Ez
Hy
II
III
IV
x
IV
H y , Ex
 yy ,  xx
x
y
II
I
Hz
 zz
2X Grid
Hx
y
Ex
Ez Mode
x
Hz E
y
y
Hz Mode
% OVERLAY MATERIALS ONTO 1X GRID
URxx = URxx(1:2:Nx2,2:2:Ny2);
URyy = URyy(2:2:Nx2,1:2:Ny2);
URzz = URzz(2:2:Nx2,2:2:Ny2);
ERxx = ERxx(2:2:Nx2,1:2:Ny2);
ERyy = ERyy(1:2:Nx2,2:2:Ny2);
ERzz = ERzz(1:2:Nx2,1:2:Ny2);
Lecture 14
Slide 35
(5) Compute the Wave Vector Terms
k0 
2
0

 sin  
kinc  k0 nref 

cos  
2
k x  m   k x ,inc  m
x
k y ,ref  m  
 k0 nref 
k y ,trn  m  
 k0 ntrn 
This is a vector quantity
m   , 2, 1, 0,1, 2,
2
 k x2  m 
2
k
2
x
 m
Nx points total.
For proper symmetry, Nx
should be odd.
m = [-floor(Nx/2):floor(Nx/2)]';
These equations come from the dispersion equation for the reflected and transmitted regions.
Recall that there used to be a negative sign here. We are able to drop it by also dropping the negative sign when calculating diffraction efficiency.
Lecture 14
Slide 36
18
10/15/2015
(6) Construct Diagonal Materials Matrices
 xx 1
0 


 xx  2 

ε xx  





 xx  N  
 0
  xx 1
0 


 xx  2 

μ xx  





 xx  N  
 0
0 
 yy 1



2
yy  

ε yy  





 yy  N  
 0
0 
  yy 1



2
yy  

μ yy  





 yy  N  
 0
 zz 1
0 


 zz  2 

ε zz  





 zz  N  
 0
  zz 1
0 


 zz  2 

μ zz  





 zz  N  
 0
ERxx = diag(sparse(ERxx(:)));
Lecture 14
Slide 37
(7) Construct the Derivative Matrices
Dex , Dey , Dhx , and Dhy
Frequency (or wavelength) information is incorporated into FDFD here
[DEX,DEY,DHX,DHY] = yeeder(NGRID,k0*RES,BC,kinc/k0);
Don’t forget that we have normalized our parameters so you should use yeeder() as follows:
[DEX,DEY,DHX,DHY] = yeeder(NGRID,k0*RES,BC,kinc/k0);
Be sure this function uses sparse matrices from the very beginning.
A = sparse(M,M) – creates a sparse MM matrix of zeros.
A = spdiags(b,d,A) – Adds array b to diagonal d in matrix A.
Lecture 14
Slide 38
19
10/15/2015
(8) Compute the Wave Matrix A
 Mode
A E  Dhxμ yy1Dex  Dhyμ xx1Dey  ε zz
 Mode
A H  Dexε yy1 Dhx  Deyε xx1Dhy  μ zz
Lecture 14
Slide 39
(9) Compute the Source Field
The source has an amplitude of 1.0


f src  x, y   exp jkinc  r



kinc
 exp  j  k x ,inc x  k y ,inc y  
Don’t forget to make fsrc a column vector.
1 grid
Lecture 14
Slide 40
20
10/15/2015
total‐field
scattered‐field
(10) Compute the Scattered‐Field Masking Matrix, Q
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
Reshape grid to 1D array and then diagonalize.
1

 1
0 




Q

0



0 
 0

0

Q = diag(sparse(Q(:)));
It is good practice to make the scattered‐field region at least one cell larger than the y‐low PML. Lecture 14
Slide 41
(11) Compute the source vector, b
Af = b
Lecture 14
b   QA  AQ  fsrc
Slide 42
21
10/15/2015
(12) Compute the Field f
Aside
In MATLAB, f = A\b employs a direct LU decomposition to calculate f. This is very stable and robust, but a half‐full matrix is created so memory can explode for large problems.
Iterative solutions can be faster and require much less memory, but they are less stable and may never converge to a solution. Correcting these problems requires significant modification to the FDFD algorithm taught here.
1
f =A b
Don’t forget to reshape() f from a column vector to a 2D grid after the calculation.
Lecture 14
Slide 43
(13) Extract Transmitted and Reflected Fields
SF
TF
Lecture 14
Eref
Etrn
The reflected field is extracted from inside the scattered‐field, but outside the PML.
The transmitted field is extracted from the grid after the device, but outside the PML.
Slide 44
22
10/15/2015
(14) Remove the Phase Tilt
Recall Bloch’s theorem,

 
E  r   Ak
inc


 r   e jk

inc  r
This implies the transmitted and reflected fields have the following form
Eref  x   Aref  x  e
jk x ,inc x
Etrn  x   Atrn  x  e
jk x ,inc x
We remove the phase tilt to calculate the amplitude terms.
Aref  x   Eref  x  e
Atrn  x   Etrn  x  e
 jk x ,inc x
 jk x ,inc x
Lecture 14
Slide 45
(15) Calculate the Complex Amplitudes of the Spatial Harmonics
Recall that the plane wave spectrum is the Fourier transform of the field.
We calculate the FFT of the field amplitude arrays.

 m   FFT  A

 x 
S ref  m   FFT Aref  x 
S trn
trn
Some FFT algorithms (like MATLAB) require that you divide by the number of points and shift after calculation.
Sref = flipud(fftshift(fft(Aref)))/Nx;
Strn = flipud(fftshift(fft(Atrn)))/Nx;
Lecture 14
Slide 46
23
10/15/2015
(16) Calculate Diffraction Efficiencies
The source wave was given unit amplitude so
2
Sinc  1
The diffraction efficiencies of the reflected modes are then
 k y ,ref  m  
2
R  m   S ref  m   Re 

 k y ,inc 
Recall that there used to be a negative sign here. We dropped it because we also dropped the sign when calculating .
k y ,ref  m 
The diffraction efficiencies of the transmitted modes are then
 k y ,trn  m  r ,ref 
2
T  m   S trn  m   Re 

 k y ,inc r ,trn 
T  m   U trn  m 
2
 k  m   r ,ref 
 Re  y ,trn

 k y ,inc  r ,trn 
E Mode
S  m   amplitudes of E mode
spatial harmonics
U  m   amplitudes of H mode
spatial harmonics
H Mode
Note: these equations 
Sinc  1
assume that . Lecture 14
Slide 47
(17) Calculate Reflectance, Transmittance, and Conservation of Power The overall reflectance is
REF   R  m 
m
The overall transmittance is
TRN   T  m 
m
Conservation of power is computed as
REF TRN  100%
If loss is incorporated, these quantities will add to be less than 100%.
REF + TRN < 100% loss
REF + TRN = 100% no loss or gain
REF + TRN > 100% gain
Lecture 14
Slide 48
24
10/15/2015
Examples for
Benchmarking
Lecture 14
Slide 49
Air Simulation
E Mode
h = 1.00
r  1.0
 r  1.0
-30°
L = 1.00
H Mode
m
R
T
R
T
-4
-3
-2
-1
0
1
2
3
4
0%
0%
0%
0%
0%
0%
0%
0%
0%
0%
0%
0%
0%
100%
0%
0%
0%
0%
0%
0%
0%
0%
0%
0%
0%
0%
0%
0%
0%
0%
0%
100%
0%
0%
0%
0%
E and H Mode
Lecture 14
Slide 50
25
10/15/2015
Dielectric Slab Grating
E Mode


r  1.0
 r  9.0
-60°
-25°
0°
15°
45°
80°
H Mode
R
T
R
T
49.5%
28.5%
25.1%
26.3%
37.2%
77.7%
50.6%
71.7%
75.0%
73.8%
62.9%
21.8%
5.0%
21.8%
25.1%
24.0%
13.9%
8.3%
95.4%
78.4%
75.1%
76.3%
86.4%
91.9%
Note: you can come up with your own benchmarking examples using the transfer matrix method!
 = 45°
Lecture 14
Slide 51
Binary Diffraction Grating
r1  1.0  r1  1.0
w = 0.5L
-30°
h = 0.250
r  1.0
 r  9.0
E Mode
H Mode
m
R
T
R
T
-4
-3
-2
-1
0
1
2
3
4
0%
0%
0%
6.9%
12.7%
0%
0%
0%
0%
4.6%
5.3%
2.6%
22.1%
7.8%
17.7%
16.4%
3.9%
0%
0%
0%
0%
14.1%
0.9%
0%
0%
0%
0%
2.4%
7.5%
3.1%
38.8%
5.4%
17.7%
7.6%
2.4%
0%
L = 1.250
Lecture 14
Slide 52
26
10/15/2015
Sawtooth Diffraction Grating
r1  1.0  r1  1.0
L = 1.250
h = 0.850
r  1.5
 r  3.0
E Mode
-20°
H Mode
m
R
T
R
T
-4
-3
-2
-1
0
1
2
3
4
0%
0%
0%
0%
0%
0%
0%
0%
0%
0%
0%
5.6%
39.2%
0.8%
44.2%
10.1%
0%
0%
0%
0%
0%
0%
0%
0%
0%
0%
0%
0%
0%
0.4%
53.1%
3.4%
29.5%
13.6%
0%
0%
H Mode
Lecture 14
Slide 53
27