Understanding the Finite-Difference Time-Domain Method

Understanding the Finite-Difference Time-Domain Method

John B. Schneider May 28, 2021

ii

Contents

1 Numeric Artifacts

7

1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

1.2 Finite Precision . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

1.3 Symbolic Manipulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

2 Brief Review of Electromagnetics

13

2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

2.2 Coulomb's Law and Electric Field . . . . . . . . . . . . . . . . . . . . . . . . . . 13

2.3 Electric Flux Density . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

2.4 Static Electric Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

2.5 Gradient, Divergence, and Curl . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

2.6 Laplacian . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

2.7 Gauss's and Stokes' Theorems . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

2.8 Electric Field Boundary Conditions . . . . . . . . . . . . . . . . . . . . . . . . . 25

2.9 Conductivity and Perfect Electric Conductors . . . . . . . . . . . . . . . . . . . . 25

2.10 Magnetic Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

2.11 Magnetic Field Boundary Conditions . . . . . . . . . . . . . . . . . . . . . . . . . 27

2.12 Summary of Static Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

2.13 Time Varying Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

2.14 Summary of Time-Varying Fields . . . . . . . . . . . . . . . . . . . . . . . . . . 29

2.15 Wave Equation in a Source-Free Region . . . . . . . . . . . . . . . . . . . . . . . 29

2.16 One-Dimensional Solutions to the Wave Equation . . . . . . . . . . . . . . . . . 30

3 Introduction to the FDTD Method

33

3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

3.2 The Yee Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

3.3 Update Equations in 1D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

3.4 Computer Implementation of a One-Dimensional

FDTD Simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

3.5 Bare-Bones Simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

3.6 PMC Boundary in One Dimension . . . . . . . . . . . . . . . . . . . . . . . . . . 44

3.7 Snapshots of the Field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

3.8 Additive Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

3.9 Terminating the Grid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

3.10 Total-Field/Scattered-Field Boundary . . . . . . . . . . . . . . . . . . . . . . . . 53

iii

iv

CONTENTS

3.11 Inhomogeneities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 3.12 Lossy Material . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66

4 Improving the FDTD Code

75

4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75

4.2 Arrays and Dynamic Memory Allocation . . . . . . . . . . . . . . . . . . . . . . 75

4.3 Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77

4.4 Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80

4.5 Improvement Number One . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86

4.6 Modular Design and Initialization Functions . . . . . . . . . . . . . . . . . . . . . 90

4.7 Improvement Number Two . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95

4.8 Compiling Modular Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102

4.9 Improvement Number Three . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103

5 Scaling FDTD Simulations to Any Frequency

115

5.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115

5.2 Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115

5.2.1 Gaussian Pulse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115

5.2.2 Harmonic Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116

5.2.3 The Ricker Wavelet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117

5.3 Mapping Frequencies to Discrete Fourier Transforms . . . . . . . . . . . . . . . . 120

5.4 Running Discrete Fourier Transform (DFT) . . . . . . . . . . . . . . . . . . . . . 121

5.5 Real Signals and DFT's . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123

5.6 Amplitude and Phase from Two Time-Domain Samples . . . . . . . . . . . . . . 126

5.7 Conductivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128

5.8 Transmission Coefficient for a Planar Interface . . . . . . . . . . . . . . . . . . . 132

5.8.1 Transmission through Planar Interface . . . . . . . . . . . . . . . . . . . . 134

5.8.2 Measuring the Transmission Coefficient Using FDTD . . . . . . . . . . . 135

6 Differential-Equation Based ABC's

145

6.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145

6.2 The Advection Equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145

6.3 Terminating the Grid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146

6.4 Implementation of a First-Order ABC . . . . . . . . . . . . . . . . . . . . . . . . 148

6.5 ABC Expressed Using Operator Notation . . . . . . . . . . . . . . . . . . . . . . 153

6.6 Second-Order ABC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156

6.7 Implementation of a Second-Order ABC . . . . . . . . . . . . . . . . . . . . . . 158

7 Dispersion, Impedance, Reflection, and Transmission

161

7.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161

7.2 Dispersion in the Continuous World . . . . . . . . . . . . . . . . . . . . . . . . . 161

7.3 Harmonic Representation of the FDTD Method . . . . . . . . . . . . . . . . . . . 162

7.4 Dispersion in the FDTD Grid . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165

7.5 Numeric Impedance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169

7.6 Analytic FDTD Reflection and Transmission Coefficients . . . . . . . . . . . . . . 169

CONTENTS

v

7.7 Reflection from a PEC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 7.8 Interface Aligned with an Electric-Field Node . . . . . . . . . . . . . . . . . . . . 175

8 Two-Dimensional FDTD Simulations

181

8.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181

8.2 Multidimensional Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 8.3 Two Dimensions: TMz Polarization . . . . . . . . . . . . . . . . . . . . . . . . . 185

8.4 TMz Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189 8.5 The TFSF Boundary for TMz Polarization . . . . . . . . . . . . . . . . . . . . . . 202 8.6 TMz TFSF Boundary Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 8.7 TEz Polarization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220

8.8 PEC's in TEz and TMz Simulations . . . . . . . . . . . . . . . . . . . . . . . . . 224 8.9 TEz Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227

9 Three-Dimensional FDTD

241

9.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241

9.2 3D Arrays in C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241

9.3 Governing Equations and the 3D Grid . . . . . . . . . . . . . . . . . . . . . . . . 244

9.4 3D Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252

9.5 TFSF Boundary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267

9.6 TFSF Demonstration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272

9.7 Unequal Spatial Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282

10 Dispersive Material

289

10.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289

10.2 Constitutive Relations and Dispersive Media . . . . . . . . . . . . . . . . . . . . . 290

10.2.1 Drude Materials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291

10.2.2 Lorentz Material . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292

10.2.3 Debye Material . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293

10.3 Debye Materials Using the ADE Method . . . . . . . . . . . . . . . . . . . . . . . 294

10.4 Drude Materials Using the ADE Method . . . . . . . . . . . . . . . . . . . . . . . 296

10.5 Magnetically Dispersive Material . . . . . . . . . . . . . . . . . . . . . . . . . . . 298

10.6 Piecewise Linear Recursive Convolution . . . . . . . . . . . . . . . . . . . . . . . 301

10.7 PLRC for Debye Material . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305

11 Perfectly Matched Layer

307

11.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307

11.2 Lossy Layer, 1D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308

11.3 Lossy Layer, 2D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310

11.4 Split-Field Perfectly Matched Layer . . . . . . . . . . . . . . . . . . . . . . . . . 312

11.5 Un-Split PML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315

11.6 FDTD Implementation of Un-Split PML . . . . . . . . . . . . . . . . . . . . . . . 318

vi

CONTENTS

12 Acoustic FDTD Simulations

323

12.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323

12.2 Governing FDTD Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325

12.3 Two-Dimensional Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . 328

13 Parallel Processing

331

13.1 Threads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331

13.2 Thread Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333

13.3 Message Passing Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340

13.4 Open MPI Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341

13.5 Rank and Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343

13.6 Communicating Between Processes . . . . . . . . . . . . . . . . . . . . . . . . . 344

14 Near-to-Far-Field Transformation

351

14.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351

14.2 The Equivalence Principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351

14.3 Vector Potentials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352

14.4 Electric Field in the Far-Field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359

14.5 Simpson's Composite Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . 363

14.6 Collocating the Electric and Magnetic Fields: The Geometric Mean . . . . . . . . 363

14.7 NTFF Transformations Using the Geometric Mean . . . . . . . . . . . . . . . . . 366

14.7.1 Double-Slit Radiation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366

14.7.2 Scattering from a Circular Cylinder . . . . . . . . . . . . . . . . . . . . . 370

14.7.3 Scattering from a Strongly Forward-Scattering Sphere . . . . . . . . . . . 371

A Construction of Fourth-Order Central Differences

A.377

B Generating a Waterfall Plot and Animation

B.379

C Rendering and Animating Two-Dimensional Data

C.383

D Notation

D.387

E PostScript Primer

E.389

E.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . E.389

E.2 The PostScript File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . E.390

E.3 PostScript Basic Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . E.390

Index

403

Chapter 1

Numeric Artifacts

1.1 Introduction

Virtually all solutions to problems in electromagnetics require the use of a computer. Even when an analytic or "closed form" solution is available which is nominally exact, one typically must use a computer to translate that solution into numeric values for a given set of parameters. Because of inherent limitations in the way numbers are stored in computers, some errors will invariably be present in the resulting solution. These errors will typically be small but they are an artifact about which one should be aware. Here we will discuss a few of the consequences of finite precision.

Later we will be discussing numeric solutions to electromagnetic problems which are based on the finite-difference time-domain (FDTD) method. The FDTD method makes approximations that force the solutions to be approximate, i.e., the method is inherently approximate. The results obtained from the FDTD method would be approximate even if we used computers that offered infinite numeric precision. The inherent approximations in the FDTD method will be discussed in subsequent chapters.

With numerical methods there is one note of caution which one should always keep in mind. Provided the implementation of a solution does not fail catastrophically, a computer is always willing to give you a result. You will probably find there are times when, to get your program simply to run, the debugging process is incredibly arduous. When your program does run, the natural assumption is that all the bugs have been fixed. Unfortunately that often is not the case. Getting the program to run is one thing, getting correct results is another. And, in fact, getting accurate results is yet another thing--your solution may be correct for the given implementation, but the implementation may not be one which is capable of producing sufficiently accurate results. Therefore, the more ways you have to test your implementation and your solution, the better. For example, a solution may be obtained at one level of discretization and then another solution using a finer discretization. If the two solutions are not sufficiently close, one has not yet converged to the "true" solution and a finer discretization must be used or, perhaps, there is some systemic error in the implementation. The bottom line: just because a computer gives you an answer does not mean that answer is correct.

Lecture notes by John Schneider. numerical-issues.tex

7

8

CHAPTER 1. NUMERIC ARTIFACTS

1.2 Finite Precision

If we sum one-eleventh eleven times we know that the result is one, i.e., 1/11 + 1/11 + 1/11 + 1/11 + 1/11 + 1/11 + 1/11 + 1/11 + 1/11 + 1/11 = 1. But is that true on a computer? Consider the C program shown in Program 1.1.

Program 1.1 oneEleventh.c: Test if 1/11 + 1/11 + 1/11 + 1/11 + 1/11 + 1/11 + 1/11 + 1/11 + 1/11 + 1/11 equals 1.

1 /* Is summing 1./11. ten times == 1.0? */ 2 #include

3

4 int main() { 5 float a;

6

7 a = 1.0 / 11.0;

8

9 if (a + a + a + a + a + a + a + a + a + a + a == 1.0)

10

printf("Equal.\n");

11 else

12

printf("Not equal.\n");

13

14 return 0; 15 }

In this program the float variable a is set to one-eleventh. In line 9 the sum of eleven a's is compared to one. If they are equal, the program prints "Equal" but prints "Not equal" otherwise. The output of this program is "Not equal." Thus, to a computer (at least one running a language typically used in the solution of electromagnetics problems), the sum of one-eleventh eleven times is not equal to one. It is worth noting that had line 9 been written a=1/11;, a would have been set to zero since integer math would be used to evaluate the division. By using a = 1.0 / 11.0;, the computer uses floating-point math.

The floating-point data types in C or FORTRAN can only store a finite number of digits. On most machines four bytes (32 binary digits or bits) are used for single-precision numbers and eight bytes (64 digits) are used for double precision. Returning to the sum of one-elevenths, as an extreme example, assumed that a computer can only store two decimal digits. One eleventh is equal to 0.09090909. . . Thus, to two decimal places one-eleventh would be approximated by 0.09. Summing this eleven times yields

0.09 + 0.09 + 0.09 + 0.09 + 0.09 + 0.09 + 0.09 + 0.09 + 0.09 + 0.09 + 0.09 = 0.99

which is clearly not equal to one. If the number is stored with more digits, the result becomes closer to one, but it never gets there. Both the decimal and binary floating-point representation of one-eleventh have an infinite number of digits. Thus, when attempting to store one-eleventh

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download