Download as pdf or txt
Download as pdf or txt
You are on page 1of 26

1/23/2020

Computational Science:
Introduction to Finite-Difference Time-Domain

Three-Dimensional FDTD

Lecture Outline
• Two Common Grid Strategies
• Simplifying the update equations for crossed grating devices
• Boundary conditions
• Plane wave source using the total-field/scattered-field technique
• Calculation of transmittance and reflectance
• MATLAB’s slice() command for 3D visualization

Slide 2

1
1/23/2020

Two Common Grid


Strategies

Slide 3

Grid Scheme for Finite-Size Devices


To simulate scattering from finite-sized devices, a PML is needed at all boundaries.

z-lo

x-lo y-hi

y-lo x-hi

z-hi

Slide 4

2
1/23/2020

Grid Scheme for Crossed Grating Devices


For crossed grating devices, a PML is only
needed at the z-axis boundaries.
Reflection Plane
TF/SF Planes

Spacer Region

Unit cell of
model valid in here
real device

Spacer Region

Transmission Plane
real device
FDTD grid

Slide 5

Simplified Update
Equations for Crossed
Grating Devices

Slide 6

3
1/23/2020

Simplify, Simplify, Simplify!


A 3D grid contains many more points than an equivalent 2D
grid. For this reason, more attention will be devoted to
simplifying and streamlining the update equations.

2D Grid
40×200 cells = 8,000 cells

3D Grid There is now…


40× more grid cells
40×40×200 = 320,000 cells 2× more field components
80× more numbers to process

Slide 7

Important Items to Simplify and Streamline

• We do not need x-axis or y-axis PMLs. They should be


eliminated from the update equations.
• Integration terms are only needed inside the PML.
These should be split into z-low and z-high integration
terms.

Slide 8

4
1/23/2020

Simplify Update Equation for Hx


The following terms are eliminated from the update coefficients:
i , j ,k

 H
1  y

i , j ,k
  zH
i, j ,k  H
 y  i , j ,k
 H i , j ,k
z  t i , j ,k 1
  H
 1  y
i , j ,k
  zH
i, j ,k  H
 y  i , j ,k
 H i , j ,k
z  t 
mHx 0
t  2 0  4
mHx1   
2 0  4
 t 
2 i , j ,k 2
 0 mHx 0  0 
     
H i, j ,k

mHx 2
i , j ,k

mHx 0
1
i, j ,k
 xx
c0
i, j ,k
mHx3
i , j ,k

mHx 0
1
i , j ,k
c0 t  x

 0  xx i , j ,k
mHx 4
i , j ,k

mHx 0
1
i , j ,k
t
 02  H i , j ,k
y  H i , j ,k
z 

For Hx, we no longer need any integration terms!

E z  E z E y  E y
t i , j 1, k i , j ,k i , j , k 1 i , j ,k
t t

C
2
E i , j ,k
H E i , j ,k
i , j ,k i , j ,k i, j ,k
I CEx t  x t I Hx t  x T C x t  t t
 t t
t
2 T 0 y z
T 0

The third and fourth terms are eliminated from the update equation.

i , j ,k
H x t t 2  mHx1  i , j ,k
H i , j ,k
x t t 2  mHx 2  i , j ,k
C E i , j ,k
x t 
 mHx 3
i , j ,k
I i , j ,k
CEx t  mHx 4 i , j ,k
I i , j ,k
Hx t

Slide 9

Final Form of the Update Equation for Hx


The update coefficients are computed before the main FDTD loop.
H i , j ,k  i , j ,k

i , j ,k 1 z i , j ,k 1 H
1  z  i , j ,k 1 c0
mHx 0   mHx1  mHx 2 
t 2 0 mHx 0
i , j ,k
 t 2 0  mHx 0
i , j ,k
 xx
i , j ,k

 

The curl is computed inside the main FDTD loop, but before the update equation.

E z  E z E y  E y
i , j 1, k i , j ,k i , j , k 1 i , j ,k

E i, j ,k
C x t  t t
 t t

y z

The update equation is computed inside the main FDTD loop immediately after the
curl term is calculated.

i, j ,k
H x t t 2  mHx1  i , j ,k
H i , j ,k
x t t 2  mHx 2  i , j ,k
C E i , j ,k
x t

Slide 10

5
1/23/2020

Final Form of the Update Equation for Hy


The update coefficients are computed before the main FDTD loop.
H i , j ,k  i , j ,k

i , j ,k 1 z i , j ,k 1 H
1  z  i , j ,k 1 c0
mHy 0   mHy1  mHy 2 
t 2 0 mHy 0
i , j ,k
 t 2 0  mHy 0
i , j ,k
 yy
i , j ,k

 

The curl term is computed inside the main FDTD loop, but before the update
equation.

E x  E x E z  E z
i , j , k 1 i , j ,k i 1, j , k i , j,k

E i , j ,k
C y t  t t
 t t

z x

The update equation is computed inside the main FDTD loop immediately after the
curl term is calculated.

Hy
i , j ,k

t
t
2

 mHy1
i, j ,k
H i , j ,k
y t  t
2
 mHy 2 i , j ,k
C E i , j ,k
y t

Slide 11

Final Form of the Update Equation for Hz


The update coefficients are computed before the main FDTD loop.
i , j ,k
c0  t   z
2 H
i , j ,k c0 t i , j ,k
mHz 2  mHz 3 
 zz
i, j ,k
0  zz
i, j ,k

The integration term and curl are computed inside the main FDTD loop, but before
the update equation.

E y  E y E x  E x
i 1, j , k i , j ,k i , j 1, k i , j ,k
t

I CEz
i , j ,k
t

C
T 0
E i , j ,k
z t C E i , j ,k
z t  t

x
t
 t

y
t

The update equation is computed inside the main FDTD loop immediately after the
integration term and curl term are updated.

Hz
i , j ,k

t
t
2
 Hz
i , j ,k

t
t
2
 mHz 2  i, j ,k
C E i , j ,k
z t 
 mHz 3
i , j ,k
I i , j ,k
CEz t

Slide 12

6
1/23/2020

Final Form of the Update Equation for Dx


The update coefficients are computed before the main FDTD loop.
D i, j,k  i, j ,k

i , j ,k 1 z i , j ,k 1 D
1  z  i , j ,k c0
mDx 0   mDx1  mDx 2 
t 2 0 mDx 0
i, j,k
 t 2 0  mDx 0
i , j ,k

 

The curl term is computed inside the main FDTD loop, but before the update
equation.

i , j ,k i , j 1, k i , j ,k i , j , k 1
Hz  Hz Hy  Hy
H i , j ,k t  2t t  2t t  2t t  2t
C x t  t  
2 y z

The update equation is computed inside the main FDTD loop immediately after the
curl term is calculated.

D x
i, j ,k

t t

 mDx1
i , j ,k
 D x t
i , j ,k

 mDx 2
i, j ,k
C H i, j ,k
x t  t
2
Slide 13

Final Form of the Update Equation for Dy


The update coefficients are computed before the main FDTD loop.
D i , j ,k  i , j ,k

i , j ,k 1 z i , j ,k 1 D
1  z  i , j ,k c0
mDy 0   mDy1  mDy 2 
t 2 0 mDy 0
i , j ,k
 t 2 0  mDy 0
i, j,k

 

The integration terms are computed inside the main FDTD loop, but before the
update equation.
i , j ,k i , j , k 1 i , j ,k i 1, j , k
i , j ,k
Hx t  2t
 Hx t  2t
Hz t  2t
 Hz t  2t
C yH  
t  2t z x

The update equation is computed inside the main FDTD loop immediately after the
integration terms are updated.

D y
i , j ,k

t t 
 mDy1
i, j ,k
 D y t
i , j ,k

 mDy 2
i, j ,k
C H i, j ,k
y t  t
2
Slide 14

7
1/23/2020

Final Form of the Update Equation for Dz


The update coefficients are computed before the main FDTD loop.

c0  t 
2
i , j ,k i , j ,k i, j ,k
mDz 2  c0 t mDz 3   zD
0

The integration term and curl term are computed inside the main FDTD loop, but
before the update equation.
t i , j ,k i 1, j , k
t i , j ,k i , j 1, k
Hy  Hy Hx  Hx

2
i , j ,k H i , j ,k H i , j ,k t  2t t  2t t  2t t  2t
I CHz t  C z T C z t  t  
t
2
2 x y
T 0

The update equation is computed inside the main FDTD loop immediately after the
integration and curl terms are updated.

D z
i , j ,k

t t
 D z
i , j ,k

t

 mDz 2
i , j ,k
C H i , j ,k
z t  t
2

 mDz 3
i, j ,k
I CHz
i, j ,k

t
t
2
Slide 15

Final Update Equations for Ex, Ey, and Ez


The update coefficients are computed before the main FDTD loop.
i, j,k 1 i, j ,k 1 i, j,k 1
mEx1  i, j,k
mEy1  i, j,k
mEz1  i, j,k
 xx  yy  zz

The update equations are computed inside the main FDTD loop.

E x
i, j,k
 mEx1
t  t

i, j,k
D x  i, j,k

t  t

E y
i, j,k

t  t 
 mEy1
i, j,k
 D i, j,k
y t  t

E z
i, j,k

t  t

 mEz1
i, j,k
 D i, j,k
z t  t

Slide 16

8
1/23/2020

Boundary Conditions

Slide 17

Periodic Boundary Conditions


All of the spatial derivatives appear in the curl calculations. Therefore, all boundary
conditions are implemented in the curl calculations as well.

We will implement periodic boundary conditions all the way around the grid.

Slide 18

9
1/23/2020

Curl of
The curl equations are

E z  E z E y  E y
i , j 1, k i , j ,k i , j , k 1 i , j ,k

E i , j ,k
C x t  t t
 t t
y z
E x  E x E z  E z
i , j , k 1 i , j ,k i 1, j , k i , j ,k

E i , j ,k
C y t  t t
 t t
z x
E y  E y E x  E x
i 1, j , k i , j ,k i , j 1, k i , j ,k

E i , j ,k
C z t  t t
 t t
x y

Problems arise when calculating these at the x-high, y-high, and z-high boundaries.

Slide 19

Curl of
The curl equations are
i , j ,k i , j 1, k i , j ,k i , j , k 1
i , j ,k Hz  Hz Hy  Hy
t  2t t  2t t  2t t  2t
C xH  
t  2t y z
i , j ,k i , j , k 1 i , j ,k i 1, j , k
H x t  t  H x t  t Hz  Hz
H i , j ,k t  2t t  2t
C y t  t  2 2

2 z x
i , j ,k i 1, j , k i , j 1, k
Hy  Hy i , j ,k
H x t  t  H x
H i , j ,k t  2t t  2t t  2t
C z t  t   2

2 x y
Problems areise when calculating these at the x-low, y-low, and z-low boundaries.

Slide 20

10
1/23/2020

x-Component of Curl of with PBC


There are four cases where the curl must be computed explicitly.

 E i , j 1,k  E i , j ,k E i , j ,k 1  E i , j ,k
 zt z t

y t y t
for j  N y and k  N z
 y z

 E z  E z E y  E y
i ,1, k i , N y ,k i , N y , k 1 i , N y ,k

 t t
 t t
for j  N y and k  N z
E i , j ,k  y z
C x t 
 E z  E z E y  E y
i , j 1, N z i, j,Nz i , j ,1 i, j,N z

 t t
 t t
for j  N y and k  N z
 y z
 i ,1, N z
 E z t  E z E y  E y
i,N y ,Nz i , N y ,1 i, N y , Nz


t
 t t
for j  N y and k  N z
 y z

Slide 21

MATLAB Code for x-Component of Curl of 𝐸 with PBC

% Compute CEx
for nx = 1 : Nx
for ny = 1 : Ny-1
for nz = 1 : Nz-1
CEx(nx,ny,nz) = (Ez(nx,ny+1,nz) - Ez(nx,ny,nz))/dy ...
- (Ey(nx,ny,nz+1) - Ey(nx,ny,nz))/dz;
end
CEx(nx,ny,Nz) = (Ez(nx,ny+1,Nz) - Ez(nx,ny,Nz))/dy ...
- (Ey(nx,ny,1) - Ey(nx,ny,Nz))/dz;
end
for nz = 1 : Nz-1
CEx(nx,Ny,nz) = (Ez(nx,1,nz) - Ez(nx,Ny,nz))/dy ...
- (Ey(nx,Ny,nz+1) - Ey(nx,Ny,nz))/dz;
end
CEx(nx,Ny,Nz) = (Ez(nx,1,Nz) - Ez(nx,Ny,Nz))/dy ...
- (Ey(nx,Ny,1) - Ey(nx,Ny,Nz))/dz;
end

Note: It important for speed and efficiency that the boundary conditions be
incorporated without using if/then statements. This should be done explicitly.
Slide 22

11
1/23/2020

x-Component of Curl of with PBC


There are four cases where the curl must be computed explicitly.

 H i , j ,k  H i , j 1,k H i , j ,k  H i , j ,k 1
 z t  2t z t  t
2

y t  t
2
y t  t
2
for j  1 and k  1
 y z

i ,1, k 1
 H i ,1,k  H i , N y ,k H i ,1, k
y t  t  H y t  t
 z t  t
2
z t  t
2
 2 2
for j  1 and k  1
 y z
H i , j ,k
C x t  t  i , j ,1 i, j,Nz
2
 H z i , j,1t  H z i , jt1,1 H y t  H y t
 t 2 t 2

t 2 t 2
for j  1 and k  1
 y z
 i ,1,1 i , N ,1 i ,1,1 i ,1, N z
 H z t  t  H z t  yt H y t  H y t
 2
 2 2

t 2
t
for j  1 and k  1
 y z
Slide 23

MATLAB Code for x-Component of Curl of 𝐻 with PBC


% Compute CHx
for nx = 1 : Nx
CHx(nx,1,1) = (Hz(nx,1,1) - Hz(nx,Ny,1))/dy ...
- (Hy(nx,1,1) - Hy(nx,1,Nz))/dz;
for nz = 2 : Nz
CHx(nx,1,nz) = (Hz(nx,1,nz) - Hz(nx,Ny,nz))/dy ...
- (Hy(nx,1,nz) - Hy(nx,1,nz-1))/dz;
end
for ny = 2 : Ny
CHx(nx,ny,1) = (Hz(nx,ny,1) - Hz(nx,ny-1,1))/dy ...
- (Hy(nx,ny,1) - Hy(nx,ny,Nz))/dz;
for nz = 2 : Nz
CHx(nx,ny,nz) = (Hz(nx,ny,nz) - Hz(nx,ny-1,nz))/dy ...
- (Hy(nx,ny,nz) - Hy(nx,ny,nz-1))/dz;
end
end
end

Note: It important for speed and efficiency that the boundary conditions be
incorporated without using if/then statements. This should be done explicitly.

Slide 24

12
1/23/2020

Plane Wave Source Using the


Total-Field/Scattered-Field
Method

Slide 25

TF/SF Framework
scattered-field

Scattered-
Field
Reflection Plane
TF/SF Planes

Total-
Spacer Region Field

Unit cell of
total-field

real device

Spacer Region

Transmission Plane

Slide 26

13
1/23/2020

Corrections
Scattered-
Field

Every cell along the


Reflection Plane TF/SF interface requires
TF/SF Planes a correction term.

Spacer Region
Total-
Unit cell of Field
real device

Spacer Region

Transmission Plane

Slide 27

Corrections on Scattered-Field Side (1 of 2)


It is the curl of 𝐸 terms that require corrections on the
scattered-field side.

Here, the source (i.e. corrections) are incorporated through


the 𝐸 and 𝐸 field components.

E z  E z E y  E y
i , j 1, k i , j ,k i , j , k 1 i , j ,k

E i , j ,k
C x t  t t
 t t
y z
E x  E x E z  E z
i , j , k 1 i , j ,k i 1, j , k i , j ,k

E i , j ,k
C y t  t t
 t t
z x
E y  E y E x  E x
i 1, j , k i , j ,k i , j 1, k i , j ,k

E i , j ,k
C z t  t t
 t t
x y

Slide 28

14
1/23/2020

Corrections on Scattered-Field Side (2 of 2)

E z  E z E y  E y
i , j 1, k i , j ,k i , j , k 1 i , j ,k

E i , j ,k 1  src i , j ,k 1
C x t  t t
 t t
 Ey
y z z t

E x  E x E z  E z
i , j , k 1 i , j ,k i 1, j , k i , j ,k

E i , j ,k 1  src i , j ,k 1
C y t  t t
 t t
 Ex
z x z t

Standard curl equations


Corrections for TS/SF
% TF/SF Correction
CEx(:,:,nz_src-1) = CEx(:,:,nz_src-1) + Ey_src(T)/dz;
CEy(:,:,nz_src-1) = CEy(:,:,nz_src-1) - Ex_src(T)/dz; Slide 29

Corrections on Total-Field Side (1 of 2)


It is the curl of 𝐻 terms that require corrections on the
total-field side.

Here, the source (i.e. corrections) are incorporated


through the 𝐻 and 𝐻 field components.

i , j ,k i , j 1, k i , j ,k i , j , k 1
Hz  Hz Hy  Hy
H i , j ,k t  2t t  2t t  2t t  2t
C x t  t  
2 y z
i , j ,k i , j , k 1 i , j ,k i 1, j , k
H x t  t  H x t  t Hz  Hz
H i , j ,k t  2t t  2t
C y t  t  2 2

2 z x
i , j ,k i 1, j , k i , j 1, k
Hy  Hy i , j ,k
H x t  t  H x
H i , j ,k t  2t t  2t t  2t
C z t  t   2

2 x y
Slide 30

15
1/23/2020

Corrections on Total-Field Side (2 of 2)


% TF/SF Correction
CHx(:,:,nz_src) = CHx(:,:,nz_src) + Hy_src(T)/dz;
CHy(:,:,nz_src) = CHy(:,:,nz_src) - Hx_src(T)/dz;

Corrections for TS/SF

Standard curl equations

i , j ,k i , j 1, k i , j ,k i , j , k 1
i , j ,k Hz  Hz Hy  Hy 1 src i , j ,k 1
t  2t t  2t t  2t t  2t
C xH    H y t
t  2t y z z t 2

i , j ,k i , j , k 1 i , j ,k i 1, j , k
H x t  t  H x t  t H z t  t  H z 1 src i , j ,k 1
H i , j ,k t  2t
C y t  t  2 2
 2
 H x t
2 z x z t 2

Slide 31

Source Functions We Need for TF/SF


i , j , ksrc 1
H xsrc
t  2t
Scattered-
i , j , ksrc 1
Field
H ysrc
t  2t
Reflection Plane
TF/SF Planes
E xsrc
i , j , ksrc

Total- t
Spacer Region
E
Field src i , j , ksrc
y t
Unit cell of
real device

Spacer Region

Transmission Plane

Slide 32

16
1/23/2020

Polarization Vector
The electric field can be polarized in any direction in the x-y plane.

Let the incident electric field be expressed as


 
E src  P cos t  k0 ninc z 
Note:

P 1
E src i , j , ksrc
x t  Px cos t  k0 ninc z 

E ysrc
i , j , ksrc
 Py cos t  k0 ninc z 
t

Note that the Pz is not needed in this formulation.

Why isn’t this information needed?

Slide 33

The Magnetic Field


The magnetic field 𝐻 is related to the electric field 𝐻 through Maxwell’s curl equation.
  src
  H
 E src inc

c0 t
Substituting the plane wave form of the electric field leads to an expression for the
magnetic field source.
 r,src  r,src
H xsrc  t    Py cos t  k0 ninc z  H ysrc  t   Px cos  t  k0 ninc z 
r,src r,src

i , j , ksrc 1  r,src
H xsrc   Py cos   t  2t   k0 ninc  ksrc  1 z 
t  2t r,src
i , j , ksrc 1  r,src
H ysrc  Px cos   t  2t   k0 ninc  ksrc  1 z 
t  2t r,src
Slide 34

17
1/23/2020

Generalization for a Gaussian Source


A Gaussian source is implemented as

E xsrc
i , j , ksrc
 Px  g  t 
t

E ysrc
i , j , ksrc
 Py  g  t 
t

i , j , ksrc 1  r,src
H xsrc   Py  g t   t 
t  2t r,src
i , j , ksrc 1  r,src
H ysrc  Px  g t   t 
t  2t r,src

nsrc z t
t   
2c0 2
Slide 35

Typical View of 3D-FDTD with TF/SF

Gaussian Pulse

Slide 36

18
1/23/2020

Calculation of Transmittance
and Reflectance

Reflectance recorded here

Transmittance recorded here

Slide 37

Block Diagram of Power Calculation


Calculate Steady-State Ex and Ey During FDTD Simulation

Calculate Transverse Wave Vector Expansion

Frequency

Calculate Longitudinal Wave Vectors

Interpolate Fields at Origin

Normalize to Source

Calculate Amplitudes of Spatial Harmonics

Calculate Sz

Calculate Diffraction Efficiencies

Calculate Overall Reflectance and Transmittance

Slide 38

19
1/23/2020

Calculate of Steady-State Fields During Simulation

Ex ,ref E y ,ref

Reflection Plane
TF/SF Planes

Spacer Region
Note: We do not calculate Ez.
We will do this another way after FDTD.
Unit cell of
real device

Spacer Region Ex ,trn E y ,trn

Transmission Plane

Slide 39

Interpolate Field Components


The fields are staggered because they are on a Yee grid. To calculate transmittance and reflectance in 3D, we
need to interpolate the fields at a common point in each Yee cell in order to perform calculations with vector
quantities.
Here, we will interpolate them at the origin of the Yee cell.
% Interpolate Fields at Origin
Exr = zeros(Nx,Ny);
Exr(1,:) = (Exref(Nx,:,nfreq) + Exref(1,:,nfreq))/2;
Exr(2:Nx,:) = (Exref(1:Nx-1,:,nfreq) + Exref(2:Nx,:,nfreq))/2;

i , j , kref i 1, j , kref


origin,kref Ex,ref  Ex,ref
Ex ,ref 
2
i , j ,kref i , j 1, kref
origin,kref E y ,ref  E y ,ref
E y ,ref 
2
i , j ,k trn i 1, j , ktrn
origin,k trn Ex ,trn  E x ,trn
Ex ,trn 
2
i , j , k trn i , j 1,ktrn
origin,ktrn E y ,trn  E y ,trn
E y ,trn 
2
Slide 40

20
1/23/2020

Transverse Wave Vector Expansion (1 of 2)


Crossed grating devices diffraction along two dimensions,
x and y.

To quantify diffraction for crossed grating structures, we


must calculate an expansion for both kx and ky.

2 m
k x  m   k x ,inc  m  , , 2, 1, 0,1, 2, 
x
2 n
k y  n   k y ,inc  n  , , 2, 1, 0,1, 2, 
y

k xy  m, n   k x  m  xˆ  k y  n  yˆ

% TRANSVERSE WAVE VECTOR EXPANSION


M = [-floor(Nx/2):floor(Nx/2)]';
N = [-floor(Ny/2):floor(Ny/2)]';
kx = - 2*pi*M/Sx;
ky = - 2*pi*N/Sy;
[ky,kx] = meshgrid(ky,kx);
Slide 41

Transverse Wave Vector Expansion (2 of 2)


The vector expansions can be visualized this way.
kx  m  ky n


k xy  m, n   k x  m  xˆ  k y  n  yˆ
Slide 42

21
1/23/2020

Longitudinal Wave Vector Expansion (1 of 2)


The longitudinal components of the wave vectors are computed as

k z ,ref  m, n    k0 nref   k x2  m   k y2  n 
2
% Compute Longitudinal Wave Vector Components
k0 = 2*pi/lam;
k z ,trn  m, n    k0 ntrn  m  k n
2
k 2
x
2
y
kzinc = k0*nref;
kzR = sqrt((k0*nref)^2 - kx.^2 - ky.^2);
kzT = sqrt((k0*ntrn)^2 - kx.^2 - ky.^2);

The center few modes will have real kz’s. These correspond to propagating waves. The
others will have imaginary kz’s and correspond to evanescent waves that do not transport
energy.


k xy  m, n  k z  m, n  Slide 43

Longitudinal Wave Vector Expansion (2 of 2)


The overall wave vector expansion can be visualized this way

k xy  m, n  k z ,ref  m, n 

 
kref  m, n  ktrn  m, n 

Slide 44

22
1/23/2020

Normalize to Source
When a Gaussian source is used, the energy decreases at high frequencies.
If nothing is done, lower energy observed at the high frequencies will be confused with low reflectance or
transmittance.
The solution is to normalize the steady-state fields to the source.

Ex ,ref  f  % Normalize to Source


Ex ,ref  f   Exr = Exr / SRC(nfreq);
Ex ,src  f  Eyr = Eyr / SRC(nfreq);
Ext = Ext / SRC(nfreq);
E y ,ref  f  Eyt = Eyt / SRC(nfreq);
E y ,ref  f  
E y ,src  f 
Ex ,trn  f 
Ex ,trn  f  
Ex ,src  f 
E y ,trn  f 
E y ,trn  f  
E y ,src  f 
Slide 45

Calculate Spatial Harmonics


Calculate the x and y amplitude coefficients of the spatial harmonics by Fourier transforming
the steady-state Ex and Ey.
% Calculate Amplitude Components of Spatial Harmonics
Sxr = fftshift(fft2(Exr))/(Nx*Ny);
Syr = fftshift(fft2(Eyr))/(Nx*Ny);
Sxt = fftshift(fft2(Ext))/(Nx*Ny);
Syt = fftshift(fft2(Eyt))/(Nx*Ny);

Reflected spatial harmonics 

Transmitted spatial harmonics 

Slide 46

23
1/23/2020

Calculate Sz
It is not necessary to calculate the steady-state field Ez. Instead, calculate Sz from Sx and Sy
using the divergence equation.

   r E  m, n    0
 

  
   E  m, n    0
 
  jk m x  jk  n  y  jk m , n z
   S  m, n  e x   e y e z     0
 
  jk x  m  x  jk y  n  y  jk z  m , n  z   jk m x  jk  n  y  jk m , n z   jk m x  jk  n  y  jk m , n z
S x  m, n  e e e  S y  m, n  e x   e y e z    S z  m, n  e x   e y e z    0
x y z
k x  m  S x  m, n   k y  n  S y  m, n   k z  m, n  S z  m, n   0

k x  m  S x  m, n   k y  n  S y  m, n 
S z  m, n   
k z  m, n 

% Calculate Longitudinal Components


Szr = -(kx.*Sxr + ky.*Syr)./kzR;
Szt = -(kx.*Sxt + ky.*Syt)./kzT;

Slide 47

Calculate Diffraction Efficiencies


The diffraction efficiencies are calculated from the wave vector components and the
amplitudes of the spatial harmonics.

 2  k  f ; m, n  
DE ref  f ; m, n   Sref  f ; m, n   Re  z ,ref 
 k z ,inc  f  
 2  k  f ; m, n   r ,ref 
DE trn  f ; m, n   S trn  f ; m, n   Re  z ,trn 
 k z ,inc  f   r ,trn 

% Calculate Amplitude of Spatial Harmonics


Sref = abs(Sxr).^2 + abs(Syr).^2 + abs(Szr).^2;
Strn = abs(Sxt).^2 + abs(Syt).^2 + abs(Szt).^2;

% Calculate Diffraction Efficiencies


ref = real(kzR/kzinc) .* Sref;
trn = real(kzT*urref/kzinc/urtrn) .* Strn;

Slide 48

24
1/23/2020

Calculate Reflectance and Transmittance


The overall reflectance is the sum of all the diffraction efficiencies of the reflected modes.
Similarly, the overall transmittance is the sum of all the diffraction efficiencies of the
transmitted modes.
R  f    DE ref  f ; m, n  % Compute Reflectance and Transmittance
n m REF(nfreq) = sum(ref(:));
T  f    DE trn  f ; m, n  TRN(nfreq) = sum(trn(:));
n m

It is always good practice to check for conservation of energy. When no gain or loss is
incorporated into the model, the sum of the reflectance and transmittance should be 100%.

R  f   T  f   100% % CALCULATE CONSERVATION OF ENERGY


CON(nfreq) = REF(nfreq) + TRN(nfreq);

Slide 49

MATLAB’s slice()
Command for 3D Visualization

Slide 50

25
1/23/2020

MATLAB’s slice() Command

slice(X,Y,Z,V,sx,sy,sz)

X, Y, and Z are 3D arrays generated using meshgrid().

V is the 3D array of data to visualize.

sx is a 1D array of numbers of where to place slices that are perpendicular to the x-axis.
sy is a 1D array of numbers of where to place slices that are perpendicular to the y-axis.
sz is a 1D array of numbers of where to place slices that are perpendicular to the z-axis.

Slide 51

Visualizing a 3D Data Array

% Draw Ex Field
slice(Y,X,-Z,Ex,0,0,0);
axis equal tight off;
colorbar;
view(-75,20);

Slide 52

26

You might also like