EMLAB 1 Numerical Boundary Conditions. EMLAB 2 A Problem at the Boundary of the Grid We must...

35
EMLAB 1 Numerical Boundary Conditions

Transcript of EMLAB 1 Numerical Boundary Conditions. EMLAB 2 A Problem at the Boundary of the Grid We must...

Page 1: EMLAB 1 Numerical Boundary Conditions. EMLAB 2 A Problem at the Boundary of the Grid We must implement the update equations for every point in the grid.

EMLAB

1

NumericalBoundary Conditions

Page 2: EMLAB 1 Numerical Boundary Conditions. EMLAB 2 A Problem at the Boundary of the Grid We must implement the update equations for every point in the grid.

EMLAB

2

A Problem at the Boundary of the Grid

We must implement the update equations for every point in the grid.

What do we do at k = Nz ?Ey(k=Nz+1) does not exist.

What do we do at k = 1?Hx(k=0) does not exist.

Page 3: EMLAB 1 Numerical Boundary Conditions. EMLAB 2 A Problem at the Boundary of the Grid We must implement the update equations for every point in the grid.

EMLAB

3Dirichlet Boundary Condition

One easy thing to do is assume the fields outside the grid are zero.This is called a Dirichlet boundary condition.We modify the update equations as follows.

Page 4: EMLAB 1 Numerical Boundary Conditions. EMLAB 2 A Problem at the Boundary of the Grid We must implement the update equations for every point in the grid.

EMLAB

4Equations MATLAB Code

Update Equations

DO NOT use ‘if’ statements toimplement boundary condi-tions.

Page 5: EMLAB 1 Numerical Boundary Conditions. EMLAB 2 A Problem at the Boundary of the Grid We must implement the update equations for every point in the grid.

EMLAB

5Periodic Boundary Condition

Some devices are periodic along a particular direction. When this is the case, the field is also periodic. We modify the update equations as follows.

Page 6: EMLAB 1 Numerical Boundary Conditions. EMLAB 2 A Problem at the Boundary of the Grid We must implement the update equations for every point in the grid.

EMLAB

6

Grid Resolution

Page 7: EMLAB 1 Numerical Boundary Conditions. EMLAB 2 A Problem at the Boundary of the Grid We must implement the update equations for every point in the grid.

EMLAB

7Consideration #1: Wavelength

The grid resolution must be sufficient toresolve the shortest wavelength.

First, you must determine the smallest wave-length:

max

0min nf

c

c

nmax is the largest refractive index foundanywhere in the grid. fc is the maximumfrequency in your simulation.

Second, you resolve the wave with at least 10 cells.

10,min

NN

Nλ Comments

10~20 Low contrast dielectrics

20~30 High contrast dielectrics

40~60 Most metallic structures

100~200 Plasmonic devices

Page 8: EMLAB 1 Numerical Boundary Conditions. EMLAB 2 A Problem at the Boundary of the Grid We must implement the update equations for every point in the grid.

EMLAB

8Consideration #2: Mechanical Features

The grid resolution must be sufficient to resolve the smallest mechanical features of the device.

First, you must determine the smallest feature:

mind

Second, you must divide this by 1 to 4.

10,min dd

d NN

Page 9: EMLAB 1 Numerical Boundary Conditions. EMLAB 2 A Problem at the Boundary of the Grid We must implement the update equations for every point in the grid.

EMLAB

9Calculating the Initial Grid Resolution

Must resolve the minimum wavelength

Must resolve the minimum structural dimen-sion

Set the initial grid resolution to the smallestnumber computed above

10,min

NN

10,min dd

d NN

],min[ dyx

Page 10: EMLAB 1 Numerical Boundary Conditions. EMLAB 2 A Problem at the Boundary of the Grid We must implement the update equations for every point in the grid.

EMLAB

10

“Snap” grid to critical dimensions

Decide what dimensions along each axis are critical

→ Typically this is a lattice constant or grating period along x→ Typically this is a layer thickness along y

yx dd and

Compute how many grid cells comprise dx,y, and round UP

Adjust grid resolution to fit this dimension in grid EXACTLY

Page 11: EMLAB 1 Numerical Boundary Conditions. EMLAB 2 A Problem at the Boundary of the Grid We must implement the update equations for every point in the grid.

EMLAB

11

Courant Stability Condition

Page 12: EMLAB 1 Numerical Boundary Conditions. EMLAB 2 A Problem at the Boundary of the Grid We must implement the update equations for every point in the grid.

EMLAB

12Numerical Propagation Through Grid

During a single iteration, a disturbance in the electric field at one point can only be felt by the immediately adjacent magnetic fields. It takes at least two time steps before that disturbance is felt by an adjacent electric field. This is simply due to how the update equations are implemented during a single itera-tion.

Page 13: EMLAB 1 Numerical Boundary Conditions. EMLAB 2 A Problem at the Boundary of the Grid We must implement the update equations for every point in the grid.

EMLAB

13

Electromagnetic waves propagate at the speed of light in a vacuum.Inside a material, they propagate at a reduced speed.

Physical Propagation Through Space

Page 14: EMLAB 1 Numerical Boundary Conditions. EMLAB 2 A Problem at the Boundary of the Grid We must implement the update equations for every point in the grid.

EMLAB

14A Limit on Δt

Over a time duration of one time step t, an electromagnetic disturbancewill travel:

Numerical distance covered in one time step: Δz

Physical distance covered in one time step: c0Δt/n

• Because of the numerical algorithm, it is not possible for a disturbance to travel far-ther than one unit cell in a single time step.

• We need to make sure that a physical wave would not propagate farther than a single unit cell in one time step.

This places an upper limit on the time step.

n should be set to the smallest refractive index found anywhere in the grid. Usually this is just made to be 1.0 and dropped from the equation.

0c

znt

zn

tc

0

Page 15: EMLAB 1 Numerical Boundary Conditions. EMLAB 2 A Problem at the Boundary of the Grid We must implement the update equations for every point in the grid.

EMLAB

15The Courant Stability ConditionRefractive index is greater than or equal to one, so our condition on Δt can be written more simply as:

0c

zt

Sort of a worst case.

n=1 produces the fastest possible physical wave.

For 2D or 3D grids, the condition can be generalized as

2220 )(1

)(1

)(1

1

zyxc

t

The Courant stability condition

Page 16: EMLAB 1 Numerical Boundary Conditions. EMLAB 2 A Problem at the Boundary of the Grid We must implement the update equations for every point in the grid.

EMLAB

16Practical Implementation of the Stability Condition

The stability condition will be most restrictive along the shortest dimension of the grid unit cell.

A good equation to ensure stability and accuracy on any grid is then

Note: A factor of 0.5 was included here as a safety margin.

This can be generalized to account for special cases.

1. Your grid is filled with dielectric and trav-els slower everywhere.

2. Your model includes dispersive materials with refractive index less than one.

0

min

2ct

0

minmin

2c

nt

],,min[min zyx

Page 17: EMLAB 1 Numerical Boundary Conditions. EMLAB 2 A Problem at the Boundary of the Grid We must implement the update equations for every point in the grid.

EMLAB

17Time Step for Our 1D Grid

02c

znt bc

nbc = refractive index at the grid boundaries.

This means a wave will travel the distance of one grid cell in exactly two time steps. It is a necessary condition for the perfect boundary condition we will soon implement. This implies that we cannot have different materials at the two boundaries using this boundary condition.

Page 18: EMLAB 1 Numerical Boundary Conditions. EMLAB 2 A Problem at the Boundary of the Grid We must implement the update equations for every point in the grid.

EMLAB

18

Perfect 1D Boundary Condition

Page 19: EMLAB 1 Numerical Boundary Conditions. EMLAB 2 A Problem at the Boundary of the Grid We must implement the update equations for every point in the grid.

EMLAB

19The Problem

The finite‐difference equation here requires knowledge of the electric field outside of the grid.

Page 20: EMLAB 1 Numerical Boundary Conditions. EMLAB 2 A Problem at the Boundary of the Grid We must implement the update equations for every point in the grid.

EMLAB

20Implementing the Perfect Boundary Condition

If…• the field is only travelling outward at the boundaries• the materials at the boundaries are linear, homogeneous, isotropic and non‐

dispersive• The refractive index at both boundaries is nbc.• Δt = nbc Δ z/(2c0) exactly.

then

Page 21: EMLAB 1 Numerical Boundary Conditions. EMLAB 2 A Problem at the Boundary of the Grid We must implement the update equations for every point in the grid.

EMLAB

21Visualizing the Perfect Boundary Condition

Page 22: EMLAB 1 Numerical Boundary Conditions. EMLAB 2 A Problem at the Boundary of the Grid We must implement the update equations for every point in the grid.

EMLAB

22Summary of the 1D Perfect Boundary Condition

Conditions• Waves at the boundaries are only travelling outward.• Materials at the boundaries are linear, homogeneous, isotropic and non‐dispersive• The refractive index is the same at both boundaries and is nbc.• Time step is chosen so physical waves travel 1 cell in exactly two time steps• Δ t = nbc Δ z/(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.

Page 23: EMLAB 1 Numerical Boundary Conditions. EMLAB 2 A Problem at the Boundary of the Grid We must implement the update equations for every point in the grid.

EMLAB

23

Sources

Page 24: EMLAB 1 Numerical Boundary Conditions. EMLAB 2 A Problem at the Boundary of the Grid We must implement the update equations for every point in the grid.

EMLAB

24The Gaussian Pulse

In FDTD, we typically use short pulses as sources. This approximates an impulse function so we can excite a single simulation with a broad range of frequencies at the same time.

Page 25: EMLAB 1 Numerical Boundary Conditions. EMLAB 2 A Problem at the Boundary of the Grid We must implement the update equations for every point in the grid.

EMLAB

25Frequency Content of Gaussian Pulse

The Fourier transform of a Gaussian pulse is another Gaussian function.

The frequency content of the Gaussian pulse extends from DC up to around B.

Page 26: EMLAB 1 Numerical Boundary Conditions. EMLAB 2 A Problem at the Boundary of the Grid We must implement the update equations for every point in the grid.

EMLAB

26

Designing the Pulse Source (1 of 2)

Step 1: Determine the bandwidth B of the source to cover all frequencies of interest.

B

Step 2: Compute the pulse width to encompass the needed bandwidth.

Step 3: You may need to reduce your time step. Your Gaussian pulse should be re-solved by at least 10 to 20 time steps.

Typically, you determine a first Δt based on the Courantstability condition, then determine a second Δ t based onresolving the maximum frequency, and finally go with thesmallest value of the two Δ t’s.All of this should be satisfied automatically if Δ t = n Δ z/(2c0).

Page 27: EMLAB 1 Numerical Boundary Conditions. EMLAB 2 A Problem at the Boundary of the Grid We must implement the update equations for every point in the grid.

EMLAB

27Visualizing the Arrays

Page 28: EMLAB 1 Numerical Boundary Conditions. EMLAB 2 A Problem at the Boundary of the Grid We must implement the update equations for every point in the grid.

EMLAB

28Designing the Pulse Source (2 of 2)

Step 4: Compute the delay time t0

The pulse source must start at zero and gradually increase. NO STEP FUNCTIONS!!

60 t

WRONG!!The step function at the beginning will induce very large field gradients.

STILL WRONG!!While better, this source still starts with a step function that will produce large field gradients.

CORRECT!!This source “eases” into the Gaussian source.

Page 29: EMLAB 1 Numerical Boundary Conditions. EMLAB 2 A Problem at the Boundary of the Grid We must implement the update equations for every point in the grid.

EMLAB

29Two Ways to Incorporate a Source

Source #1: Simple Hard SourceThe simple hard source is the easiest to implement. After updating the field across the en-tire grid, one field component at one point on the grid is overwritten with the source. This approach injects power into the model, but the source point behaves like a perfect electric conductor or perfect magnetic conductor and will scatter waves.

OVERWRITENot usually a practical source.We won’t use it.

Source #2: Simple Soft SourceThe simple soft source is better than the hard source because it is transparent to scat-tered waves passing through it. After updating the field across the entire grid, the source function is added to one field component at one point on the grid. This ap-proach injects power into the model in both directions. It is great for testing bound-ary conditions.

ADD TORarely used. Use this until we learn TF/SF.

Page 30: EMLAB 1 Numerical Boundary Conditions. EMLAB 2 A Problem at the Boundary of the Grid We must implement the update equations for every point in the grid.

EMLAB

30

Total Number of Iterations

Page 31: EMLAB 1 Numerical Boundary Conditions. EMLAB 2 A Problem at the Boundary of the Grid We must implement the update equations for every point in the grid.

EMLAB

31Considerations for Estimating the TotalNumber of Iterations

The total number of iterations depends heavily on the device beingmodeled and what properties of it are being calculated.

Device Considerations1. Highly resonant devices typically require more iterations.2. Purely scattering devices typically require very few iterations.3. More iterations are needed the more times the waves bounce around in the grid.

Information Considerations1. Calculating abrupt spectral shapes requires many iterations.2. Calculating fine frequency resolution requires many iterations.3. Calculating the approximate position of resonances oftenrequires fewer iterations. Great for hunting resonances!

Page 32: EMLAB 1 Numerical Boundary Conditions. EMLAB 2 A Problem at the Boundary of the Grid We must implement the update equations for every point in the grid.

EMLAB

32A Rule of Thumb

How long does it take a wave to propagate across the grid (worst case)?

Simulation time T must include the entire pulse of duration τ.

Simulation time should allow for 5 bounces.

A rule‐of‐thumb for total simulation time is then

Given the time step Δt, the total number of iterations is then

Note: For highly resonant devices, this will NOT be enough time!

This must be an integer quantity.

Page 33: EMLAB 1 Numerical Boundary Conditions. EMLAB 2 A Problem at the Boundary of the Grid We must implement the update equations for every point in the grid.

EMLAB

33

Revised FDTD Algorithm

Page 34: EMLAB 1 Numerical Boundary Conditions. EMLAB 2 A Problem at the Boundary of the Grid We must implement the update equations for every point in the grid.

EMLAB

34Revised FDTD Algorithm

Page 35: EMLAB 1 Numerical Boundary Conditions. EMLAB 2 A Problem at the Boundary of the Grid We must implement the update equations for every point in the grid.

EMLAB

35

Equations → MATLAB Code