learning from one dimensional · 2020-02-16 · 2/16/2020 1 computational science: introduction to...
TRANSCRIPT
2/16/2020
1
Computational Science:
Introduction to Finite‐Difference Time‐Domain
Learning FromOne‐Dimensional FDTD
Lecture Outline
•Review of Lecture 6• Total‐Field/Scattered‐Field Soft Source • Fourier Transform•Reflectance and Transmittance
•Displaying the Results
Slide 2
1
2
2/16/2020
2
Slide 3
Review
Dirichlet Boundary Condition
Slide 4
2 2
2 2
1
0
t t
t t
z
k t tHx z
k kx x
k kx x
t t
k tHx zt
y
t
k ky
Ny
m k Nz
m k Nz
E EH
HE
H
H
2 2
2
1
1
1
10
t t
t
k kx t tk
Eyk ky y
k
t t t
tkEyt ty
x
xky t
E E
E
m kz
m k
H
z
H
EH
Dirichlet boundary conditions assume all field quantities outside of grid are zero.
The update equations are modified as follows.
3
4
2/16/2020
3
Computing Grid Resolution
Slide 5
0min
max max
c
f n
min 10NN
1) Resolve Wavelength
2) Resolve Features
1dN 4dN 1dN 1dN
min 1d dd
dN
N
min , d
3) Initial Resolution
4) “Snap” Grid to Critical Dimensions
ceil c
c
N d
d N
Courant Stability Condition
Slide 6
Generalized Courant Stability Condition
min
0 2 2 2
1 1 1
nt
cx y z
For 1D Grids with Perfectly Absorbing Boundary Condition
bcbc
0
refractive index at boundaries2
n zt n
c
5
6
2/16/2020
4
Perfectly Absorbing Boundary Condition
Slide 7
Necessary Conditions• Waves at the boundaries are only travelling outward.• Materials at the boundaries are linear, homogeneous, isotropic and non‐dispersive.• Refractive index must be the same about both boundaries.• Time step is chosen so physical waves travel 1 cell in two time steps.t = nz/(2c0)
Implementation at z‐Low BoundaryAt the z‐low boundary, we need only modify the E‐field update equation.
Implementation at z‐High BoundaryAt the z‐high boundary, we need only modify the H‐field update equation.
2
1
1 12 1
12
1
ttkEyt t ty
x
x y
hh
HE Eh
zHh m
2 2
2
2 1 1 z
z
z
t
z
t
N N tx
k
NyN
xty Ht x
ee
EE He e m
zH
The Gaussian Source
Slide 8
The Gaussian source approximates an impulse so that a structure can be characterized over an enormous range of frequencies in a single simulation.
2
0expt
tt
g
duration of simulation
0t
max
0.5
f
0 6t
maxf
max
1 1
e f
max
1
f
Frequency
G f
7
8
2/16/2020
5
Estimating Total Number of Iterations
9
prop12 5T t
Total Simulation Time
Allow for 3‐5 bounces.Highly resonant devices will need much more.
Allow for the entire pulse without cutting it off.
Total Number of Iterations
STEPS roundT
t
This must be an integer quantity.
time it takes for a wave to propagate across the grid one time.
maxprop
0
zn N zt
c
Revised FDTD Algorithm
Slide 10
Finished!
Compute Grid Resolution
2 2
2 2
1
2
t t
z z z z
t t
k k k k kx x Hx y y zt tt t
N N N Nx x Hx y ztt t
H H m E E z k N
H H m E z k Ne
min minmin ,
round
d
c
c
dz
N N
N d z
z d N
Update H from E
no
Compute Time Step bc 02t n z c
Compute Source
max 0
2
0
0.5 5
exp
f t
t tg t
Compute Update Coeff’s0 0 k k
Ey Hxk kyy xx
c t c tm m
Initialize Fields0k k
y xE H
1 1 1 1
2
2 2
2
1
1
1
ty y Ey xt t t t
k k k k kt ty y Ey x xt t t t t
E E m H z k
E E m H H z k
h
Update E from H
src srck ky y tt t tE E g
Inject Source
Visualize fields
Done?yes
2
12 1 1,
tx th h h H
Record H‐Field Boundary Term
2 1 1, Nzy t
e e e E
Record E‐Field Boundary Term
z
z
Loop over time
t
Build DeviceERyy and URxx
Initialize Boundary Terms
2 1 2 1 0h h e e
Includes:• Basic FDTD engine• Dirichlet BC’s• Calculate source parameters• Simple soft source• Perfectly absorbing BC’s
Excludes:• TF/SF source• Fourier transforms• Reflectance/transmittance• Calculate grid parameters• Incorporate device
9
10
2/16/2020
6
Slide 11
Total‐Field/Scattered‐Field Soft Source
Total‐Field / Scattered‐Field
• The total‐field/scattered‐field (TF/SF) is a technique to inject a “one‐way” source.•Benefits• Eliminates backward propagating waves• Ensures waves at the boundaries are only travelling outward• 100% of power injected by the source is incident on the device being simulated.
Slide 12
scattered‐field
total‐field
11
12
2/16/2020
7
Example Simulation #1
Slide 13
Materials Field TF/SFPML
PML
PML
PML
PML
PML
Scattered‐FieldScattered‐Field
Total‐FieldTotal‐Field
1 1.0n
Materials Field TF/SFPML
PML
PML
PML
PML
PML
Scattered‐FieldScattered‐Field
Total‐FieldTotal‐Field
1 1.0n
2 3.0n
Example Simulation #2
Slide 14
Materials Field TF/SFPML
PML
PML
PML
PML
PML
Scattered‐FieldScattered‐Field
Total‐FieldTotal‐Field
1 1.0n
Materials Field TF/SFPML
PML
PML
PML
PML
PML
Scattered‐FieldScattered‐Field
Total‐FieldTotal‐Field
1 1.0n
2 3.0n
Scattered‐Field
13
14
2/16/2020
8
Animation of TF/SF in 1D‐FDTD
15
PAB PAB
bcnbcn
1D‐FDTD Grid Strategy
Slide 16
max min and n n
Total‐FieldScattered‐Field
TF/SF Interface
src src and k kr r
Source Injection Point
Transmission Record Point
Reflection Record Point
Structure Being Modeled
Spacer Region
max
Spacer Region
max
Spacer Regions
The spacer regions are not needed for our 1D‐FDTD code, but we will need them for 2D and 3D. They are still good to include in 1D for field visualization and learning.
15
16
2/16/2020
9
The Total‐Field/Scattered‐Field Framework
Slide 17
Problem Points!
total‐field
scattered‐field
1D FDTD Grid
srcksrc 1k
Correction to Finite‐Difference Equations at the Problem Cells (1 of 2)
Slide 18
On the scattered‐field side of the TF/SF interface, the finite‐difference equation contains a term from the total‐field side. Due to the staggered nature of the Yee grid, this only occurs in the update equation for a magnetic field.
src
src src src
2 2
src 1
1 1 1
t t
k
k k yk tx x Hxt
k
t
t
y EH H m
E
z
This is an equation in the
scattered‐field, but 𝐸 is
a total‐field quantity.
Subtract the source from 𝐸 to make it look like a scattered‐field quantity.
sr src
src src s
sr
r
2 2
c
c
csrc 1
1 1 1
t t
k
yk k
k
y tk t
x x H
t
xt
y
t
kE E
Hz
EH m
src src src
src sr src csrc
2 2
s
1 1
1 c1 1 rt t
k k k
Hxk k y yk t tx H
k
t y tx xt
mE EH H m
zE
z
standard update equation
This is a correction term that can be implemented after the standard update equation to inject a source.
total‐field
scattered‐field
srcksrc 1k
17
18
2/16/2020
10
Correction to Finite‐Difference Equations at the Problem Cells (2 of 2)
Slide 19
On the total‐field side of the TF/SF interface, the finite‐difference equation contains a term from the scattered‐field side. Due to the staggered nature of the Yee grid, this only occurs in the update equation for an electric field.
src
src src src 2
src
2
1
t t
k
x t
k
xk k k t
y y Eyt t t
HE E m
H
z
This is an equation in the
total‐field, but 𝐻 is a scattered‐field quantity.
Add the source to 𝐻 to make it look like a total‐field quantity.
src
src s
sr src
2
c
2rc src 2
1c1 srtt t
k
x
k
xk k k t
y y Eyt
k
t t
t x tH
E E mz
HH
src src src
src src src 2 2 src
2
1sr
1
ct t
t
k k k
x x Eyk k k t t
y y Eyt t
k
t x tH
H H mE E m
z z
standard update equation
This is a correction term that can be implemented after the standard update equation to inject a source.
total‐field
scattered‐field
srcksrc 1k
The Two Source Terms
Slide 20
From the previous slides, two source functions must be calculated before entering the main FDTD loop. These are:
srcsrc k
y tE
src
2
1srct
k
x tH
A few observations must be accounted for before we can calculate these source functions correctly.
1. The amplitude of these functions can be different as 𝐸 and 𝐻 are related through the material impedance.
2. These functions are a half grid cell apart and have a small time delay between them3. These functions exist at different time steps.
19
20
2/16/2020
11
Amplitude of the 𝐻 Field (1 of 3)
Slide 21
Assuming the source is injected inside a homogeneous material, the fields must be plane waves. The electric field has the form:
sinyE t t z
We must find the amplitude A and phase of the magnetic field relative to the electric field. In general, the magnetic field can be written as
sinxH t A t z
Amplitude of the 𝐻 Field (2 of 3)
Slide 22
Substitute the sine wave expressions into Maxwell’s equations…
r
0
r
0
r
0
sin sin
cos cos
yx E tH t
z c t
A t z t zz c t
A t z t zc
In order for this equation to be true, the follow two equations must be satisfied. Recall that 𝛽 𝜔 𝜇𝜀 and 𝑐 1 𝜇 𝜀⁄ .
r
0
Ac
0 r r
0 r
Ac
21
22
2/16/2020
12
Amplitude of the 𝐻 Field (3 of 3)
Slide 23
The answer for the Ey/Hxmode is
r,src
r,src
0EyHx EyHxA
We could similarly show for the Ex/Hymode that
r,src
r,src
0ExHy ExHyA
IMPORTANT:The permittivity r,src and permeability r,src in these equations are the material properties where the source is to be injected.
Calculation of the Source Functions
Slide 24
We calculate the electric field as
srcsrc k
x tE g t
Half time step difference
Delay through one half of a grid cell
Amplitude due to Maxwell’s equations
Ex/HyMode
We calculate the electric field as
srcsrc k
y tE g t
We calculate the magnetic field as
s
srcrc
src2
1srcsrc
02 2t
krkr
k
x t
n z tg t
cH
Half time step difference
Delay through one half of a grid cell
Amplitude due to Maxwell’s equations
Ey/HxMode
src
src
src
2
s1sr rc c
02 2t
krk
k
r
y t
n z tg t
cH
We calculate the magnetic field as
r,src r,src src, , material properties where source is injectedn
23
24
2/16/2020
13
Visualizing the Source Functions
25
Ex/HyMode Ey/HxMode
max
2.0
6.0
1 GHz
4.3 mm
7.16 ps
r
r
f
z
t
t
3.5 pst
t10.74 pst
Slide 26
Fourier Transforms
25
26
2/16/2020
14
Recall Transient Vs. Steady‐State
Slide 27
Steady‐State Response
FFTH h t
What is being plotted?
Re j tH e
Transient Response
1FFTh t H
What is being plotted?
h tThe steady‐state response is the Fourier transform of the transient response.
Recording the Reflection and Transmission Responses
Slide 28
time
time
Transm
ission Response
Refle
ction Response
FDTD Simulation
27
28
2/16/2020
15
Brute Force Fourier Transforms
Slide 29
The easiest, but least memory efficient, method to compute a Fourier transform is to perform a simulation and record the desired field as a function of time. After the simulation is finished, these functions can be Fourier transformed using an FFT.
reflected field transmitted field
Storing the response functions is seldom done because it can require a lot of memory, especially when the response is recorded at many points on the grid.
Efficient Fourier Transform (1 of 2)
Slide 30
The standard Fourier transform is defined as
2j ftF f f t e dt
If the function 𝑓 𝑡 is only known at discrete points, the Fourier transform can be approximated numerically as
2
1
Mj fm t
m
F f f m t e t
This can be written in a slightly different form.
2
1
M mj f t
m
F f t e f m t
total number of time steps
integer time step
M
m
Examplet = 33.3564 psf = 1.0000 GHzK = 0.9781 – i0.2081
29
30
2/16/2020
16
Efficient Fourier Transform (2 of 2)
Slide 31
The final form on the previous slide suggests an efficient implementation. The Fourier transform is updated every iteration so by the end of the main loop:
2
1
fM
t m
m
j f meF f t
2j f te
This “kernel” can be computed prior to the main FDTD loop for each frequency of interest. The kernels can be stored in a 1D array.
This is simply the field value of interest at the current time step.
To speed up the simulation, this multiplication can be done after the main FDTD loop in a post‐processing step.
Visualizing the Data Structures for Calculating Steady‐State Fields Across the Entire Grid
Slide 32
Frequency 1
Frequency 2
Frequency 3
Frequency 4
Frequency 5
Frequency 6
Frequency 7
Frequency 8
Frequency 9
Frequency 10
Frequency 11
Frequency 12
Kernels
FDTD Grid
f1
f2
f3
f4
f5
f6
f7
f8
f9
f10
f11
f12
31
32
2/16/2020
17
Visualizing the Data Structures for Calculating Transmittance and Reflectance
Slide 33
Frequency 1
Frequency 2
Frequency 3
Frequency 4
Frequency 5
Frequency 6
Frequency 7
Frequency 8
Frequency 9
Frequency 10
Frequency 11
Frequency 12
Kernels
FDTD Grid
f1
f2
f3
f4
f5
f6
f7
f8
f9
f10
f11
f12
Steady‐state
fields o
n refle
ction sid
e
Steady‐state
fields o
n tran
smitte
d sid
e
Efficient Fourier Transform Algorithm
Slide 34
Finished!
Compute Kernels2 nj f t
nK e
Update H from E
no
Update Fourier Transforms
Done?yes
Update E from H
Initialize Fourier Transforms
0nF
, ,m i j kn n n yt t t t tF F K E
Finalize Fourier Transforms
n nF t F
Fn will now be the steady‐state Eyat point (i, j, k) and frequency n.
f
z
and/or
f
z
z
f zand/or
f zand/or
33
34
2/16/2020
18
MATLAB Code for Fourier Transforms
35
% SOURCE PARAMETERSf2 = 5.0 * gigahertz;NFREQ = 1000;FREQ = linspace(0,f2,NFREQ);
% INITIALIZE FOURIER TRANSFORMSK = exp(-1i*2*pi*dt*FREQ);EyR = zeros(1,NFREQ);EyT = zeros(1,NFREQ);
% MAIN FDTD LOOPfor T = 1 : STEPS
% Perform FDTD Functions
% Update Fourier Transformsfor nf = 1 : NFREQ
EyR(nf) = EyR(nf) + (K(nf)^T)*Ey(1);EyT(nf) = EyT(nf) + (K(nf)^T)*Ey(Nz);
end
% Visualizeend
% FINISH FOURIER TRANSFORMSEyR = EyR*dt;EyR = EyT*dt;
REMEMBER! We are not finished the Fourier transforms until we multiply by t.
Slide 36
Calculating Reflectance and Transmittance
35
36
2/16/2020
19
Absorptance, Reflectance and Transmittance
Slide 37
When simulating passive devices, the most common output is a plot of the absorptance, reflectance and/or transmittance as a function of frequency.
Absorptance, A: fraction of power absorbed by a device.
Reflectance, R: fraction of power reflected from a device.
Transmittance, T: fraction of power transmitted through a device.
Conservation of Power
1A R T In this course, we will mostly
ignore losses and assume A = 0.
The Response of a Device in FDTD
Slide 38
The easiest, but least memory efficient, method to compute a Fourier transform is to perform a simulation and record the desired field as a function of time. After the simulation is finished, these functions can be Fourier transformed using an FFT.
reflected field transmitted field
source
The spectral content of the source decreases with frequency, producing the observed roll‐off in the reflected and transmitted spectra.
37
38
2/16/2020
20
The Fourier Transforms
Slide 39
It is typical to start the computation of power by Fourier transforming the reflected and transmitted field using one of the methods described previously. Typical FDTD simulation results look like this
srcFFT E t
trnFFT E t
refFFT E t
srcE t
trnE t
refE t
Normalizing the Fourier Transforms
Slide 40
It is necessary to normalize the spectra to calculate transmittance and reflectance. This is one by dividing the reflection and transmission spectrum by the source spectrum.
It is ALWAYS good practice to check for power conservation by adding the reflectance and transmittance and ensuring the sum equals 100% (assuming no loss or gain in your device).
C f TR f f
Note: this equation will require modification to handle the case where the transmitted side resides in a different material.
sr
re
c
2
fFFT
FFT E t
E tR f
sr
tr
c
2
nFFT
FFT E t
E tT f
39
40
2/16/2020
21
MATLAB Code for Reflectance and Transmittance
41
% SOURCE PARAMETERSf2 = 5.0 * gigahertz;NFREQ = 1000;FREQ = linspace(0,f2,NFREQ);
% INITIALIZE FOURIER TRANSFORMSK = exp(-1i*2*pi*dt*FREQ);EyR = zeros(1,NFREQ);EyT = zeros(1,NFREQ);SRC = zeros(1,NFREQ);
% MAIN FDTD LOOPfor T = 1 : STEPS
% Perform FDTD Functions
% Update Fourier Transformsfor nf = 1 : NFREQ
EyR(nf) = EyR(nf) + (K(nf)^T)*Ey(1);EyT(nf) = EyT(nf) + (K(nf)^T)*Ey(Nz);SRC(nf) = SRC(nf) + (K(nf)^T)*Esrc(T);
end
% Visualizeend
% COMPUTE REFLECTANCE AND TRANSMITTANCEREF = abs(EyR./SRC).^2;TRN = abs(EyT./SRC).^2;CON = REF + TRN;
No need to multiply by t here because that term would cancel after performing the divisions.
The Time & Frequency Axes
Slide 42
max
0.5f
t
Time AxisThe time axis is calculated according to
T = [0:STEPS-1]*dt;
Frequency Axis
The FDTD algorithm is performed in small time increments t.The Nyquist theorem tells us that the upper frequency we can resolve with this time step is
STEPS should be an odd number here.
Staying consistent with this notation, our frequency axis after an fftshift(fft()) is computed as:
fmax = 0.5/dt;freq = linspace(-fmax,+fmax,STEPS);
41
42
2/16/2020
22
Frequency Resolution Vs. Upper Frequency
Slide 43
Upper Frequency Limit
The time step t determines the upper frequency that can be resolved by your FDTD model.
max
0.5f
t
Frequency Resolution
The number of time iterations (STEPS) determines how finely the frequencies can be resolved.
1f
t
STEPSNote: the frequency spacing between your kernels only controls your graphical frequency resolution, not the actual frequency resolution.
Movie of Real‐Time Fourier Transforms
44
43
44
2/16/2020
23
Slide 45
RevisedFDTD Algorithm
Continued next slide…
Revised FDTD Algorithm (1 of 2)
Slide 46
Update H from E
yesCompute Source
max 0
2
0,src
src
0
2
0,src
0.5 3
exp
2 2
exp
y
r
r
x
f t
t tE t
n z tA t
c
t t tH t A
, ,m i j kn n n yt t t t tF F K E
Update Fourier Transforms
Visualize fields
Done?no
Initialize FDTD
• Compute grid resolution• Build device• Compute time step• Compute update coefficients• Initialize fields
Initialize Fourier Transforms2 0nj f t
n nK e F
Handle H‐Field Source
src
src sr rc c
2
s
2,sr
11
c1
t t
kk k Hxx x tt t
ky
mEH H
z
Update E from H
Handle E‐Field Source
r s
src
src s c
2
rc 1,src t
kEyk k
y yk
t t t t tx
mE E H
z
Initialize Fields + Boundary Terms
2 1 2 1 0k ky xE H h h e e
Record H at Boundary1
2 1 1, xh h h H
Record E at Boundary
2 1 1, zNye e e E
Loop over time
t
z
z
f
Finalize Fourier Transforms
n nF t F
Includes:• Basic FDTD engine• Dirichlet BC’s• Calculate source
parameters• Simple soft source• Perfectly absorbing
BC’s• TF/SF source• Fourier transforms• REF/TRN• Calculate grid
parameters• Incorporate device
45
46
2/16/2020
24
Revised FDTD Algorithm (2 of 2)
Slide 47
…from previous slide
Normalize Transforms
s
ref t
rc sr
rn
c
FFT FFT &
FFT FFT
t
E t
EE
t E
t
Calculate Reflectance & Transmittance
2
tr
s
ref
rc s
n
rc
2FFT FFT
FFT FFT
E tR
tf
E E t
E
tT f
Calculate Power Conservation
C f TR f f
Visualize the Results
Finished!!
Tips for Visualization in FDTD
• Always show the materials and fields during the simulation. Superimposed is best.• Try to show all the field components in the model. If your code is unstable, this may help point to the reason.• Graphics commands slow the simulation dramatically. Update graphics after some duration of time, after some number of iterations, and limit any fancy formatting.• Try to display transmittance, reflectance, and power conservation during the simulation. Often, you can identify problems during the simulation and not have to wait until it finishes.
Slide 48
47
48