Untitled
Untitled
Raymond C. Rumpf
artechhouse.com
ISBN-13: 978-1-63081-926-2
All rights reserved. Printed and bound in the United States of America. No part of
this book may be reproduced or utilized in any form or by any means, electronic or
mechanical, including photocopying, recording, or by any information storage and
retrieval system, without permission in writing from the publisher.
All terms mentioned in this book that are known to be trademarks or service marks
have been appropriately capitalized. Artech House cannot attest to the accuracy of this
information. Use of a term in this book should not be regarded as affecting the validity
of any trademark or service mark.
10 9 8 7 6 5 4 3 2 1
Foreword xiii
Preface xv
Acknowledgments xvii
Introduction xix
References xxii
CHAPTER 1
MATLAB Preliminaries 1
1.1 Basic Structure of an FDFD Program in MATLAB 1
1.1.1 MATLAB Code for Ideal Structure of a Program 2
1.2 MATLAB and Linear Algebra 3
1.2.1 Special Matrices 6
1.2.2 Matrix Algebra 8
1.3 Setting Up a Grid in MATLAB 8
1.3.1 MATLAB Array Indexing 8
1.3.2 Parameters Describing a Grid in MATLAB 10
1.3.3 Calculating the Grid Parameters 11
1.4 Building Geometries onto Grids 15
1.4.1 Adding Rectangles to a Grid 16
1.4.2 The Centering Algorithm 17
1.4.3 The Meshgrid 19
1.4.4 Adding Circles and Ellipses to a Grid 20
1.4.5 Grid Rotation 22
1.4.6 Boolean Operations 23
1.5 Three-Dimensional Grids 25
1.6 Visualization Techniques 27
1.6.1 Visualizing Data on Grids 27
1.6.2 Visualizing Three-Dimensional Data 29
1.6.3 Visualizing Complex Data 31
1.6.4 Animating the Fields Calculated by FDFD 32
Reference 32
CHAPTER 2
Electromagnetic Preliminaries 33
2.1 Maxwell’s Equations 33
2.2 The Constitutive Parameters 37
vii
CHAPTER 3
The Finite-Difference Method 71
3.1 Introduction 71
3.2 Finite-Difference Approximations 72
3.2.1 Deriving Expressions for Finite-Difference Approximations 73
3.2.2 Example #1—Interpolations and Derivatives from Three Points 76
3.2.3 Example #2—Interpolations and Derivatives from Two Points 78
3.2.4 Example #3—Interpolations and Derivatives from Four Points 79
3.3 Numerical Differentiation 80
3.4 Numerical Boundary Conditions 81
3.4.1 Dirichlet Boundary Conditions 81
3.4.2 Periodic Boundary Conditions 82
3.5 Derivative Matrices 82
3.6 Finite-Difference Approximation of Differential Equations 85
3.7 Solving Matrix Differential Equations 87
3.7.1 Example—Solving a Single-Variable Differential Equation 87
3.8 Multiple Variables and Staggered Grids 89
3.8.1 Example—Solving a Multivariable Problem 92
References 94
CHAPTER 4
Finite-Difference Approximation of Maxwell’s Equations 95
4.1 Introduction to the Yee Grid Scheme 95
4.2 Preparing Maxwell’s Equations for FDFD Analysis 97
4.3 Finite-Difference Approximation of Maxwell’s Curl Equations 99
CHAPTER 5
The Perfectly Matched Layer Absorbing Boundary 141
5.1 The Absorbing Boundary 141
5.2 Derivation of the UPML Absorbing Boundary 143
5.3 Incorporating the UPML into Maxwell’s Equations 146
5.4 Calculating the UPML Parameters 147
5.5 Implementation of the UPML in MATLAB 149
5.5.1 Using the addupml2d() Function 150
5.6 The SCPML Absorbing Boundary 153
5.6.1 MATLAB Implementation of calcpml3d() 155
5.6.2 Using the calcpml3d() Function 155
References 159
CHAPTER 6
FDFD for Calculating Guided Modes 161
6.1 Formulation for Rigorous Hybrid Mode Calculation 161
6.2 Formulation for Rigorous Slab Waveguide Mode Calculation 166
6.2.1 Formulation of E Mode Slab Waveguide Analysis 167
6.2.2 Formulation of H Mode Slab Waveguide Analysis 168
6.2.3 Formulations for Slab Waveguides in Other Orientations 168
6.2.4 The Effective Index Method 169
CHAPTER 7
FDFD for Calculating Photonic Bands 199
7.1 Photonic Bands for Rectangular Lattices 199
7.2 Formulation for Rectangular Lattices 201
7.3 Implementation of Photonic Band Calculation 203
7.3.1 Description of MATLAB Code for Calculating Photonic
Band Diagrams 205
7.3.2 Description of MATLAB Code for Calculating IFCs 210
References 214
CHAPTER 8
FDFD for Scattering Analysis 215
8.1 Formulation of FDFD for Scattering Analysis 215
8.1.1 Matrix Wave Equations for Two-Dimensional Analysis 215
8.2 Incorporating Sources 217
8.2.1 Derivation of the QAAQ Equation 218
8.2.2 Calculating the Source Field fsrc(x,y) 220
8.2.3 Calculating the SF Masking Matrix Q 222
8.2.4 Compensating for Numerical Dispersion 224
8.3 Calculating Reflection and Transmission for Periodic Structures 226
8.4 Implementation of the FDFD Method for Scattering Analysis 228
8.4.1 Standard Sequence of Simulations for a Newly Written
FDFD Code 231
8.4.2 FDFD Analysis of a Sawtooth Diffraction Grating 233
8.4.3 FDFD Analysis of a Self-Collimating Photonic Crystal 239
8.4.4 FDFD Analysis of an OIC Directional Coupler 246
References 252
CHAPTER 9
Parameter Sweeps with FDFD 255
9.1 Introduction to Parameter Sweeps 255
9.2 Modifying FDFD for Parameter Sweeps 257
9.2.1 Generic MATLAB Function to Simulate Periodic Structures 258
9.2.2 Main MATLAB Program to Simulate the GMRF 260
9.2.3 Main MATLAB Programs to Analyze a Metal Polarizer 262
9.3 Identifying Common Problems in FDFD 266
References 267
CHAPTER 10
FDFD Analysis of Three-Dimensional and Anisotropic Devices 269
10.1 Formulation of Three-Dimensional FDFD 269
10.1.1 Finite-Difference Approximation of Maxwell’s Curl
Equations 270
10.1.2 Maxwell’s Equations in Matrix Form 273
10.1.3 Interpolation Matrices 274
10.1.4 Three-Dimensional Matrix Wave Equation 275
10.2 Incorporating Sources into Three-Dimensional FDFD 277
10.3 Iterative Solution for FDFD 278
10.4 Calculating Reflection and Transmission for Doubly Periodic
Structures 280
10.5 Implementation of Three-Dimensional FDFD and Examples 282
10.5.1 Standard Sequence of Simulations for a Newly Written
Three-Dimensional FDFD Code 282
10.5.2 Generic Three-Dimensional FDFD Function to Simulate
Periodic Structures 285
10.5.3 Simulation of a Crossed-Grating GMRF 287
10.5.4 Simulation of a Frequency Selective Surface 290
10.5.5 Parameter Retrieval for a Left-Handed Metamaterial 294
10.5.6 Simulation of an Invisibility Cloak 300
References 303
APPENDIX A
A.1 Best Practices for Building Devices onto Yee Grids 305
A.2 Method Summaries 308
xiii
begins with a review of the relevant MATLAB materials including linear algebra as
the tool to keep track of everything being simulated. The second chapter reviews
electromagnetism and Maxwell’s equations. This is an excellent chapter providing
all of the necessary backgrounds for success, with tutorials on gratings, waveguides,
and transmission lines. He also shows how the guiding principles of Maxwell’s equa-
tions scale with physical size and material properties, a critical concept to grasp and
understand in CEM. The next two chapters, Chapters 3 and 4, provide the basic
understanding of the implementation issues for successful CEM. These are the fun-
damentals of finite-difference approaches for computation, the need for boundary
conditions and the organization of the (Yee) grid in an FDFD simulation, essential
to capture the physics of the problem at hand, and to obtain quantitative accuracy
estimates for simulation results. Chapter 5 explains the inevitable constraints of
finite computational modeling and the need for perfectly matched boundaries to
ensure the solution volume is not corrupted by computational artifacts from outgoing
waves. Chapter 6 explicitly considers guided modes, slab waveguide structures, and
includes a section on the simulation of surface plasma waves and surface plasmon
polaritons. Chapters 7 and 8 explain very clearly and elegantly the role of, and the
computation of, so-called photonic bands and equifrequency surfaces for structured
materials, both important for characterizing and visualizing electromagnetic propa-
gation through, as well as reflection or transmission from, periodic structures. The
benefits of sweeping variables and parameters in CEM cannot be overstated, and
this is covered in Chapter 9. Parameter sweeps can provide deep physical insights
into the performance of devices and trends for their optimization. The final chapter
includes a number of state-of-the-art and highly stimulating examples involving
modern-day metamaterials and design strategies based on transformation optics,
such as how to simulate an invisibility cloak.
In summary, this book will be of value to anyone interested in CEM modeling.
While alternative simulation approaches exist, for example, for very large prob-
lems, FDFD can be comprehensively applied to model almost all electromagnetic
phenomena. For example, transient and time-evolving phenomena can be studied
by taking a frequency sweep followed by Fourier transformation. Also, being a
frequency-domain method, dispersion studies are very straightforward, and physical
phenomena such as skin depth and plasmonic effects are automatically incorporated.
The many MATLAB codes associated with simulations presented in the book are
available for download, granting those superpowers immediately!
Michael Fiddy
Professor, Optical Science and Engineering and of Electrical Engineering
at the University of North Carolina at Charlotte (UNCC)
Research physicist, Army Research Laboratory in
the Directed Energy Bioeffects Group
January 2022
xv
xvii
xix
calculated. You will observe this practice in the formulations in this book. A person
hardly benefits from clean code if the code is only cleaned up after it is made to
work. I have learned to write clean code from the very start. It helps to clear my
chaotic mind. I found that clean code just seems to run better. Further, I developed
and practiced strong visualization skills. Over the years, I have learned that the
key to computation is visualization. A person can stare at an array of numbers all
day without seeing the trends or errors. Our brains are already programmed to
interpret images and catch inconsistencies, so visualizing the data graphically is the
most powerful tool for learning and troubleshooting numerical methods. Producing
exciting graphics is fun and an excellent way to showcase your simulations!
It is with a tremendous amount of personal debate and guilt that I have omitted
some topics from this book. I have left out wonderful subjects like near-field-to-far-
field transformation [2, 9], unstructured grids [10, 11], nonorthogonal grids [12],
FDFD in different coordinates systems [13], and more. I have left out variants of
the FDFD method like the beam propagation method [14], method of lines [15–17],
slice absorption method [18–21], and others. There are countless types of devices
that I have not demonstrated in this book. I chose the examples in this book to be
representative of the broadest array of devices possible. For example, simulating
metasurfaces [22, 23] is identical to simulating frequency selective surfaces [24].
So, I only included an example of a frequency selective surface to keep the book as
concise as possible. With some thought, a beginner will be able to simulate almost
anything with simple modifications to the examples in this book.
The chapters in this book are written in a cumulative order, where later chapters
rely on topics covered in previous chapters. Chapters 1 to 5 are background chapters
needed to understand how the various forms of the FDFD method are formulated and
implemented. Chapter 1 does not teach MATLAB, but it covers special topics and
skills in MATLAB that are important for implementing FDFD and understanding
why some things in this book are done the way they are. Chapter 2 does not teach
electromagnetics, but reviews some key concepts needed to understand and imple-
ment the FDFD method. This includes Maxwell’s equations, parameters describing
the properties of materials, waves, polarization, and some limited device theory.
With great effort, I have tried to make the notation consistent between the analytical
equations, the numerical equations, and the computer codes as much as possible.
Chapter 3 covers the finite-difference method and how it will be used to solve Max-
well’s equations. It is quite different than how the finite-difference method is taught
in most texts. With practice, the techniques taught in Chapter 3 will let you solve
completely new differential equations in mere seconds to minutes. Chapter 4 covers
how to make the fields and materials in Maxwell’s equations discrete functions using
the Yee grid scheme [25]. The Yee grid makes approximating Maxwell’s equations
with finite-differences simple and accurate. The Yee grid enforces the divergence
equations implicitly so only the curl equations have to be solved explicitly. Chapter
5 covers the PML absorbing boundary that will be used to absorb outgoing waves
in the simulation. Both a uniaxial PML (UPML) and a stretched-coordinate PML
(SCPML) will be presented. Both types of PMLs absorb outgoing waves equally, but
the UPML is easier to implement. The SCPML has advantages for large problems
when the final matrix equation must be solved iteratively.
References
[1] Sullivan, D. M., Electromagnetic Simulation Using the FDTD Method, Hoboken, NJ:
John Wiley & Sons, 2013.
[2] Taflove, A., and S. C. Hagness, Computational Electrodynamics: The Finite-Difference
Time-Domain Method, Norwood, MA: Artech House, 2005.
[3] Özgün, Ö., and M. Kuzuoğlu, MATLAB-Based Finite Element Programming in
Electromagnetic Modeling, New York: CRC Press, 2018.
[4] Rumpf, R., “Design and Optimization of Nano-Optical Elements by Coupling Fabrication
to Optical Behavior,” 2006.
[5] Jin, J.-M., The Finite Element Method in Electromagnetics, Hoboken, NJ: John Wiley &
Sons, 2015.
[6] Ho-Le, K., “Finite Element Mesh Generation Methods: A Review and Classification,”
Computer-Aided Design, Vol. 20, No. 1, 1988, pp. 27–38.
[7] Lo, D. S., Finite Element Mesh Generation: CRC Press, 2014.
[8] Mirebeau, J.-M., “Optimal Meshes for Finite Elements of Arbitrary Order,” Constructive
Approximation, Vol. 32, No. 2, 2010, pp. 339–383.
[9] Luebbers, R. J., et al., “A Finite-Difference Time-Domain Near Zone to Far Zone
Transformation (Electromagnetic Scattering),” IEEE Trans. on Antennas and Propagation,
Vol. 39, No. 4, 1991, pp. 429–433.
[10] Fernandez, F., and L. Kulas, “A Simple Finite Difference Approach Using Unstructured
Meshes from FEM Mesh Generators,” 15th International Conference on Microwaves,
Radar and Wireless Communications, Warsaw, Poland, May 17–19, 2004, pp. 585–588.
[11] Gedney, S., F. S. Lansing, and D. L. Rascoe, “Full Wave Analysis of Microwave Monolithic
Circuit Devices Using a Generalized Yee-Algorithm Based on an Unstructured Grid,”
IEEE Trans. on Microwave Theory and Techniques, Vol. 44, No. 8, 1996, pp.
1393–1400.
[12] Lavranos, C., and G. Kyriacou, “Eigenvalue Analysis of Curved Waveguides Employing
FDFD Method in Orthogonal Curvilinear Co-Ordinates,” Electronics Letters, Vol. 42,
No. 12, 2006, pp. 702–704.
[13] Xiao, J., H. Ni, and X. Sun, “Full-Vector Mode Solver for Bending Waveguides Based on
the Finite-Difference Frequency-Domain Method in Cylindrical Coordinate Systems,”
Optics Letters, Vol. 33, No. 16, 2008, pp. 1848–1850.
[14] El-Refaei, H., D. Yevick, and I. Betty, “Stable and Noniterative Bidirectional Beam
Propagation Method,” IEEE Photonics Technology Letters, Vol. 12, No. 4, 2000, pp.
389–391.
[15] Helfert, S. F., and R. Pregla, “The Method of Lines: A Versatile Tool for the Analysis of
Waveguide Structures,” Electromagnetics, Vol. 22, No. 8, 2002, pp. 615–637.
[16] Pregla, R., and W. Pascher, “The Method of Lines,” Numerical Techniques for Microwave
and Millimeter Wave Passive Structures, Vol. 1, 1989, pp. 381–446.
[17] Sadiku, M. N., and C. Obiozor, “A Simple Introduction to the Method of Lines,”
International Journal of Electrical Engineering Education, Vol. 37, No. 3, 2000, pp.
282–296.
[18] Deng, H., and S. Chen, “Efficient Implementation of Fourier Modal Slice Absorption
Method for Lamellar Crossed Gratings,” Optical Engineering, Vol. 52, No. 6, 2013, p.
068201.
[19] Deng, H., and S. Chen, “Convergence Improvement of the Fourier Modal Slice Absorption
Method for Crossed Gratings,” Optik, Vol. 126, No. 24, 2015, pp. 5310–5315.
[20] Deng, H., S.-Q. Chen, and L. Ma, “Calculation of Zero-Order Diffraction by Using the
Modal Slice Absorption Method for Gratings,” Journal of University of Electronic Science
and Technology of China, 2015, p. 06.
[21] Rumpf, R. C., A. Tal, and S. M. Kuebler, “Rigorous Electromagnetic Analysis of
Volumetrically Complex Media Using the Slice Absorption Method,” Journal of the Optical
Society of America A, Vol. 24, No. 10, 2007, pp. 3123–3134.
[22] Simovski, C., “Material Parameters of Metamaterials (A Review),” Optics and Spectroscopy,
Vol. 107, No. 5, 2009, pp. 726–753.
[23] Vahabzadeh, Y., et al., “Computational Analysis of Metasurfaces,” IEEE J. on Multiscale
and Multiphysics Computational Techniques, Vol. 3, 2018, pp. 37–49.
[24] Farahat, N., and R. Mittra, “Analysis of Frequency Selective Surfaces Using the Finite
Difference Time Domain (FDTD) Method,” IEEE Antennas and Propagation Society
International Symposium, San Antonio, TX, June 16–21, 2002, pp. 568–571.
[25] Yee, K., “Numerical Solution of Initial Boundary Value Problems Involving Maxwell’s
Equations in Isotropic Media,” IEEE Trans. on Antennas and Propagation, Vol. 14, No.
3, 1966, pp. 302–307.
MATLAB Preliminaries
This chapter covers some basic topics related to MATLAB that are useful for imple-
menting the finite-difference frequency-domain (FDFD) method. It is assumed that
the reader has a basic familiarity with MATLAB® and computer programming. If
not, visit the MathWorks website for excellent introductory and tutorial materials.
If MATLAB is not available to you, Octave is an excellent open-source alternative
that offers close to 100% compatibility with the MATLAB language.
A block diagram of the basic structure for an FDFD program in MATLAB is illus-
trated in Figure 1.1. The MATLAB code corresponding to the block diagram is
provided in Section 1.1.1. It is a common practice to begin a MATLAB program
with a commented section that summarizes the purpose of the program, how to
use it, and any other information that may be useful to know. This is especially
helpful if the code may be used by others or put away and used again years later.
When help followed by the program name is entered at the command prompt, the
commented section at the start of the program will be displayed in the command
window. It is useful for the first line of the program to be the name of the file and
any other information provided immediately below. The header for the program in
Section 1.1.1 extends from lines 1 to 8.
Immediately after the header, MATLAB is initialized on lines 10 to 13. Through-
out this book, MATLAB will be initialized in three steps. First, all open figure
windows are closed with the command close all. Second, all texts are cleared
from the command window with the command clc. Third, and most important,
all variables and functions are cleared from memory with the command clear all.
After MATLAB is initialized, the simulation itself is initialized by defining
all of the units and constants that will be used by the program. This code extends
from lines 15 to 31. Here, meters is set to the value 1 and all other length units are
defined relative to this. This makes it easier to keep the units consistent and allows
for much cleaner code that is easy to read and understand. For example, the dimen-
sion a can be defined as 2.0 mm with the following line of code.
a = 2.0 * millimeters;
The name MATLAB is an acronym for MATrix LABoratory. The original purpose
of MATLAB was to provide an easy interface to matrix libraries like LINPACK and
EISPACK. A matrix is nothing more than a table of numbers that holds information
from large sets of linear algebraic equations. For example, define the following set
of four equations.
a11x1 + a12 x2 + a13x3 + a14 x4 = b1
a21x1 + a22 x2 + a23x3 + a24 x4 = b2
(1.1)
a31x1 + a32 x2 + a33x3 + a34 x4 = b3
a41x1 + a42 x2 + a43x3 + a44 x4 = b4
In these equations, the amn terms are coefficients that will have numerical values
assigned to them. The terms b1, b2 , b3, and b4 are constants representing the exci-
tation and will also have numerical values assigned to them. Last, x1, x 2 , x3, and
x4 are the unknowns that are to be determined by solving the system of equations.
In FDFD, instead of having four unknown terms, there will be hundreds of
thousands of unknown terms. It is quite tedious to keep writing all of the equations
in (1.1) and to manipulate many equations at every step of a derivation. To get around
this, it is much more convenient to express and manipulate large sets of equations
as matrices. Using matrices, (1.1) is written compactly as
Ax = b (1.2)
where
⎡ x1 ⎤
⎢ ⎥
x2
x = ⎢ ⎥ (1.4)
⎢ x3 ⎥
⎢ x4 ⎥
⎢⎣ ⎥⎦
⎡ b1 ⎤
⎢ ⎥
b2
b= ⎢ ⎥ (1.5)
⎢ b3 ⎥
⎢ ⎥
⎢⎣ b4 ⎥⎦
All of the terms from the large set of equations have been assembled into the
matrix A and the column vectors x and b. In this book, bold uppercase letters rep-
resent matrices while bold lowercase letters represent column vectors. This allows
all of the data associated with the large set of equations to be manipulated using just
the terms A, x, and b using a modified set of rules for matrix algebra [1]. To solve
(1.2) for x, both sides of the equation are predivided by A to get A–1Ax = A–1b. The
product A–1A equals the identity matrix I which vanishes from the equation to get
x = A −1b (1.6)
It is these types of calculations that MATLAB makes incredibly easy to do. For
example, the following code enters values for the matrix A and column vector b and
then solves for x using (1.6). Note that commas separate elements along a row while
semicolons separate elements along the columns. Inserting the commas is optional
in MATLAB, but can help make the code more readable.
Observe how the column vector x is calculated in the above MATLAB code.
From a computer coding perspective, it is a mistake to read (1.6) as the inverse of
A times the column vector b. This interpretation leads to obtaining the solution as
x = inv(A)*b. While a correct solution can be obtained this way, there is a sig-
nificant difference between calculating a matrix inverse and performing a matrix
division in MATLAB. Matrix division does not calculate the inverse of matrix A
and usually involves significantly fewer calculations. Calculating x as x = A\b is
called backward division and is the preferred way in FDFD to solve the system of
equations defined by Ax = b.
Matrices are tables of numbers arranged by rows and columns, as illustrated
in Figure 1.2. MATLAB makes inserting, extracting, and manipulating rows and
columns in matrices very easy. For example, if the second row of matrix A is to
be replaced with all numerical values of 7, the MATLAB command to do this is
A(2,:) = 7. Similarly, if the third column is to be replaced with all numerical val-
ues of 4, the MATLAB command to do this is A(:,3) = 4.
Solving differential equations by numerical methods very often leads to matri-
ces with numbers placed along the diagonals of a matrix. Figure 1.3 illustrates
how the diagonals are referenced by number. The center diagonal is assigned the
index of 0 and is the diagonal being referred to when reading or hearing the label
“the diagonal.” Diagonals above the center diagonal are given positive indices and
diagonals below the center diagonal are given negative indices. MATLAB makes
inserting, extracting, and manipulating diagonals in matrices very easy using the
functions diag() and spdiags(). The diagonals of a matrix will be the primary
means for constructing the matrices used in FDFD and will be covered in detail in
Chapters 3 and 4.
It is very common in numerical methods to have very large matrices with numbers
placed along only a single diagonal or just a handful of diagonals. A matrix with non-
zero elements along only the center diagonal is called a diagonal matrix. A matrix
with non-zero elements along a small set of diagonals is called a banded matrix. It
is common to have 99.9% or more of the elements in a diagonal or banded matrix
be all zeros. Storing every element in these matrices as double-precision floating-
point numbers is unnecessary and consumes a lot of memory. Tremendous memory
savings can be achieved if only the non-zero elements of a matrix are stored. This
is called a sparse matrix and a plethora of algorithms exists that are optimized for
working with sparse matrices. In MATLAB, a matrix is simply declared as sparse
and everything else is handled automatically. Thank you MATLAB! While a matrix
can be declared to be sparse using the function sparse(), this is bad practice because
a full matrix will be created and stored before declaring it as sparse. Instead, it is
best to initialize the matrices as sparse from the very beginning so large and full
matrices never have to be created or stored.
⎡ 0 0 ! 0 ⎤
⎢ 0 0 ⎥
Z= ⎢ ⎥ (1.7)
" #
⎢ 0 0 ⎥⎦
⎣
⎡ 0 ⎤
⎢ 0 ⎥
0= ⎢ ⎥ (1.8)
!
⎢ 0 ⎥
⎣ ⎦
A sparse zero matrix can be initialized using sparse(). The following line of
MATLAB code creates a sparse zeros matrix of size M × M.
Z = sparse(M,M);
The identity matrix I is a diagonal matrix with ones placed along the center
diagonal and zeros everywhere else. This is the closest thing to the numerical value
of 1 that is still a matrix. Any matrix A multiplied or divided by the identity matrix
is the matrix A again.
⎡1 ⎤
⎢ 1 ⎥
I= ⎢ ⎥ (1.9)
!
⎢ 1 ⎥
⎣ ⎦
A sparse identity matrix can be initialized using the MATLAB command speye().
The following line of MATLAB code creates a sparse identity matrix of size M × M.
I = speye(M,M);
⎡ 1 1 2 2 ⎤
⎡ A B ⎤ ⎢ 1 1 2 2 ⎥
(1.10)
G = ⎢ = ⎢ ⎥
⎣ C D ⎥⎦ ⎢ 3 3 4 4
⎥
⎣ 3 3 4 4 ⎦
⎡ ⎤ ⎡ ⎤ ⎡ ⎤ ⎡ ⎤
A = ⎢1 1⎥ B= ⎢ 2 2 ⎥ C= ⎢ 3 3 ⎥ D= ⎢ 4 4 ⎥ (1.11)
⎣ 1 1 ⎦ ⎣ 2 2 ⎦ ⎣ 3 3 ⎦ ⎣ 4 4 ⎦
The following MATLAB code builds the small matrices A, B, C, and D and then
calculates the large matrix G as a block matrix. This practice will make more sense
to perform when matrices are larger and more complicated.
A = 1*ones(2,2);
B = 2*ones(2,2);
C = 3*ones(2,2);
D = 4*ones(2,2);
G = [ A B ; C D ];
A+B= B+A
(1.12)
AB ≠ BA
( A + B) + C = A + ( B + C )
(1.13)
( AB) C = A ( BC )
The distributive laws are
( A + B) C = AC + BC
(1.14)
A ( B + C ) = AB + AC
The commutative laws apply to matrix division as well
A −1B ≠ BA −1 (1.15)
for column number, as illustrated in Figure 1.4(a). Both m and n are integers with a
starting value of 1. This means the first index m is the vertical position with values
increasing downward. The second index n is the horizontal position with values
increasing toward the right. The manner in which a traditional array is visualized
is shown in Figure 1.4(b). The elements of a two-dimensional array are referenced
using two integer indices, i and j, but they are defined and interpreted differently
than the indices of a matrix. The first index i starts at 0 and describes the horizontal
position with values increasing toward the right. The second index j also starts at
0 and describes the vertical position with values increasing upward.
The most confusing aspect of the inconsistency between matrices and arrays
is the direction that the indices access the elements. For matrices, the first index is
vertical position and the second is horizontal position. However, people tend to think
of functions as f(x,y), where the first argument is the horizontal position and the
Figure 1.4 Matrix versus array in MATLAB. (a) A matrix and the MATLAB syntax to access
elements in the matrix. (b) A traditional array and the representative syntax used by other
programming languages to access elements in the array.
second argument is the vertical position. There are multiple ways to work around
this inconsistency, but MATLAB will always treat arrays as if they are matrices. In
the author’s experience in teaching this subject, he has observed students struggle
much more with building geometries into arrays than they struggle with numerical
algorithms. For this reason, it is recommended to program MATLAB as if the arrays
are actually traditional arrays where the first index references horizontal position and
the second the vertical position. This practice will make building devices into arrays
more intuitive. Treating arrays in this manner will need to be considered when the
arrays are visualized because MATLAB will try to visualize those arrays as if they
were matrices. Unlike arrays in most other programming languages, in MATLAB
the array indices will start at 1 instead of 0 and the vertical array index will have
increasing values in the downward direction instead of upward. This second point
is actually a nice coincidence that will work in your favor. In electromagnetics, it is
preferred to have waves propagate in positive directions. It is also preferred to have
waves flow either left-to-right or top-to-bottom. So, having the positive direction
be downward is convenient.
Sx = Nx ∗ dx (1.16)
Sy = Ny ∗ dy (1.17)
Figure 1.5 Definition of the grid parameters Sx, Sy, Nx, Ny, dx, and dy.
until it is converged. More about how to perform proper convergence studies will
be covered in Chapters 6 to 10.
Another variable that will be defined in the dashboard is the maximum refrac-
tive index nmax found anywhere in the simulation. Given the free space wavelength
lam0 for the simulation, the smallest wavelength that the simulation will have to
resolve is lam0/nmax. It is this smallest wavelength that should be resolved with
NRES points. Based on this, the preliminary calculation for dx is
dx = lam0/nmax/NRES (1.18)
The second consideration for grid resolution is that dx and dy must be sufficiently
small to resolve the minimum feature size of the device to be simulated. This concept
is illustrated in Figure 1.7. It is best to resolve the minimum features with at least
one to two grid cells. This is particularly important when simulating small features
composed of metals or high permittivity materials. Sometimes it is okay to be lazy
and ignore the minimum feature size consideration when simulating devices with
low permittivity or when it is known beforehand that the device will not have any
small features. For a good preliminary calculation of the grid resolution, go with
the smaller value of dx calculated for resolving the minimum wavelength and the
minimum feature size.
After the preliminary values of dx and dy are calculated, they can be adjusted,
if necessary, so that a critical dimension is resolved on the grid with an exact inte-
ger number of cells. For periodic structures, resolving the period exactly is often
Figure 1.7 (a) Lattice to build into an array. (b) Grids where lattices are resolved with a different
number of points representing the minimum dimension.
very important. For diffraction gratings, resolving the groove depth is often very
important. It is up to you as the device expert to identify any critical dimensions
and the need to resolve them exactly. If a wrong guess is made for the most critical
dimension, the simulation may exhibit slow convergence but will still give the cor-
rect answer if proper convergence habits are followed.
dx = a/nx (1.20)
After this recalculation of dx, the dimension a will be resolved on the grid exactly
by nx cells. This procedure ensures that dx is made smaller instead of bigger so grid
resolution is improved instead of lost.
The concepts discussed above to calculate the grid resolution parameter dx are
illustrated in Figure 1.8. At the top is a bar representing some critical dimension a
that should be resolved exactly with an integer number of grid cells for best numeri-
cal efficiency and least error. The preliminary calculation of dx does not achieve
this so it is adjusted in a second step. This will be called snapping the grid to critical
dimensions. Equations (1.18) to (1.20) are repeated to calculate dy. Uniform grids
can only snap to one critical dimension per axis so choose wisely which dimension
is critical. Make snapping the grid standard practice when setting up a grid for
FDFD analysis! This practice will provide your FDFD codes better accuracy and
faster convergence.
At this point, only the grid resolution parameters dx and dy are known and they
will not be modified again in the program. The next step is to calculate the overall
size of the grid. This includes the physical dimensions Sx and Sy and the number
of points Nx and Ny along the x- and y-directions, respectively. Usually, Sx and Sy
are calculated first. A typical grid setup for an FDFD simulation is illustrated in
Figure 1.9. Lengths 1, 5, 6, and 10 represent absorbing boundaries that will be
incorporated onto the grid to absorb waves propagating outward so that they do
not reflect back into the simulation. These will typically be 10 to 20 cells large.
Lengths 3 and 8 are the dimensions of the device to be simulated. Lengths 2, 4, 7,
and 9 are spacer regions placed between the device and the absorbing boundaries.
These are typically made to be at least a quarter to one wavelength large and are
needed to obtain accurate results or to better visualize the field around the device.
The grid must be made sufficiently large to fit all of this at the same time.
After Sx and Sy are calculated, the total number of points on the grid in the
x-direction is calculated as Sx/dx. However, this is likely not going to be an integer
quantity because the total size of the grid Sx was not considered in the calculation
of dx. For this reason, the quantity Sx/dx is rounded up to the nearest integer to
calculate the total number of points Nx.
Figure 1.10 (a) FDFD simulation of scattering from a dielectric cylinder. (b) Relative permittivity
array ER that completely describes the cylinder to be simulated.
Building geometries into arrays is often the most difficult for students. The fol-
lowing sections cover the techniques required to build a wide variety of different
geometries into data arrays so that different devices can be simulated. Complicated
shapes can usually be created from combinations of simple shapes. With practice,
these techniques will become intuitive and easy.
gratings and polarizers are often described well by rectangles in their cross section.
Rectangles are also elements of more complicated geometries. For example, a triangle
can be thought of as a stack of thin rectangles of varying lengths. Rectangles can be
added to a grid simply by calculating the array indices where the shape begins and
ends and then adding the numbers to the array. For example, the MATLAB code
below builds a rectangle into the array ER. The result is illustrated in Figure 1.11.
1 Nx = 10;
2 Ny = 15;
3
4 nx1 = 5;
5 nx2 = 8;
6 ny1 = 6;
7 ny2 = 13;
8
9 ER = ones(Nx,Ny);
10 ER(nx1:nx2,ny1:ny2) = 6;
In practice, the array indices will not be hard-coded like in this example. Instead,
they will be calculated from parameters defined in the dashboard. This practice
will be demonstrated in later chapters when FDFD implementation is discussed.
1 nx = 4;
2 ny = 8;
3 nx1 = 1 + floor((Nx – nx)/2);
4 nx2 = nx1 + nx – 1;
5 ny1 = 1 + floor((Ny – ny)/2);
6 ny2 = ny1 + ny – 1;
The concept of this technique is as follows. The array index corresponding to the
center of the grid in the x-direction is Nx/2, temporarily ignoring that this quantity
must be rounded to an integer. This means the array index nx1 where the rectangle
starts should be Nx/2 minus half of the number of cells the rectangle is wide nx/2.
Putting these together means the starting array index is Nx/2–nx/2, which is simpli-
fied to (Nx–nx)/2. To get an integer array index, this is rounded down to the near-
est integer using MATLAB’s floor() function. To prevent getting an array index
of 0, the value of 1 is added to the rounded integer. The final equation to calculate
nx1 is on line 3 of the MATLAB code immediately above. Calculating the stop
index nx2 is much easier after the start index nx1 is known. The stop index nx2 is
nx2=nx1+nx-1. The final equation to calculate nx2 is on line 4 of the MATLAB code
immediately above. The reason for the -1 is so the rectangle occupies the correct
number of cells on the grid to accurately represent its size. In this example, nx=4
and nx1=4. If the –1 were not used, the stop index nx2 would be calculated to be
8, causing five cells to be filled in on the grid (4, 5, 6, 7, and 8). Doing this would
make the rectangle one cell larger than it should be. While this may seem minimal,
it can lead to very slow convergence requiring very high grid resolution to make
the one-cell error insignificant. It is best practice to take great care to always use
the most accurate number of cells. The final centered rectangle is shown in Figure
1.12. Observe that the rectangle is not perfectly centered in the y-direction. This is
because the height of the rectangle is an even number of cells and the height of the
grid is an odd number of cells. Often, the position of the device on the grid is much
less important than getting its dimensions correct. For this reason, there is more
room to be lazy calculating nx1 than there is when calculating nx2 relative to nx1.
associated with these arrays were described previously. Two axis arrays, xa and ya,
must be defined before the meshgrid parameters X and Y can be calculated. The array
xa contains the center position of all the cells in the x-direction, while the array ya
contains the center position of all the cells in the y-direction. These are illustrated
below and to the left of the ER (or UR) array shown in Figure 1.13. The color in the
cells of xa and ya represents the number values that are stored in those arrays.
Given the axis arrays xa and ya, the meshgrid parameters X and Y are calculated
using MATLAB’s function meshgrid(). Since X and Y are associated with arrays and
not matrices, the order of x and y is swapped when calling the meshgrid() function.
[Y,X] = meshgrid(ya,xa)
Both X and Y are arrays the same size as the grid for ER (or UR). The number
values in the array X contain the position of those number values in the x-direction.
For this reason, the numbers in any vertical column of X are the same. The number
values in the array Y contain the position of those number values in the y-direction.
For this reason, the numbers in any horizontal row of Y are the same. This redun-
dant information may seem like a waste of computer memory, but the utility of the
meshgrid arrays will be demonstrated shortly.
The meshgrid makes it incredibly easy to build an ellipse and the code to do it
is very simple and easy to read. Figure 1.14 overlays the ellipse onto the final array
ER where the ellipse has been incorporated using meshgrid. Observe how the dimen-
sions of the ellipse are conveyed in the ER array.
The MATLAB code to build the ellipse into the array ER is provided below.
The code begins with a short dashboard that defines the physical size of the grid
with Sx and Sy, the number of points on the grid with Nx and Ny, the center of the
ellipse with x0 and y0, and the radii of the ellipse in the x- and y-directions with
the variables rx and ry, respectively. The next parameters calculated are the grid
resolution parameters dx and dy, axis arrays xa and ya, and finally the meshgrid
arrays X and Y. The very last line uses the meshgrid arrays to build the ellipse in a
single and simple line of code that comes directly from (1.22).
% DASHBOARD
Sx = 1;
Sy = 1;
Nx = 20;
Ny = 20;
x0 = 0.3;
y0 = 0.6;
rx = 0.2;
ry = 0.35;
% CALCULATE GRID
dx = Sx/Nx;
dy = Sy/Ny;
xa = [0.5:Nx–0.5]*dx;
ya = [0.5:Ny–0.5]*dy;
[Y,X] = meshgrid(ya,xa);
% BUILD ELLIPSE
ER = ((X – x0)/rx).^2 + ((Y – y0)/ry).^2 <= 1;
While this code builds an ellipse, it is easily modified to build a circle. One
way to do this is to simply ensure that rx and ry are equal. Alternatively, and more
simply, the last line above could be replaced with
Observe that neither the equation for the ellipse nor the circle calculate the square
root of the meshgrid arrays. Instead, the radius quantities are squared so that only
a single number has to be squared instead of calculating the square root of every
number in the meshgrid. This is done for speed and efficiency.
The MATLAB code to build this rotated ellipse is provided below. The first step
is to convert the Cartesian meshgrid parameters X and Y into polar coordinates TH
and R using MATLAB’s cart2pol() function. The meshgrid parameters passed to
cart2pol() are made to equal zero at the point (x0,y 0) by subtracting these values
from X and Y. This makes the new meshgrid rotate about the center of the ellipse
being built onto the grid. Next, the polar coordinates are immediately converted
back to Cartesian coordinates to get a second set of meshgrid arrays XR and YR. This
is the step where some angle theta is added to TH, making XR and YR the rotated
meshgrid arrays. Now the ellipse is calculated using the rotated meshgrid terms
in the exact same way it would be calculated using the standard meshgrid terms.
% UNITS
degrees = pi/180;
% DASHBOARD
Sx = 1;
Sy = 1;
Nx = 20;
Ny = 20;
x0 = 0.3;
y0 = 0.6;
rx = 0.2;
ry = 0.35;
theta = 30*degrees;
% CALCULATE GRID
dx = Sx/Nx;
dy = Sy/Ny;
xa = [0.5:Nx–0.5]*dx;
ya = [0.5:Ny–0.5]*dy;
[Y,X] = meshgrid(ya,xa);
[TH,R] = cart2pol(X–x0,Y–y0);
[XR,YR] = pol2cart(TH+theta,R);
% BUILD ELLIPSE
ER = (XR/rx).^2 + (YR/ry).^2 <= 1;
be used, it is very useful to build the simple shapes from just zeros and ones so that
the Boolean operations can be performed more naturally. When the final geometry
resides on the grid, the zeros and ones are easily converted to physical values of
relative permittivity and/or relative permeability. The concept of this calculation is
illustrated in Figure 1.17. At left is a grid containing a square with a circle subtracted
from it using a Boolean operation. This might be a unit cell of a photonic crystal,
for example. The array at this point contains only zeros and ones to facilitate the
Boolean operation.
If the structure depicted in Figure 1.17 is made of a material with relative per-
mittivity er2=9 and is embedded in a medium with relative permittivity of er1=2,
the zeros must be replaced with the value of er1 and the ones must be replaced with
the value of er2. One simple way to do this is using (1.23).
Figure 1.17 Converting binary arrays to arrays containing real values of relative permittivity.
The first occurrence of er1 in (1.23) places that value throughout the entire
array ER. The second term (er2-er1)*ER adds the difference er2-er1 to the cells
on the grid where er2 is to be placed. Since er1 is the current value in those cells,
er2-er1 is added to them to get a final value of er2. With some practice, this will
become very intuitive and techniques for assigning more than two material values
to the grid are straightforward to implement.
1 % demo_3Dgrid.m
2
3 % INITIALIZE MATLAB
4 close all;
5 clc;
6 clear all;
7
8 % DASHBOARD
9 rx = 0.4;
10 ry = 0.3;
11 rz = 1.0;
12
13 er1 = 1.0;
14 er2 = 9.0;
15
16 Sx = 1;
17 Sy = 1;
18 Sz = 3;
19 Nx = 20;
20 Ny = 20;
21 Nz = 60;
22
23 % CALCULATE 3D MESHGRID
24 dx = Sx/Nx;
25 xa = [1:Nx]*dx;
26 xa = xa – mean(xa);
27
28 dy = Sy/Ny;
29 ya = [1:Ny]*dy;
30 ya = ya – mean(ya);
31
32 dz = Sz/Nz;
33 za = [1:Nz]*dz;
34 za = za – mean(za);
35
36 [Y,X,Z] = meshgrid(ya,xa,za);
37
38 % BUILD ELLIPSE
39 ER = (X/rx).^2 + (Y/ry).^2 + (Z/rz).^2 < 1;
40 ER = er1 + (er2 – er1)*ER;
Line 1 is a comment with the name of the program. Lines 3 to 6 initialize MAT-
LAB. Lines 8 to 21 comprise the dashboard where everything about the program
is controlled. The radii of the ellipsoid are defined on lines 9 to 11 as rx, ry, and
rz. Lines 13 and 14 define the relative permittivity values to be assigned to this
grid. er1 is the relative permittivity outside of the ellipsoid and er2 is the relative
permittivity of the ellipsoid. Lines 16 to 21 define a simple three-dimensional grid
in terms of the physical size Sx, Sy, and Sz and the number of points along each
dimension Nx, Ny, and Nz. The three-dimensional meshgrid is calculated from lines
24 to 36 in four groups of code. The first three groups of code calculate the grid
resolution parameters dx, dy, and dz as well as the axis arrays xa, ya, and za. Line
36 calculates the meshgrid parameters X, Y, and Z. The meshgrid parameters are
all three-dimensional arrays of size Nx-by-Ny-by-Nz. Last, lines 38 to 40 build the
ellipsoid onto the three-dimensional grid. Line 39 actually builds the ellipsoid into
the array ER where 0’s are placed outside of the ellipsoid and 1’s are placed inside
of the ellipsoid. This makes the ellipsoid suitable for Boolean operations with other
structures if that is desired. Line 40 converts the 0’s and 1’s to the actual values of
relative permittivity. This line works by assigning the value of er1 to all points in
the array ER and then adding (er2 - er1) at the points in ER that contain 1’s. After
this line, all 0’s in ER are replaced with er1 and all 1’s in ER are replaced with er2.
The output of the program described above is the three-dimensional array ER
containing the relative permittivity throughout the grid. Figure 1.18 shows the
array ER that is constructed by the above MATLAB program. The axes are labeled
with the array indices instead of the physical position along the grid for illustration
purposes. For real simulation work, it is usually more meaningful to label the axes
with physical dimensions.
Even low-resolution data can be made to look smooth and continuous. Also notice
the orientation of the vertical axis. The function imagesc() inverts the y-axis so
the numbers increase going downward. In contrast, pcolor() orients the vertical
axis so that numbers increase going upward. This was discussed previously and the
preferred orientation is to have numbers increase going downward like that pro-
duced by imagesc(). Last, observe that pcolor() adds coordinate lines by default
to the image. When arrays contain many points, the black lines become so dense
the entire image becomes black. In FDFD, it will be a standard practice to turn off
those lines and to reverse the y-direction when using pcolor(). The bottom row
of Figure 1.19 visualizes arrays containing 15 × 15 points. The image generated by
pcolor() has the black lines removed and the y-axis reversed to match imagesc().
The application of pcolor() to visualize smooth data is apparent.
A key issue about imagesc() and pcolor() is that both assume the array being
visualized is a matrix. Both graphics commands place the first dimension of the
array along the vertical axis and the second dimension of the array along the hori-
zontal axis. This is the exact opposite of how arrays will be handled throughout
this book. To correct this, the arrays are simply transposed to put them in the cor-
rect orientation for visualization.
The MATLAB code to visualize an array R is provided below. Observe that the
array R is transposed in the calls to imagesc() and pcolor() on lines 29 and 34,
respectively. The axis lines produced by default for pcolor() are removed using
shading interp on line 35. The direction of the y-axis for pcolor() is reversed
by setting the property ‘YDir’ to ‘reverse’ on line 37. Otherwise, the code uses
standard graphics procedures.
1 % imagescpcolor.m
2
3 % INITIALIZE MATLAB
4 close all;
5 clc;
6 clear all;
7
8 % DASHBOARD GRID
9 Sx = 2;
10 Sy = 2;
11 Nx = 15;
12 Ny = 15;
13
14 % CALCULATE MESHGRID
15 dx = Sx/Nx;
16 xa = [1:Nx]*dx;
17 xa = xa – mean(xa);
18
19 dy = Sy/Ny;
20 ya = [1:Ny]*dy;
21
22 [Y,X] = meshgrid(ya,xa);
23
24 % CALCULATE DATA TO VISUALIZE
25 R = sqrt(X.^2 + Y.^2);
26
27 % VISUALIZE USING IMAGESC AND PCOLOR
28 subplot(121);
29 imagesc(xa,ya,R.’);
30 axis equal tight;
31 colorbar;
32
33 subplot(122);
34 pcolor(xa,ya,R.’);
35 shading interp;
36 axis equal tight;
37 set(gca,’YDir’,’reverse’);
38 colorbar;
plane. This can be done to visualize three-dimensional objects built onto a grid, as
shown in Figure 1.20(a), or to visualize electromagnetic fields in three dimensions,
as shown in Figure 1.20(b).
The MATLAB code to produce the visualizations in Figure 1.20 is provided
below. The slice function takes three-dimensional meshgrid parameters X, Y, and Z as
the first three input arguments. The fourth input argument is the three-dimensional
array to be visualized. The fifth input argument is an array containing all of the
positions along the x-axis to image slices. In this case, a single value of 0 is given to
draw a single slice at the plane defined by x = 0. The sixth and seventh input argu-
ments are similar arrays for the positions of the slices along the y- and z-axes. See
the documentation for MATLAB for additional options for the slice() function.
slice(Y,X,Z,A,0,0,0);
shading flat;
grid on;
axis equal tight;
colorbar(‘LineWidth’,3);
view(120,20);
camlight headlight;
Figure 1.20 (a) Visualization of a three-dimensional ellipsoid object using slice(). (b) Visualizing
a three-dimensional wave using slice().
Figure 1.21 Four ways to visualize data in complex arrays: (a) real part, (b) imaginary part,
(c) absolute value, and (d) phase.
to completely understand the field. For most work, the author prefers to visualize
the real part of the field.
Reference
[1] Gentle, J. E., “Matrix Algebra Theory, Computations and Applications in Statistics”
Springer Texts in Statistics, New York: Springer, Vol. 10, 2007.
Electromagnetic Preliminaries
This chapter will review the key electromagnetic concepts and equations needed to
understand and implement the finite-difference frequency-domain (FDFD) method.
Maxwell’s equations and the constitutive relations are introduced and expanded
into Cartesian coordinates that will be used in the FDFD method. From here, the
wave equation is derived and some properties of waves are discussed including
polarization and the dispersion relation. The scattering of waves at an interface and
how polarization is defined relative to the interface are reviewed. The conditions
are explained where Maxwell’s equations can be reduced to analyze devices in just
two dimensions. To set up how reflection and transmission will be calculated in
FDFD for periodic structures, diffraction gratings are reviewed as well as diffrac-
tion efficiency of the diffraction orders. Waveguides and transmission lines will be
briefly discussed to understand the terminology, parameters, and mathematical
form of the modes associated with the devices. Last, scalability in electromagnetics
is discussed along with its implications and applications in FDFD.
There are two ways that electric fields and static electric charges can store energy.
First, energy can be stored in the electric field itself because energy can be propa-
gated through the vacuum of space in electromagnetic waves. This is the electric
33
!
field intensity E(t) and it has units of volts per meter (V/m). The electric field inten-
sity is most closely associated with voltage and force. Second, energy can be stored
in the matter as displaced !charge, like in a battery or the dielectric in a capacitor.
The electric flux density D(t) includes both forms of electric energy and has units
of Coulombs per square meter (C/m 2). It is most closely associated with charge.
Similarly, there are two ways that magnetic fields and moving electric charges can
store energy. First, energy can be stored in the magnetic field itself because energy
can be propagated through the ! vacuum of space in electromagnetic waves. This is
the magnetic field intensity H(t) and it has units of Amperes per meter (A/m). The
magnetic field intensity is most closely associated with electric current. Second,
magnetic energy! can be stored in matter as rotated magnetic dipoles. The magnetic
flux density B(t) includes both forms of magnetic energy and has units of Webers
per square meter (Wb/m 2) or Tesla (T). Magnetic flux is most closely associated
with force. The needle of a compass aligns with the magnetic flux.
Gauss’ law for electric fields equates two different ways of calculating the total
charge enclosed in! a volume. The total charge can be obtained either by integrating
the electric flux D(t) through a closed surface or by integrating the electric charge
density ρ v (C/m3) throughout the volume enclosed by the same surface. Since there
is no such thing as a magnetic charge, Gauss’ law for magnetic fields equals zero
and only contains the term integrating the magnetic flux. Faraday’s law equates
two different ways of calculating the electromotive force (EMF). The EMF can
be calculated from a line integral of the electric field intensity around a closed
path or by integrating the rate of change of the magnetic flux through the surface
enclosed by the path. A negative sign is incorporated to enforce the negative sign
convention. Ampere’s circuit law equates two different ways of calculating the total
electric current passing through an area. The total current can be calculated from a
line integral of the magnetic field intensity! around a path enclosing the area or by
integrating the electric current density J(t) (A/m 2) plus the rate of change of the
electric flux density passing through that area.
Observe that Maxwell’s equations do not contain any material parameters.
For this reason, Maxwell’s equations only describe the manner in which electric
and magnetic fields are created and interact with each other. They do not directly
describe how the fields interact with matter. This information comes from the con-
stitutive relations [2].
! !
D (t ) = e (t ) ∗ E (t ) Electric Response of Matter (2.5)
! !
B (t ) = m (t ) ∗ H (t ) Magnetic Response of Matter (2.6)
In these equations, ε (t) is the electric permittivity and has units of Farads per meter
(F/m). The electric permittivity is a measure of how well a medium stores electric
energy. It accounts for the ability of both matter and the field itself to store electric
energy. Similarly, the magnetic permeability μ (t) has units of Henries per meter (H/m)
and is a measure of how well a medium stores magnetic energy. The permittivity and
permeability change with frequency. This is called material dispersion. This leads
to the convolution operation observed in the time-domain constitutive relations.
In differential form, Gauss’ law for electric fields states that electric flux will
diverge from positive charge and converge on negative charge. In the absence of
charge, the electric flux cannot diverge or converge so it cannot have a beginning or
an end. This means the electric flux can only form loops when no charge is present.
There is no magnetic charge so Gauss’ law for magnetic fields states that magnetic
flux cannot have divergence. That is, the magnetic flux cannot have a beginning
or an end so it can only form loops. Faraday’s law states that oscillating magnetic
flux will have an electric field circulating around it. Ampere’s circuit law states that
a circulating magnetic field will exist around either an oscillating electric flux or
an electrical current. In FDFD, the two divergence equations play the most critical
role in how Maxwell’s equations are made discrete, and the two curl equations play
the most critical role in equations used for FDFD.
Last, the constitutive relations in the frequency-domain simplify considerably
since they no longer contain convolutions.
! !
D = eE Electric Response of Matter (2.12)
! !
B = mH Magnetic Response of Matter (2.13)
The volume charge density ρ v is not often used in electrodynamics (i.e., waves)
problems because the waves being analyzed are away from free charges. For this
reason, ρ v will be set equal to zero and dropped from Gauss’ law. It is common to
substitute the!constitutive relations into Maxwell’s
! equations to eliminate the electric
flux density D and magnetic flux density B terms. This gives
!
( )
∇ • eE = 0
(2.14)
!
( )
∇ • mH = 0
(2.15)
! !
∇ × E = − jwm H (2.16)
! ! !
∇ × H = J + jweE (2.17)
!
The electric current density J in (2.17) is related to the electric field intensity
through a form of Ohm’s law in electromagnetics [2] where σ is the electrical con-
ductivity of the medium.
! !
J = sE (2.18)
where
s
e! = e + (2.22)
jw
It is so common to account for loss with a complex permittivity that the tilde
notation is rarely used. In fact, the complex permittivity throughout this book will
be written without the tilde even though it is a complex quantity. It is more common
to communicate about the properties of a material through the complex relative
permittivity εr̃ than it is the complex permittivity ε.̃ Given the free space permittiv-
ity ε 0, these parameters are related as follows.
e! = e0 e!r (2.23)
In FDFD, material loss is handled simply by making the relative permittivity a
complex number ε.̃ It is important to be cautious of sign convention when expressing
the complex permittivity ε.̃ This book, and most of the engineering, adopts the
negative sign convention where a wave propagating in the +z-direction is written as
exp(−jkz). The positive sign convention would express the same wave as exp(jkz).
For the negative sign convention, the imaginary part of the complex permittivity
is negative when a material has loss and waves decay as they propagate. When
simulating active materials that have gain, the imaginary part of the complex
permittivity is positive and waves grow as they propagate. This is consistent with
(2.22) where the imaginary part has j in the denominator. When brought to the
numerator, the imaginary part becomes negative. It is very easy to mistakenly use
the wrong sign for the imaginary part of the complex permittivity.
In a vacuum, the permittivity becomes the free space permittivity, or vacuum per-
mittivity, and is
materials, the constitutive parameters are tensor quantities and the constitutive
relations are written as
⎡ D ⎤ ⎡ e e e ⎤⎡ E ⎤
! ! ⎢ x ⎥ ⎢ xx xy xz ⎥⎢ x ⎥
D = [ e ] E or ⎢ Dy ⎥ = ⎢ eyx eyy eyz ⎥ ⎢ Ey ⎥ (2.30)
⎢ D ⎥ ⎢ e ⎥⎢ ⎥
⎢⎣ z ⎥⎦ ⎢⎣ zx ezy ezz ⎥⎦ ⎢⎣ Ez ⎥⎦
⎡ B ⎤ ⎡ m m m ⎤⎡ ⎤
! ! ⎢ x ⎥ ⎢ xx xy xz ⎥ ⎢ Hx ⎥
B = [ m]H or ⎢ By ⎥ = ⎢ myx myy myz ⎥ ⎢ Hy ⎥ (2.31)
⎢ B ⎥ ⎢ m ⎥⎢ ⎥
⎢⎣ z ⎥⎦ ⎢⎣ zx mzy mzz ⎥⎦ ⎢⎣ Hz ⎥⎦
Handling full nine-element tensors in FDFD is more complicated and will be
described in Chapter 10. For all other chapters in this book, anisotropy will be
restricted to diagonally anisotropic media where all of the off-diagonal terms in
the tensors are zero and FDFD simplifies considerably.
⎡ D ⎤ ⎡ e 0 0 ⎤⎡ E ⎤
⎢ x ⎥ ⎢ xx ⎥⎢ x ⎥
⎢ Dy ⎥ = ⎢ 0 eyy 0 ⎥ ⎢ Ey ⎥ (2.32)
⎢ D ⎥ ⎢ 0 0 e ⎥⎢ E ⎥
⎢⎣ z ⎥⎦ ⎢⎣ zz ⎥⎦ ⎢⎣ z ⎥⎦
⎡ B ⎤ ⎡ m 0 0 ⎤⎡ H ⎤
⎢ x ⎥ ⎢ xx ⎥⎢ x ⎥
⎢ By ⎥ = ⎢ 0 myy 0 ⎥ ⎢ Hy ⎥ (2.33)
⎢ B ⎥ ⎢ 0 0 mzz ⎥⎢ H ⎥
⎢⎣ z ⎥⎦ ⎢⎣ ⎥⎦ ⎢⎣ z ⎥⎦
⎡ m 0 0 ⎤
⎢ a ⎥
⎡⎣ mr ⎤⎦ = ⎢ 0 mb 0 ⎥ (2.35)
⎢ 0 0 m ⎥
⎣ c ⎦
Isotropic materials have all of the principal values equal (ε a = ε b = ε c) and the
tensor reduces to a single scalar quantity. Materials where only two of the principal
values are equal (ε a = ε b ≠ ε c) are called uniaxial [8]. Materials where all three of
the principal values are different (ε a ≠ ε b ≠ ε c) are called biaxial [8]. The subscripts
of the principal values in (2.34) and (2.35) are written as a, b, and c to indicate that
the principal axes can be in directions other than x, y, and z. The principal axes of
an anisotropic medium do not even have to be perpendicular to each other. When
the principal axes align perfectly with the Cartesian axes, the tensors are diagonal,
and (2.34) and (2.35) are written in terms of the Cartesian axes as
⎡ e ⎤
⎢ xx 0 0 ⎥
⎡⎣er ⎦⎤ = ⎢ 0 eyy 0 ⎥ (2.36)
⎢ ⎥
⎣ 0 0 ezz ⎦
⎡ m ⎤
⎢ xx 0 0 ⎥
⎡⎣ mr ⎤⎦ = ⎢ 0 myy 0 ⎥ (2.37)
⎢ ⎥
⎣ 0 0 mzz ⎦
When the principal axes of the anisotropic medium are not aligned with the
Cartesian axes, off-diagonal terms arise in the tensors. The diagonal element ε mn
in the tensor [ε r] is interpreted as how much of electric field intensity component
En contributes to electric flux density component Dm. The diagonal element μ mn in
the tensor [μ r] is interpreted as how much of magnetic field intensity component
Hn contributes to magnetic flux density component Bm.
⎡ e e e ⎤
⎢ xx xy xz ⎥
⎡⎣er ⎤⎦ = ⎢ eyx eyy eyz ⎥ (2.38)
⎢ ⎥
⎢⎣ ezx ezy ezz ⎥⎦
⎡ m m m ⎤
⎢ xx xy xz ⎥
⎡⎣ mr ⎤⎦ = ⎢ myx myy myz ⎥ (2.39)
⎢ ⎥
⎢⎣ mzx mzy mzz ⎥⎦
calculating the rotation matrix [R x(θ )] and performing the rotation according to
! !
v2 = [Rx (q)]v1. In Cartesian coordinates, this expands to
⎡v ⎤ ⎡v ⎤
⎢ x,2 ⎥ ⎢ x,1 ⎥
⎢ vy,2 ⎥ = ⎡⎣Rx ( q )⎤⎦⎢ vy,1 ⎥ (2.40)
⎢ ⎥ ⎢ ⎥
⎢⎣ vz,2 ⎥⎦ ⎢⎣ vz,1 ⎥⎦
where
⎡1 0 0 ⎤
⎡⎣Rx ( q )⎤⎦ = ⎢ 0 cos q −sin q ⎥ (2.41)
⎢ 0 sin q cos q ⎥
⎣ ⎦
Similar rotation matrices can be constructed to rotate about the y- or z-axes. The
rotation matrices for rotation about the Cartesian axes and illustrations of the rota-
tions they perform are provided in Figure 2.1.
Figure 2.1 Rotation matrices that rotate about the Cartesian axes by angle θ .
⎡v ⎤ ⎡v ⎤
⎢ x,2 ⎥ ⎢ x,1 ⎥
⎢ vy,2 ⎥ = ⎡⎣Rz ( q2 )⎤⎦⎡⎣Ry ( q1 )⎤⎦⎢ vy,1 ⎥ (2.42)
⎢ ⎥ ⎢ ⎥
⎢⎣ vz,2 ⎥⎦ ⎢⎣ vz,1 ⎥⎦
Observe the order of the rotation matrices in (2.42) that may appear at first glance
!
to be backward. However, it is [Ry(θ 1)] that operates on v1 first and then [R z(θ 2)]
operates on the result second. It is further possible to calculate a composite rotation
matrix [R] that performs both rotations in the specified order with a single matrix
! !
according to v2 = [R]v1. This expands to
⎡v ⎤ ⎡v ⎤
⎢ x,2 ⎥ ⎢ x,1 ⎥
⎢ vy,2 ⎥ = [ R] ⎢ vy,1 ⎥ (2.43)
⎢ ⎥ ⎢ ⎥
⎢⎣ vz,2 ⎥⎦ ⎢⎣ vz,1 ⎥⎦
Now that rotating vectors using rotation matrices is understood, rotating ten-
sors can be discussed. Both operations utilize the same rotation matrices and even
the same composite rotation matrices. The tensor [ε r] is rotated about the x-axis
by angle θ according to
−1
⎡⎣erʹ ⎤⎦ = ⎡⎣Rx ( q )⎤⎦⎡⎣er ⎤⎦⎡⎣Rx ( q )⎤⎦ (2.45)
Using the composite rotation matrix in (2.44), the tensor is rotated according to
It is often convenient in FDFD to define the principal values of tensors and the
angles that are to be rotated in the dashboard. When the device is built onto the
grid, the full tensors can be calculated by rotation during the build process.
Maxwell’s curl equations, as presented in (2.16) and (2.21), are vector equations
and independent of the coordinate system. It is possible to expand the vector terms
in these equations into their Cartesian components. While other coordinate systems
for FDFD are possible and very useful in special cases [10–13], Cartesian coordi-
nates will be used throughout this book. Using Cartesian coordinates, the vectors
in the curl equations expand to
( ) (
∇ × Ex âx + Ey ây + Ez âz = −jw [ m ] H x âx + H y ây + Hz âz ) (2.48)
( ) (
∇ × H x âx + H y ây + Hz âz = jw [ e ] Ex âx + Ey ây + Ez âz ) (2.49)
Next, on the left-hand side of the equations the curl is calculated, and on the
right-hand side the tensor quantities [μ ] and [ε ] are assumed to be diagonally aniso-
tropic. This converts the curl equations to
⎛ ∂Ez ∂Ey ⎞ ⎛ ∂E ∂E ⎞ ⎛ ∂Ey ∂E ⎞
⎜ − ⎟ âx + ⎜ x − z ⎟ ây + ⎜ − x ⎟ âz
⎝ ∂y ∂z ⎠ ⎝ ∂z ∂x ⎠ ⎝ ∂x ∂y ⎠ (2.50)
= −jwmxx H x âx − jwmyy H y ây − jwmzz Hz âz
⎛ ∂Hz ∂H y ⎞ ⎛ ∂H ∂Hz ⎞ ⎛ ∂H y ∂H ⎞
⎜ − ⎟ âx + ⎜ x − ⎟ ây + ⎜ − x
⎟ âz
⎝ ∂y ∂z ⎠ ⎝ ∂z ∂x ⎠ ⎝ ∂x ∂y ⎠ (2.51)
= jwexx Ex âx + jweyy Ey ây + jwezz Ez âz
Equation (2.50) can be expanded into a set of three coupled partial differential equa-
tions by setting the individual vector components equal on either side of the equation.
∂Ez ∂Ey
− = −jwmxx H x (2.52)
∂y ∂z
∂Ex ∂Ez
− = −jwmyy H y (2.53)
∂z ∂x
∂Ey ∂Ex
− = −jwmzz Hz (2.54)
∂x ∂y
Similarly, (2.51) can be expanded into a set of three coupled partial differential equa-
tions by setting the individual vector components equal on either side of this equation.
∂Hz ∂H y
− = jwexx Ex (2.55)
∂y ∂z
∂H x ∂Hz
− = jweyy Ey (2.56)
∂z ∂x
∂H y ∂H x
− = jwezz Ez (2.57)
∂x ∂y
Equations (2.52)–(2.57) are the key equations that will be solved numerically
in FDFD.
Two different electromagnetic wave equations can ! be derived from Maxwell’s curl
equations, one in! terms of just the electric field E and the other just in terms of the
magnetic field H. To ! derive a wave equation solely in terms of the electric field,
(2.16) is solved for H !and that expression is substituted into (2.21) to eliminate the
magnetic field term H. Last, all terms are brought to the left side of the equation.
The tilde notation on permittivity ε ̃ was dropped even though the permittivity may
be complex.
⎛1 !⎞ !
∇ × ⎜ ∇ × E⎟ − w 2 e E = 0 (2.58)
⎝m ⎠
This equation cannot be simplified further because the permeability μ may be
inhomogeneous. That is, μ may vary with position making it so the term cannot be
brought outside of the curl operation that contains spatial derivatives. If the medium
is homogeneous, both μ and ε become constants and μ can be moved outside of the
curl operation and (2.58) becomes
! !
( )
∇ × ∇ × E − w 2 meE = 0
(2.59)
!
The
! double-curl
! operation is rewritten using the general vector identity ∇ × (∇ × A) =
∇(∇ ⋅ A) − ∇2 A. This lets (2.59) be written as
! ! !
( )
∇ ∇ • E − ∇2E − w 2 meE = 0
(2.60)
!
From (2.14), the divergence of E is zero in a homogeneous medium so the divergence
term in (2.60) drops from the equation. This reduces (2.60) to
! !
∇ 2
E + w 2
me E = 0 (2.61)
2p w
k0 = = (2.63)
l0 c0
Substituting (2.62) into (2.61) gives the wave equation for waves inside of a
homogeneous medium.
! !
∇2E + k2E = 0 (2.64)
Equation (2.64) can be compared to the historical wave equation that has been
known since at least the 1700s [14]. Given the angular frequency ω and the velocity
of the wave v, the historical wave equation is
⎛ w ⎞2
∇2y + ⎜ ⎟ y = 0 (2.65)
⎝v⎠
In (2.65), ψ is the wave disturbance and can be many things including height
of a vibrating string, pressure in a fluid, an electric field, and more. Comparing
the terms in parentheses in the two wave equations gives some additional physical
meaning to the terms. Seeing that w me = ω /v, the velocity of an electromagnetic
wave must be
1
v= (2.66)
me
In a vacuum, μ = μ 0 and ε = ε 0 and an equation for the speed of light c 0 can be
written from (2.66).
1
c0 = = 299,792,458 m/s (2.67)
m0 e0
Next, the term inside of the square root in (2.66) can be expanded into me =
m0 e0 mr er . After letting n = mr er , (2.66) can be written as
c0
v= (2.68)
n
n= mr er (2.69)
The parameter n is called the refractive index. From (2.68), it is interpreted as
the factor by which a wave slows down inside of a medium relative to the speed of
light in a vacuum c 0. Since both μ r and ε r can be complex quantities, the refractive
index can also be complex. Using the negative sign convention, it is usually written as
n = no − jk (2.70)
The real part of the refractive index no is called the ordinary refractive index
and quantifies the speed of the wave according to v = c 0/no. The imaginary part of
refractive index κ is called the extinction coefficient and it quantifies the attenuation
of a wave. Waves decay with distance z according to exp(−jk0κ z). The product k0κ
is called the attenuation coefficient α of a wave.
The general solution to (2.64) in a linear, homogenous, and isotropic (LHI) medium is
! ! ! ! ! !!
E = E0+e− jki r + E0−e jki r (2.71)
! !
where E0+ is the! complex vector amplitude of the wave traveling in the positive k
direction
! and E0− is the complex vector amplitude of the wave traveling in the nega-
tive k direction. The amplitudes are complex quantities because waves have both a
!
magnitude and a phase. In this equation, the vector position is r = xâx + yây + zâz.
It will be useful to focus attention only on a single term in (2.71). For convenience,
the forward wave will be chosen.
! ! !!
E = Pe− jki r (2.72)
!+ !
The vector amplitude E0 is replaced with P to convey that this term!describes
the polarization and complex amplitude of the wave. The wave vector ! k conveys
two pieces of information at the same time. First, ! the direction of k is the direction
that the phase of the wave advances. That is, k is the direction that the !ripples of
the wave will move as illustrated in Figure 2.2. Second, the magnitude of k conveys
the wavelength λ of the wave through
! 2p
k = (2.73)
l
When the frequency f is known, the free space wavelength λ 0 is also ! known
because they are related through c 0 = f λ 0. In this case, the magnitude of k conveys
refractive index n through
!
k = k0n (2.74)
!
Figure 2.2 Relation between the wave vector k , wavelength λ , and the direction that the
ripples of the wave move.
( )
E = h M × k̂ e− jki r
(2.80)
the magnetic field that is not conveyed ! through the electric field. Polarization first
appeared in (2.72) as the vector P. Accounting for polarization is very important
in electromagnetic simulations because waves interact with structures differently
depending on the orientation of the fields. This is particularly important when the
structure being simulated is on the same physical scale as the wavelength.
An electromagnetic wave is said to have linear polarization (LP) when the
electric field oscillates in a single plane. An LP wave is illustrated in Figure 2.3(a).
A wave propagating in the +z-direction that is linearly polarized in the x-direction
is written as
!
E ( z ) = ( E0 âx ) exp (−jkz ) (2.81)
!
The expression in parentheses is the polarization vector P = E 0 âx. The term
E 0 is the complex amplitude of the wave. It is a complex number because it affects
both the magnitude and phase of the wave. A wave propagating in the +z-direction
that is linearly polarized in the y-direction is written as
!
( )
E ( z ) = E0 ây exp (−jkz )
(2.82)
The electric field for an LP wave is not restricted to being just in the x- or
y-directions. The electric field can oscillate at any angle θ in the xy plane and still
be linearly polarized. The expression for such a wave is
!
( )
E ( z ) = E0 cos qâx + sin qây exp (−jkz )
(2.83)
Figure 2.3 Summary of electromagnetic wave polarizations. (a) Linear polarization where
the electric field oscillates within a plane. (b) Left circular polarization where electric field
rotates counterclockwise from behind. (c) Right circular polarization where electric field rotates
clockwise from behind. (d) Elliptical polarization where electric field rotation traces an ellipse.
!
â1 and â2 are
! ! unit vectors perpendicular to k and satisfy the handedness defined by
â1 × â2 = k/ k . Otherwise, the direction of â1 and â2 do not matter when specifying
polarization until a device or interface is involved. E1 is the real-valued amplitude
of the electric field component in the direction of â1. E 2 is the real-valued ampli-
tude of the electric field component in the direction of â2 . θ is the phase common
to both of these components and does not need to be considered when trying to
determine the polarization. δ is the phase difference between the two components
of the electric field. If δ = 0°, the polarization is linear no matter the values of E1
and E 2 . If δ = ±90° and E1 = E 2 , the polarization is circular. A phase of δ = +90°
indicates RCP and a phase of δ = −90° indicates LCP. Anything else is considered
elliptical polarization. In some sense, all polarizations are elliptical. Linear and
circular polarizations are just special cases of elliptical polarization.
2 ⎛ wn ⎞2
kx2 + ky2 + kz2 = (k0n) = ⎜ ⎟ (2.87)
⎝ c0 ⎠
Equation (2.87) is the dispersion relation for an LHI medium. It states that
the magnitude of the wave vector in an LHI medium is constant regardless of the
direction of the wave. The dispersion relation is used in FDFD to calculate a miss-
ing wave vector component when the others are known.
Figure 2.4 (a) Diagram of scattering at an interface with azimuthal angle ϕ ≠ 0°. (b) Diagram
of scattering at an interface with azimuthal angle ϕ = 0°. The angles and amplitudes remain
constant regardless of azimuthal angle ϕ .
Therefore,
! the direction â TE must be in the same direction as the cross product âz ×
kinc . However,
! this cross product has no meaning at normal incidence when âz
and kinc are parallel. This special case must be handled when calculating â TE . At
normal incidence, the direction of the TE polarization will be chosen to be in the
y-direction. Putting all of this together, the direction of the TE polarization is cal-
culated according to
⎧ !
⎪⎪ â × k
z
!inc θ1 ≠ 0°
âTE = ⎨ âz × kinc (2.89)
⎪
⎪⎩ ây θ1 = 0°
After the direction of the TE polarization is known, the direction of the TM
polarization is easily calculated from! it. The TM polarization must be perpendicu-
! to both the TE polarization and kinc so it is in the direction of the cross product
lar
kinc × â TE .
!
âTM = kinc × âTE (2.90)
Given
! unit vectors in the TE and TM polarization directions, the polarization
vector P for the electric field is easily written given the complex amplitude of the
TE polarization P TE and the complex amplitude of the TM polarization P TM.
!
P = pTE âTE + pTM âTM (2.91)
This equation for polarization is a manifestation of (2.85), but here a device
is involved so the directions of the unit vectors are important. Without a device or
interface defined, it does not make sense to talk about TE and TM polarizations.
When the incident wave encounters the interface, some of the incident wave
can reflect. The angle of the reflected wave θ ref is equal to the angle of the incident
wave θ 1. This is called Snell’s law of reflection [16].
qref = q1 (2.92)
In addition, some of the incident wave can transmit through the interface into
the second medium. If the wave changes speed, the angle of the transmitted wave
θ 2 may be different from the angle of the incident wave θ 1 in order to keep the field
continuous across the interface. The angles θ 1 and θ 2 will be different when the
wave is incident at some angle θ 1 ≠ 0° and when the first and second mediums have
different refractive indices, n1 ≠ n2 . Snell’s law of refraction [16] relates the angle
of the incident wave θ 1, angle of the transmitted wave θ 2 , and refractive indices on
both sides of the interface n1 and n2 .
n1 sin q1 = n2 sin q2 (2.93)
Snell’s laws of reflection and refraction calculate the angles of the waves but
not the amplitudes. To calculate how much of the incident wave is reflected and
transmitted, the Fresnel equations are needed [2]. The Fresnel equations relate the
amplitudes of the incident E 0,inc, reflected E 0,ref, and transmitted waves E 0,trn given
the angles θ 1 and θ 2 and the impedances η 1 and η 2 of the two mediums. They are
derived by enforcing the boundary conditions for both the electric and magnetic
fields at the interface.
TE
h2 cos q1 − h1 cos q2 2h2 cos q1
TE
E0,ref E0,trn
rTE = = tTE = = (2.94)
TE
E0,inc h2 cos q1 + h1 cos q2 TE
E0,inc h2 cos q1 + h1 cos q2
TM
h2 cos q2 − h1 cos q1 2h2 cos q1
TM
E0,ref E0,trn
rTM = = tTM = = (2.95)
TM
E0,inc h2 cos q2 + h1 cos q1 TM
E0,inc h2 cos q2 + h1 cos q1
In these equations, the reflection and transmission properties are different for
the TE and TM polarizations because each has to satisfy different boundary con-
ditions at the interface.
! 1 ! !
℘ = Re ⎡⎣E × H ∗ ⎤⎦ (2.96)
2
The * superscript
! !in∗ the H* term represents a complex conjugate operation. It
! H !are! perpendicular to each !other
is known that !E and ! so the
! magnitude of their
cross product E × H ∗ is E H .!It is !also known that E, H, and k form a !right-handed
system where the direction of E × H ∗ !has! to be in the same direction as k. Therefore,
the direction of the cross product is k/ k . Combining the magnitude and direction
of the cross product as described above lets the Poynting vector be written as
⎡ !⎤
! 1 ⎢! ! k⎥
℘ = Re E H ! (2.97)
2 ⎢ k ⎥⎦
⎣
! !
Next, the magnitudes E and H are related ! !through the impedance η of the
medium according to (2.77). This leads to H = E /η and the Poynting vector can
be written completely in terms of the electric field.
⎡ ! !⎤
! 1 ⎢! E k⎥
℘ = Re E ! (2.98)
2 ⎢ h k⎥
⎣ ⎦
It is only the normal component of the Poynting vector that contributes to power
flow to and from the interface. Components of the Poynting vector that are parallel
to the interface can be ignored because they describe the power that stays confined
at the interface. In the present analysis, z is the normal direction so it is only the z
component of the Poynting vector that needs to be considered.
⎡ !2 ⎤
1 ⎢ E kz ⎥
℘z = Re ⎢ ! (2.99)
2 h k⎥
⎢⎣ ⎥⎦
Reflectance R is the fraction of power from the incident wave that is reflected
from the interface. The transmittance T is the fraction of power from the incident
wave that is transmitted through the interface. From this definition, reflectance and
transmittance are calculated from the z components of the Poynting vectors of the
incident, reflected, and transmitted waves as
⎡ ! 2 ⎤
1 ⎢ E0,ref kz,ref ⎥
Re − !
2 ⎢ h1 k ⎥
℘z,ref ⎢⎣ ref ⎥
⎦
R= = ! (2.100)
℘z,inc ⎡ 2 ⎤
1 ⎢ E0,inc kz,inc ⎥
Re !
2 ⎢ h1 k ⎥
⎢⎣ inc ⎥
⎦
⎡! 2 ⎤
1 ⎢ E0,trn kz,trn ⎥
Re !
2 ⎢ h2 ktrn ⎥⎥
℘z,trn ⎢⎣ ⎦
T = = (2.101)
℘z,inc ⎡! 2 ⎤
1 ⎢ E0,inc kz,inc ⎥
Re !
2 ⎢ h1 kinc ⎥⎥
⎢⎣ ⎦
Observe the negative sign in the numerator of (2.100). The reflected wave is propa
gating in the −z-direction so kz,ref is negative. The negative sign is incorporated in
the equation to get an overall positive ! number.
! !
From (2.88), it follows that kinc = kref = k0 n1, ktrn = k0 n2 , kz,inc = −kz,ref =
k0 n1cosθ 1, and kz,trn = k0 n2cosθ 2 . Given these relations, (2.100) and (2.101) reduce
to the following for lossless media.
! 2
E0,ref 2
R= ! 2
= r (2.102)
E0,inc
! 2
E0,trn h cos q 2 h cos q2
T = ! 1 2
= t 1 (2.103)
2
E0,inc 2h cos q1
h2 cos q1
Writing these equations for both the TE and TM polarizations gives
2 2 h1 cos q2
RTE = rTE TTE = tTE (2.104)
h2 cos q1
2 2 h1 cos q2
RTM = rTM TTM = tTM (2.105)
h2 cos q1
Figure 2.5 (a) Illustration of the conditions for a three-dimensional simulation to numerically
reduce to two dimensions. (b) Interpretation as a two-dimensional “al” simulation.
∂Ez
= −jwmxx H x (2.108)
∂y
∂Ez
− = −jwmyy H y (2.109)
∂x
∂Ey ∂Ex
− = −jwmzz Hz (2.110)
∂x ∂y
∂Hz
= jwexx Ex (2.111)
∂y
∂Hz
− = jweyy Ey (2.112)
∂x
∂H y ∂H x
− = jwezz Ez (2.113)
∂x ∂y
After inspecting these equations, it becomes apparent that they have separated
into two independent sets of three coupled partial differential equations. No terms
in (2.108), (2.109), and (2.113) exist in (2.110), (2.111), and (2.112). Likewise, no
terms in (2.110), (2.111), and (2.112) exist in (2.108), (2.109), and (2.113). If the
angle of incidence in Figure 2.4 is set to θ 1 = 90°, then (2.108), (2.109), and (2.113)
correspond to the TM polarization while (2.110), (2.111), and (2.112) correspond
to the TE polarization. For the TM polarization, it is possible to derive a single
differential equation just in terms of Ez by solving (2.108) for Hx and (2.109) for
Hy and then substituting these expressions into (2.113). For this reason, the TM
polarization will also be called the E mode in this book. These equations are
1 ∂Ez
Hx = − (2.114)
jwmxx ∂y
1 ∂Ez
Hy = (2.115)
jwmyy ∂x
∂ ⎛ 1 ∂Ez ⎞ ∂ ⎛ 1 ∂Ez ⎞
⎜ ⎟+ ⎜ ⎟ + w 2 ezz Ez = 0 (2.116)
∂x ⎜⎝ myy ∂x ⎟⎠ ∂y ⎝ mxx ∂y ⎠
For the TE polarization, it is possible to derive a single differential equation
just in terms of Hz by solving (2.111) for Ex and (2.112) for Ey and then substitut-
ing these expressions into (2.110). For this reason, the TE polarization will also be
called the H mode in this book. These equations are
1 ∂Hz
Ex = (2.117)
jwexx ∂y
1 ∂Hz
Ey = − (2.118)
jweyy ∂x
∂ ⎛ 1 ∂Hz ⎞ ∂ ⎛ 1 ∂Hz ⎞
⎜ ⎟+ ⎜ ⎟ + w 2 mzz Hz = 0 (2.119)
∂x ⎜⎝ eyy ∂x ⎟⎠ ∂y ⎝ exx ∂y ⎠
Solving a single differential equation instead of six coupled partial differential
equations greatly reduces the computational complexity and improves efficiency.
This allows simulations to be performed more quickly and larger problems to be
solved. Similarly, if the problem is uniform along two dimensions, the simulation
can be reduced to just one dimension for even greater computational efficiency. It
is always a good practice to reduce the dimensionality of a simulation if at all pos-
sible. If a simulation is performed in something other than the xy plane, the sense
of TE and TM may be different for the E and H modes.
A diffraction grating is a planar periodic structure that splits and disperses elec-
tromagnetic waves [17]. Essentially, all periodic structures behave like diffraction
gratings in terms of reflected and transmitted waves. For this reason, every periodic
structure in FDFD will be analyzed in the framework of a diffraction grating even
if the device is not a diffraction grating. Understanding diffraction gratings is very
important for understanding how reflection and transmission from any periodic
structure will be evaluated after FDFD calculates the fields. When a wave is incident
onto a diffraction grating, the grating splits the reflected and transmitted waves
into multiple discrete waves propagating away from the grating at different angles.
These are called diffraction orders and the concept is illustrated in Figure 2.6. The
reason for the splitting of the wave into discrete directions will be discussed in
Section 2.9.1. The fraction of power coupled into a specific diffraction order from
the incident wave is called the diffraction efficiency. The overall reflectance from a
device is the sum of the diffraction efficiencies of all the reflected diffraction orders.
Figure 2.6 Geometry of diffraction from a grating. The grating is depicted as a paper-thin
interface to generalize the configuration of the grating. The grating could be at the bottom of
the top medium, on the surface of the bottom medium, or in some intermediate medium.
Similarly, the overall transmittance from a device is the sum of the diffraction effi-
ciencies of all the transmitted diffraction orders.
The permittivity contrast Δ ε describes how much ! the permittivity function varies
around
! the average value ε avg . The grating vector K is analogous to the wave vector
k! and conveys two pieces of information at the same time. First, ! the direction of
K is perpendicular to the grooves of the diffraction grating like k is perpendicular
to the ripples of a wave. In this sense, the grooves are analogous to wave ripples,
but the grooves of a grating do!not move and do not oscillate like the ripples of a
wave. Second,! the magnitude K conveys the period Λ of the grating just like the
magnitude k conveys the wavelength of a wave.
! 2p
K = (2.121)
Λ
When a wave passes through a diffraction grating, its amplitude gets perturbed
by! ! grating
the ! with! the same basic pattern as the grating. If the applied wave is
!
Einc (r) = E0 exp(−jkinc i r), the perturbed wave can be written as
! ! ! ! ! ! !
( ) (
E ( r ) ∝ E0 ⎡⎣eavg + Δe cos K i r ⎤⎦ exp −jkinc i r
) (2.122)
The proportionality sign ∝ is used here because no conclusions are being made
about the amplitude of the perturbed wave. Attention is focused solely on the
! !
interaction between the grating vector K and wave vector kinc . Applying trigonometric
identities to this equation shows that (2.122) is actually three! waves propagating in
different directions.!One wave
! propagates in the direction of kinc , another !propagates
!
in the direction of kinc − K, and the last propagates in the direction of kinc + K.
! ! ! !
( !
E ( r ) ∝ E0 eavg exp − jkinc i r )
! Δe ! ! ! ! Δe ! ! ! (2.123)
+ E0
2 ⎣ ( ⎦ )
exp ⎡ − j kinc − K i r ⎤ + E0
2 ⎣ (
exp ⎡ − j kinc + K i r ⎤
⎦ )
Each of these three waves is also perturbed by the diffraction grating and splits
into three more directions, giving a total of nine waves. Each of these nine waves
is perturbed by the diffraction grating, split into three waves, and so on. This leads
to an infinite sum of discrete waves.
! ! ∞ ! ! ! !
E (r ) ∝ ∑ ( )
Em exp ⎡⎣−j kinc − mK i r ⎤⎦ (2.124)
m=−∞
To derive the grating equation that will calculate the angles of the diffraction
orders, let the geometry of the grating be that shown in Figure 2.6. The incident
wave vector is written as
!
kinc = k0ninc sin qinc âx + k0ninc cos qinc ây (2.125)
After experiencing the grating, the wave vector expansion from (2.124) becomes
! ! ! ! ⎛ 2π ⎞
k(m) = kinc − mK. Replacing !kinc in this expression with (2.125) and letting K = ⎜ ⎟ âx
gives a new expression for k(m). ⎝Λ ⎠
! ⎛ 2p ⎞
k ( m) = ⎜k0ninc sin qinc − m ⎟ âx + k0ninc cos qinc ây (2.126)
⎝ Λ⎠
Boundary conditions require that the x-components of the wave vectors be the
same for both the reflected and transmitted diffraction orders. For this reason,
kx(m) taken from (2.126) is written without having to identify it as either reflected
or transmitted.
2p
kx ( m) = k0ninc sin qinc − m (2.127)
Λ
Equation (2.127) will be used in FDFD to calculate the tangential components of the
wave vectors associated with the diffraction orders. The term kx(m) can be written
in terms of the refractive index nobs where the diffraction is being observed and the
angle θ (m) of the diffraction order. Putting kx(m) = k0 nobssin[θ (m)] into (2.127) gives
2p
k0nobs sin ⎡⎣q ( m)⎤⎦ = k0ninc sin qinc − m (2.128)
Λ
The grating equation is derived by dividing this equation by the free space wave-
number k0 = 2π / λ 0.
l0
nobs sin ⎡⎣q ( m)⎤⎦ = ninc sin qinc − m (2.129)
Λ
⎡ ! 2 ⎤
1 ⎢ E0,ref ( m) kz,ref ( m) ⎥
Re − !
2 ⎢ href k ⎥
℘z,ref ( m) ⎢⎣ ref ⎥⎦
RDE ( m) = = ! (2.130)
℘z,inc ⎡ 2 ⎤
1 ⎢ E0,inc kz,inc ⎥
Re !
2 ⎢ hinc k ⎥
⎣⎢ inc ⎦⎥
⎡! 2 ⎤
1 ⎢ E0,trn ( m) kz,trn ( m) ⎥
Re !
2 ⎢ htrn ktrn ⎥⎥
℘z,trn ( m) ⎢⎣ ⎦
TDE ( m) = = (2.131)
℘z,inc ⎡! 2 ⎤
1 ⎢ E0,inc kz,inc ⎥
Re !
2 ⎢ hinc kinc ⎥⎥
⎢⎣ ⎦
! ! !
Recognizing that kinc = kref = k0 nref, ktrn = k0 ntrn, η ref = m0 mr,ref /e0 er,ref , η trn =
m0 mr,trn /e0 er,trn , and nref = mr,ref er,ref , and ntrn = mr,trn er,trn ,. (2.130) and (2.131)
reduce to the following for lossless media.
! 2
E0,ref ( m) ⎡ k ( m) ⎤
RDE ( m) = ! 2
Re ⎢− z,ref ⎥ (2.132)
E0,inc ⎣ kz,inc ⎦
! 2
E0,trn ( m) ⎡m k ( m) ⎤
TDE ( m) = ! Re ⎢ r,ref z,trn ⎥ (2.133)
⎣ mr,trn kz,inc ⎦
2
E0,inc
! 2
In FDFD, the source will almost always!be given a unit
! amplitude so E inc
=
1. The amplitudes of the diffraction orders Eref (m) and Etrn (m) will be determined
from the FDFD simulation. The z components of the diffraction orders are deter
mined from the dispersion relation in the medium where they exist.
2
kz,ref ( m) = − (k0nref ) − kx2 ( m)
(2.134)
kz,trn ( m) = (k0ntrn ) − kx2 ( m)
(2.135)
A negative sign was inserted into (2.134) because the reflected wave is propa-
gating in the −z-direction. Observe from (2.134) and (2.135) that the longitudinal
components of the wave vectors can become imaginary. This means the mth dif-
fraction order is cutoff and is not a propagating wave. These are evanescent waves
and they do not contribute to power flow away from the diffraction grating. These
are ignored in the diffraction efficiency equations by taking only the real part of
kz,ref(m) and kz,trn(m).
Equations (2.132) and (2.133) are used when electric fields are calculated from
the simulation (E mode simulation). If magnetic fields are known instead (H mode
simulation), (2.136) and (2.137) should be used instead.
! 2
H0,ref ( m) ⎡ kz,ref ( m) ⎤
RDE ( m) = ! 2
Re ⎢− ⎥ (2.136)
H0,inc ⎣ kz,inc ⎦
! 2
H0,trn ( m) ⎡e k ( m) ⎤
TDE ( m) = ! Re ⎢ r,ref z,trn ⎥ (2.137)
⎣ er,trn kz,inc ⎦
2
H0,inc
!
! Geometry of diffraction from a crossed grating described by grating vectors K 1 =
Figure 2.7
K xâx and K 2 = Kyây. Diffraction orders occur within a cone of angles on both sides of the grating
and are identified by their two indices (m,n).
given as Λ y. The key difference from planar diffraction discussed previously is that
diffraction orders can occur in a cone of directions above and below the grating.
The
! period! and symmetry of a crossed grating is described by two grating vec-
tors K1 and K2 . For a rectangular grating, these are defined as
! !
K1 = Kx âx K2 = Ky ây (2.138)
! 2p ! 2p
K1 = Kx = K2 = Ky = (2.139)
Λx Λy
For three-dimensional diffraction problems, boundary conditions must be
applied to both x and y components of the incident wave vector. This leads to an
infinite expansion for both x and y components of the wave vectors associated with
the diffraction orders. These are equal for both reflected and transmitted diffrac-
tion orders and are given by
2p
kx ( m, n) = kx,inc − m (2.140)
Λx
2p
ky ( m, n) = ky,inc − n (2.141)
Λy
Observe for crossed gratings that there are two integers m and n that identify
the diffraction orders. That is because diffraction no longer occurs in just a single
plane, but fans out in a cone of directions. While the wave vectors of both the
reflected and transmitted diffraction orders share the same x and y components,
the longitudinal components must be calculated separately because the mediums
can be different. These are calculated from the dispersion relation as
2
kz,ref ( m, n) = − (k0nref ) − kx2 ( m, n) − ky2 ( m, n)
(2.142)
kz,trn ( m, n) = (k0ntrn ) − kx2 ( m, n) − ky2 ( m, n)
(2.143)
The diffraction efficiencies are calculated using essentially the same equations as
for planar diffraction. The difference is that the diffraction efficiencies are calculated
for diffraction orders identified by two indices m and n. When diffraction efficiency
is calculated from electric fields, the equations are
! 2
E0,re f ( m, n) ⎡ kz,ref ( m, n) ⎤
RDE ( m, n) = ! 2
Re ⎢− ⎥ (2.144)
E0,inc ⎣ kz,inc ⎦
! 2
E0,trn ( m, n) ⎡ mr,ref kz,trn ( m, n) ⎤
TDE ( m, n) = ! Re ⎢ ⎥ (2.145)
⎣ mr,trn
2
E0,inc kz,inc ⎦
When diffraction efficiency is calculated from magnetic fields, the equations are
! 2
H0,ref ( m, n) ⎡ kz,ref ( m, n) ⎤
RDE ( m, n) = ! 2
Re ⎢− ⎥ (2.146)
H0,inc ⎣ kz,inc ⎦
! 2
H0,trn ( m, n) ⎡ er,ref kz,trn ( m, n) ⎤
TDE ( m, n) = ! Re ⎢ ⎥ (2.147)
⎣ er,trn
2
H0,inc kz,inc ⎦
Waveguides for electromagnetic waves are analogous to pipes for fluids [18–21].
They confine electromagnetic waves so that power will not be lost due to the spread-
ing of the wave as it propagates. At radio frequencies, common waveguides include
transmission lines like microstrips [22] and rectangular metal waveguides [2]. At
optical frequencies, common waveguides include optical fibers [20] and integrated
optical waveguides [23]. There exist plenty more types of waveguides including some
very interesting and exotic designs, usually intended for specialized applications.
Electromagnetic fields must obey Maxwell’s equations so the fields cannot take on
any configuration they please. Due to the rules defined by Maxwell’s equations,
the fields can only take on certain discrete configurations called guided modes. A
guided mode can have a cutoff frequency. At frequencies less than the cutoff fre-
quency, the guided mode is said to be cutoff and will decay very quickly along the
waveguide if any attempt is made to excite the mode. Not all guided modes have a
cutoff frequency and will still be guided modes even as the frequency approaches
zero. At a fixed frequency, waveguides can sometimes support multiple modes. The
guided mode supported at the lowest frequency is called the fundamental mode.
The fundamental mode is generally the most important of the guided modes. Sin-
gle-mode waveguides operate at a frequency where only the fundamental mode is
supported by the waveguide.
Transmission lines are waveguides in every sense, but they are a special class
of waveguides that tend to be thought of more as a circuit element or a simple
electrical interconnect. For a waveguide to be considered a transmission line, it
must have at least two conductors. The fundamental mode in transmission lines has
no cutoff frequency and can operate down to zero frequency. When a transmission
line contains only a single homogeneous dielectric around the conductors, it can
support a completely transverse electromagnetic (TEM) mode where neither the
electric nor magnetic field has a vector component in the direction of propagation.
Figure 2.8 Comparison of slab and channel waveguides. (a) Slab waveguides confine
propagation along a single axis. (b) Channel waveguides confine propagation along two axes.
!
function e(x, y) is simply a description of the relative amplitude and direction of the
electric field throughout the xy plane at z = 0. To determine what a guided mode
looks like at any other position z, the complex propagation constant γ must also be
calculated. Given γ , the electric field at any position is written as
! !
E ( x, y, z ) = e ( x, y ) exp (−gz ) (2.148)
The complex propagation constant γ is a complex number with real and imagi-
nary parts defined as
g = a + jb (2.149)
The terms α and β have physical meaning that can be determined by substitut-
ing (2.149) into (2.148) and expanding the exponential. This gives
! !
E ( x, y, z ) = e ( x, y ) exp (−az ) exp (−jbz ) (2.150)
From (2.150), it is observed that α describes the decay of the guided mode
that would occur due to the guided mode being leaky or due to ohmic loss in the
materials the waveguide is made of. The parameter α is called the attenuation coef-
ficient. In most guided mode calculations, the loss is ignored and the waveguides
are not leaky so α = 0. It can also be observed that β leads to the guided mode
oscillating with distance z due to the exponential having an imaginary argument.
The parameter β is called the phase constant and describes how quickly the guided
mode accumulates phase as it propagates. As long as the waveguide is straight and
!
possesses no discontinuities, the picture of the mode e(x, y) does not change and
the mode simply accumulates phase and/or decays as it propagates. In this sense, a
propagating mode is quite boring!
In photonics, sometimes the effective refractive index neff is used to characterize
propagation instead of the complex propagation constant γ . The two parameters are
almost synonymous and are related through γ = jk0 neff. The meaning of the effective
refractive index is that a guided mode will accumulate phase at the same rate as a
plane wave propagating in an infinite and homogeneous medium of refractive index
neff. In dielectric waveguides, the effective refractive index is very close to the aver-
age refractive index calculated over the area of the guided mode. The concept of the
effective refractive index can be used to reduce some complicated three-dimensional
simulations down to simpler two-dimensional simulations. This will be discussed
in more detail in Chapter 6 when the effective index method is discussed.
!
All of the information about the guided mode is contained in e(x, y) and γ (or
neff). If the waveguide supports more than one guided mode, each mode will have
its own pair of parameters describing it because each mode will look different and
!
propagate differently. The mth guided mode will have em (x, y) and γ m (or nm,eff). The
magnetic field can be calculated directly from the electric field and has the same
basic form given in (2.151). The magnetic field component of a guided mode ! has
the same complex propagation constant γ , but an entirely different picture h(x, y)
in the xy plane.
! !
H ( x, y, z ) = h ( x, y ) exp (−gz ) (2.151)
!
The purpose of a! guided-mode calculation is simply to calculate em (x, y), γ m (or
nm,eff), and possibly hm (x, y) for each guided mode. The analysis only calculates what
guided modes are supported by the waveguide, not what guided modes may actually
be excited or their amplitudes relative to the other modes. A scattering simulation
with a source is required in order to determine which of the guided modes may be
excited and what the amplitudes of the modes would be. Scattering simulations
with waveguides will be discussed in Chapter 8.
Figure 2.9 (a) Microstrip transmission line. (b) Coaxial transmission line. (c) RLGC equivalent
circuit model for a transmission line.
d 2V ( z )
− ( R + jwL) (G + jwC )V ( z ) = 0 (2.154)
dz2
d 2I ( z )
− ( R + jwL) (G + jwC ) I ( z ) = 0 (2.155)
dz2
The collection of terms (R + jω L)(G + jω C) defines the complex propagation con-
stant γ . The general solution to both of the wave equations is
wave. The parameter α is the attenuation coefficient and β is the phase constant.
Equation (2.158) can be solved for α and β to write them in terms of the RLGC
parameters. The equations for α and β are almost identical and differ only by the
sign of the (RG − ω 2 LC) term.
a =
(RG − w2LC ) + (R2 + w2L2 ) (G2 + w2C2 )
(2.159)
2
− ( RG − w 2LC ) + (R2 + w2L2 ) (G2 + w2C2 )
b= (2.160)
2
The characteristic impedance Z 0 quantifies the amplitude and phase relation-
ship between the voltage and current at any point along the transmission line. An
expression for Z 0 in terms of the RLGC parameters is derived by substituting (2.156)
and (2.157) into (2.152) and (2.153), combining the two new equations, and then
solving for V0+/I0+. This long derivation gives
V0+ R + jwL
Z0 = = (2.161)
I0+ G + jwC
Scalability has two big implications for electromagnetic simulations. First, the
frequency, wavelength, and dimensions of a device are artificial concepts to an elec-
tromagnetic simulation. These quantities may be specified at the start of a simulation,
but they are quickly normalized so the only parameters known to the simulation are
relative permittivity, relative permeability, and size relative to wavelength. Each of
these are unitless quantities that carry no information about the actual frequency,
wavelength, or physical size of the device being simulated. When the simulation is
finished, the results are often denormalized back to whatever frequency or physical
dimensions were initially specified, but these are not part of the simulation itself.
Second, if a device is simulated, or if a device is identified in the literature, which
exhibits the desired behavior but at the wrong frequency, it is only a matter of scal-
ing the dimensions to get the same behavior at a different frequency.
The numerical solution to Maxwell’s equations will be obtained using the finite-
difference method. The finite-difference method will convert Maxwell’s equations
to a single matrix equation that can be solved numerically. The matrix equation
can have one of two forms: (1) an eigenvalue problem and (2) a scattering problem.
For eigenvalue problems, the matrix equation will have the form of
Af = vf (2.162)
In (2.162), the matrix A enforces Maxwell’s equations onto the fields stored in the
column vector f. The eigenvalue problem is essentially a test. If performing the opera-
tion of A on the function stored in f gives the function f again scaled by a constant
v, then the function in f is a valid solution to the eigenvalue problem. The solution f
is an eigenvector and the constant v is an eigenvalue. Eigenvectors and eigenvalues
come in pairs and should always be kept together. When solved numerically, M
solutions to the eigenvalue problem are calculated when the matrix A is size M × M.
There is no source or excitation associated with eigenvalue problems. When analyz-
ing waveguides, for example, the solutions are the possible modes supported by the
waveguide. Eigenvalue problems only calculate what modes could propagate in the
waveguide. Calculating what modes may actually be propagating in a waveguide
requires a source to determine. Eigenvalue problems will be formulated and solved
in Chapter 6 to analyze waveguides and in Chapter 7 to calculate photonic bands.
For scattering problems, the matrix equation will have the form of
Af = b (2.163)
In (2.163), the matrix A enforces Maxwell’s equations like the A matrix in (2.162).
In contrast to eigenvalue problems, scattering problems require a source and pro-
duce only a single solution. The source is encoded into the column vector b. Scat-
tering problems will be formulated and solved in Chapters 8 to 10 for a variety of
devices and applications.
References
[1] Sadiku, M. N. O., Elements of Electromagnetics, Seventh Edition, New York: Oxford
University Press, 2018.
[2] Balanis, C. A., Advanced Engineering Electromagnetics, New York: Wiley, 1989.
[3] Fleisch, D., A Student’s Guide to Maxwell’s Equations, New York: Cambridge University
Press, 2008.
[4] Huray, P. G., Maxwell’s Equations, Hoboken, NJ: John Wiley & Sons, 2011.
[5] Maxwell, J. C., “On Physical Lines of Force,” Philosophical Magazine, Vol. 90, No. S1,
2010, pp. 11–23.
[6] Simovski, C., “Material Parameters of Metamaterials (A Review),” Optics and Spectroscopy,
Vol. 107, No. 5, 2009, pp. 726–753.
[7] Rumpf, R. C., “Engineering the Dispersion and Anisotropy of Periodic Electromagnetic
Structures,” Solid State Physics, Vol. 66, 2015, pp. 213–300.
[8] Mackay, T. G., and A. Lakhtakia, Electromagnetic Anisotropy and Bianisotropy: A Field
Guide, Singapore: World Scientific, 2019.
[9] Brand, L., Vector and Tensor Analysis, Mineola, NY: Dover Publications, 2020.
[10] Rewienski, M., and M. Mrozowski, “An Iterative Algorithm for Reducing Dispersion
Error on Yee’s Mesh in Cylindrical Coordinates,” IEEE Microwave and Guided Wave
Letters, Vol. 10, No. 9, 2000, pp. 353–355.
[11] Xiao, J., H. Ni, and X. Sun, “Full-Vector Mode Solver for Bending Waveguides Based on
the Finite-Difference Frequency-Domain Method in Cylindrical Coordinate Systems,”
Optics Letters, Vol. 33, No. 16, 2008, pp. 1848–1850.
[12] Aghaie, K. Z., S. Fan, and M. J. Digonnet, “Birefringence Analysis of Photonic-Bandgap
Fibers Using the Hexagonal Yee’s Cell,” IEEE J. of Quantum Electronics, Vol. 46, No.
6, 2010, pp. 920–930.
[13] Guo, S., et al., “Photonic Band Gap Analysis Using Finite-Difference Frequency-Domain
Method,” Optics Express, Vol. 12, No. 8, 2004, pp. 1741–1746.
[14] Speiser, D., K. Williams, and S. Caparrini, Discovering the Principles of Mechanics
1600–1800: Essays, Basel–Boston, MA: Birkhäuser, 2008.
[15] Goldstein, D. H., Polarized Light, Boca Raton, FL: CRC Press, 2017.
[16] Hecht, E., Optics, Fifth Edition, Boston, MA: Pearson Education, Inc., 2017.
[17] Loewen, E. G., and E. Popov, Diffraction Gratings and Applications: CRC Press, 2018.
[18] Kuester, E. F., Theory of Waveguides and Transmission Lines, Boca Raton, FL: CRC
Press, 2020.
[19] Okamoto, K., Fundamentals of Optical Waveguides, San Diego, CA: Academic Press,
2006.
[20] Ōkoshi, T., Optical Fibers, New York: Academic Press, 1982.
[21] Olyslager, F., Electromagnetic Waveguides and Transmission Lines, Oxford, U.K.: Oxford
University Press, 1999.
[22] Poh, S. Y., W. C. Chew, and J. A. Kong, “Approximate Formulas for Line Capacitance
and Characteristic Impedance of Microstrip Line,” IEEE Trans. on Microwave Theory
and Techniques, Vol. 29, No. 2, 1981, pp. 135–142.
[23] Selvaraja, S. K., and P. Sethi, “Review on Optical Waveguides,” Emerging Waveguide
Technology, Vol. 95, 2018.
[24] Pozar, D. M., Microwave Engineering, Hoboken, NJ: John Wiley & Sons, 2011.
[25] Oldham, K. T. S., The Doctrine of Description: Gustav Kirchhoff, Classical Physics, and
the “Purpose of all Science” 19th-Century Germany, Berkeley, CA: University of California,
2008.
[26] Alexander, C. K., and M. N. O. Sadiku, Fundamentals of Electric Circuits, New York:
McGraw-Hill Higher Education, 2007.
This chapter describes how functions can be made discrete and how differential
equations can be solved using the finite-difference method. Estimating derivatives
of discrete functions using finite differences is introduced, and boundary condi-
tions for calculating the derivatives at the boundaries of the discrete functions are
described. With this background, the concept of derivative matrices is introduced
that will allow differential equations to be written as matrix equations almost effort-
lessly. The chapter ends by discussing how to solve differential equations using the
finite-difference method and how to handle multivariable systems.
3.1 Introduction
71
df ( 2) f (3) − f (1)
≅ (3.1)
dx 2Δx
Equation (3.1) is a finite-difference approximation of the first-order derivative
at n = 2. The solid black lines in Figure 3.2 show the exact slope calculated from
the analytical function and the estimated slope calculated from the finite-difference
estimation. In practice, the exact slope is rarely ever known because the analytical
function is rarely ever known. The exact slope is only shown here for illustration
purposes. It is clear that the estimated slope is not perfectly equal to the exact
slope. The angle between the slopes represents the numerical error introduced by
f ( x ) = a0 + a1x + a2 x2 + ! + aN xN (3.2)
f = Xa (3.4)
where
⎡ f1 ⎤
⎢ ⎥
⎢ f2 ⎥
f = ⎢ f3 ⎥ (3.5)
⎢ ⎥
⎢ ! ⎥
⎢ fN +1 ⎥
⎣ ⎦
⎡ 1 x1 x12 ! x1N ⎤
⎢ ⎥
⎢ 1 x2 x22 ! x2N ⎥
X = ⎢ 1 x3 x32 ! x3N ⎥ (3.6)
⎢ ⎥
⎢ ! ! ! " ⎥
⎢ 2 N ⎥
⎢⎣ 1 xN +1 xN +1 xN +1 ⎥
⎦
⎡ a0 ⎤
⎢ ⎥
⎢ a1 ⎥
a= ⎢ a2 ⎥ (3.7)
⎢ ⎥
⎢ ! ⎥
⎢ aN ⎥
⎣ ⎦
To write simpler equations, the function f(x) evaluated at the discrete position
xm will be written as fm. Numerical values for the discrete function values fm placed
into the column vector f are not known and remain symbolic when deriving expres-
sions for finite-difference approximations. The matrix X in (3.6) has the form of a
Vandermonde matrix [2, 3] and contains the positions of the discrete points raised
to different powers along its columns. The polynomial coefficients to be calculated
are stored in the column vector a. They are found by solving (3.4) for a and extract-
ing them from the column vector.
a = X −1f (3.8)
After the polynomial coefficients are calculated, (3.2) can be directly used
to interpolate the function at any position x. Expressions to estimate any of the
f ( x ) = a0 + a1x + a2 x2 + ! + aN xN
f ′ ( x ) = a1 + 2a2 x + ! + NaN xN −1 (3.9)
f ′′ ( x ) = 2a2 + 6a3x + ! + N ( N − 1) aN xN −2
!
After close inspection of (3.9), the equations will simplify considerably if the
function or its derivatives are evaluated at x = 0. Setting x = 0 reduces the expres-
sions in (3.9) to
f (0) = a0
f ′ (0) = a1
f ′′ (0) = 2a2 (3.10)
!
f (n)
(0) = ( n!) an
Equation (3.10) implies that to derive an expression for the nth derivative, at
least n + 1 points are needed so that the polynomial coefficients a 0 to an can be
calculated. A finite-difference approximation derived from n + 1 points is said to
be nth-order accurate because it is calculated from an nth-order polynomial.
The above discussion implies a simple procedure to derive expressions for finite-
difference approximations. Step 1 identifies N + 1 coordinates from which to esti-
mate the function or one of its derivatives. The position xfd where the function or
one of its derivatives is to be estimated is subtracted from the list of coordinates.
This is done so that (3.9) can be evaluated at x = 0. Putting the shifted coordinates
into the column vector x gives
⎡ x1 − xfd ⎤
⎢ ⎥
⎢ x2 − xfd ⎥
Step 1 x = ⎢ x3 − xfd ⎥ (3.11)
⎢ ⎥
⎢ ! ⎥
⎢ xN +1 − xfd ⎥
⎣ ⎦
Step 2 builds the matrix X in (3.6) using the shifted coordinates stored in the
column vector x. A useful way to express X is given in (3.12). Observe that the first
column in X contains all 1’s, or x0. The second column in X is x1, the third column
in X is x 2 , and so on. This suggests an easy way to build the matrix X in MATLAB
by inserting x raised to different powers into the columns of X.
⎡ 1 ⎤
⎢ 1 ⎥
⎢ ⎥
Step 2 X = ⎢ x x2 ! x N ⎥ (3.12)
⎢ ! ⎥
⎢ 1 ⎥
⎣ ⎦
Step 3 inverts the matrix X to obtain the matrix Y. It will be shown that the
coefficients of the finite-difference approximations are contained along the rows
of Y, but still need to be multiplied by the constant n!, where n is the row number
containing the finite-difference coefficients.
Step 3 Y = X −1 (3.13)
The terms multiplying the discrete function values in (3.15) are called the finite-
difference coefficients. Information from the position of the points and the position
where the expression is estimating the derivative is encoded into these terms. With
practice, the procedure can stop at Step 3 and the finite-difference coefficients can
be taken directly from the rows of Y. Be careful to multiply the row in Y by the
correct constant if a second derivative or higher is being derived.
⎡ −Δx ⎤
Step 1 x = ⎢ 0 ⎥ (3.16)
⎢ +Δx ⎥
⎣ ⎦
⎡ 1 −Δx Δx2 ⎤
Step 2 X = ⎢1 0 0 ⎥ (3.17)
⎢ 2
⎥
⎢⎣ 1 +Δx Δx ⎥⎦
⎡ ⎤
⎢ 0 1 0 ⎥
⎢ ⎥
1 1 ⎥
Step 3 Y = ⎢ − 0 (3.18)
⎢ 2Δx 2Δx ⎥
⎢ 1 1 1 ⎥
⎢ 2 − 2 ⎥
⎢⎣ 2Δx Δx 2Δx2 ⎦⎥
Step 4 a0 = 0f1 + 1f2 + 0f3 (3.19)
1 1
a1 = − f1 + 0f2 + f3
2Δx 2Δx
1 1 1
a2 = f1 − 2 f2 + f3
2Δx2 Δx 2Δx2
Step 5a f2 ≈ f2 (3.20)
df2 f − f1
Step 5b ≈ 3 (3.21)
dx 2Δx
d 2 f2 f3 − 2f2 + f1
Step 5c 2 ≈ (3.22)
dx Δx2
Equation (3.20) gives an expression to interpolate the function value at n = 2
from the function values at n = 1 to n = 3. Since the function value at n = 2 is one
of the known function values, the interpolation expression is just f 2 . This obvious
answer is a great check to verify the calculations were performed correctly. Equa-
tion (3.21) estimates the first derivative at n = 2. It should be recognized that this
is the same as that in (3.1) which was derived by slope. Last, (3.22) estimates the
second derivative at n = 2. In this case, information from all three function values
were needed in order to assess the curvature of the function quantified by the sec-
ond derivative.
What if the same derivation is to be performed, but it is desired to get an expres-
sion for the function and its derivatives at n = 1 from the function values from n =
1 to n = 3? This derivation gives
⎡ 0 ⎤
Step 1 x = ⎢ Δx ⎥ (3.23)
⎢ 2Δx ⎥
⎣ ⎦
⎡1 0 0 ⎤
Step 2 X = ⎢ 1 Δx Δx2 ⎥⎥
⎢ (3.24)
2
⎢⎣ 1 2Δx 4Δx ⎦⎥
⎡ ⎤
⎢ 1 0 0 ⎥
⎢ ⎥
⎢ 3 2 1 ⎥
Step 3 Y = − − (3.25)
⎢ 2Δx Δx 2Δx ⎥
⎢ 1 1 1 ⎥
⎢ 2 − 2 ⎥
⎢⎣ 2Δx Δx 2Δx2 ⎥⎦
f1 ≈ f1
Step 5a (3.27)
d 2 f1 f3 − 2f2 + f1
2 ≈
Step 5c dx Δx2 (3.29)
Observe that the interpolation in (3.27) is correct. Observe that the first deriva-
tive in (3.28) now contains three terms instead of two due to estimating the deriva-
tive at the first point instead of the second. Last, observe (3.29) is the same as (3.22)
despite the derivative being estimated at a different point. This happens because
there is no other way to estimate a second derivative from only three points.
df1.5 f − f1
≈ 2 (3.30)
dx Δx
⎡ Δx ⎤
⎢ − 2 ⎥
Step 1 x = ⎢ ⎥ (3.31)
⎢ + Δx ⎥
⎢⎣ 2 ⎥⎦
⎡ Δx ⎤
⎢1 − 2 ⎥
Step 2 X = ⎢ ⎥ (3.32)
⎢ 1 + Δx ⎥
⎢⎣ 2 ⎥⎦
⎡ 1 1 ⎤
⎢ 2 2 ⎥
Step 3 Y = ⎢ ⎥ (3.33)
⎢ − 1 + 1 ⎥
⎢⎣ Δx Δx ⎥⎦
1 1
Step 4 a0 = f1 + f2 (3.34)
2 2
1 1
a1 = − f1 + f
Δx Δx 2
f2 + f1
Step 5a f1.5 ≈ (3.35)
2
df1.5 f − f1
Step 5b ≈ 2 (3.36)
dx Δx
⎡ 3Δx ⎤
⎢ − ⎥
2
⎢ ⎥
⎢ Δx ⎥
−
Step 1 x = ⎢ 2 ⎥ (3.37)
⎢ Δx ⎥
⎢ + ⎥
2
⎢ 3Δx ⎥
⎢ + ⎥
⎢⎣ 2 ⎥⎦
⎡ 1 9 9 1 ⎤
⎢ − 16 16 16
−
16 ⎥
⎢ ⎥
⎢ 1 9 9 1 ⎥
− + −
⎢ 24Δx ⎥ (3.39)
Step 3 Y = ⎢ 24Δx 8Δx 8Δx
⎥
1 1 1 1
⎢ 2 − 2 − 2 2 ⎥
⎢ 4Δx 4Δx 4Δx 4Δx ⎥
⎢ − 1 1
−
1 1 ⎥
⎢⎣ 6Δx3 2Δx3 2Δx 3
6Δx3 ⎥⎦
1 9 9 1
Step 4 a0 = − f1 + f2 + f3 − f
16 16 16 16 4
1 27 27 1
a1 = f − f + f − f
24Δx 1 24Δx 2 24Δx 3 24Δx 4
1 1 1 1 (3.40)
a2 = f − f − f + f
4Δx2 1 4Δx2 2 4Δx2 3 4Δx2 4
1 3 3 1
a3 = − f + f − f + f
6Δx3 1 6Δx3 2 6Δx3 3 6Δx3 4
d 2 f2.5 f4 − f3 − f2 + f1
Step 5c 2 ≈ (3.43)
dx 2Δx2
for n = 1 : 14
fder(n) = (f(n+1) − f(n−1))/(2*dx);
end
If you were following the previous section closely enough, perhaps you caught a seri-
ous problem that will arise at the first and last points that will cause the numerical
differentiation to fail. The finite-difference approximations at the end points of the
discrete function required function values f(0) and f(15). These do not exist and so
they cannot be used in any finite-difference approximations. However, something
must still be done to calculate the derivatives at the two end points. The manner
in which the end points are handled is called a numerical boundary condition [1].
Great care must be taken when choosing the numerical boundary condition to ensure
that it is consistent with the physics of what is being analyzed or simulated. There
are many options for boundary conditions, but the two most common for FDFD
are the Dirichlet and the periodic boundary conditions (PBCs) described below.
last point n = N. The points at the boundaries of the grid get their own special and
unique finite-difference approximations. They are very lucky points!
⎧ f ( 2) − 0
⎪ n=1
⎪ 2Δx
df ( n) ⎪ f ( n + 1) − f ( n − 1)
≈⎨ 2 ≤ n ≤ N −1 (3.45)
dx ⎪ 2Δx
⎪ 0 − f ( N − 1)
⎪ n=N
⎩ 2Δx
f ′ = D xf (3.47)
The manner in which the derivative matrix Dx is constructed for the example
depicted in Figure 3.3 is shown in Figure 3.4. The column vector f′ on the left side
of the matrix equation is populated with the finite-difference expressions that need
to be calculated. In this case, Dirichlet boundary conditions were used. The column
vector f on the far-right side of the matrix equation is populated with the discrete
function values at each point on the grid. The large square matrix Dx is populated
last with values so that the matrix multiplication on the right side gives the column
vector on the left side. When determining the elements of the derivative matrix,
it is a common practice to first write the matrix equation with a blank derivative
matrix and second to populate the derivative matrix.
It turns out that Dx is a banded matrix containing numerical values along only
two of its diagonals. This makes constructing the derivative matrix very easy, espe-
cially in MATLAB that has built-in functions for inserting diagonals into matrices.
Also, observe that most of the elements in the 14 × 14 derivative matrix are zero.
Matrices typically encountered in the finite-difference method are of size 10k ×
10k and larger. Tremendous memory savings can be achieved by storing derivative
matrices as sparse matrices. Always construct and store derivative matrices as sparse
matrices! Do not worry, MATLAB makes working with sparse matrices very easy.
From Figure 3.4, the derivative matrix with Dirichlet boundary conditions can
be extracted from the matrix equation and written more generically as
⎡ +1 ⎤
⎢ −1 +1 ⎥
1 ⎢ −1 ! ⎥
Dx = ⎢ ⎥ Dirichlet boundary conditions (3.48)
2Δx ! +1
⎢ ⎥
⎢ −1 +1 ⎥
⎣ −1 ⎦
Figure 3.4 Construction of the derivative matrix using Dirichlet boundary conditions.
This derivative matrix Dx has a very convenient form due to being composed
of just two uniform diagonals and a constant 1/2Δx on the outside. This makes it
very easy to construct as a sparse matrix in MATLAB using the following code.
Z = sparse(N,N);
DX = spdiags(−ones(N−1,1),−1,Z);
DX = spdiags(+ones(N,1),+1,DX);
DX = DX/(2*dx);
This convenient form was possible due to uniform spacing between points. It is
possible to have nonuniform spacing in FDFD, but the derivative matrices are more
complicated to build. For a uniform grid, building the derivative matrix begins by
declaring the matrix Z to be a sparse N×N matrix filled with all zeros. The function
spdiags() inserts and extracts diagonals in sparse matrices, but is only being used
to insert diagonals here. It is given three input arguments. The first input argument
is a one-dimensional array of numbers to insert along the diagonal. The second
input argument is the diagonal number to insert numbers into, where 0 indicates
the center diagonal, positive integers identify diagonals above the center diagonal,
and negative integers identify diagonals below the center diagonal. The third input
argument is the matrix to insert the diagonal into. The first call to spdiags() inserts
the −1 diagonal into the zeros matrix Z. The second call to spdiags() inserts the
+1 diagonal into the DX matrix instead of the Z matrix so that the first diagonal is
retained. The last line of code divides all of the elements by 2*dx.
This example can be repeated to demonstrate incorporating PBCs. This is illus-
trated in Figure 3.5. In this case, additional terms are added to the upper-rightmost
element in the matrix and lower-leftmost element because the PBCs required them
at the first and last points of the discrete function.
From Figure 3.5, the derivative matrix with PBCs can be extracted from the
matrix equation and written more generically as
⎡ +1 −1 ⎤
⎢ ⎥
⎢ −1 +1 ⎥
1 ⎢ −1 ! ⎥
Dx = ⎢ ⎥ Periodic boundary conditions (3.49)
2Δx ! +1
⎢ ⎥
⎢ −1 +1 ⎥
⎢⎣ +1 −1 ⎥⎦
The MATLAB code to build this matrix is similar to the case for Dirichlet
boundary conditions, but two additional numbers must be inserted into the matrix
to incorporate the PBCs.
Z = sparse(N,N);
DX = spdiags(−ones(N−1,1),−1,Z);
DX = spdiags(+ones(N,1),+1,DX);
DX(1,N) = −1;
DX(N,1) = +1;
DX = DX/(2*dx);
df ( x )
+ c ( x) f ( x) = b ( x) (3.50)
dx
Given the differential equation, it is converted term-by-term into a matrix equa-
tion as shown in Figure 3.6. The derivative operation d/dx is written as a derivate
matrix Dx. The unknown function f(x) is written as a column vector f, the point-
by-point multiplication with c(x) is written as a square matrix C, and the excita-
tion function b(x) is written as a column vector b. Note that bold uppercase letters
represent matrices and bold lowercase letters represent column vectors.
The final matrix equation expands to (3.51). Observe that the point-by-point
multiplication matrix C is a diagonal matrix with the discrete values of c(n) placed
along the center diagonal. All other elements in the C matrix are zero. With practice,
converting differential equations to matrix equations becomes nearly effortless.
Before the matrix differential equation can be solved, it must be cast into the stan-
dard form of Af = b. From Figure 3.6, the matrix differential equation is
D xf + Cf = b (3.52)
To put this in a standard form, the column vector f is factored out on the left-hand
side of the matrix equation.
( Dx + C ) f = b (3.53)
Af = b (3.54)
A = Dx + C (3.55)
Equation (3.54) is easily solved either by direct LU decomposition [1] or via an
iterative technique [6, 7]. MATLAB makes obtaining a solution by either method
very easy. The solution f is written symbolically as
f = A −1b (3.56)
The MATLAB code that solves (3.57) numerically can be downloaded at https://
empossible.net/fdfdbook/. The file is named Chapter3_fdm1d.m. The first line simply
displays this file name as a comment. Lines 3 to 6 initialize MATLAB as described
in Chapter 1. Lines 8 to 13 define and calculate the grid for the numerical solution.
The variables a and b define the bounds for the solution, Nx is the number of dis-
crete points, xa is an array containing the positions of the discrete points along the
x-axis, and dx is the spacing between the points. Lines 15 to 19 build the deriva-
tive matrix DX that implements the finite-difference approximation summarized in
(3.59). Observe that the finite-difference equation at the last point n = N is modi-
fied to calculate the derivative from the two adjacent last points separated by Δx.
⎧ f ( n + 1) − f ( n − 1)
df ⎪⎪ n<N
≅ ⎨ 2Δx (3.59)
dx ⎪ f ( N ) − f ( N − 1)
n= N
⎪⎩ Δx
Line 16 creates a one-dimensional array d containing all values of 1/2Δx that
will be used to insert into the diagonals of the derivative matrix. Line 17 inserts −d
along the −1 diagonal and line 18 inserts +d along the +1 diagonal. Line 19 over-
writes the last row in DX with the finite-difference approximation to be used only at
n = N. At the same time, this line places −1/dx at DX(Nx,Nx−1) and places +1/dx at
DX(Nx,Nx). Lines 21 to 23 build the matrix equation to be solved without the initial
value f(0) = 1 incorporated yet. The standard form of the matrix equation from (3.57)
is Af = b where A = Dx and b is a column vector with all elements equal to −1/3.
Lines 25 to 28 incorporate the boundary value f(0) = 1 into the matrix equation.
Line 26 sets the first row in A to all zeros to completely erase the finite-difference
equation associated with the first point on the grid. Line 27 sets the diagonal ele-
ment in the first row to 1. The value that f(1) is set equal to is inserted into the first
element of b on line 28 to make the first discrete equation in the matrix equation
f(1) = 1 instead of a finite-difference equation. Line 31 solves for the column vector
f using backward division in MATLAB. Lines 33 to 35 plot the numerical solution
which is shown in Figure 3.7. This matches exactly the analytical solution derived
Figure 3.7 Plot of finite-difference method solution to df/dx = −1/3 given f(0) = 1.
in (3.58) and demonstrates how simple the MATLAB code can be for implementing
the finite-difference method.
Suppose it is desired to solve the following system of two coupled differential equa-
tions of two unknowns f(x) and g(x) using the finite-difference method.
df ( x )
+ u ( x ) g ( x ) = b1 ( x ) (3.60)
dx
dg ( x )
+ v ( x ) f ( x ) = b2 ( x ) (3.61)
dx
It is entirely possible to solve this system of equations using only the concepts
taught previously. However, there is a better way to handle the finite-difference
approximations that gives greater accuracy and improves numerical efficiency.
From Figure 3.2, it was clear that more closely spaced points will more accurately
estimate a derivative. The finite-difference approximations up to now spanned 2Δ x
across the grid as illustrated in Figure 3.2. Equation (3.62) shows a way to calcu-
late a finite-difference that only spans Δ x, across the grid. This greatly improves
accuracy, but the result from this derivative is defined at the midpoint. Interpret-
ing the finite-difference approximation in (3.62) as a central finite difference, the
derivative is estimated at the location n + 1/2, which is midway between the grid
points n and n + 1.
df ( n + 1/2) f ( n + 1) − f ( n )
≈ (3.62)
dx Δx
Applying this concept to (3.60) gives a discrete differential equation of the follow-
ing form.
f ( n + 1) − f ( n ) ?
+ u ( n ) g ( n ) = b1 ( n ) (3.63)
Δx
Equation (3.63) has a serious problem that can lead to instability and inac-
curacy of the results. The terms u(n)g(n) and b1(n) give values defined at n, but
the finite-difference approximation gives a value defined at n + 1/2. All terms in a
finite-difference equation should be defined at the same point in space. One pos-
sible way to correct this is to use interpolation to calculate the second two terms in
(3.63) at the point n + 1/2.
f ( n + 1) − f ( n ) u ( n + 1) g ( n + 1) + u ( n ) g ( n ) b1 ( n + 1) + b1 ( n )
+ = (3.64)
Δx 2 2
This can be made to work, but it involves more calculations than is necessary
and there is a better way. Instead, the discrete functions f, v, and b2 are defined as
usual at points 1, 2, 3, …, N on the grid. However, the discrete functions g, u, and
b1 are defined at midpoints 1.5, 2.5, 3.5, …, N + 0.5 on the grid. Given the stag-
gering, the discrete form of the two differential equations becomes
f ( n + 1) − f ( n ) ⎛ 1⎞ ⎛ 1⎞ ⎛ 1⎞
+ u ⎜ n + ⎟ g ⎜ n + ⎟ = b1 ⎜ n + ⎟ (3.65)
Δx ⎝ 2⎠ ⎝ 2⎠ ⎝ 2⎠
(
g n+ 1
2 ) − g ( n − ) + ν ( n) f ( n) = b ( n)
1
2
(3.66)
Δx 2
These equations have the simplicity of (3.63) but provide accuracy exceeding
anything else because the finite-difference approximations only span a single Δx.
The notation of using array indices like n + 1/2 can be confusing. In this book, the
array indices will only ever be written as integers to match the array indices used in
the computer codes. The reader will have to remember which functions are stored at
the offset locations. In addition, the following notation will be adopted for discrete
functions to make the discrete equations more compact and more clearly identify
which terms are discrete.
f −f
n+1 n
+ un g = b1 n (3.67)
Δx n
g n+1 − g n
+ vn f = b2 n (3.68)
Δx n
Two discrete functions f⎪ n and g⎪ n staggered across a grid is illustrated in Figure
3.8. Even though f⎪ n and g⎪ n have the same array index n, observe that they are
located Δx/2 apart from each other.
To convert to matrix form, (3.67) is written once for every point on the grid,
and this set of N equations is written in matrix form in (3.69). Similarly, (3.68) is
written once for every point on the grid, and this second set of N equations is writ-
ten in matrix form in (3.70).
Figure 3.8 The position of two discrete functions is staggered across the grid.
Dfxf + Ug = b1 (3.69)
Dgx g + Vf = b2 (3.70)
The superscripts on the derivative matrices identify for which function they cal-
culate the derivatives. Due to the staggering of the discrete functions, the derivative
matrices for f and g are different from each other. Following the procedure outlined
previously in this chapter, the contents of the derivative matrices can be determined.
For the present example, the derivative matrices incorporating Dirichlet boundary
conditions are provided in (3.71) and (3.72).
⎡ ⎤
⎡ f 1 ⎤ ⎡ u1 ⎤⎡ g 1 ⎤ ⎢ b1 1 ⎥
⎡ −1 +1 ⎤⎢ ⎥ ⎢ ⎥⎢ ⎥
1 ⎢ −1 ! ⎥⎢ f2 ⎥ ⎢ u2 ⎥⎢ g 2 ⎥ ⎢ b1 2 ⎥
Δx ⎢ ! +1 ⎥ ⎢ ⎥+⎢ ⎥⎢ ⎥= ⎢ ⎥ (3.71)
! ⎥ ⎢ ! ! ⎥ ⎢ ! ⎥
⎢ −1 ⎥⎦ ⎢ ⎥⎢
⎣ ⎢ f N ⎥ ⎢⎣ uN ⎥⎦ ⎢ gN ⎥ ⎢ b ⎥
⎣ ⎦ ⎣ ⎦ ⎢⎣ 1 N ⎥⎦
⎡ ⎤
⎡ g1 ⎤ ⎡ v1 ⎤⎡ f 1 ⎤ ⎢ b2 1 ⎥
⎡ +1 ⎤⎢ ⎥ ⎢ ⎥⎢ ⎥
1 ⎢ −1 +1 ⎥⎢ g2 ⎥ ⎢ v2 ⎥⎢ f 2 ⎥ ⎢ b2 2 ⎥
Δx ⎢ ! ! ⎥⎢ ⎥+⎢ ⎥⎢ ⎥= ⎢ ⎥ (3.72)
⎢ ⎥⎢ ! ⎥ ⎢ !
⎥⎢ ! ⎥ ⎢ ! ⎥
−1 +1
⎣ ⎦⎢ g N ⎥ ⎢⎣ vN ⎥⎦ ⎢ fN ⎥ ⎢ b ⎥
⎣ ⎦ ⎣ ⎦ ⎢⎣ 2 N ⎥⎦
Observe the difference between the derivative matrices Dxf and Dxg. While they
look similar, the +1’s and −1’s are inserted along different diagonals. When Dirichlet
or PBCs are used, the derivative matrices can be related through
( )
H
Dgx = − Dfx (3.73)
In this equation, the superscript H indicates a Hermitian transpose, which is an
ordinary transpose followed by calculating the complex conjugate of each element
in the matrix. This relation means that after one derivative matrix is constructed,
the other can be calculated immediately from it, simplifying the computer code. It
may seem strange to use a complex conjugate when the derivative matrices contain
only real numbers. In Chapter 4, PBCs will involve complex numbers in order to
incorporate a source at an oblique angle of incidence. Be careful because the rela-
tion in (3.73) does not hold for all boundary conditions!
After arriving at (3.69) and (3.70), there are two options for solving the system
of equations. The least preferred is to combine the two matrix equations into a
single block matrix equation where it assumes the standard form.
⎡ Df U ⎤ ⎡ f ⎤ ⎡ b ⎤
⎢ x ⎥⎢ ⎥ = ⎢ 1 ⎥ (3.74)
⎢⎣ V D x ⎥⎦ ⎣ g ⎦ ⎢⎣ b2 ⎥⎦
g
This equation can then be solved using standard matrix division algorithms [1].
In this book, the preferred solution method utilizes smaller matrices so it tends to
be faster and more memory efficient. First, (3.69) is solved for g.
(
g = U−1 b1 − Dfxf ) (3.75)
Second, this expression for g is substituted into (3.70) to get a single equation in
terms of just f.
( )
Dgx U−1 b1 − Dfxf + Vf = b2
(3.76)
f = A −1b (3.77)
Dfxf + 3g = 0 (3.82)
Dgx g − 2f = 0 (3.83)
Equation (3.82) is solved for g to get
1
g = − Dfxf (3.84)
3
This expression for g is substituted into (3.83) to get
⎛ 1 ⎞
Dgx ⎜ − Dfxf ⎟ − 2f = 0 (3.85)
⎝ 3 ⎠
(D Dg
x
f
x )
+ 6I f = 0
(3.86)
This is as far as the problem can be taken on paper. The rest is handled in
MATLAB and the code to obtain and plot the solution can be downloaded at
https://empossible.net/fdfdbook/. The filename is Chapter3_mvfdm.m. Line 1 is a
comment with this name of the program. Lines 3 to 6 initialize MATLAB. The grid
for the problem is calculated on lines 8 to 13 and is the same as the single variable
example covered in Section 3.7.1. The derivative matrices for the staggered grid are
constructed on lines 15 to 22. Line 16 builds a one-dimensional array containing
1/Δx throughout the entire array. Lines 18 to 20 build the derivative matrix Dxf
that operates on the function f(x). In MATLAB, the derivative matrix is given the
variable name DFX. Line 18 initializes DFX as a sparse matrix of size Nx × Nx. Line
19 adds the center diagonal containing all −1/Δx. Line 20 adds the upper diagonal
containing all +1/Δx. After DFX is constructed correctly, the derivative matrix Dxg
is calculated immediately from it using the relation in (3.73) on line 22. The new
derivative matrix is given the variable name DGX.
Given the derivative matrices, the matrix equation in (3.86) is constructed
on lines 24 to 27. The boundary values for f(x) are incorporated into the matrix
equation on lines 29 to 36. Lines 30 to 32 replace the finite-difference equation
associated with the first point on the grid with the equation f⎪ 1 = 10. Lines 34 to
36 replace the finite-difference equation associated with the last point on the grid
with the equation f⎪ Nx = 1. The matrix equation Af = b is solved on line 39. Given
the solution for f, the solution for g is calculated immediately from f using (3.84).
This happens on line 40.
Lines 42 to 51 visualize the results. A legend is provided to distinguish the
lines. The final plot from this analysis is provided in Figure 3.9. The answer looks
like perfect sine waves. While no analytical solution is obtained using the finite-
difference method, the results give a huge hint about the answer when solving dif-
ferential equations analytically.
References
[1] Chapra, S. C., and R. P. Canale, Numerical Methods for Engineers, Seventh Edition, New
York: McGraw-Hill Education, 2015.
[2] Klinger, A., “The Vandermonde Matrix,” The American Mathematical Monthly, Vol. 74,
No. 5, 1967, pp. 571–574.
[3] Rushanan, J. J., “On the Vandermonde Matrix,” The American Mathematical Monthly,
Vol. 96, No. 10, 1989, pp. 921–924.
[4] Cheng, A. H.-D., and D. T. Cheng, “Heritage and Early History of the Boundary Element
Method,” Engineering Analysis with Boundary Elements, Vol. 29, No. 3, 2005, pp.
268–302.
[5] Harms, P., R. Mittra, and W. Ko, “Implementation of the Periodic Boundary Condition
in the Finite-Difference Time-Domain Algorithm for FSS Structures,” IEEE Trans. on
Antennas and Propagation, Vol. 42, No. 9, 1994, pp. 1317–1324.
[6] Greenbaum, A., Iterative Methods for Solving Linear Systems: SIAM, 1997.
[7] Saad, Y., Iterative Methods for Sparse Linear Systems: SIAM, 2003.
Finite-Difference Approximation of
Maxwell’s Equations
This chapter will explain how Maxwell’s equations are converted into matrix equa-
tions using the finite-difference method. The chapter will show how to prepare
Maxwell’s equations for finite-difference frequency-domain (FDFD) by normalizing
the fields and grid coordinates so they are all the same order of magnitude and as
close to the numerical value of one as possible. The analytical functions in Max-
well’s equations are made discrete according to the Yee grid scheme [1], allowing
the derivatives to be approximated with simple and accurate finite differences. After
this is done for full three-dimensional equations, the equations are reduced to two
dimensions. The equations are then expressed in matrix form in preparation for being
solved by the various FDFD methods described in following chapters. The derivative
matrices used in FDFD are discussed in detail. A MATLAB function is presented
to build the derivative matrices for the two-dimensional FDFD analyses described
in Chapters 6 to 9. A second MATLAB function is presented to build the deriva-
tive matrices for the three-dimensional FDFD analyses described in Chapter 10.
∂Ez ∂Ey
− = − jwmxx H x (4.1)
∂y ∂z
∂Ex ∂Ez
− = − jwmyy H y (4.2)
∂z ∂x
∂Ey ∂Ex
− = − jwmzz Hz (4.3)
∂x ∂y
95
∂Hz ∂H y
− = jwexx Ex (4.4)
∂y ∂z
∂H x ∂Hz
− = jweyy Ey (4.5)
∂z ∂x
∂H y ∂H x
− = jwezz Ez (4.6)
∂x ∂y
Examining (4.1), it will be best to define the positions of the discrete values of
Ey and Ez to be immediately on either side of the discrete values of Hx. This will
allow the partial derivatives to be estimated using the simplest and most accurate
central finite-difference approximations. It will also be most convenient to define
the discrete tensor element μ xx to be at the same locations as Hx. A similar argument
can be made for (4.1) to (4.6). Ex and Ez will be defined to be on either side of Hy.
E x and Ey will be defined to be on either side of Hz. Hy and Hz will be defined to be
on either side of Ex. Hx and Hz will be defined to be on either side of Ey. Last, Hx
and Hy will be defined to be on either side of Ez. Furthermore, ε yy will be defined
at the same points as Ey, ε zz will be defined at the same points as Ez, μ xx will be
defined at the same points as Hx, μ yy will be defined at the same points as Hy, and
μ zz will be defined at the same points as Hz. This will present some challenges when
devices are built onto the grid because material interfaces that slice through the
middle of Yee cells will place some field components inside of one medium and the
other field components inside of another. Later in this chapter, the 2× grid technique
will be presented as an easy way to assign materials to the Yee grid that naturally
handles the staggering.
The arrangement of field components that satisfies all of the above was first
proposed by Yee [1] and is now called the Yee grid scheme. In this scheme, a Carte-
sian space is divided into many tiny cells and the six field components are staggered
the same way within each cell. A single cell of the standard Yee grid is illustrated
in Figure 4.1. The integers i, j, and k represent the array indices to access the fields
stored in memory. Even though the six field components have the same array indi-
ces, they are at physically different locations within the cell. This will have impor-
tant implications in how materials will be assigned to the grid, how sources will be
injected, and how the fields will be postprocessed after the simulation is over. While
Ex, Ey, and Ez are components of a single vector quantity, they will be out of phase
because they are at different locations within the Yee cell. If the vector components
ever need to be combined, they must be interpolated at a common point within
the Yee cell before combining them. The origin of the Yee cell will be used in this
book as the common point. Even more, a material interface that slices through the
middle of the Yee cell may place the different field components within the same
cell in different mediums, making the arrays storing the constitutive parameters
different for each field component.
In addition to being the most efficient arrangement for finite-difference approxi-
mations, the Yee grid scheme offers additional benefits. These include the grid
being divergence-free and physical boundary conditions being naturally satisfied
[2]. By simply staggering the positions of the field components according to the
Yee grid scheme, Maxwell’s divergence equations are satisfied so they do not need
to be explicitly handled by the FDFD method. In addition, no special treatment at
the interface between two materials is needed in order to obtain an accurate and
stable simulation.
From Chapter 2, the final form of Maxwell’s equations for isotropic media was
!
∇ i eE = 0 ( )
(4.7)
!
∇ i mH = 0( )
(4.8)
! !
∇ × E = − jwm H (4.9)
! !
∇ × H = jweE (4.10)
( )
"
∇ i mr H! = 0 (4.13)
! "
∇ × E = k0 mr H! (4.14)
" !
∇ × H! =kε E (4.15)
0 r
Equation (4.7) was divided by the free space permittivity ε 0 to arrive at (4.12),
and (4.8) was divided by the free space permeability μ 0 to arrive at (4.13). With this
normalization applied to Maxwell’s equations, there is no need to remember which
of the curl equations
" has the negative sign! The curl equations with normalized
magnetic field H! expand into the following set of six coupled partial differential
equations when diagonally anisotropic media is assumed.
∂Ez ∂Ey
− = k0 mxx H! x (4.16)
∂y ∂z
∂Ex ∂Ez
− = k0 myy H! y (4.17)
∂z ∂x
∂Ey ∂Ex
− = k0 mzz H! z (4.18)
∂x ∂y
∂H! z ∂H! y
− = k0 exx Ex (4.19)
∂y ∂z
∂H! x ∂H! z
− = k0 eyy Ey (4.20)
∂z ∂x
∂H! y ∂H! x
− = k0 ezz Ez (4.21)
∂x ∂y
This will be the final form of the analytical equations for the FDFD method
when the frequency is not known until the simulation calculates it. When the fre-
quency is not known at the start of the simulation, the free space wavenumber k0
must be retained as a variable to be calculated by the FDFD algorithm. This situa-
tion occurs in photonic band calculations and will be covered in Chapter 7. In other
cases, the frequency is known at the start of the simulation and a numerical value
can be assigned to k0. In this case, it is best to normalize the spatial coordinates x,
y, and z by dividing them by the free space wavelength λ 0. Since k0 = 2π ∕ λ 0, the grid
x′ = k0 x y′ = k0 y z′ = k0z (4.22)
∂Ez ∂Ey
− = mxx H! x (4.23)
∂ y′ ∂z ′
∂Ex ∂Ez
− = myy H! y (4.24)
∂z ′ ∂ x′
∂Ey ∂Ex
− = mzz H! z (4.25)
∂ x′ ∂ y′
∂H! z ∂H! y
− = exx Ex (4.26)
∂ y′ ∂z ′
∂H! x ∂H! z
− = eyy Ey (4.27)
∂z ′ ∂ x′
∂H! y ∂H! x
− = ezz Ez (4.28)
∂ x′ ∂ y′
Given the Yee grid scheme, (4.16) to (4.21) can be written in discrete form by esti-
mating the partial derivatives with central finite differences. To demonstrate, start
with (4.21) where the two partial derivatives to estimate with finite differences are
∂H! y / ∂x and ∂H! x / ∂y. The manner in which this equation is made discrete is illus-
trated in Figure 4.2. All of the discrete terms will be defined at the same location
as Ez⎪ i,j,k in the Yee grid. The relative permittivity term ε zz⎪ i,j,k should be defined at
the same point as Ez⎪ i,j,k. For this reason, the discrete representation of the term on
the right side of (4.28) is written as k0ε zz⎪ i,j,k Ez⎪ i,j,k.
The first partial derivative in (4.21) is ∂H! y / ∂x and its finite-difference approxi-
mation is illustrated in Figure 4.2(a). To ensure the central finite-difference esti-
mates, the derivative at the same location as Ez⎪ i,j,k, magnetic field terms that lie
symmetrically on either side of Ez⎪ i,j,k should be used. These terms are the magnetic
field term H! y from the same cell as Ez⎪ i,j,k and the magnetic field term H! y
i,j,k i−1,j,k
from the previous cell in the x-direction. The finite-difference approximation for
∂H! y / ∂x is therefore
∂H! y H! y − H! y
i,j,k i−1,j,k
≈ (4.29)
∂x Δx
Figure 4.2 (a) Illustration of the finite-difference approximation of ∂H! y / ∂x . (b) Illustration of
the finite-difference approximation of ∂H! x / ∂ y .
The second partial derivative in (4.21) is ∂H! x / ∂y and its finite-difference approx-
imation is illustrated in Figure 4.2(b). The magnetic field terms that lie symmetrically
on either side of Ez⎪ i,j,k are H! x and H! x i,j–1,k.. The finite-difference approximation
i,j,k i−1,j,k
!
for ∂H x / ∂ y′ is therefore
∂H! x H! x − H! x
i,j,k i,j−1,k
≈ (4.30)
∂y Δy
All finite-difference approximations of derivatives of magnetic field terms will
reach to a previous cell for the second magnetic field term. When applying this same
reasoning to finite-difference approximations of derivatives of electric field terms,
however, the finite-difference approximations will reach to a next cell in the posi-
tive direction along the axes. This difference is due to the staggered layout of the
field components on the Yee grid. Applying these steps to all of (4.16) to (4.21), the
discrete equations are
Ez − Ez Ey − Ey
= k0 mxx i,j,k H! x
i,j+1,k i,j,k i,j,k+1 i,j,k
− (4.31)
Δy Δz i,j,k
Ex i,j,k+1 − Ex i,j,k Ez − Ez
= k0 myy H! y
i+1,j,k i,j,k
− (4.32)
Δz Δx i,j,k i,j,k
Ey − Ey Ex i,j+1,k − Ex i,j,k
= k0 mzz H! z
i+1,j,k i,j,k
− (4.33)
Δx Δy i,j,k i,j,k
H! z − H! z H! y − H! y
= k0 exx i,j,k Ex i,j,k
i,j,k i,j−1,k i,j,k i,j,k−1
− (4.34)
Δy Δz
H! x − H! x H! z − H! z
= k0 eyy
i,j,k i,j,k−1 i,j,k i−1,j,k
− Ey (4.35)
Δz Δx i,j,k i,j,k
H! y − H! y H! x − H! x
= k0 ezz
i,j,k i−1,j,k i,j,k i,j−1,k
− Ez (4.36)
Δx Δy i,j,k i,j,k
A strict rule for finite-difference equations is that every term in the equation
must be defined at the same point in space. The Yee grid is staggered in a way that
ensures this condition is met for all field components. Recall that for the relative
permeability terms, μ xx⎪ i,j,k is defined at the same points as H! x , μ yy⎪ i,j,k is
i,j,k
defined at the same points as H y ! , and μ zz⎪ i,j,k is defined at the same points as
i,j,k
H! . Similarly for the relative permittivity terms, ε xx⎪ i,j,k is defined at the same
z i,j,k
points as E x⎪ i,j,k, ε yy⎪ i,j,k is defined at the same points as Ey⎪ i,j,k, and ε zz⎪ i,j,k must be
defined at the same points as Ez⎪ i,j,k.
Focus for a moment on just (4.31). This equation is written once for every cell on
the grid, leading to a large set of finite-difference equations. The set of equations can
In these equations, the terms have the same definitions as they did for (4.37) to
(4.42). The only difference is that the free space wavenumber k0 has been absorbed
into the derivative matrices through the normalized grid coordinates defined in
(4.22).
In Chapter 2, it was shown that it is possible to reduce the math of some three-
dimensional problems to two dimensions when: (1) the device is uniform along z,
(2) wave propagation is restricted to the xy plane, and (3) materials are isotropic or
diagonally anisotropic. When these conditions are met, all derivatives with respect
to z are zero and (4.31) to (4.36) reduce to
Ez − Ez
= k0 mxx i,j H! x
i,j+1 i,j
(4.49)
Δy i,j
Ez − Ez
= k0 myy H! y
i+1,j i,j
− (4.50)
Δx i,j i,j
Ey − Ey Ex i,j+1 − Ex i,j
= k0 mzz H! z
i+1,j i,j
− (4.51)
Δx Δy i,j i,j
H! z − H! z
= k0 exx i,j Ex i,j
i,j i,j−1
(4.52)
Δy
H! z − H! z
= k0 eyy
i,j i−1,j
− Ey (4.53)
Δx i,j i,j
H! y − H! y H! x − H! x
= k0 ezz
i,j i−1,j i,j i,j−1
− Ez (4.54)
Δx Δy i,j i,j
Observe the k array index was dropped because there is no longer a z dimension to
be considered in the analysis. This is fortunate because the same symbol k is being
used for the wavenumber!
When the frequency is known at the start of the simulation, the k0 term will
have a numerical value and is absorbed into the grid coordinates to normalize them
according to (4.22). When this is done, (4.49) to (4.54) become
Ez − Ez
= mxx i,j H! x
i,j+1 i,j
(4.55)
Δ y′ i,j
Ez − Ez
= myy H! y
i+1,j i,j
− (4.56)
Δ x′ i,j i,j
Ey − Ey Ex i,j+1 − Ex i,j
= mzz H! z
i+1,j i,j
− (4.57)
Δ x′ Δ y′ i,j i,j
H! z − H! z
= exx i,j Ex i,j
i,j i,j−1
(4.58)
Δ y′
H! z − H! z
= eyy
i,j i−1,j
− Ey (4.59)
Δ x′ i,j i,j
H! y − H! y H! x − H! x
= ezz
i,j i−1,j i,j i,j−1
− Ez (4.60)
Δ x′ Δ y′ i,j i,j
As was observed in Chapter 2, both sets of discrete equations have decoupled
into two independent sets of three equations. Equations (4.49), (4.50), and (4.54)
describe the E mode (TM polarization) when frequency is not known and (4.55),
(4.56), and (4.60) describe the E mode when frequency is known. Equations (4.51)
to (4.53) describe the H mode (TE polarization) when frequency is not known and
(4.57) to (4.59) describe the H mode when frequency is known.
After inspecting these two groups of equations, it can be seen that one of the
modes by itself does not utilize all of the field components within a three-dimen-
sional Yee cell. For two-dimensional simulations, the three-dimensional Yee cell has
separated into two two-dimensional Yee cells, one for each distinct mode. This is
illustrated in Figure 4.3 where the Yee cell for the E mode is extracted from the top
half of the three-dimensional Yee cell and the Yee cell for the H mode is extracted
from the bottom half.
Figure 4.3 Extracting both two-dimensional Yee cells from the three-dimensional Yee cell.
Ez − Ez
= k0 mxx i,j H! x
i,j+1 i,j
(4.61)
Δy i,j
Ez − Ez
= k0 myy H! y
i+1,j i,j
− (4.62)
Δx i,j i,j
H! y − H! y H! x − H! x
= k0 ezz
i,j i−1,j i,j i,j−1
− Ez (4.63)
Δx Δy i,j i,j
Each of (4.61) to (4.63) is written once for every point on the grid, and each set
of equations can be written as its own matrix equation. These are
H! z − H! z
= k0 exx i,j Ex i,j
i,j i,j−1
(4.67)
Δy
H! z − H! z
= k0 eyy
i,j i−1,j
− Ey (4.68)
Δx i,j i,j
Ey − Ey Ex i,j+1 − Ex i,j
= k0 mzz H! z
i+1,j i,j
− (4.69)
Δx Δy i,j i,j
Each of (4.67) to (4.69) is written once for every cell on the grid and each set of
equations can be written as its own matrix equation. These are
Ez − Ez
= mxx i,j H! x
i,j+1 i,j
(4.73)
Δ y′ i,j
Ez − Ez
= myy H! y
i+1,j i,j
− (4.74)
Δ x′ i,j i,j
H! y − H! y H! x − H! x
= ezz
i,j i−1,j i,j i,j−1
− Ez (4.75)
Δ x′ Δ y′ i,j i,j
Each of the above equations is written once for every cell on the grid and each
set of equations can be written as its own matrix equation. These are
Deyʹez = µ xx h! x (4.76)
−Dexʹez = µ yy h! y (4.77)
Dhxʹh! y − Dhyʹh! x = εzz ez (4.78)
H! z − H! z
= exx i,j Ex i,j
i,j i,j−1
(4.79)
Δ y′
H! z − H! z
= eyy
i,j i−1,j
− Ey (4.80)
Δ x′ i,j i,j
Ey − Ey Ex i,j+1 − Ex i,j
= mzz H! z
i+1,j i,j
− (4.81)
Δ x′ Δ y′ i,j i,j
Each of the above equations is written once for every cell on the grid and each
set of equations can be written as its own matrix equation. These are
It is now necessary to use what was discussed in Chapter 3 to build the derivative
matrices for two-dimensional finite-difference analysis on the Yee grid. This will
be accomplished by writing all four derivative matrices for a small 3 × 3 grid and
identifying the patterns that will construct the derivative matrices for larger grids
fast and simple. The grids for both the E mode and H mode are shown in Figure 4.4.
⎡ ⎤ ⎡ ⎤
⎢ Ez
1,1 ⎥ ⎢ Ez 2,1 − Ez 1,1 ⎥
⎢ ⎥ ⎢ ⎥
⎢ Ez
2,1 ⎥ ⎢ Ez 3,1 − Ez 2,1 ⎥
⎡ −1 1 0 0 0 0 0 0 0 ⎤⎢ ⎥ ⎢ ⎥
⎢ 0 −1 1 0 0 0 0 0 0 ⎥⎢ Ez
3,1 ⎥ ⎢ 0 − Ez 3,1 ⎥
⎢ 0 0 −1 0 0 0 0 0 0 ⎥⎢ ⎥ ⎢ ⎥
⎢ ⎥⎢ Ez ⎥ ⎢ Ez 2,2 − Ez 1,2 ⎥
1 ⎢ 0 0 0 −1 1 0 0 0 0 ⎥⎢
1,2
⎥ 1 ⎢ ⎥
Δx ⎢
0 0 0 0 −1 1 0 0 0 ⎥⎢ Ez
2,2
⎥ = Δx ⎢ Ez 3,2 − Ez 2,2 ⎥ (4.85)
⎢ 0 0 0 0 0 −1 0 0 0 ⎥⎢ ⎥ ⎢ ⎥
⎢ 0 0 0 0 0 0 −1 1 0 ⎥⎢ Ez
3,2
⎥ ⎢ 0 − Ez 3,2 ⎥
⎢ 0 0 0 0 0 0 0 −1 1 ⎥⎢ ⎥ ⎢ ⎥
⎢ 0 0 0 0 0 0 0 0 −1 ⎥⎢ Ez ⎥ ⎢ Ez 2,3 − Ez 1,3 ⎥
⎣ ⎦⎢ 1,3
⎥ ⎢ ⎥
⎢ Ez ⎥ ⎢ Ez − Ez ⎥
⎢ 2,3
⎥ ⎢ 3,3 2,3
⎥
⎢ Ez ⎥ ⎢ 0 − Ez ⎥
⎣ 3,3 ⎦ ⎣ 3,3 ⎦
Observe the order that the electric field components are listed in (4.85). It is
important to always list the field components in this same order every time. It is
convention to list the fields along the x-direction first and the y-direction second.
From (4.85), the derivative matrix Dxe is read off as the square matrix premulti-
plying the column vector of electric field components, including the division by
Δx. Observe the form of the matrix for Dxe given in (4.86). It is composed of just
two diagonals. The center diagonal contains all −1’s and the first upper diagonal
contains mostly all +1’s but has some 0’s inserted where Dirichlet boundary con-
ditions were applied. The zeros occur every Nx rows, where Nx is the number of
cells the grid is wide.
⎡ −1 1 0 0 0 0 0 0 0 ⎤
⎢ 0 −1 1 0 0 0 0 0 0 ⎥
⎢ 0 0 −1 0 0 0 0 0 0 ⎥
⎢ 0 0 0 −1 1 0 0 0 0 ⎥
e 1 ⎢ ⎥
Dx = 0 0 0 0 −1 1 0 0 0 (4.86)
Δx ⎢ 0 0 0 0 0 −1 0 0 0
⎥
⎢ ⎥
⎢ 0 0 0 0 0 0 −1 1 0 ⎥
⎢ 0 0 0 0 0 0 0 −1 1 ⎥
⎢ 0 0 0 0 0 0 0 0 −1 ⎥
⎣ ⎦
⎡ ⎤ ⎡ ⎤
⎢ Ez
1,1 ⎥ ⎢ Ez 1,2 − Ez 1,1 ⎥
⎢ ⎥ ⎢ ⎥
⎢ Ez
2,1 ⎥ ⎢ Ez 2,2 − Ez 2,1 ⎥
⎡ −1 0 0 1 0 0 0 0 0 ⎤⎢ ⎥ ⎢ ⎥
⎢ 0 −1 0 0 1 0 0 0 0 ⎥⎢ Ez
3,1 ⎥ ⎢ Ez 3,2 − Ez 3,1 ⎥
⎢ 0 0 −1 0 0 1 0 0 0 ⎥⎢ ⎥ ⎢ ⎥
⎢ ⎥⎢ Ez ⎥ ⎢ Ez 1,3 − Ez 1,2 ⎥
1 ⎢ 0 0 0 −1 0 0 1 0 0 ⎥⎢
1,2
⎥ 1 ⎢ ⎥
Δy ⎢
0 0 0 0 −1 0 0 1 0 ⎥⎢ Ez
2,2
⎥ = Δy ⎢ Ez 2,3 − Ez 2,2 ⎥ (4.87)
⎢ 0 0 0 0 0 −1 0 0 1 ⎥⎢ ⎥ ⎢ ⎥
⎢ 0 0 0 0 0 0 −1 0 0 ⎥⎢ Ez
3,2
⎥ ⎢ Ez 3,3 − Ez 3,2 ⎥
⎢ 0 0 0 0 0 0 0 −1 0 ⎥⎢ ⎥ ⎢ ⎥
⎢ 0 0 0 0 0 0 0 0 −1 ⎥⎢ Ez ⎥ ⎢ 0 − Ez 1,3 ⎥
⎣ ⎦⎢ 1,3
⎥ ⎢ ⎥
⎢ Ez ⎥ ⎢ 0 − Ez ⎥
⎢ 2,3
⎥ ⎢ 2,3
⎥
⎢ Ez ⎥ ⎢ 0 − Ez ⎥
⎣ 3,3 ⎦ ⎣ 3,3 ⎦
From (4.87), the derivative matrix Dye is read off as the square matrix premul-
tiplying the column vector of electric field components, including the division by
Δy. Observe the form of the matrix for Dye given in (4.88). It is composed of just
two diagonals. The center diagonal contains all −1’s and the upper Nx diagonal
contains all +1’s. For Dye, the upper diagonal is not interrupted by any 0’s so it is
an easier diagonal to calculate.
⎡ −1 0 0 1 0 0 0 0 0 ⎤
⎢ 0 −1 0 0 1 0 0 0 0 ⎥
⎢ 0 0 −1 0 0 1 0 0 0 ⎥
⎢ 0 0 0 −1 0 0 1 0 0 ⎥
e 1 ⎢ ⎥
Dy = 0 0 0 0 −1 0 0 1 0 (4.88)
Δy ⎢ 0 0 0 0 0 −1 0 0 1
⎥
⎢ ⎥
⎢ 0 0 0 0 0 0 −1 0 0 ⎥
⎢ 0 0 0 0 0 0 0 −1 0 ⎥
⎢ 0 0 0 0 0 0 0 0 −1 ⎥
⎣ ⎦
From (4.89), the derivative matrix Dxh is read off as the square matrix premul-
tiplying the column vector of magnetic field components, including the division
by Δx. Observe the form of the matrix for Dxh given in (4.90). Like the derivative
matrices for the electric fields, it is composed of just two diagonals. However, for
the magnetic field the center diagonal contains all +1’s and the first lower diagonal
contains mostly all −1’s but has some 0’s inserted where Dirichlet boundary condi-
tions were applied. The zeros occur every Nx rows, where Nx is the number of cells
the grid is wide.
⎡ 1 0 0 0 0 0 0 0 0 ⎤
⎢ −1 1 0 0 0 0 0 0 0 ⎥
⎢ 0 −1 1 0 0 0 0 0 0 ⎥
⎢ 0 0 0 1 0 0 0 0 0 ⎥
h 1 ⎢ ⎥
Dx = 0 0 0 −1 1 0 0 0 0 (4.90)
Δx ⎢ 0 0 0 0 −1 1 0 0 0
⎥
⎢ ⎥
⎢ 0 0 0 0 0 0 1 0 0 ⎥
⎢ 0 0 0 0 0 0 −1 1 0 ⎥
⎢ 0 0 0 0 0 0 0 −1 1 ⎥
⎣ ⎦
⎡ ⎤ ⎡ ⎤
⎢ H! x ⎥
!
⎢ H x 1,1 − 0 ⎥
1,1
⎢ ⎥ ⎢ ⎥
⎢ H! x ⎥
!
⎢ H x 2,1 − 0 ⎥
2,1
⎡ 1 0 0 0 0 0 0 0 0 ⎤⎢ H! x
⎥ ⎢ ! ⎥
⎢ ⎥⎢ ⎥ ⎢ H x 3,1 − 0 ⎥
0 1 0 0 0 0 0 0 0 3,1
⎢ ⎥⎢ ⎥ ⎢ ⎥
⎢
0 0 1 0 0 0 0 0 0
⎥⎢ H! x ⎥ ⎢ H! x 1,2 − H! x 1,1 ⎥
1 ⎢ −1 0 0 1 0 0 0 0 0 ⎥⎢
1,2
⎥ 1 ⎢ ! ⎥
0 −1 0 0 1 0 0 0 0 ⎥⎢ H! x ⎥= ⎢ Hx − H! x ⎥ (4.91)
Δy ⎢ 2,2 Δy 2,2 2,1
⎢ 0 0 −1 0 0 1 0 0 0 ⎥⎢ ⎥ ⎢ ⎥
⎢ 0 0 0 −1 0 0 1 0 0 ⎥⎢ H! x ⎥ ⎢ H! x − H! x ⎥
⎥⎢ ⎥ ⎢ ⎥
3,2 3,2 3,1
⎢ 0 0 0 0 −1 0 0 1 0
⎢ 0 0 0 0 0 −1 0 0 1 ⎥⎢ H! x ⎥ ⎢ H! x − H! x ⎥
⎣ ⎦⎢ 1,3 ⎥ ⎢ 1,3 1,2 ⎥
⎢ H! x ⎥ ⎢ H! !
− Hx ⎥
⎢ 2,3 ⎥ ⎢ x 2,3 2,2 ⎥
⎢ H! x ⎥ ⎢ H! !
− Hx ⎥
⎢⎣ 3,3 ⎥⎦ ⎢⎣ x 3,3 3,2 ⎥⎦
From (4.91), the derivative matrix Dyh is read off as the square matrix premul-
tiplying the column vector of electric field components, including the division by
Δy. Observe the form of the matrix for Dyh given in (4.88). It is composed of just
two diagonals. The center diagonal contains all +1’s and the lower –Nx diagonal
contains all –1’s. The lower diagonal in Dyh is not interrupted by 0’s so this diagonal
is easier to construct.
⎡ 1 0 0 0 0 0 0 0 0 ⎤
⎢ 0 1 0 0 0 0 0 0 0 ⎥
⎢ 0 0 1 0 0 0 0 0 0 ⎥
⎢ −1 0 0 1 0 0 0 0 0 ⎥
h 1 ⎢ ⎥
Dy = 0 −1 0 0 1 0 0 0 0 (4.92)
Δy ⎢ 0 0 −1 0 0 1 0 0 0
⎥
⎢ ⎥
⎢ 0 0 0 −1 0 0 1 0 0 ⎥
⎢ 0 0 0 0 −1 0 0 1 0 ⎥
⎢ 0 0 0 0 0 −1 0 0 1 ⎥
⎣ ⎦
While only Ez, H! x, and H! y were considered for the above derivative matrices, the
same derivative matrices for electric and magnetic fields are constructed no matter
what combination of field component and finite-difference equation is considered.
It is recommended to the reader to do these derivations as an exercise. Observe
that the majority of the elements in the derivative matrices are equal to zero. This
becomes even more pronounced when larger grids are considered. Storing all of
the elements of a derivative matrix using double-precision floating-point numbers
would consume a lot of memory. Instead, it is much more efficient to store the
derivative matrices as sparse matrices where only the non-zero elements are stored.
MATLAB makes working with sparse matrices very easy. Always store and work
with derivative matrices as sparse matrices!
Figure 4.5 (a) Large three-dimensional photonic crystal. (b) Application of periodic boundary
conditions to efficiently analyze the three-dimensional photonic crystal with a two-dimensional
simulation.
⎧ E − Ez
⎪ z i+1,j i,j
i < Nx
∂Ez ⎪ Δx
≈ ⎨ (4.93)
∂x ⎪ Ez 1,j − Ez N ,j
⎪ x
i = Nx
⎩ Δx
A big limitation of the PBC in (4.93) is that it only works when the source wave
is at normal incidence. When the source wave is applied at an oblique angle of inci-
dence, the fields at the left and right sides of the grid are out of phase and the PBC
in (4.93) fails. This concept is illustrated in Figure 4.6. The fields at the far left and
far right sides of the grid are in phase for a wave at normal incidence, but they are
out of phase for a wave at an oblique angle. To compensate for the phase difference
across the unit cell, the PBC in (4.93) must be modified.
The fundamental states for electromagnetic waves inside of periodic structures
are called Bloch waves and they obey Bloch’s theorem [3]. For the E mode, Bloch’s
theorem requires the field component Ez to have the following form.
⎣ ( )
Ez ( x, y ) = A ( x, y ) exp ⎡ − j bx x + by y ⎤
⎦
(4.94)
Figure 4.6 Comparison of phase at the far left and far right sides of a grid for a wave at normal
incidence and a wave at an oblique angle of incidence.
The function A(x,y) is the complex amplitude !function of the Bloch wave, β x
!
and β y are components of the Bloch wave vector b, and r is the position vector.
The amplitude part of the Bloch wave A(x,y) is periodic exactly like the structure
the Bloch wave is propagating through. This means the PBC in (4.93) can be applied
to A(x,y), but it cannot be applied to the exponential term exp[−j(β xx + β yy)]. From
(4.94), the Ez component at the left boundary (xlo) and right boundary (xhi) of the
grid can be written as
( ) (⎣ ) ( )
Ez xlo , y = A xlo , y exp ⎡ − j bx xlo + by y ⎤ Left Boundary
⎦
(4.95)
( ) ( ⎣ ) ( )
Ez xhi , y = A xhi , y exp ⎡ − j bx xhi + by y ⎤ Right Boundary
⎦
(4.96)
Since the amplitude function A(x,y) of the Bloch wave is periodic, boundary
conditions at the left and right boundaries of the grid require that A(xhi,y) = A(xlo,y).
This allows (4.96) to be written as
( ) ( ) (
Ez xhi , y = A xlo , y exp ⎡ − j bx xhi + by y ⎤
⎣ ⎦ ) (4.97)
( ) ( ⎣ ) (
A xlo , y = Ez xlo , y exp ⎡ + j bx xlo + by y ⎤
⎦ ) (4.98)
Substituting this expression for A(xlo,y) into (4.97) leads to an equation that relates
the electric fields at the left and right boundaries of the grid.
( ) ( ) (
Ez xhi , y = Ez xlo , y exp ⎡⎣ − jbx xhi − xlo ⎤⎦
) (4.99)
The exponential term in (4.99) describes the phase that accumulates across the
unit cell in the x-direction. Boundary conditions dictate that the tangential compo-
nent of the wave vector be continuous. From Figure 4.5, the boundary conditions
imply that β x = kx,inc. The expression xhi − xlo is the physical width of the grid which
is the period of the device Λ x. It is convenient to define a term Φ x that incorporates
the transverse phase across one unit cell.
( )
Φx = exp ⎡⎣ − jbx xhi − xlo ⎤⎦ = exp − jkx,inc Λ x
( ) (4.100)
Given all of this, the PBC for electric fields that accounts for the angle of inci-
dence of the source wave is
⎧ E − Em i,j
⎪ m i+1,j i < Nx
∂Em ⎪ Δx
≈ ⎨ m = x, y, z (4.101)
∂x ⎪ Φx Em 1,j − Em Nx ,j
⎪ i = Nx
⎩ Δx
Similarly, the PBC for magnetic fields that accounts for the angle of incidence
of the source wave is
⎧ H! m − Φ∗x H! m
⎪ 1,j N x ,j
∂H! m ⎪ i =1
≈ ⎨ Δx m = x, y, z (4.102)
∂x ⎪ H! m − H! m
i,j i−1,j
⎪ i >1
⎩ Δx
The ∗ superscript in (4.102) indicates that a complex conjugate is applied to
reverse the sign of the phase in the term Φ x. For derivatives of electric fields, the
boundary condition problem arose at the right side of the grid and terms from the
left side were used. For derivatives of magnetic fields, the boundary condition prob-
lem arises at the left side of the grid and terms from the right side are used. This
reverses the sign of the phase to be used in the PBC for magnetic fields.
In some cases, it may be desired to use PBCs at the top (ylo) and bottom (yhi)
boundaries of the grid in addition to the left (xlo) and right (xhi) boundaries. This
is how photonic bands will be calculated in Chapter 7. In these cases, the finite-
difference approximations with PBCs are written as
⎧ E − Em i,j
⎪ m i,j+1 j < Ny
∂Em ⎪⎪ Δy
≈ ⎨ m = x, y, z (4.103)
∂y ⎪ Φy Em i,1 − Em i,N
⎪ y
j = Ny
⎪⎩ Δy
⎧
⎪ H! m − Φ∗y H! m
i,1 i,N y
j =1
∂H! m ⎪⎪ Δy
≈⎨ m = x, y, z (4.104)
∂y ⎪ H! m − H! m i,j−1
i,j
⎪ j >1
⎪⎩ Δy
(
Φy = exp − jky,inc Λ y ) (4.105)
a column vector containing all of the electric field components Ez⎪ i,j throughout the
grid. Using PBCs, this large set of equations in matrix form is
⎡ ⎤ ⎡ ⎤
⎢ Ez
1,1 ⎥ ⎢ Ez 2,1 − Ez 1,1 ⎥
⎢ ⎥ ⎢ ⎥
⎡ −1 1 0 0 0 0 0 0 0 ⎤⎢ Ez
2,1 ⎥ ⎢ Ez 3,1 − Ez 2,1 ⎥
⎢ ⎥⎢ ⎥ ⎢ ⎥
⎢ 0 −1 1 0 0 0 0 0 0 ⎥⎢ Ez
3,1 ⎥ ⎢ Φx Ez 1,1 − Ez 3,1 ⎥
⎢ Φx 0 −1 0 0 0 0 0 0 ⎥⎢ ⎥ ⎢ ⎥
⎢ ⎥⎢ Ez ⎥ ⎢ Ez 2,2 − Ez 1,2 ⎥
0 0 0 −1 1 0 0 0 0 ⎥⎢
1 ⎢
1,2
⎥ 1 ⎢ ⎥
⎢ 0 0 0 0 −1 1 0 0 0 ⎥⎢ Ez ⎥ = Δx ⎢ Ez 3,2 − Ez 2,2 ⎥ (4.106)
Δx ⎢ ⎥⎢ 2,2
⎥ ⎢ ⎥
0 0 0 Φ x 0 −1 0 0 0
⎢ ⎥⎢ Ez ⎥ ⎢ Φx Ez 1,2 − Ez 3,2 ⎥
⎢ 0 0 0 0 0 0 −1 1 0 ⎥⎢ 3,2
⎥ ⎢ ⎥
⎢ ⎥⎢ Ez ⎥ ⎢ Ez 2,3 − Ez 1,3 ⎥
⎢ 0 0 0 0 0 0 0 −1 1 ⎥⎢ 1,3
⎥ ⎢ ⎥
⎢ 0 0 0 0 0 0 Φ x 0 −1 ⎥⎢ Ez ⎥ ⎢ Ez − Ez ⎥
⎣ ⎦
⎢ 2,3
⎥ ⎢ 3,3 2,3
⎥
⎢ Ez ⎥ ⎢ Φx Ez − Ez ⎥
⎣ 3,3 ⎦ ⎣ 1,3 3,3 ⎦
From (4.106), the derivative matrix Dxe is read off as the square matrix premulti-
plying the column vector of electric field components, including the division by Δx.
Observe the form of the matrix for Dxe given in (4.107). It is essentially the derivative
matrix with Dirichlet boundary conditions but with phase terms Φ x added in the
rows where PBCs are used. This suggests an easy way to build a derivative matrix.
First, build the derivative matrix with Dirichlet boundary conditions. Second, incor-
porate the phase terms only if PBCs are required.
⎡ −1 1 0 0 0 0 0 0 0 ⎤
⎢ ⎥
⎢ 0 −1 1 0 0 0 0 0 0 ⎥
⎢ Φx 0 −1 0 0 0 0 0 0 ⎥
⎢ ⎥
0 0 0 −1 1 0 0 0 0 ⎥
1 ⎢
Dex = ⎢ 0 0 0 0 −1 1 0 0 0 ⎥ (4.107)
Δx ⎢ ⎥
0 0 0 Φ x 0 −1 0 0 0
⎢ ⎥
⎢ 0 0 0 0 0 0 −1 1 0 ⎥
⎢ ⎥
⎢ 0 0 0 0 0 0 0 −1 1 ⎥
⎢ 0 0 0 0 0 0 Φ x 0 −1 ⎥
⎣ ⎦
The derivative matrix Dye with PBCs is determined by writing the finite-difference
approximation in (4.61) once for each point on the grid depicted in Figure 4.4, writ-
ing the large set of equations as a single matrix equation, and then reading off the
derivative matrix. The results of this are
⎡ ⎤
⎡
Ez
⎤ ⎢ Ez 1,2 − Ez 1,1 ⎥
⎢ 1,1 ⎥ ⎢ ⎥
⎡ −1 0 0 1 0 0 0 0 0 ⎤⎢ ⎥ ⎢ Ez 2,2 − Ez 2,1 ⎥
⎢ ⎥⎢ Ez ⎥ ⎢ ⎥
2,1
⎢ 0 −1 0 0 1 0 0 0 0 ⎥⎢ ⎥ ⎢ Ez − Ez ⎥
⎢ ⎥⎢ Ez ⎥ ⎢ 3,2 3,1 ⎥
⎢ 0 0 −1 0 0 1 0 0 0 ⎥⎢
3,1
⎥ ⎢ E − Ez ⎥
⎢ 0 0 0 −1 0 0 1 0 0 ⎥⎢ Ez ⎥ ⎢ z 1,3 1,2 ⎥
1,2
1 ⎢ ⎥⎢ ⎥ 1 ⎢ ⎥
Δy ⎢
0 0 0 0 −1 0 0 1 0 ⎥⎢ Ez
2,2
⎥ = Δy ⎢ Ez 2,3 − Ez 2,2 ⎥ (4.108)
⎢ 0 0 0 0 0 −1 0 0 1 ⎥⎢ ⎥ ⎢ ⎥
⎢ ⎥⎢ Ez ⎥ ⎢ Ez 3,3 − Ez 3,2 ⎥
⎢ Φy 0 0 0 0 0 −1 0 0 ⎥⎢
3,2
⎥ ⎢ ⎥
⎢ 0 Φy 0 0 0 0 0 −1 0 ⎥⎢ Ez ⎥ ⎢ ΦE − Ez ⎥
1,3
⎢ ⎥⎢ ⎥ ⎢ y z 1,1 1,3 ⎥
⎢ 0 0 Φy 0 0 0 0 0 −1 ⎥⎢ Ez ⎥ ⎢ ΦE ⎥
⎣ ⎦⎢ ⎥ ⎢ y z 2,1 − Ez 2,3
2,3
⎥
⎢ Ez ⎥ ⎢ ⎥
⎣ 3,3 ⎦ ⎢ Φy Ez 3,1 − Ez 3,3 ⎥
⎣ ⎦
⎡ −1 0 0 1 0 0 0 0 0 ⎤
⎢ ⎥
⎢ 0 −1 0 0 1 0 0 0 0 ⎥
⎢ ⎥
⎢ 0 0 −1 0 0 1 0 0 0 ⎥
⎢ 0 0 0 −1 0 0 1 0 0 ⎥
e 1 ⎢ ⎥
Dy = 0 0 0 0 −1 0 0 1 0 ⎥ (4.109)
Δy ⎢
⎢ 0 0 0 0 0 −1 0 0 1 ⎥
⎢ ⎥
⎢ Φy 0 0 0 0 0 −1 0 0 ⎥
⎢ 0 Φy 0 0 0 0 0 −1 0 ⎥
⎢ ⎥
⎢ 0 0 Φy 0 0 0 0 0 −1 ⎥
⎣ ⎦
The derivative matrix Dxh with PBCs is determined by writing the finite-differ-
ence approximation in (4.68) once for each point on the grid depicted in Figure 4.4,
writing the large set of equations as a single matrix equation, and then reading off
the derivative matrix. The results of this are
⎡ ⎤ ⎡ ! ⎤
⎢ H! y ⎥
∗ !
⎢ H y 1,1 − Φx H y 3,1 ⎥
1,1
⎡ ⎤ ⎢ ⎥ ⎢ ⎥
1 0 −Φ∗x 0 0 0 0 0 0 ⎢ H! y ⎥ ⎢ H! y 2,1 − H! y 1,1 ⎥
⎢ ⎥ 2,1
⎢ −1 1 0 0 0 0 0 0 0 ⎥⎢ ⎥ ⎢ ⎥
⎢ ⎥⎢ H! y ⎥ ⎢ H! y − H! y ⎥
3,1 3,1 2,1
⎢ 0 −1 1 0 0 0 0 0 0 ⎥⎢ ⎥ ⎢ ⎥
⎢ 0 0 0 1 0 −Φ x 0
∗
0 0 ⎥⎢
⎢ H! y ⎥ !
⎢ H y − ΦxH y ∗ ! ⎥
1,2 ⎥ ⎢ 1,2 3,2 ⎥ (4.110)
1 ⎢ ⎥
⎢ 0 0 0 −1 1 0 0 0 0 ⎥⎢ H! y ⎥ = 1 ⎢ H! − H! ⎥
y 2,2 y 1,2
Δx ⎢ ⎢ 2,2 ⎥ Δx ⎢ ⎥
0 0 0 0 −1 1 0 0 0 ⎥⎢
⎢ ⎥ H! y ⎥ ⎢ H!
y 3,2
− H! y ⎥
⎢ 0 0 0 0 0 0 1 0 −Φ∗x ⎥⎢ 3,2 ⎥ ⎢ 2,2 ⎥
⎢ ⎥⎢ H! y ⎥ ⎢ H! ∗ !
− ΦxH y ⎥
⎢ 0 0 0 0 0 0 −1 1 0 ⎥⎢ 1,3 ⎥ ⎢ y 1,3 3,3 ⎥
⎢ ⎥ ⎢ ! ⎥
⎢
⎣
0 0 0 0 0 0 0 −1 1 ⎥⎢
⎦ H! y ⎥ ⎢ H y 2,3
− H!
y 1,3 ⎥
2,3
⎢ ⎥ ⎢ ! ⎥
⎢⎣ H! y ⎥⎦
!
⎢⎣ H y 3,3 − H y 2,3 ⎥⎦
3,3
⎡ 1 0 −Φ∗x 0 0 0 0 0 ⎤
0
⎢ ⎥
⎢ −1 1 0 0 0 0 0 0 0 ⎥
⎢ ⎥
⎢ 0 −1 1 0 0 0 0 0 0 ⎥
⎢ 0 0 0 1 0 −Φ x 0
∗
0 0 ⎥
1 ⎢ ⎥
Dhx = ⎢ 0 0 0 −1 1 0 0 0 0 ⎥ (4.111)
Δx ⎢
0 0 0 0 −1 1 0 0 0 ⎥
⎢ ⎥
⎢ 0 0 0 0 0 0 1 0 −Φ∗x ⎥
⎢ ⎥
⎢ 0 0 0 0 0 0 −1 1 0 ⎥
⎢ 0 0 0 0 0 0 0 −1 1 ⎥
⎣ ⎦
Last, the derivative matrix Dyh with PBCs is determined by writing the finite-
difference approximation in (4.67) once for each point on the grid depicted in Figure
4.4, writing the large set of equations as a single matrix equation, and then reading
off the derivative matrix. The results of this are
⎡ ⎤ ⎡ ! ∗ ! ⎤
⎢ H! x ⎥ ⎢ H x 1,1 − Φy H x 1,3 ⎥
1,1
⎡ 1 0 0 0 0 0 −Φ*y 0 0 ⎤⎢ ⎥ ⎢ ⎥
H! x ⎢ H! x 2,1 − Φy H! x 2,3
∗
⎢ ⎥⎢ ⎥ ⎥
⎢ ⎥⎢ 2,1
0 1 0 0 0 0 0 −Φ∗y 0 ⎥ ⎢ ⎥
⎢ ⎥⎢ H! x ⎥ ⎢ H! x − Φ∗y H! x ⎥
⎢ 0 0 1 0 0 0 0 0 −Φ∗y ⎥⎢ 3,1
⎥ ⎢ 3,1 3,3
⎥
⎢ ⎥⎢ H! x ⎥ !
⎢ Hx − Hx ! ⎥
⎢ −1 0 0 1 0 0 0 0 0 ⎥⎢ 1,2 ⎢ 1,2 1,1 ⎥ (4.112)
1 ⎥ 1 ⎢ !
⎢ 0 −1 0 0 1 0 0 0 0 ⎥⎢ H! x ⎥= Hz − H! x ⎥
Δy ⎢ ⎥⎢ 2,2 ⎥ Δy ⎢ 2,2 2,1 ⎥
⎢ 0 0 −1 0 0 1 0 0 0 ⎥⎢
⎢ ⎥⎢ H! z ⎥ ⎢ H!
x 3,2
!
− Hx ⎥
3,2 ⎥ ⎢ 3,1 ⎥
⎢ 0 0 0 −1 0 0 1 0 0 ⎥⎢ ⎢ H! ⎥
⎢ ⎥⎢ H! x ⎥ !
− Hx
0 0 0 0 −1 0 0 1 0 1,3 ⎥ ⎢ x 1,3 1,2 ⎥
⎢ ⎥⎢ ⎥ ⎢ ! ⎥
⎢ ⎥⎢ H! x H − H!
0 0 0 0 0 −1 0 0 1 2,3 ⎥ ⎢ x 2,3 x 2,2 ⎥
⎣ ⎦⎢ ⎥ ⎢ ! ⎥
⎢⎣ H! x ⎥⎦
!
⎢⎣ H x 3,3 − H x 3,2 ⎥⎦
3,3
⎡ 1 0 0 0 0 0 −Φ∗y 0 0 ⎤
⎢ ⎥
⎢ 0 1 0 0 0 0 0 −Φ∗y 0 ⎥
⎢ ⎥
⎢ 0 0 1 0 0 0 0 0 −Φ∗y ⎥
⎢ ⎥
⎢ −1 0 0 1 0 0 0 0 0 ⎥
1 ⎢
h
Dy = 0 −1 0 0 1 0 0 0 0 ⎥ (4.113)
Δy ⎢ ⎥
⎢ 0 0 −1 0 0 1 0 0 0 ⎥
⎢ ⎥
⎢ 0 0 0 −1 0 0 1 0 0 ⎥
⎢ ⎥
⎢ 0 0 0 0 −1 0 0 1 0 ⎥
⎢ 0 0 0 0 0 −1 0 0 1 ⎥
⎣ ⎦
( ) ( )
H H
Dhx = − Dex Dhy = − Dey (4.114)
The superscript H indicates a Hermitian transpose. This is an ordinary transpose
followed by calculating the complex conjugate of all the elements in the matrix.
This is a very convenient relation because only the electric field derivative matrices
have to be constructed and the magnetic field derivative matrices can be calculated
directly from the electric field derivative matrices using (4.114). While it is possible
to formulate and implement FDFD using only the electric field derivative matrices,
it is not recommended because this relation does not hold for all boundary condi-
tions. Be cautious when applying the relation in (4.114)!
Observe the form of the matrix for Dxe given in (4.115). Three-dimensional
derivative matrices are still composed of just two diagonals. The center diagonal
contains all −1’s and the first upper diagonal contains mostly all +1’s but has some
0’s inserted where Dirichlet boundary conditions were applied. The zeros occur
every Nx rows, where Nx is the number of cells the grid is large in the x-direction.
The derivative matrix Dye with Dirichlet boundary conditions is
⎡ −1 0 0 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 −1 0 0 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 −1 0 0 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 −1 0 0 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 −1 0 0 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 −1 0 0 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 −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 −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 −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 −1 0 0 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 −1 0 0 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 −1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 ⎥
1 ⎢ 0 0 0 0 0 0 0 0 0 0 0 0 −1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 ⎥
Dey = ⎢ 0 0 0 0 0 0 0 0 0 0 0 0 0 −1 0 0 1 0 0 0 0 0 0 0 0 0 0 ⎥
Δy ⎢ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 −1 0 0 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 −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 −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 −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 −1 0 0 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 −1 0 0 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 −1 0 0 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 −1 0 0 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 −1 0 0 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 −1 0 0 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 −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 −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 −1 ⎦
(4.116)
Observe the form of the matrix for Dye given in (4.116). The center diagonal
contains all −1’s. The upper diagonal is placed along the Nx diagonal. It contains a
pattern of (Ny − 1)Nx ones followed by Nx zeros, repeated across the entire diagonal.
The derivative matrix Dze with Dirichlet boundary conditions is
⎡ −1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ⎤
⎢ ⎥
⎢ 0 −1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ⎥
⎢ 0 0 −1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ⎥
⎢ ⎥
⎢ 0 0 0 −1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ⎥
⎢ 0 0 0 0 −1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 ⎥
⎢ 0 0 0 0 0 −1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 ⎥
⎢ ⎥
⎢ 0 0 0 0 0 0 −1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 ⎥
⎢ 0 0 0 0 0 0 0 −1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 ⎥
⎢ 0 0 0 0 0 0 0 0 −1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 ⎥
⎢ ⎥
⎢ 0 0 0 0 0 0 0 0 0 −1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 ⎥
⎢ 0 0 0 0 0 0 0 0 0 0 −1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 ⎥
⎢ 0 0 0 0 0 0 0 0 0 0 0 −1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 ⎥
⎢ ⎥
⎢ 0 0 0 0 0 0 0 0 0 0 0 0 −1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 ⎥
e 1⎢ ⎥
Dz = 0 0 0 0 0 0 0 0 0 0 0 0 0 −1 0 0 0 0 0 0 0 0 1 0 0 0 0
Δz⎢ ⎥
⎢ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 −1 0 0 0 0 0 0 0 0 1 0 0 0 ⎥
⎢ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 −1 0 0 0 0 0 0 0 0 1 0 0 ⎥
⎢ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 −1 0 0 0 0 0 0 0 0 1 0 ⎥
⎢ ⎥
⎢ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 −1 0 0 0 0 0 0 0 0 1 ⎥
⎢ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 −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 −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 −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 −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 −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 −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 −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 −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 −1 ⎦⎥
(4.117)
Observe the form of the matrix for Dze given in (4.117). The center diagonal
contains all −1’s. The upper diagonal contains all +1’s and is placed along the
NxNy diagonal.
⎡ −1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ⎤
⎢ ⎥
⎢ 0 −1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ⎥
⎢ 0 0 −1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ⎥
⎢ ⎥
⎢ 0 0 0 −1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ⎥
⎢ 0 0 0 0 −1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 ⎥
⎢ ⎥
⎢ 0 0 0 0 0 −1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 ⎥
⎢ 0 0 0 0 0 0 −1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 ⎥
⎢ ⎥
⎢ 0 0 0 0 0 0 0 −1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 ⎥
⎢ 0 0 0 0 0 0 0 0 −1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 ⎥
⎢ ⎥
⎢ 0 0 0 0 0 0 0 0 0 −1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 ⎥
⎢ 0 0 0 0 0 0 0 0 0 0 −1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 ⎥
⎢ ⎥
⎢ 0 0 0 0 0 0 0 0 0 0 0 −1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 ⎥
⎢ 0 0 0 0 0 0 0 0 0 0 0 0 −1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 ⎥
e 1 ⎢ ⎥
Dz = 0 0 0 0 0 0 0 0 0 0 0 0 0 −1 0 0 0 0 0 0 0 0 1 0 0 0 0 ⎥
Δz ⎢
⎢ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 −1 0 0 0 0 0 0 0 0 1 0 0 0 ⎥
⎢ ⎥
⎢ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 −1 0 0 0 0 0 0 0 0 1 0 0 ⎥
⎢ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 −1 0 0 0 0 0 0 0 0 1 0 ⎥
⎢ ⎥
⎢ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 −1 0 0 0 0 0 0 0 0 1 ⎥
⎢ Φ z 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 −1 0 0 0 0 0 0 0 0 ⎥
⎢ 0 Φz 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 −1 0 0 0 0 0 0 0 ⎥⎥
⎢
⎢ 0 0 Φz 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 −1 0 0 0 0 0 0 ⎥
⎢ 0 0 0 Φz 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 −1 0 0 0 0 0 ⎥
⎢ ⎥
⎢ 0 0 0 0 Φz 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 −1 0 0 0 0 ⎥
⎢ 0 0 0 0 0 Φz 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 −1 0 0 0 ⎥
⎢ ⎥
⎢ 0 0 0 0 0 0 Φz 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 −1 0 0 ⎥
⎢ 0 0 0 0 0 0 0 Φz 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 −1 0 ⎥
⎢ ⎥
⎣⎢ 0 0 0 0 0 0 0 0 Φz 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 −1 ⎥⎦
(4.120)
Observe that these derivative matrices are the same as the derivative matri-
ces formed using Dirichlet boundary conditions, but with additional phase terms
incorporated. The phase terms Φ x for the Dxe matrix are located along with the
1 − Nx diagonal and placed every Nx position, starting at the first element in the
diagonal. The phase terms Φ y for the Dye matrix are located along the −(Ny − 1)
Nx diagonal. The diagonal is a repeated pattern of Nx phase terms followed by (Ny − 1)
N x zeros. The phase terms Φ z for the Dze matrix are located along the entire
−(Nz − 1)NyNx diagonal.
( ) ( ) ( )
H H H
Dhx = − Dex Dhy = − Dey Dhz = − Dez (4.121)
This is the same relationship observed for two-dimensional grids with the addi-
tion of the relation between Dzh and Dze. As mentioned previously, be cautious when
applying this relationship when other boundary conditions are being used.
be the numbers inserted into the two main diagonals of the derivative matrix DEX.
The variable d0 will be inserted into the center diagonal so it is initialized as a
one-dimensional array of all −1’s. The variable d1 will be inserted into the first
upper diagonal. It is a one-dimensional array initialized with all +1’s, but with
0’s inserted into the positions where Dirichlet boundary conditions are needed
every Nx number of cells. Given the one-dimensional arrays d0 and d1, they are
inserted into the derivative matrix at the same time using MATLAB’s function
spdiags(). The first input argument into the spdiags() function is a matrix, and
its columns are the one-dimensional arrays to be inserted into the diagonals. It is
convenient to divide these arrays by the grid resolution parameter dx at this step.
The second input argument is an array containing the diagonal numbers that the
previous one-dimensional arrays should be inserted into. In this case, 0 indicates
the center diagonal and +1 indicates the first upper diagonal. The third input
argument to spdiags() is the matrix into which the diagonals should be inserted.
The zero matrix is given here so only the diagonals inserted by this single call to
spdiags() will appear in the DEX matrix. At this point, the derivative matrix is
correct for Dirichlet boundary conditions. The last part of this section of code is
to insert a third diagonal containing the phase terms where PBCs are to be used
instead of Dirichlet boundary conditions. The variable d1 is overwritten here with
the new diagonal containing the phase terms that are inserted into the DEX matrix
using spdiags().
Lines 74 to 100 of the yeeder2d() function are very similar to the previous sec-
tion of code. It builds the derivative matrix Dye, which in MATLAB will be called
DEY. When the numerical size of the grid in the y-direction is Ny = 1, the deriva-
tive matrix is initialized by placing −jky,inc along the entire center diagonal. When
the numerical size of the grid is greater than 1, the yeeder2d() function moves on
to building two one-dimensional arrays that will be inserted into the two main
diagonals of the derivative matrix. The variable d0 will be inserted into the center
diagonal so it is initialized as a one-dimensional array of all −1’s. The variable d1
will be inserted into the Nxth upper diagonal. It is a one-dimensional array initial-
ized with all +1’s. Given the one-dimensional arrays d0 and d1, they are inserted
into the derivative matrix at the same time using the built-in function spdiags().
At this point, the derivative matrix is correct for Dirichlet boundary conditions. The
last part of this section of code inserts a third diagonal containing the phase terms
where PBCs are to be used instead of Dirichlet boundary conditions. The variable
d1 is overwritten with the new diagonal containing the phase terms and then it is
inserted into the DEY matrix using spdiags().
Lines 102 to 107 of the yeeder2d() function build the derivative matrices for
the magnetic fields Dxh and Dyh. In MATLAB, these will be called DHX and DHY,
respectively. This is a very easy step because the boundary conditions that this
function incorporates allows Dxh and Dyh to be calculated directly from Dxe and Dye
using (4.114).
Adding and deleting elements from sparse matrices can be slow, especially for
large matrices. To optimize the speed and efficiency of yeeder2d(), the diagonals
were calculated ahead of time and inserted into the derivative matrices with a
minimum number of calls to spdiags(). It is possible to write yeeder2d() a bit
differently that utilizes just a single call to spdiags(), but that approach was not
taken here in order to make the MATLAB code easier to read and understand.
1 % Chapter4_yeeder2d_demo.m
2
3 % INITIALIZE MATLAB
4 close all;
5 clc;
6 clear all;
7
8 % DEFINE INPUT ARGUMENTS FOR YEEDER2D
9 NS = [3 4];
10 RES = [0.2 0.1];
11 BC = [0 0];
12
13 % CALL YEEDER2D
14 [DEX,DEY,DHX,DHY] = yeeder2d(NS,RES,BC);
15
16 % SHOW DERIVATIVE MATRICES
17 disp(‘DEX = ‘);
18 disp(full(DEX));
19
20 disp(‘DEY = ‘);
21 disp(full(DEY));
22
23 disp(‘DHX = ‘);
24 disp(full(DHX));
25
26 disp(‘DHY = ‘);
27 disp(full(DHY));
The derivative matrices are displayed to the command window from lines 16
to 27. They are sparse matrices so they are converted to full matrices before being
displayed. Be careful to only attempt to display the derivative matrices for small
grids this way. The output of the function is
DEX =
-5 5 0 0 0 0 0 0 0 0 0 0
0 -5 5 0 0 0 0 0 0 0 0 0
0 0 -5 0 0 0 0 0 0 0 0 0
0 0 0 -5 5 0 0 0 0 0 0 0
0 0 0 0 -5 5 0 0 0 0 0 0
0 0 0 0 0 -5 0 0 0 0 0 0
0 0 0 0 0 0 -5 5 0 0 0 0
0 0 0 0 0 0 0 -5 5 0 0 0
0 0 0 0 0 0 0 0 -5 0 0 0
0 0 0 0 0 0 0 0 0 -5 5 0
0 0 0 0 0 0 0 0 0 0 -5 5
0 0 0 0 0 0 0 0 0 0 0 -5
DEY =
-10 0 0 10 0 0 0 0 0 0 0 0
0 -10 0 0 10 0 0 0 0 0 0 0
0 0 -10 0 0 10 0 0 0 0 0 0
0 0 0 -10 0 0 10 0 0 0 0 0
0 0 0 0 -10 0 0 10 0 0 0 0
0 0 0 0 0 -10 0 0 10 0 0 0
0 0 0 0 0 0 -10 0 0 10 0 0
0 0 0 0 0 0 0 -10 0 0 10 0
0 0 0 0 0 0 0 0 -10 0 0 10
0 0 0 0 0 0 0 0 0 -10 0 0
0 0 0 0 0 0 0 0 0 0 -10 0
0 0 0 0 0 0 0 0 0 0 0 -10
DHX =
5 0 0 0 0 0 0 0 0 0 0 0
-5 5 0 0 0 0 0 0 0 0 0 0
0 -5 5 0 0 0 0 0 0 0 0 0
0 0 0 5 0 0 0 0 0 0 0 0
0 0 0 -5 5 0 0 0 0 0 0 0
0 0 0 0 -5 5 0 0 0 0 0 0
0 0 0 0 0 0 5 0 0 0 0 0
0 0 0 0 0 0 -5 5 0 0 0 0
0 0 0 0 0 0 0 -5 5 0 0 0
0 0 0 0 0 0 0 0 0 5 0 0
0 0 0 0 0 0 0 0 0 -5 5 0
0 0 0 0 0 0 0 0 0 0 -5 5
DHY =
10 0 0 0 0 0 0 0 0 0 0 0
0 10 0 0 0 0 0 0 0 0 0 0
0 0 10 0 0 0 0 0 0 0 0 0
-10 0 0 10 0 0 0 0 0 0 0 0
0 -10 0 0 10 0 0 0 0 0 0 0
0 0 -10 0 0 10 0 0 0 0 0 0
0 0 0 -10 0 0 10 0 0 0 0 0
0 0 0 0 -10 0 0 10 0 0 0 0
0 0 0 0 0 -10 0 0 10 0 0 0
0 0 0 0 0 0 -10 0 0 10 0 0
0 0 0 0 0 0 0 -10 0 0 10 0
0 0 0 0 0 0 0 0 -10 0 0 10
The MATLAB code for the yeeder3d() function can be downloaded at https://
empossible.net/fdfdbook/. This function calculates the derivative matrices DEX,
DEY, DEZ, DHX, DHY, and DHZ across a three-dimensional Yee grid. This function is
only necessary for the FDFD codes presented in Chapter 10. Lines 2 to 25 are the
header of the function and are what is displayed in the command window if help
yeeder3d is entered at the command prompt. It is always a good practice to include
a header in functions in order to remember how to use them.
Lines 27 to 45 handle the input arguments by extracting meaningful information
and initializing some variables. The size of the grid and grid resolution parameters
are extracted from the input arguments on lines 32 to 34. Lines 36 to 39 calculate
a default kinc vector if one is not provided. The default vector is set to all zeros.
The size of the derivative matrices is determined on line 42 by calculating the total
number of points on the three-dimensional Yee grid. Line 45 initializes a sparse
matrix Z of all zeros.
Lines 47 to 75 build the DEX derivative matrix and resembles the code given
in yeeder2d() very closely. If the size of the grid in the x-direction is 1, lines 52
and 53 initialize the derivative matrix to a diagonal matrix with −jkx,inc along the
entire center diagonal. If the size of the grid is larger than 1, lines 56 to 75 build the
matrix. Line 59 calculates an array d0 containing the numbers to be inserted into
the center diagonal of DEX. Lines 62 and 63 calculate an array d1 containing the
numbers to be inserted into the +1 diagonal in DEX. Line 63 sets every Nx number of
cells to zero to incorporate Dirichet boundary conditions. Line 66 divides the two
arrays d0 and d1 by dx and inserts them into DEX. If periodic boundary conditions
are called for, lines 69 to 73 incorporate these into DEX.
Lines 77 to 110 build the DEY derivative matrix. If the size of the grid in the
y-direction is 1, lines 82 and 83 initialize the derivative matrix to a diagonal matrix
with −jky,inc along the entire center diagonal. If the size of the grid is larger than
1, lines 86 to 110 build the matrix. Line 89 calculates an array d0 containing the
numbers to be inserted into the center diagonal of DEY. Lines 91 and 94 calculate an
array d1 containing the numbers to be inserted into the Nx diagonal in DEY. Line 92
creates an array containing (Ny-1)*Nx ones followed by Nx zeros. Line 93 repeats
this array Nz-1 number of times to form a larger array. Line 94 adds Nx zeros to the
beginning of this larger array and (Ny-1)*Nx ones to the end. While all of this may
seem confusing, it is just done to create the correct pattern of zeros and ones that must
be placed along the Nx*(Ny-1) diagonal of DEY to construct the derivative matrix.
Line 97 divides the two arrays d0 and d1 by dy and inserts them into DEY. If peri-
odic boundary conditions are called for, lines 100 to 108 incorporate these into DEY.
Lines 112 to 135 build the DEZ derivative matrix. If the size of the grid in the
z-direction is 1, lines 117 and 118 initialize the derivative matrix to a diagonal matrix
with −jkz,inc along the entire center diagonal. If the size the grid is larger than one,
lines 120 to 135 build the matrix. Line 124 calculates an array d0 of all ones. There
is no need for a second array d1 to be calculated because the second diagonal is not
broken up in any way to enforce boundary conditions. Line 127 divides this array
by dz and inserts it twice into DEZ, but one diagonal is inserted with opposite sign.
If periodic boundary conditions are called for, lines 130 to 133 incorporate these
into DEZ. Last, lines 137 to 143 calculate the magnetic field derivative matrices DHX,
DHY, and DHZ directly from the electric field derivative matrices. This is possible
because only Dirichlet and periodic boundary conditions are used.
1 % Chapter4_yeeder3d_demo.m
2
3 % INITIALIZE MATLAB
4 close all;
5 clc;
6 clear all;
7
8 % DEFINE INPUT ARGUMENTS FOR YEEDER2D
9 NS = [2 2 2];
10 RES = [0.3 0.2 0.1];
11 BC = [0 0 0];
12
13 % CALL YEEDER3D
14 [DEX,DEY,DEZ,DHX,DHY,DHZ] = yeeder3d(NS,RES,BC);
15
16 % SHOW DERIVATIVE MATRICES
17 disp(‘DEX = ‘);
18 disp(full(DEX));
19
20 disp(‘DEY = ‘);
21 disp(full(DEY));
22
23 disp(‘DEY = ‘);
24 disp(full(DEZ));
25
26 disp(‘DHX = ‘);
27 disp(full(DHX));
28
29 disp(‘DHY = ‘);
30 disp(full(DHY));
31
32 disp(‘DHZ = ‘);
33 disp(full(DHZ));
The derivative matrices are displayed to the command window from lines 16
to 33. They are sparse matrices so they are converted to full matrices before being
displayed. Be careful to only attempt to display the derivative matrices for small
grids this way. The output of the function is
DEX =
-3.3333 3.3333 0 0 0 0 0 0
0 -3.3333 0 0 0 0 0 0
0 0 -3.3333 3.3333 0 0 0 0
0 0 0 -3.3333 0 0 0 0
0 0 0 0 -3.3333 3.3333 0 0
0 0 0 0 0 -3.3333 0 0
0 0 0 0 0 0 -3.3333 3.3333
0 0 0 0 0 0 0 -3.3333
DEY =
-5 0 5 0 0 0 0 0
0 -5 0 5 0 0 0 0
0 0 -5 0 0 0 0 0
0 0 0 -5 0 0 0 0
0 0 0 0 -5 0 5 0
0 0 0 0 0 -5 0 5
0 0 0 0 0 0 -5 0
0 0 0 0 0 0 0 -5
DEY =
-10 0 0 0 10 0 0 0
0 -10 0 0 0 10 0 0
0 0 -10 0 0 0 10 0
0 0 0 -10 0 0 0 10
0 0 0 0 -10 0 0 0
0 0 0 0 0 -10 0 0
0 0 0 0 0 0 -10 0
0 0 0 0 0 0 0 -10
DHX =
3.3333 0 0 0 0 0 0 0
-3.3333 3.3333 0 0 0 0 0 0
0 0 3.3333 0 0 0 0 0
0 0 -3.3333 3.3333 0 0 0 0
0 0 0 0 3.3333 0 0 0
0 0 0 0 -3.3333 3.3333 0 0
0 0 0 0 0 0 3.3333 0
0 0 0 0 0 0 -3.3333 3.3333
DHY =
5 0 0 0 0 0 0 0
0 5 0 0 0 0 0 0
-5 0 5 0 0 0 0 0
0 -5 0 5 0 0 0 0
0 0 0 0 5 0 0 0
0 0 0 0 0 5 0 0
0 0 0 0 -5 0 5 0
0 0 0 0 0 -5 0 5
DHZ =
10 0 0 0 0 0 0 0
0 10 0 0 0 0 0 0
0 0 10 0 0 0 0 0
0 0 0 10 0 0 0 0
-10 0 0 0 10 0 0 0
0 -10 0 0 0 10 0 0
0 0 -10 0 0 0 10 0
0 0 0 -10 0 0 0 10
In FDFD, the field components are positioned throughout space following the Yee
grid scheme. While the Yee grid offers many numerical advantages, it makes it
more difficult to build devices onto the grid, especially when material boundaries
slice through the middle of cells on the grid. Sorting out the assignment of mate-
rial values to the different permittivity and permeability arrays across the Yee grid
can be tedious and difficult. The 2× grid technique was developed to make this
process simple and fast and is particularly well suited for dielectric devices with
curved features [4].
From Figures 4.4 and 4.7, the field components are staggered across the Yee grid
in a way that suggests that somehow a simulation is getting twice the resolution
as the standard Yee grid. While this is not entirely true, it is the inspiration for the
2× grid technique. Figure 4.7 illustrates the same grids as Figure 4.4 but the grids
are overlaid with a second grid drawn with dashed lines. The second grid has the
same physical size as the original Yee grid, but has twice as many cells at half the
size as the original Yee grid. This second grid that has twice as many cells is called
the 2× grid. The field components from the Yee grid overlay perfectly onto unique
cells in the 2× grid.
Calculating the tensor arrays ERxx, ERyy, ERzz, URxx, URyy, and URzz using the
2× grid technique is a four-step process. First, the grid parameters for the standard
Yee grid are calculated. This includes the number of cells wide Nx, number of cells
tall Ny, and the resolution parameters dx and dy. Second, the grid parameters for
the 2× grid are calculated directly from the Yee grid parameters so that the same
physical amount of space is represented with twice as many cells.
Nx2 = 2*Nx;
Ny2 = 2*Ny;
dx2 = dx/2;
dy2 = dy/2;
Third, the device to be simulated is built onto the 2× grid without having to
consider anything about the Yee grid or staggering. This is easily accomplished
using any of the techniques presented in Chapter 1. When this is done, two arrays
are produced. ER2 is the array containing the relative permittivity across the 2× grid
and UR2 is the array containing the relative permeability across the 2× grid. Fourth,
the tensor elements ERxx, ERyy, and ERzz across the Yee grid are extracted from the
2× grid array ER2 using the three lines of code below.
ERxx = ER2(2:2:Nx2,1:2:Ny2);
ERyy = ER2(1:2:Nx2,2:2:Ny2);
ERzz = ER2(1:2:Nx2,1:2:Ny2);
Each of these lines of code pulls numbers from every other cell in ER2. The dif-
ference is the starting index being a 1 or a 2, and these are determined by examin-
ing Figure 4.7. The constitutive values for ε xx⎪ i,j reside at the same points as Ex⎪ i,j,
and the first occurrence of E x⎪ i,j on the 2× grid is at i = 2 and j = 1. Therefore, 2
and 1 are used as the starting indices for where the array ERxx is extracted from
the array ER2. A similar examination will show that ERyy is extracted from ER2
with starting indices i = 1 and j = 2, and ERzz is extracted from ER2 with starting
indices i = 1 and j = 1.
Last, the tensor elements URxx, URyy, and URzz across the Yee grid are extracted
from the 2× grid array UR2 using the three lines of code below.
URxx = UR2(1:2:Nx2,2:2:Ny2);
URyy = UR2(2:2:Nx2,1:2:Ny2);
URzz = UR2(2:2:Nx2,2:2:Ny2);
Each of these lines of code pulls numbers from every other cell of UR2. The
constitutive values for μ xx⎪ i,j reside at the same points as H! x , and the first occur-
i,j
rence of H! x on the 2× grid is at i = 1 and j = 2. Therefore, 1 and 2 are used as the
i,j
starting indices for where the array URxx is extracted from the array UR2. A similar
examination will show that URyy is extracted from UR2 with starting indices i = 2
and j = 1, and URzz is extracted from UR2 with starting indices i = 2 and j = 2.
It is best to illustrate the 2× grid technique by example. Suppose it is desired to
simulate scattering from a cylinder. In this case, a circle has to be constructed onto
a two-dimensional Yee grid and values for permittivity and permeability assigned
Figure 4.7 2× grid overlaid onto the Yee grid for both E and H modes.
correctly to the six tensor arrays. Figure 4.8(a) shows a 5 × 5 Yee grid indicated by
solid lines, the field components for both E and H modes distributed throughout the
grid, and the 2× grid indicated by dashed lines. The highlighted cells in the back-
ground convey the device that was constructed onto the 2× grid. In this example,
the 2× grid arrays ER2 and UR2 have the same pattern, but this does not have to be
the case and it does not mean they will ultimately have the same values stored in
them. The column of diagrams in Figure 4.8(c) shows the arrays ERxx, ERyy, and
ERzz which are extracted from the array ER2. The column of diagrams in Figure
4.8(b) shows the arrays URxx, URyy, and URzz which are extracted from the array
UR2. Observe the arrays do not look similar. In fact, they are different for the cells
where the edge of the circle slices through the middle of the Yee cells. Constructing
the tensor arrays individually for the Yee grid would be a more complicated and
tedious task, but the 2× grid technique makes it simple and intuitive.
Figure 4.8 Extracting the tensor element arrays from the 2× grid arrays. (a) Original array on
2× grid. (b) Relative permeability tensor arrays URxx, URyy, and URzz extracted from the 2× grid.
(c) Relative permittivity tensor arrays ERxx, ERyy, and ERzz extracted from the 2× 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);
Furthermore, when full nine-element tensors are used, the equations to extract
the tensor arrays from the three-dimensional 2× grid are
ERxx = ER2xx(2:2:Nx2,1:2:Ny2,1:2:Nz2);
ERxy = ER2xy(1:2:Nx2,2:2:Ny2,1:2:Nz2);
ERxz = ER2xz(1:2:Nx2,1:2:Ny2,2:2:Nz2);
ERyx = ER2yx(2:2:Nx2,1:2:Ny2,1:2:Nz2);
ERyy = ER2yy(1:2:Nx2,2:2:Ny2,1:2:Nz2);
ERyz = ER2yz(1:2:Nx2,1:2:Ny2,2:2:Nz2);
ERzx = ER2zx(2:2:Nx2,1:2:Ny2,1:2:Nz2);
ERzy = ER2zy(1:2:Nx2,2:2:Ny2,1:2:Nz2);
ERzz = ER2zz(1:2:Nx2,1:2:Ny2,2:2:Nz2);
URxx = UR2xx(1:2:Nx2,2:2:Ny2,2:2:Nz2);
URxy = UR2xy(2:2:Nx2,1:2:Ny2,2:2:Nz2);
URxz = UR2xz(2:2:Nx2,2:2:Ny2,1:2:Nz2);
URyx = UR2yx(1:2:Nx2,2:2:Ny2,2:2:Nz2);
URyy = UR2yy(2:2:Nx2,1:2:Ny2,2:2:Nz2);
URyz = UR2yz(2:2:Nx2,2:2:Ny2,1:2:Nz2);
URzx = UR2zx(1:2:Nx2,2:2:Ny2,2:2:Nz2);
URzy = UR2zy(2:2:Nx2,1:2:Ny2,2:2:Nz2);
URzz = UR2zz(2:2:Nx2,2:2:Ny2,1:2:Nz2);
2
⎛ wn ⎞ 2 2 2
⎜⎝ c ⎟⎠ = kx + ky + kz (4.122)
0
Figure 4.9 Illustration of the concept of numerical dispersion caused by the Yee grid. Despite
having the same frequency, the analytical
! !and numerical waves propagate at different velocities
characterized by the wave vectors k and k ′. The difference has been exaggerated in this figure
for illustration purposes.
an LHI medium. The following equations give the expression for a numerical plane
wave for the E mode.
− j ⎡⎣kx′ IΔx+ ky′ JΔy ⎤⎦
Ez = Ez0e (4.123)
I, J
In these expressions, the wave vector components are written with a prime
superscript to indicate that they are the numerical wave vector components for the
numerical wave that propagates at a slightly slower velocity than the physical wave.
Substituting these expressions into (4.61) to (4.63) written for an LHI medium
described by relative permeability μ r and relative permittivity ε r gives
Next, (4.126) is solved for H! x0 , (4.127) is solved for H! y0 , (4.128) is solved for Ez0,
and each of the new expressions is simplified to get
Ez0 ⎛ kʹ Δy ⎞
H! x0 = 2j sin ⎜ y ⎟ (4.129)
k0 mr Δy ⎝ 2 ⎠
Ez0 ⎛ kʹ Δx ⎞
H! y0 = − 2j sin ⎜ x ⎟ (4.130)
k0 mr Δx ⎝ 2 ⎠
H! y0 ⎛ kʹ Δx ⎞ H! x0 ⎛ kʹ Δy ⎞
Ez0 = 2j sin ⎜ x ⎟ − 2j sin ⎜ y ⎟ (4.131)
k0 er Δx ⎝ 2 ⎠ k0 er Δy ⎝ 2 ⎠
Last, (4.129) and (4.130) are substituted into (4.131) to arrive at the numerical dis-
persion relation for the E mode.
2 2
⎡2 ⎛ kxʹ Δx ⎞⎤ ⎡ 2 ⎛ kyʹ Δy ⎞⎤
k02 mr er = ⎢ sin ⎜ ⎟⎥ + ⎢ sin ⎜ ⎟⎥ (4.132)
⎣ Δx ⎝ 2 ⎠⎦ ⎢⎣ Δy ⎝ 2 ⎠⎥⎦
Recognizing that k0 = ω ∕c 0 and n = μ rε r, (4.132) can be written in a form that looks
more like the analytical dispersion relation in (4.122).
2 2 2
⎛ wn ⎞ ⎡ 2 ⎛ kx′ Δx ⎞ ⎤ ⎡ 2 ⎛ ky′ Δy ⎞ ⎤
⎜⎝ c ⎟⎠ = ⎢ Δx sin ⎜⎝ 2 ⎟⎠ ⎥ + ⎢ Δy sin ⎜ 2 ⎟ ⎥ (4.133)
0 ⎣ ⎦ ⎢⎣ ⎝ ⎠ ⎥⎦
Figure 4.10 shows the comparison of the numerical dispersion described by
(4.133) and the analytical dispersion described by (4.122) for a Yee grid where the
grid resolution is Δx = 0.35λ and Δy = 0.15λ , and the background refractive index
is n = 1.0. In this figure, the analytical and numerical wave vectors are plotted as
a function of direction. Larger values of k correspond to slower waves. Numerical
error in a simulation arises because these lines are different. Observe that numerical
dispersion is greatest in the directions with poorest grid resolution. In this case, the
grid resolution in the x-direction is around three times lower than the y-direction,
so the greatest discrepancy between the analytical and numerical waves are expe-
rienced in the x-direction.
Figure 4.10 Plot of analytical and numerical wave vectors as a function of direction on a two-
dimensional Yee grid where Δx = 0.35λ , Δy = 0.15λ , and n = 1.
The same numerical dispersion relation as (4.133) would be derived if the H mode
were analyzed. This is recommended as an exercise to the reader. It is straightfor-
ward to generalize the numerical dispersion relation to full three dimensions. This is
2 2 2 2
⎛ wn ⎞ ⎡ 2 ⎛ kx′ Δx ⎞ ⎤ ⎡ 2 ⎛ ky′ Δy ⎞ ⎤ ⎡ 2 ⎛ kz′ Δz ⎞ ⎤
⎜⎝ c ⎟⎠ = ⎢ Δx sin ⎜⎝ 2 ⎟⎠ ⎥ + ⎢ Δy sin ⎜ 2 ⎟ ⎥ + ⎢ Δz sin ⎜⎝ 2 ⎟⎠ ⎥ (4.134)
0 ⎣ ⎦ ⎢⎣ ⎝ ⎠ ⎥⎦ ⎣ ⎦
Observe that in the limit as Δx, Δy, and Δz approach zero, the numerical dis-
persion relation becomes exactly the analytical dispersion relation. This shows that
numerical dispersion can be reduced by decreasing the values of Δx, Δy, and Δz.
However, this would require more points on the grid, greater memory requirements,
and slower simulations. Other solutions include using finite-difference approxima-
tions with higher-order accuracy [5] or using a hexagonal grid [6, 7]. In Chapter 8,
an alternative technique will be presented to compensate for numerical dispersion
that does not require any of this.
To get a feel for the numbers, let n = 1, Δx = 0.1λ 0, and k′y = 0. Under these
conditions, (4.133) reduces to
10 ⎛ k′ l ⎞
1= sin ⎜ x 0 ⎟ (4.135)
p ⎝ 20 ⎠
The numerical wave vector component k′x differs from the analytical wave vec-
tor component kx by a constant ψ according to kx = ψ k′x. In addition, since n = 1
the analytical wave vector component is simply kx = k0 = 2π ∕ λ 0. Applying these
realizations to (4.135) gives
10 ⎛ p ⎞ (4.136)
1= sin ⎜
p ⎝ 10y ⎟⎠
References
[1] Yee, K., “Numerical Solution of Initial Boundary Value Problems Involving Maxwell’s
Equations in Isotropic Media,” IEEE Trans. on Antennas and Propagation, Vol. 14, No.
3, 1966, pp. 302–307.
[2] Taflove, A., and S. C. Hagness, Computational Electrodynamics: The Finite-Difference
Time-Domain Method, Norwood, MA: Artech House, 2005.
[3] Rumpf, R. C., “Engineering the Dispersion and Anisotropy of Periodic Electromagnetic
Structures,” Solid State Physics, Vol. 66, 2015, pp. 213–300.
[4] Rumpf, R. C., “Simple Implementation of Arbitrarily Shaped Total-Field/Scattered-Field
Regions in Finite-Difference Frequency-Domain,” Progress in Electromagnetics Research,
Vol. 36, 2012, pp. 221–248.
[5] Kuzu, L., “A Fourth-Order Accurate Compact 2-D FDFD Method for Waveguide
Problems,” Turkish Journal of Electrical Engineering & Computer Sciences, Vol. 23, No.
4, 2015, pp. 1001–1008.
[6] Aghaie, K. Z., S. Fan, and M. J. Digonnet, “Birefringence Analysis of Photonic-Bandgap
Fibers Using the Hexagonal Yee’s Cell,” IEEE J. of Quantum Electronics, Vol. 46, No.
6, 2010, pp. 920–930.
[7] Guo, S., et al., “Photonic Band Gap Analysis Using Finite-Difference Frequency-Domain
Method,” Optics Express, Vol. 12, No. 8, 2004, pp. 1741–1746.
This chapter will derive and describe how to implement a perfectly matched layer
(PML) absorbing boundary [1] in the finite-difference frequency-domain (FDFD)
method. The uniaxial PML (UPML) [2, 3] will be derived and explained how it
physically absorbs waves. The UPML will be incorporated into Maxwell’s equations
in a way that only entails modifying the permittivity and permeability arrays. This
simplifies things considerably because FDFD can be formulated and implemented
with minimal consideration of the UPML. Calculating the various PML parameters
will be covered afterward along with a MATLAB function that calculates the PML
terms and incorporates a UPML into the permittivity and permeability arrays for
FDFD. Last, the stretched-coordinate PML (SCPML) [4, 5] will be described that
is more complicated to implement, but improves the conditioning of the matrices,
allowing large and three-dimensional FDFD problems to be solved by iteration. The
SCPML will only be used in Chapter 10.
During the course of a simulation, waves will propagate outward until they reach
the boundaries of the grid. In most cases, it is desired to prevent the waves from
reflecting from the boundaries of the grid and reentering the simulation domain. If
reflections from the boundaries are not eliminated, it becomes difficult or impos-
sible to distinguish between what was reflected from a device being simulated from
what was reflected from the boundaries. The purpose of the absorbing boundary
is to make it appear as if the outward propagating waves keep propagating out to
infinity. Waves will be absorbed by incorporating loss into the outer cells of the
grid in a special way that does not produce additional reflections. Figure 5.1 shows
the field calculated from two FDFD simulations of a point source centered on the
grid. The only difference between the two simulations is the use of an absorbing
boundary. The field from the simulation without an absorbing boundary is com-
pletely crazy due to all of the reflections. Imagine if you were trying to calculate
something meaningful about a device from this simulation! When the absorbing
boundary is added, the cylindrical wave emitting from the point source is clear
and obvious.
An enormous amount of research has been carried out over the years to develop
an efficient absorbing boundary [6, 7]. Today, the PML [1, 8] has emerged as the
141
Figure 5.1 (a) FDFD simulation of a point source without an absorbing boundary. (b) Same
simulation with an absorbing boundary.
To absorb outgoing waves, the UPML will incorporate loss into the outer regions of
the simulation domain. However, this must be done in a special manner that does
not introduce reflections from the lossy regions themselves. The ideal absorbing
boundary will prevent reflections from itself and absorb waves for all polarizations
and all angles of incidence.
To see if this is even possible, examine the Fresnel equations in (5.1) that cal-
culate the reflection of a wave incident from the simulation domain (medium 1)
onto the absorbing layer (medium 2). In a simulation, the impedance of the simu-
lation domain η 1 is determined by what is being simulated, so η 1 is not a variable
that can be modified to implement the absorbing layer. In addition, the absorb-
ing layer must prevent reflections for all angles of incidence θ 1, so neither θ 1 nor
θ 2 are variables that the absorbing layer can modify. The only degree of freedom
that remains in these equations to implement an absorbing boundary is η 2 . After
a careful examination of (5.1), it becomes apparent that there is no choice for η 2
that will prevent reflections for both polarizations and all angles of incidence at
the same time.
More degrees of freedom are needed to achieve the ideal absorbing boundary. It
will turn out to be sufficient if the absorbing boundary is made doubly diagonally
anisotropic. This means that both the permittivity and permeability will have to
be made diagonally anisotropic as discussed in Chapter 2. It will then be shown
that the absorbing medium should actually have uniaxial anisotropy, leading to the
absorbing medium being called a UPML. It will be convenient to set the impedance
η 2 of the UPML equal to the vacuum impedance. The most straightforward way to
best match η 2 to vacuum for a general anisotropic medium is to set the permittivity
and permeability tensors equal to each other. Equation (5.2) defines a general tensor
for the UPML. The only things that remain to be determined are the tensor elements
a, b, and c. At this moment, the tensor is biaxial and not yet uniaxial because a, b,
and c may all be different values.
⎡ a 0 0 ⎤
⎡⎣ e2 ⎤⎦ = ⎡⎣ m2 ⎤⎦ = ⎢ 0 b 0 ⎥ (5.2)
⎢ 0 0 c ⎥
⎣ ⎦
The standard Fresnel equations for reflection can no longer be used because
those were only valid for isotropic media. Building on Figure 2.4(b), let the interface
between the simulation domain and the absorbing medium lie in the xy plane. When
a wave is an incident from vacuum onto this doubly-anisotropic medium, Snell’s
law of refraction and the Fresnel equations for reflection become [2]
From (5.3), refraction and reflection can be made independent of the angle of
incidence θ 1 if b and c are chosen such that bc = 1. With this choice, (5.3) and (5.4)
reduce to
q1 = q2 (5.5)
a− b b− a
rTE = rTM = (5.6)
a+ b b+ a
Observe that angles θ 1 and θ 2 have been completely eliminated from the modi-
fied Fresnel equations indicating that they are angle independent when bc = 1. From
(5.6), reflection for both polarizations can be made perfectly zero if a = b. Given
that the parameters a, b, and c are now related through a = b = 1/c, the tensor from
(5.2) can be written in terms of a single parameter. Any of the three variables can
be used, but (5.7) expresses the tensor using a.
⎡ ⎤
⎢ a 0 0 ⎥
⎢ ⎥
⎡⎣ e2 ⎤⎦ = ⎡⎣ m2 ⎤⎦ = ⎢ 0 a 0 ⎥ (5.7)
⎢ ⎥
⎢ 1 ⎥
⎢ 0 0 a ⎥
⎣ ⎦
Recall that this tensor was derived for a wave propagating primarily in the
z-direction. Instead of expressing the tensor using the variable a, it will be expressed
using the variable sz, where the z subscript indicates this is for a wave propagating
primarily in the z-direction incident onto a z-axis boundary.
⎡ ⎤
⎢ sz 0 0 ⎥
⎢ ⎥
⎢ ⎥
⎡⎣ e2 ⎤⎦ = ⎡⎣ m2 ⎤⎦ = ⎢ 0 sz 0 ⎥ For waves propagating in z-direction (5.8)
⎢ ⎥
⎢ 1 ⎥
⎢ 0 0 s ⎥
⎣ z ⎦
⎡ 1 ⎤
⎢ 0 0 ⎥
⎢ sx ⎥
⎢ ⎥
⎡⎣ e2 ⎤⎦ = ⎡⎣ m2 ⎤⎦ = ⎢ 0 sx 0 ⎥ For waves propagating in x-direction (5.9)
⎢ ⎥
⎢ ⎥
⎢ 0 0 sx ⎥
⎣ ⎦
The procedure can be repeated one last time for a wave propagating primarily
in the y-direction that is incident onto a y-axis boundary. This would lead to the
tensor elements being related through a = 1/b = c. This tensor will be expressed
using the variable sy.
⎡ ⎤
⎢ sy 0 0 ⎥
⎢ ⎥
⎢ 1 ⎥
⎡⎣ e2 ⎤⎦ = ⎡⎣ m2 ⎤⎦ = ⎢ 0 0 ⎥ For waves propagating in y-direction (5.10)
⎢ sy ⎥
⎢ ⎥
⎢ 0 0 sy ⎥
⎢⎣ ⎥⎦
Compare the elements in the tensors in (5.8) to (5.10). Each is uniaxial but the
position of the inverse PML term 1/si is different for each case along with the sub-
scripts on the PML terms. In order to absorb all waves at all boundaries, all of the
above tensors are multiplied to form a single tensor describing the UPML.
⎡ 1 ⎤⎡ ⎤⎡ ⎤
⎢ 0 0 ⎥ ⎢ sy 0 0 ⎥ ⎢ sz 0 0 ⎥
⎢ sx ⎥⎢ ⎥⎢ ⎥
⎢ ⎥⎢ 1 ⎥⎢ ⎥
⎡ er,UPML ⎤ = ⎡ mr,UPML ⎤ = [ S ] = ⎢ 0 sx 0 ⎥ ⎢ 0 0 ⎥ ⎢ 0 sz 0 ⎥
⎣ ⎦ ⎣ ⎦ sy ⎥⎢
⎢ ⎥⎢ ⎥
⎢ ⎥⎢ ⎥⎢ 1 ⎥
0 0 sx ⎥ ⎢ 0 0 sy ⎥ ⎢ 0 0
⎢
⎣ ⎦ ⎢⎣ ⎥⎦ ⎣ sz ⎥
⎦
⎡ ss ⎤ (5.11)
⎢ y z 0 0 ⎥
⎢ sx ⎥
⎢ sx sz ⎥
= ⎢ 0 0 ⎥
⎢ sy ⎥
⎢ sx sy ⎥
⎢ 0 0 ⎥
⎢ sz ⎥
⎣ ⎦
From this derivation, the UPML parameters sx, sy, and sz are interpreted as con-
stitutive parameters like permittivity and permeability. In Chapter 2, the loss was
incorporated into the permittivity through the electrical conductivity σ as ε ̃ = ε r +
σ /jωε 0. This gives the start of a recipe for how to make the UPML parameters have
a loss to absorb outgoing waves. This will be discussed in more detail in Section 5.4.
In the previous section, the UPML parameters were derived as constitutive param-
eters like permittivity and permeability. This implies the UPML parameters should
be incorporated into Maxwell’s equations the same way as the actual constitu-
tive parameters. With a UPML tensor [S], Maxwell’s curl equations are modified
according to
! !
∇ × E = − jw [ S ][ m ] H (5.12)
! !
∇ × H = jw [ S ][ e ] E (5.13)
When the tensor quantities are multiplied to combine them, (5.12) and (5.13)
are written as
! !
∇ × E = − jw [ m′ ] H (5.14)
! !
∇ × H = jw [ e ′ ] E (5.15)
where [μ ′] = [S][μ ] and [ε ′] = [S][ε ]. Observe that (5.14) and (5.15) have the same
form as the ordinary curl equations, as if there were no UPML incorporated. This
means that FDFD can be formulated and implemented with hardly considering the
UPML at all. This is the primary advantage of the UPML. Incorporating the UPML
will involve one simple step in the algorithm where the PML terms are incorporated
into the permittivity and permeability tensors according to
⎡ ss ⎤
⎢ y zm 0 0 ⎥
⎢ sx xx ⎥
⎢ sx sz ⎥
[ mʹ] = [S] [ m ] = ⎢ 0 sz yy
m 0 ⎥ (5.16)
⎢ ⎥
⎢ sx sy ⎥
⎢ 0 0 m ⎥
⎢⎣ sz zz ⎥⎦
⎡ ss ⎤
⎢ y ze 0 0 ⎥
⎢ sx xx ⎥
⎢ sx sz ⎥
[ eʹ] = [S] [ e ] = ⎢ 0 sy yy
e 0 ⎥ (5.17)
⎢ ⎥
⎢ sx sy ⎥
⎢ 0 0 e ⎥
⎢⎣ sz zz ⎥⎦
⎡ s ⎤
⎢ y mxx 0 0 ⎥
⎢ sx ⎥
⎢ s ⎥
[ m′ ] = [ S ][ m ] = ⎢ 0 sx myy 0 ⎥ (5.18)
⎢ y ⎥
⎢ ⎥
⎢ 0 0 sx sy mzz ⎥
⎢⎣ ⎥⎦
⎡ s ⎤
⎢ y exx 0 0 ⎥
⎢ sx ⎥
⎢ s ⎥
[ e′ ] = [ S ][ e ] = ⎢ 0 sx eyy 0 ⎥ (5.19)
⎢ y ⎥
⎢ ⎥
⎢ 0 0 sx sy ezz ⎥
⎢⎣ ⎥⎦
Up to this point, it has only been mentioned that the UPML parameters are complex
numbers to incorporate loss just like a complex permittivity. When incorporating
the loss, it is best to gradually increase the loss into the PML [10]. Numerical prob-
lems can arise at the entrance of an abrupt PML that cause reflections. In addition,
profiling the PML reduces reflections of waves that are incident onto the PML at
larger angles. With this in mind, there has been much research to determine the
best values and optimum profiles for the PML parameters [11–16]. If the UPML
terms are interpreted as constitutive parameters, they should be defined as such.
This implies that for the negative sign convention the imaginary part should be
negative, s = Re[s] − jIm[s]. Recognizing that k0 = w m0 e0 and η 0 = m0 /e0 , the
UPML term can be written as s = 1 − j η 0σ /k0. If the FDFD analysis is normalizing
its parameters properly, then λ 0 ≈ 1 and k0 ≈ 2π . Now the UPML term reduces to
s ≈ 1 − j60 σ . In order to taper this basic definition of s, the following equations
will be used for calculating the UPML terms.
sx ( x ) = ax ( x ) ⎡⎣1 − j60s x ( x ) ⎤⎦
(5.20)
sy ( y ) = ay ( y ) ⎡⎣1 − j60s y ( y ) ⎤⎦
The functions σ x(x) and σ y(y) quantify the artificial conductivity associated with
the UMPL and are not intended to represent physical conductivities associated with
devices in the simulation. Observe the UPML conductivities are functions of x and
y. This is because the UPML conductivities will be tapered from zero where a wave
enters the UPML up to some maximum value σ max at the far side of the UPML. For
this book, the following profile for the UPML conductivity functions will be used.
⎛ px ⎞
s x ( x ) = s max sin2 ⎜
⎝ 2Lx ⎟⎠
(5.21)
⎛ py ⎞
s y ( y ) = s max sin ⎜
2
⎟
⎝ 2Ly ⎠
In these equations, Lx is the physical size of the UPML extending in the x-direc-
tion and Ly is the physical size of the UPML extending in the y-direction. The ratios
x/L x and y/Ly are quantities that range from 0 to 1 from the start to the end of the
UPML. Interpreting the ratios this way will be very useful in the computer code
because the same ratios can be calculated directly from array indices without hav-
ing to calculate physical distance or size. The conductivity profiles σ x(x) and σ y(y)
calculated from (5.21) are shown in Figure 5.2. They are equal to zero through most
of the simulation domain and only become nonzero inside of the UPML regions.
The functions ax(x) and ay(y) in (5.20) scale the overall magnitude of the PML
functions sx(x) and sy(y). Even the amplitude functions are tapered following a
profile given in (5.22) which is controlled by the parameter p. The functions ax(x)
and ay(y) range from 1 where the wave enters the UPML up to some maximum
value amax at the end of the UPML. If visualized, they would look similar to that
shown in Figure 5.2, but would have a value of 1 throughout most of the simula-
tion domain and only being larger than 1 inside of the UPML regions. Observe
that (5.22) makes use of the same ratios x/L x and y/Ly that will be calculated from
array indices in the computer code.
p
⎛ x⎞
ax ( x ) = 1 + ( amax − 1) ⎜ ⎟
⎝ Lx ⎠
p (5.22)
⎛ y⎞
ay ( y ) = 1 + ( amax − 1) ⎜ ⎟
⎝ Ly ⎠
From (5.21) and (5.22), the UPML is defined from the parameters σ max, amax,
and p. In this book, the following values will be used: σ max = 1, amax = 4, and p =
3. The size of the UPML will not be defined in terms of physical size Lx and Ly.
Instead, to be consistent with calculating the ratios from array indices, the size
of the UPML will be defined in terms of the number of cells on the grid that the
UPMLs will occupy. For two-dimensional simulations, up to four UPML regions
will be defined. This is because a UPML will be needed at both sides of the grid
for both x- and y-axis boundaries. NXLO will define the number of cells large the
UPML is at the lower x-axis boundary, NXHI will define the number of cells large
the UPML is at the upper x-axis boundary, NYLO will define the number of cells
large the UPML is at the lower y-axis boundary, and NYHI will define the number
of cells large the UPML is at the upper y-axis boundary. The standard size for a
UPML is 10 to 20 cells. The larger the UPML regions, the better the UPMLs will
perform, but simulations will be larger, require more memory, and take more time
to calculate. The different UPML regions do not have to be the same size, but are
typically made to be the same size. The size of each UPML can be chosen based on
apriori knowledge of where more or less wave power will enter the UPMLs or to
more efficiently handle other special cases.
array ER2 on the 2× grid, the relative permeability array UR2 on the 2× grid, and an
array NPML defining the number of cells large for each of the four different UPML
regions on the Yee grid. The output arguments are the permittivity and permeability
diagonal tensor element arrays ERxx, ERyy, ERzz, URxx, URyy, and URzz on the Yee
grid with the UPML incorporated.
The addupml2d() function is initialized from lines 21 to 37. This section starts
by defining the parameters amax and σ max and profile parameter p that controls the
tapering of the UPML. In MATLAB, these parameters are named amax, cmax, and
p, respectively. Next, the size of the 2× grid is determined from the size of the array
ER2. Last, the size of the four different UPML regions is extracted individually from
the array NPML. Since the values in the array NPML are for the standard Yee grid and
not the 2× grid, each of the elements in NPML is multiplied by two to get the size of
the UPML regions on the 2× grid.
The real work in this function happens from lines 39 to 73 where the UPML
functions sx(x) and sy(y) are calculated as arrays sx and sy, respectively, on the 2×
grid. First, they are initialized to all ones, which are the correct values if no UPML
is incorporated. Next, each UPML region is built into sx and sy separately because
each region could potentially be of a different size. The boundary at nx=1 is called
the xlo UPML. To build the UPML here, a loop is a setup that iterates from nx=1
to nx=NXLO. If the UPML at the xlo side is 20 cells large, the loop will iterate from
1 to 20. The first two lines of code inside of the loop calculate the values of ax(x)
and σ x(x) according to (5.21) and (5.22). In MATLAB, the variables are called ax
and cx. The third, and last, line of code in the loop calculates sx(x) at the current
position in the UPML using (5.20). While the loop iterates from 1 to 20, the UPML
is filled in by the loop from right to left, or from 20 down to 1. This is the purpose
of the array index NXLO–nx+1 where the UPML function value is written at each
iteration of the loop. The next loop does essentially the same, but assigns values
to the array sx for the xhi UPML region. The last two loops repeat the first two
loops, but instead, assign values to the array sy since they are incorporating the
ylo and yhi UPML regions.
Lines 75 to 95 of the addupml2d() function calculate the tensor elements ε xx(x,y),
ε yy(x,y), ε zz(x,y), μ xx(x,y), μ yy(x,y), and μ zz(x,y). In MATLAB, the arrays are called
ERxx, ERyy, ERzz, URxx, URyy, and URzz, respectively. First, the tensor elements are
calculated on the 2× grid with the UPML parameters incorporated following (5.18)
and (5.19). Second, the tensor elements on the standard Yee grid are extracted from
the tensor elements on the 2× grid.
each axis boundary is defined on line 13. Due to the small size of the grid, the PML
was set to two cells large at each boundary. The materials arrays ER2 and UR2 are
set to all 1’s corresponding to vacuum on lines 15 to 17. These arrays are defined
on the 2× grid so the grid size parameters Nx and Ny were multiplied by two. The
addupml2d() function is called on lines 20 and 21 where the input arguments are
passed to the function, the UPML is incorporated, and the tensor elements are
returned in the arrays ERxx, ERyy, ERzz, URxx, URyy, and URzz.
1 % Chapter5_addumpl2d_demo.m
2
3 % INITIALIZE MATLAB
4 close all;
5 clc;
6 clear all;
7
8 % DEFINE GRID
9 Nx = 5;
10 Ny = 5;
11
12 % DEFINE PML
13 NPML = [2 2 2 2];
14
15 % BUILD ER2 AND UR2 ARRAYS
16 ER2 = ones(2*Nx,2*Ny);
17 UR2 = ones(2*Nx,2*Ny);
18
19 % CALL ADDUPML2D
20 [ERxx,ERyy,ERzz,URxx,URyy,URzz] ...
21 = addupml2d(ER2,UR2,NPML);
22
23 % DISPLAY THE RESULTS
24 disp(‘ERxx =’);
25 disp(ERxx);
26
27 disp(‘ERyy =’);
28 disp(ERyy);
29
30 disp(‘ERzz =’);
31 disp(ERzz);
32
33 disp(‘URxx =’);
34 disp(URxx);
35
36 disp(‘URyy =’);
37 disp(URyy);
38
39 disp(‘URzz =’);
40 disp(URzz);
The material tensors are displayed to the command window from lines 23 to
40. These are arrays and not matrices. The output of this program is
ERxx =
1.0–e+02 *
0.0207 – 0.0001i 0.0036 + 0.0000i 0.0000 + 0.0001i 0.0008 + 0.0001i 0.0100 + 0.0000i
0.2581 – 0.0250i 0.0444 – 0.0036i 0.0001 + 0.0011i 0.0100 + 0.0000i 0.1248 – 0.0117i
0.0400 – 2.4000i 0.0138 – 0.4125i 0.0100 + 0.0000i 0.0105 – 0.0920i 0.0227 – 1.1603i
0.0581 – 0.0010i 0.0100 + 0.0000i 0.0000 + 0.0002i 0.0022 + 0.0002i 0.0281 – 0.0004i
0.0100 + 0.0000i 0.0017 + 0.0000i 0.0000 + 0.0000i 0.0004 + 0.0000i 0.0048 + 0.0000i
ERyy =
1.0e+02 *
0.0207 – 0.0001i 0.2581 – 0.0250i 0.0400 – 2.4000i 0.0581 – 0.0010i 0.0100 + 0.0000i
0.0036 + 0.0000i 0.0444 – 0.0036i 0.0138 – 0.4125i 0.0100 + 0.0000i 0.0017 + 0.0000i
0.0000 + 0.0001i 0.0001 + 0.0011i 0.0100 + 0.0000i 0.0000 + 0.0002i 0.0000 + 0.0000i
0.0008 + 0.0001i 0.0100 + 0.0000i 0.0105 – 0.0920i 0.0022 + 0.0002i 0.0004 + 0.0000i
0.0100 + 0.0000i 0.1248 – 0.0117i 0.0227 – 1.1603i 0.0281 – 0.0004i 0.0048 + 0.0000i
ERzz =
1.0e+04 *
–5.7584 – 0.1920i –0.9894 – 0.0495i 0.0004 – 0.0240i –0.2203 – 0.0288i –2.7838 – 0.1008i
–0.9894 – 0.0495i –0.1700 – 0.0113i 0.0001 – 0.0041i –0.0378 – 0.0056i –0.4783 – 0.0253i
0.0004 – 0.0240i 0.0001 – 0.0041i 0.0001 + 0.0000i 0.0001 – 0.0009i 0.0002 – 0.0116i
–0.2203 – 0.0288i –0.0378 – 0.0056i 0.0001 – 0.0009i –0.0084 – 0.0019i –0.1065 – 0.0142i
–2.7838 – 0.1008i –0.4783 – 0.0253i 0.0002 – 0.0116i –0.1065 – 0.0142i –1.3458 – 0.0526i
URxx =
1.0e+02 *
0.0048 + 0.0000i 0.0004 + 0.0000i 0.0000 + 0.0000i 0.0017 + 0.0000i 0.0100 + 0.0000i
0.0281 – 0.0004i 0.0022 + 0.0002i 0.0000 + 0.0002i 0.0100 + 0.0000i 0.0581 – 0.0010i
0.0227 – 1.1603i 0.0105 – 0.0920i 0.0100 + 0.0000i 0.0138 – 0.4125i 0.0400 – 2.4000i
0.1248 – 0.0117i 0.0100 + 0.0000i 0.0001 + 0.0011i 0.0444 – 0.0036i 0.2581 – 0.0250i
0.0100 + 0.0000i 0.0008 + 0.0001i 0.0000 + 0.0001i 0.0036 + 0.0000i 0.0207 – 0.0001i
URyy =
1.0e+02 *
0.0048 + 0.0000i 0.0281 – 0.0004i 0.0227 – 1.1603i 0.1248 – 0.0117i 0.0100 + 0.0000i
0.0004 + 0.0000i 0.0022 + 0.0002i 0.0105 – 0.0920i 0.0100 + 0.0000i 0.0008 + 0.0001i
0.0000 + 0.0000i 0.0000 + 0.0002i 0.0100 + 0.0000i 0.0001 + 0.0011i 0.0000 + 0.0001i
0.0017 + 0.0000i 0.0100 + 0.0000i 0.0138 – 0.4125i 0.0444 – 0.0036i 0.0036 + 0.0000i
0.0100 + 0.0000i 0.0581 – 0.0010i 0.0400 – 2.4000i 0.2581 – 0.0250i 0.0207 – 0.0001i
URzz =
1.0e+04 *
–1.3458 – 0.0526i –0.1065 – 0.0142i 0.0002 – 0.0116i –0.4783 – 0.0253i –2.7838 – 0.1008i
–0.1065 – 0.0142i –0.0084 – 0.0019i 0.0001 – 0.0009i –0.0378 – 0.0056i –0.2203 – 0.0288i
0.0002 – 0.0116i 0.0001 – 0.0009i 0.0001 + 0.0000i 0.0001 – 0.0041i 0.0004 – 0.0240i
–0.4783 – 0.0253i –0.0378 – 0.0056i 0.0001 – 0.0041i –0.1700 – 0.0113i –0.9894 – 0.0495i
–2.7838 – 0.1008i –0.2203 – 0.0288i 0.0004 – 0.0240i –0.9894 – 0.0495i –5.7584 – 0.1920i
The SCPML is an absorbing boundary that will be needed for the FDFD codes
presented in Chapter 10. The SCPML will be presented by rearranging the terms of
the UPML and interpreting the terms differently. This conversion is not mathemati-
cally rigorous, but will help to understand the SCPML more intuitively. Equations
(5.12) and (5.13) show how the UPML is incorporated into Maxwell’s equations.
The SCPML is derived by moving the UPML tensor [S] to the left-hand side of the
equations and associating them with the curl operations.
! !
[S]−1 ∇ × E = −jw [ m ] H (5.23)
" !
[S]−1 ∇ × H! = jw [ e ] E (5.24)
⎡ sx ⎤⎡
⎢ 0 0 ⎥⎢ 0 − ∂ ∂ ⎤
⎢ sy sz ⎥⎢ ∂z ∂y ⎥ ⎡
⎢ ⎥⎢ ∂ ⎥ Ex ⎤ ⎡ m m m ⎤⎡ H ⎤
sy ∂ ⎥⎢ ⎥ ⎢ xx xy xz ⎥⎢ x ⎥
⎢ 0 0 ⎥⎢ 0 − ⎢ E ⎥ = − jw ⎢ myx myy myz ⎥ ⎢ Hy ⎥ (5.25)
⎢ sx sz ⎥ ⎢ ∂z ∂x ⎥ ⎢ y ⎥ ⎢ ⎥⎢ ⎥
⎥ E
⎢ sz ⎥ ⎢ − ∂ ∂ ⎢
⎣ z ⎥
⎦ ⎢⎣ mzx mzy mzz ⎥⎦ ⎢⎣ Hz ⎥⎦
⎢ 0 0 ⎥ ⎢ ∂y ∂x 0 ⎥
⎢⎣ sx sy ⎥ ⎣ ⎥⎦
⎦
⎡ sx ⎤⎡
⎢ 0 0 ⎥⎢ 0 − ∂ ∂ ⎤
⎢ sy sz ⎥⎢ ∂z ∂y ⎥ ⎡
⎢ ⎥⎢ ∂ ⎥ Hx ⎤ ⎡ e e e ⎤⎡ E ⎤
sy ∂ ⎥⎢ ⎥ ⎢ xx xy xz ⎥⎢ x ⎥
⎢ 0 0 ⎥⎢ 0 − ⎢ H ⎥ = jw ⎢ eyx eyy eyz ⎥ ⎢ Ey ⎥ (5.26)
⎢ sx sz ⎥ ⎢ ∂z ∂x ⎥ ⎢ y ⎥ ⎢ ⎥⎢ ⎥
⎥ H
⎢ sz ⎥ ⎢ − ∂ ∂ ⎥ ⎢⎣ z ⎥⎦ ⎢⎣ ezx ezy ezz ⎥⎦ ⎢⎣ Ez ⎥⎦
⎢ 0 0 ⎥ ⎢ ∂y ∂x 0
⎢⎣ sx sy ⎥ ⎣ ⎥⎦
⎦
Both of these equations have the same matrix multiplication on the left-hand
side. Multiplying these together incorporates the PML terms into the curl operation.
After reorganizing the terms, the result of the multiplication is
⎡ s ⎛ 1 ∂ ⎞ sx ⎛ 1 ∂ ⎞ ⎤
⎢ 0 − x⎜ ⎥
⎢ sy ⎝ sz ∂z ⎟⎠ sz ⎜⎝ sy ∂y ⎟⎠ ⎥
⎢ ⎥
⎢ sy ⎛ 1 ∂ ⎞ sy ⎛ 1 ∂ ⎞ ⎥
0 − (5.27)
⎜
⎢ s ⎝ s ∂z ⎠⎟ sz ⎜⎝ sx ∂x ⎟⎠ ⎥
⎢ x z ⎥
⎢ sz ⎛ 1 ∂ ⎞ sz ⎛ 1 ∂ ⎞ ⎥
⎢ − ⎜ ⎟ ⎜ ⎟ 0 ⎥
⎢⎣ sx ⎝ sy ∂y ⎠ sy ⎝ sx ∂x ⎠ ⎥⎦
Observe the PML terms that have been associated with the partial derivatives
in (5.27). ∂x is always multiplied by sx, ∂y is always multiplied by sy, and ∂z is
always multiplied by sz. Instead of interpreting the PML terms as lossy constitutive
parameters, they are interpreted as factors scaling the coordinates. It is hard to
visualize this because the coordinates are being scaled by complex numbers. At an
x-axis boundary, the parameter sx is scaling the x coordinates to absorb outgoing
waves. The parameters sy and sz are not contributing at x-axis boundaries because
they are just equal to 1 except in the small regions where the PMLs may overlap.
In this sense, sx by itself is sufficient to absorb outgoing waves at x-axis boundar-
ies. Similarly, only sy is needed to absorb outgoing waves at y-axis boundaries and
only sz is needed to absorb outgoing waves at z-axis boundaries. For these reasons,
the PML terms that are not scaling coordinates are dropped from the tensor. This
is a conceptual step and not a mathematically rigorous step that converts a UPML
into an SCPML. Equations (5.25) and (5.26) can now be written in their final form
for the SCPML.
⎡ 1 ∂ 1 ∂ ⎤
⎢ 0 − ⎥
⎢ sz ∂z sy ∂y ⎥⎡ E ⎤ ⎡ m ⎤⎡ H ⎤
m m
⎢ 1 ∂ 1 ∂ ⎥⎢ x ⎥ ⎢ xx xy xz ⎥⎢ x ⎥
⎢ 0 − ⎥ ⎢ Ey ⎥ = − jw ⎢ myx myy myz ⎥ ⎢ H y ⎥ (5.28)
⎢ zs ∂z sx
∂x ⎥⎢ ⎥ ⎢ ⎥⎢ ⎥
⎢ 1 ∂ 1 ∂ ⎥ ⎢⎣ Ez ⎥⎦ ⎢⎣ mzx mzy mzz ⎥⎦ ⎢⎣ Hz ⎥⎦
⎢ − 0 ⎥
⎢⎣ sy ∂y sx ∂x ⎥⎦
⎡ 1 ∂ 1 ∂ ⎤
⎢ 0 − ⎥
⎢ s ∂z s ∂y ⎥⎡ ⎤ ⎡ e ⎤⎡ ⎤
z y
e e
⎢ 1 ∂ 1 ∂ ⎥⎢ H x ⎥ ⎢ xx xy xz ⎥⎢ Ex ⎥
⎢ 0 − ⎥⎢ H y ⎥ = jw ⎢ eyx eyy eyz ⎥⎢ Ey ⎥ (5.29)
⎢ sz ∂z sx ∂x ⎥⎢ ⎥ ⎢ ⎥⎢ ⎥
⎢ 1 ∂ 1 ∂ ⎥⎢⎣ Hz ⎥⎦ ⎢⎣ ezx ezy ezz ⎥⎦⎢⎣ Ez ⎥⎦
⎢− 0 ⎥
⎢⎣ sy ∂y sx ∂x ⎥⎦
While the SCPML improves the conditioning of the FDFD matrices, the PML
terms cannot be absorbed into the permittivity and permeability. They must remain
distinct terms in the formulation of FDFD and so the formulation and implementa-
tion are more complicated. Fortunately, the calculation of the PML terms for the
SCPML remains the same as they were for the UPML.
1 % Chapter5_calcpml3d_demo.m
2
3 % INITIALIZE MATLAB
4 close all;
5 clc;
6 clear all;
7
8 % DEFINE INPUT ARGUMENTS
9 NGRID = [6 6 6];
10 NPML = [2 2 2 2 2 2];
11
12 % CALL CALCPML3D
13 [sx,sy,sz] = calcpml3d(NGRID,NPML);
14
15 % DISPLAY THE RESULTS
16 disp(‘sx =’);
17 disp(sx);
18
19 disp(‘sy =’);
20 disp(sy);
21
22 disp(‘sz =’);
23 disp(sz);
The SCPML arrays are displayed to the command window from lines 15 to 23.
These are arrays and not matrices. The output of this program is
sx =
(:,:,1) =
1.0e+02 *
0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i
0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i
0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i
0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i
0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i
0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i
(:,:,2) =
1.0e+02 *
0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i
0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i
0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i
0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i
0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i
0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i
(:,:,3) =
1.0e+02 *
0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i
0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i
0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i
0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i
0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i
0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i
(:,:,4) =
1.0e+02 *
0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i
0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i
0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i
0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i
0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i
0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i
(:,:,5) =
1.0e+02 *
0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i
0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i
0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i
0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i
0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i
0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i
(:,:,6) =
1.0e+02 *
0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i
0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i
0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i
0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0100 + 0.0000i
0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i 0.0138 – 0.4125i
0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i
sy =
(:,:,1) =
1.0e+02 *
0.0400 – 2.4000i 0.0138 – 0.4125i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0138 – 0.4125i 0.0400 – 2.4000i
0.0400 – 2.4000i 0.0138 – 0.4125i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0138 – 0.4125i 0.0400 – 2.4000i
0.0400 – 2.4000i 0.0138 – 0.4125i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0138 – 0.4125i 0.0400 – 2.4000i
0.0400 – 2.4000i 0.0138 – 0.4125i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0138 – 0.4125i 0.0400 – 2.4000i
0.0400 – 2.4000i 0.0138 – 0.4125i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0138 – 0.4125i 0.0400 – 2.4000i
0.0400 – 2.4000i 0.0138 – 0.4125i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0138 – 0.4125i 0.0400 – 2.4000i
(:,:,2) =
1.0e+02 *
0.0400 – 2.4000i 0.0138 – 0.4125i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0138 – 0.4125i 0.0400 – 2.4000i
0.0400 – 2.4000i 0.0138 – 0.4125i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0138 – 0.4125i 0.0400 – 2.4000i
0.0400 – 2.4000i 0.0138 – 0.4125i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0138 – 0.4125i 0.0400 – 2.4000i
0.0400 – 2.4000i 0.0138 – 0.4125i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0138 – 0.4125i 0.0400 – 2.4000i
0.0400 – 2.4000i 0.0138 – 0.4125i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0138 – 0.4125i 0.0400 – 2.4000i
0.0400 – 2.4000i 0.0138 – 0.4125i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0138 – 0.4125i 0.0400 – 2.4000i
(:,:,3) =
1.0e+02 *
0.0400 – 2.4000i 0.0138 – 0.4125i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0138 – 0.4125i 0.0400 – 2.4000i
0.0400 – 2.4000i 0.0138 – 0.4125i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0138 – 0.4125i 0.0400 – 2.4000i
0.0400 – 2.4000i 0.0138 – 0.4125i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0138 – 0.4125i 0.0400 – 2.4000i
0.0400 – 2.4000i 0.0138 – 0.4125i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0138 – 0.4125i 0.0400 – 2.4000i
0.0400 – 2.4000i 0.0138 – 0.4125i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0138 – 0.4125i 0.0400 – 2.4000i
0.0400 – 2.4000i 0.0138 – 0.4125i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0138 – 0.4125i 0.0400 – 2.4000i
(:,:,4) =
1.0e+02 *
0.0400 – 2.4000i 0.0138 – 0.4125i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0138 – 0.4125i 0.0400 – 2.4000i
0.0400 – 2.4000i 0.0138 – 0.4125i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0138 – 0.4125i 0.0400 – 2.4000i
0.0400 – 2.4000i 0.0138 – 0.4125i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0138 – 0.4125i 0.0400 – 2.4000i
0.0400 – 2.4000i 0.0138 – 0.4125i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0138 – 0.4125i 0.0400 – 2.4000i
0.0400 – 2.4000i 0.0138 – 0.4125i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0138 – 0.4125i 0.0400 – 2.4000i
0.0400 – 2.4000i 0.0138 – 0.4125i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0138 – 0.4125i 0.0400 – 2.4000i
(:,:,5) =
1.0e+02 *
0.0400 – 2.4000i 0.0138 – 0.4125i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0138 – 0.4125i 0.0400 – 2.4000i
0.0400 – 2.4000i 0.0138 – 0.4125i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0138 – 0.4125i 0.0400 – 2.4000i
0.0400 – 2.4000i 0.0138 – 0.4125i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0138 – 0.4125i 0.0400 – 2.4000i
0.0400 – 2.4000i 0.0138 – 0.4125i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0138 – 0.4125i 0.0400 – 2.4000i
0.0400 – 2.4000i 0.0138 – 0.4125i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0138 – 0.4125i 0.0400 – 2.4000i
0.0400 – 2.4000i 0.0138 – 0.4125i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0138 – 0.4125i 0.0400 – 2.4000i
(:,:,6) =
1.0e+02 *
0.0400 – 2.4000i 0.0138 – 0.4125i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0138 – 0.4125i 0.0400 – 2.4000i
0.0400 – 2.4000i 0.0138 – 0.4125i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0138 – 0.4125i 0.0400 – 2.4000i
0.0400 – 2.4000i 0.0138 – 0.4125i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0138 – 0.4125i 0.0400 – 2.4000i
0.0400 – 2.4000i 0.0138 – 0.4125i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0138 – 0.4125i 0.0400 – 2.4000i
0.0400 – 2.4000i 0.0138 – 0.4125i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0138 – 0.4125i 0.0400 – 2.4000i
0.0400 – 2.4000i 0.0138 – 0.4125i 0.0100 + 0.0000i 0.0100 + 0.0000i 0.0138 – 0.4125i 0.0400 – 2.4000i
sz =
(:,:,1) =
1.0e+02 *
0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i
0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i
0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i
0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i
0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i
0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i
(:,:,2) =
1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i
1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i
1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i
1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i
1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i
1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i
(:,:,3) =
1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i
1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i
1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i
1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i
1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i
1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i
(:,:,4) =
1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i
1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i
1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i
1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i
1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i
1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 + 0.0000i
(:,:,5) =
1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i
1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i
1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i
1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i
1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i
1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i 1.3750 –41.2500i
(:,:,6) =
1.0e+02 *
0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i
0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i
0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i
0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i
0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i
0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i 0.0400 – 2.4000i
References
[1] Bérenger, J.-P., “Perfectly Matched Layer (PML) for Computational Electromagnetics,”
Synthesis Lectures on Computational Electromagnetics, Vol. 2, No. 1, 2007, pp. 1–117.
[2] Sacks, Z. S., et al., “A Perfectly Matched Anisotropic Absorber for Use as an Absorbing
Boundary Condition,” IEEE Trans. on Antennas and Propagation, Vol. 43, No. 12, 1995,
pp. 1460–1463.
[3] Teixeira, F., and W. C. Chew, “Systematic Derivation of Anisotropic PML Absorbing
Media in Cylindrical and Spherical Coordinates,” IEEE Microwave and Guided Wave
Letters, Vol. 7, No. 11, 1997, pp. 371–373.
[4] Li, J., and J. Dai, “An Efficient Implementation of the Stretched Coordinate Perfectly
Matched Layer,” IEEE Microwave and Wireless Components Letters, Vol. 17, No. 5,
2007, pp. 322–324.
[5] Roden, J. A., and S. D. Gedney, “Convolution PML (CPML): An Efficient FDTD
Implementation of the CFS–PML for Arbitrary Media,” Microwave and Optical Technology
Letters, Vol. 27, No. 5, 2000, pp. 334–339.
[6] Antoine, X., E. Lorin, and Q. Tang, “A Friendly Review of Absorbing Boundary Conditions
and Perfectly Matched Layers for Classical and Relativistic Quantum Waves Equations,”
Molecular Physics, Vol. 115, No. 15–16, 2017, pp. 1861–1879.
[7] Mittra, R., et al., “A Review of Absorbing Boundary Conditions for Two and Three-
Dimensional Electromagnetic Scattering Problems,” IEEE Trans. on Magnetics, Vol. 25,
No. 4, 1989, pp. 3034–3039.
[8] Pled, F., and C. Desceliers, “Review and Recent Developments on the Perfectly Matched
Layer (PML) Method for the Numerical Modeling and Simulation of Elastic Wave
Propagation in Unbounded Domains,” Archives of Computational Methods in Engineering,
2021, pp. 1–48.
Let the geometry for analyzing a channel waveguide be as shown in Figure 6.1. The
cross section of the channel waveguide is in the xy plane while the guided mode
propagates in the z-direction. For hybrid mode analysis, Maxwell’s equations will
not be separated into two sets of equations. This means that all modes supported
by the waveguide will be calculated from the same eigenvalue equation, regardless
of how the mode is polarized.
The starting point in FDFD for all waveguide mode calculations is Maxwell’s
curl equations. The frequency will be known at the start so the free space wavenum-
ber k0 can be used to normalize the grid coordinates. From Chapter 4, Maxwell’s
curl equations expanded to
∂Ez ∂Ey
− = mxx H! x (6.1)
∂ y′ ∂z ′
∂Ex ∂Ez
− = myy H! y (6.2)
∂z ′ ∂ x′
161
∂Ey ∂Ex
− = mzz H! z (6.3)
∂ x′ ∂ y′
∂H! z ∂H! y
− = exx Ex (6.4)
∂ y′ ∂z ′
∂H! x ∂H! z
− = eyy Ey (6.5)
∂z ′ ∂ x′
∂H! y ∂H! x
− = ezz Ez (6.6)
∂ x′ ∂ y′
" "
where the magnetic field was normalized according to H! = − jh0H and the grid coor-
dinates were normalized according to x′ = k0 x, y′ = k0 y, and z′ = k0 z. As discussed
in Chapter 2, all guided modes will have the following form, but here the coordi-
nates and the magnetic field are normalized to be consistent with the formulation.
! !
E ( x′, y′, z′ ) = e ( x′, y′ ) e−gz′ /k0
! ! (6.7)
H" ( x′, y′, z′ ) = h" ( x′, y′ ) e−gz′ /k0
Substituting the form of the solution in (6.7) into (6.1) to (6.6) and simplifying gives
∂ez g
+ e = mxx h!x (6.8)
∂ y′ k0 y
g ∂e
− ex − z = myy h!y (6.9)
k0 ∂ x′
∂ey ∂ex
− = mzz h!z (6.10)
∂ x′ ∂ y ′
∂h!z g
+ h!y = exxex (6.11)
∂ y′ k0
g ! ∂h!
− hx − z = eyyey (6.12)
k0 ∂ x′
∂h!y ∂h!x
− = ezz ez (6.13)
∂ x′ ∂ y ′
In these equations, the analysis has reduced to just two dimensions because z′
was eliminated from the analysis. When the field components are made discrete in
the xy plane following the Yee grid scheme, the partial derivatives in each of the
above equations can be approximated using finite differences. In addition, observe
the ratio γ /k0 that appears in four of the above equations. Let this ratio define the
normalized complex propagation constant according to γ ̃ = γ /k0. The resulting set
of discrete equations with the normalized propagation constant is
ez − ez
+ ge = mxx i,j h!x
i,j+1 i,j
!y (6.14)
Δ y′ i,j i,j
ez − ez
− ge = myy h!y
i+1,j i,j
!x − (6.15)
i,j Δ x′ i,j i,j
ey − ey ex i,j+1 − ex i,j
= mzz h!z
i+1,j i,j
− (6.16)
Δ x′ Δ y′ i,j i,j
h!z − h!z
+ g!h!y = exx i,j ex i,j
i,j i,j−1
(6.17)
Δ y′ i,j
h!z − h!z
− g!h!x = eyy
i,j i−1,j
− e (6.18)
i,j Δ x′ i,j y i,j
! y = µ xx h! x
Dey′ez + ge (6.20)
! x − Dex′ez = µ yy h! y
− ge (6.21)
h! z = µ −1
zz (
Dex′e y − Dey′e x ) (6.26)
ez = ε −1
zz (D h !
h
x′ y
− D h! )
h
y′ x
(6.27)
Dey′ ε −1
zz(Dhx′ h! y − Dhy′ h! x + ge )
! y = µ xx h! x
(6.28)
− ge
! x − Dex′ ε −1
zz ( )
Dhx′ h! y − Dhy′ h! x = µ yy h! y
(6.29)
Dhy′ µ −1
zz( )
Dex′e y − Dey′e x + g!h! y = ε xxe x
(6.30)
− g! h! x − Dhx′ µ −1
zz ( )
Dex′e y − Dey′e x = ε yye y
(6.31)
Dex′ ε −1
zz y′ x (
Dh h! − Dex′ ε −1Dh + µ yy h! y = ge
zz x′
! x )
(6.32)
(D e −1 h
ε D
y′ zz y′ )
+ µ xx h! x − Dey′ ε −1Dh h! = ge
zz x′ y
! y
(6.33)
Dhx′ µ −1
zz y′ x (
De e − Dhx′ µ −1De + ε yy e y = g! h! x
zz x′ )
(6.34)
(D h −1 e
µ D
y′ zz y′ )
+ ε xx e x − Dhy′ µ −1De e = g! h! y
zz x′ y
(6.35)
Equations (6.32) and (6.33) can be combined into a single block matrix equation
as well as (6.34) and (6.35). These two block matrix equations are
⎡ h! x ⎤ ⎡ e ⎤
P⎢ ⎥ = g! ⎢ x ⎥ (6.36)
⎢ h! y ⎥ ⎢⎣ e y ⎥⎦
⎣ ⎦
⎡ ex ⎤ ⎡ h! ⎤
Q⎢ ⎥ = g! ⎢ x ⎥ (6.37)
⎢⎣ e y ⎥⎦ ⎢ h! ⎥
⎣ y ⎦
where
⎡
⎢
P = ⎢
Dex′ ε −1Dh
zz y′ (
− Dex′ ε −1Dh + µ yy
zz x′ ) ⎤⎥
De ε −1Dh + µ xx −Dey′ ε −1 Dh ⎥
⎢⎣ y′ zz y′ zz x′ ⎥⎦
(6.38)
⎡
Q = ⎢
Dhx′ µ −1De
zz y′ (
− Dhx′ µ −1De + ε yy
zz x′ ) ⎤⎥
⎢ Dh µ −1De + ε −DDhy′ µ −1De ⎥
⎢⎣ y′ zz y′ xx zz x′ ⎥⎦ (6.39)
To derive an eigenvalue problem in terms of just the electric field terms ex and
ey, first (6.37) is solved for the magnetic field terms h! x and h! y .
⎡ h! x ⎤ 1 ⎡ e x ⎤
⎢ ⎥ = Q⎢ ⎥
⎢ h! y ⎥ g! ⎢⎣ e y ⎥⎦
⎣ ⎦ (6.40)
Second, (6.40) is substituted into (6.36) to eliminate the magnetic field terms h! x
and h! y . This gives a matrix wave equation in the form of a standard eigenvalue
problem Av = λ v.
⎡ ex ⎤ ⎡ e ⎤
Ω2 ⎢ ⎥ = g! 2 ⎢ x ⎥
⎢⎣ e y ⎥⎦ ⎢⎣ e y ⎥⎦
(6.41)
Ω2 = PQ (6.42)
This general “PQ” form of the eigenvalue problem arises in other methods like
the method of lines and rigorous coupled-wave analysis [1]. Solving eigenvalue prob-
lems is a huge and involved topic. Fortunately, MATLAB makes this very simple, and
(6.41) is solved as simple as [V,D]=eigs(OMEGASQ) where OMEGASQ is a sparse matrix
defined in (6.42). When (6.41) is solved as an eigenvalue problem, two matrices are
calculated. The eigenvector matrix V contains the electric field components of the
!
modes along its columns. That is, the mth column of V is em (x, y) that contains
ex,m(x,y) and ey,m(x,y). The eigenvalue matrix D contains the eigenvalues g! 2 along
its diagonal. In this case, the eigenvalues are the squares of the normalized complex
propagation constants for the guided modes because (6.41) is arranged such that g! 2
is the eigenvalue. Eigenvectors and eigenvalues always come in pairs. The mth col-
umn in the eigenvector matrix must always be kept with the mth eigenvalue. Given
the eigenvalue g! m
2
of the mth guided mode, the complex propagation constant γ m,
attenuation coefficient α m, phase constant β m, and effective refractive index nm,eff
are calculated as follows.
g m = k0 g! m
2
(6.43)
am = Re ⎡⎣ g m ⎤⎦ (6.44)
bm = Im ⎡⎣ g m ⎤⎦ (6.45)
gm
nm,eff = (6.46)
jk0
If needed, the magnetic field components h!x (x, y) and h!y (x, y) can be calculated
from the solution using (6.40). The longitudinal components h!z (x, y) and ez(x,y) can
be calculated using (6.26) and (6.27), respectively.
Let the geometry for analyzing a slab waveguide be as shown in Figure 6.2. Let
the cross section of the slab waveguide be in the x-direction while the guided mode
propagates in the z-direction. In this configuration, the slab waveguide and the
guided mode itself will be uniform and unchanging in the y-direction. This means
that any derivative with respect to y must be equal to zero because nothing changes
in the y-direction. Under this condition, Dey′ = Dhy′ = 0 and (6.20) to (6.25) reduce to
! y = µ xx h! x
ge (6.47)
! x − Dex′ez = µ yy h! y
− ge (6.48)
Dex′e y = µ zz h! z (6.49)
g! h! y = ε xxe x (6.50)
Dhx′ h! y = ε zz ez (6.52)
! y = µ xx h! x
ge (6.54)
Dex′e y = µ zz h! z (6.55)
The first step to derive the matrix wave equation in the form of an eigenvalue
problem is to solve (6.54) for h! x and solve (6.55) for h! z . This gives
h! x = g! µ −1 e (6.56)
xx y
h! z = µ −1De e
zz x′ y
(6.57)
The second step is to substitute the above expressions into (6.53) to eliminate
the terms h! x and h! z and then rearrange the equation into the form of a generalized
eigenvalue problem Av = λ Bv. This is solved in the same manner as for hybrid mode
analysis and is given by
(
− Dhx′ µ −1
zz x′ )
De + ε yy e y = g! 2 µ −1 e
xx y
(6.58)
! x − Dex′ez = µ yy h! y
− ge (6.59)
g! h! y = ε xxe x (6.60)
Dhx′ h! y = ε zz ez (6.61)
The first step to derive the matrix wave equation in the form of an eigenvalue
problem is to solve (6.60) for ex and solve (6.61) for ez.
e x = g! ε −1 h! (6.62)
xx y
ez = ε −1Dh h!
zz x′ y
(6.63)
The second step is to substitute the above expressions into (6.59) to eliminate
the terms ex and ez and then rearrange the equation into the form of a generalized
eigenvalue problem Av = λ Bv. This is solved in the same manner as for hybrid mode
analysis and is given by
(
− Dex′ ε −1
zz x′ )
Dh + µ yy h! y = g! 2 ε −1 h!
xx y
(6.64)
Unlike E mode analysis, the B matrix is permittivity which will likely never
be equal to that of a vacuum so (6.64) will rarely reduce to a standard eigenvalue
problem. After the eigenvalue problem is solved, the guided mode parameters are
calculated the same as for hybrid mode analysis using (6.43) to (6.46). That is
because the eigenvalue problem for slab waveguide analysis has the same eigenvalue.
Figure 6.3 Slab waveguide analysis for modes propagating in the +x-direction.
direction can be either in the y-direction or the z-direction. Each choice leads to
a different formulation for both the E and H modes and these are summarized in
Figure 6.3.
For slab modes propagating in the +y-direction in a slab waveguide, the uniform
direction can be either in the x-direction or the z-direction. The formulations for
both the E and H modes for this case are summarized in Figure 6.4.
For slab modes propagating in the +z-direction in a slab waveguide, the uniform
direction can be either in the x-direction or the y-direction. The formulations for
both the E and H modes for this case are summarized in Figure 6.5.
Figure 6.4 Slab waveguide analysis for modes propagating in the +y-direction.
Figure 6.5 Slab waveguide analysis for modes propagating in the +z-direction.
resonator depicted in Figure 6.6. This OIC leads to a very large and three-dimen-
sional simulation that would be very computationally intensive to perform rigor-
ously. Instead, the OIC can be reduced to a two-dimensional representation using
the EIM [2]. To do this, the circuit is interpreted as being composed of two regions.
The first region is away from the rib waveguide and is composed of the substrate,
a thin high-index film on the surface, and the air above. The second region comes
from on the rib waveguide and is composed of the substrate, the thin high-index
film, a high-index rib on top of the film, and the air above. Both regions are analyzed
as a slab waveguide to determine the effective refractive index of the fundamental
mode. Recall from Chapter 2 that the fundamental mode is the guided mode with
the lowest cutoff frequency. The effective refractive index of the off-waveguide
region is neff1 and the effective refractive index of the on-waveguide region is neff2 .
These analyses and the resulting fundamental mode calculated for each region are
illustrated on the right of Figure 6.6.
Given the two effective refractive indices, a model of the circuit can be con-
structed in two dimensions as illustrated at the bottom left of Figure 6.6. This
two-dimensional representation can be thought of as sort of a top view of the three-
dimensional OIC and is constructed from the two effective refractive indices. While
this two-dimensional model is not a rigorous representation of the three-dimensional
OIC, it is orders of magnitude less computationally intensive while maintaining
very good accuracy [2]. In some cases, the regions chosen may not support a guided
mode or not even be a slab waveguide at all. In this case, any reasonable estimate
of the average refractive index can still provide good results that match well with
a three-dimensional simulation.
For best accuracy, it is important to carefully consider whether E or H mode
analysis should be performed to ensure the correct polarization is used through-
out the entire analysis. For example, the OIC depicted in Figure 6.6 shows the rib
waveguide is to be illuminated with a vertically polarized mode. To be consistent,
the slab waveguide analysis should be H mode to allow the electric field to be in the
z-direction. The E mode would place the electric field solely in the x-direction, so the
E mode is not a correct choice. The two-dimensional simulation of the OIC should
be E mode to place the electric field perpendicular to the plane of the OIC. Following
a similar line of reasoning, if the rib waveguide mode were horizontally polarized,
the slab waveguide analyses would need to be E mode while the two-dimensional
simulation of the OIC would need to be H mode. Be careful when applying the EIM
because identifying the correct polarizations can be tricky!
Calculating guided modes using FDFD consists of three major steps, as illustrated
in Figure 6.7. Step 1 calculates everything that is needed for the FDFD analysis
and starts by initializing MATLAB. It is followed by the dashboard where all of
the parameters are defined that control the simulation. The program then moves
on to calculating the grid, which includes the number of cells and the resolution.
With the grid calculated, the waveguide is built onto the grid producing the tensor
arrays ERxx, ERyy, ERzz, URxx, URyy, and URzz used to build the eigenvalue problem
in the FDFD method.
With the simulation setup, the code goes on to perform the actual FDFD analysis.
Everything in this section of code works toward solving the eigenvalue problem. It
starts by reshaping the materials arrays into diagonal matrices and then building the
derivative matrices. From here, the eigenvalue problem is constructed. For hybrid
mode analysis, this entails calculating P, Q, and then Ω 2 using (6.38), (6.39), and
(6.42), respectively. For slab waveguide analysis, this entails calculating the A and
B matrices in (6.58) for the E mode or (6.64) for the H mode. When the eigenvalue
problem is constructed, it is solved using the MATLAB function eigs() to calculate
the eigenvectors and eigenvalues, referred to collectively as the eigenmodes. It is
less efficient and usually unnecessary to calculate all possible eigenmodes. Instead,
it is best to calculate only a small set of eigenmodes. If a good guess can be made
for the eigenvalue g!0 of the fundamental mode, it is possible to calculate only a
2
small set of eigenmodes with eigenvalues closest to g!0 . The small set will be the
2
index of the core. For other waveguides, some experimentation may be needed to
determine a good guess for the eigenvalue of the fundamental mode.
Last, the eigenmodes are analyzed and postprocessed to extract meaning from
the analysis. Oftentimes, this starts by calculating the various mode parameters
like the complex propagation constant γ , attenuation coefficient α , phase constant
β , and/or the effective refractive index neff. Each guided mode will have its own set
of parameters and they can be calculated from the eigenvalue g! m using (6.43) to
2
(6.46). The field terms are extracted from the columns of the eigenvector matrix.
If needed, the other field components can be calculated. A typical guided mode
calculation will end by visualizing the fields of the guided modes.
Figure 6.8 Geometry and coordinate setup for SoI rib waveguide. The dimensions are w = 0.8
μm, h = 0.6 μm, and t = 0.6 μm. The refractive indices are n1 = 1.0, n2 = 3.5, and n3 = 1.5. The
waveguide is analyzed at free space wavelength λ 0 = 1.55 μm.
the coordinate axes, dimensions, refractive indices, and the amplitude profile of the
fundamental mode supported by the rib waveguide.
The analysis will be performed at the free space wavelength λ 0 = 1.55 μm, as
this is a standard wavelength for telecommunications [7]. The region above the
waveguide is called the superstrate and is air in this example. Air will be assigned
a refractive index of n1 = 1.0. The middle layer and rib are made of silicon (Si)
which has a refractive index close to n2 = 3.5. The region below the waveguide is
called the substrate and is silicon dioxide (SiO2) in this example. The substrate will
be assigned a refractive index of n3 = 1.5. The width of the rib is w = 0.8 μm, the
height of the rib is h = 0.6 μm, and the thickness of the silicon layer away from the
rib is t = 0.6 μm.
The MATLAB code to analyze this rib waveguide can be downloaded at https://
empossible.net/fdfdbook/ and is called Chapter6_ribwaveguide.m. The code begins
with the header from lines 1 to 11. The first line is the name of the MATLAB file. In
this case, the file is saved as “Chapter 6_ribwaveguide.m.” The first task performed
is initializing MATLAB. This consists of close all to close any figure windows
that may happen to be open, clc to clear the command window, and the most
important clear all that clears all variables from memory. Next, the units used in
the simulation are defined. For photonic waveguide analysis, micrometers is set to
1. Any other units, such as nanometers, should be defined relative to micrometers.
The next section of the code from lines 12 to 33 is the dashboard. The dashboard
contains all of the parameters that define and control the simulation. Parameters
to be defined inside of the dashboard include the free space wavelength, waveguide
parameters such as dimensions and refractive indices, and grid parameters that
control the size and resolution of the grid.
The FDFD analysis here calculates the set of modes that the waveguide can
support so the analysis does not require a source. However, the free space wave-
length lam0 for the analysis must still be defined. The parameter lam0 is the first
thing defined in this dashboard on line 17. The second set of parameters defines
everything that is needed about the waveguide in order to calculate the modes it
supports. This includes the refractive index of the superstrate rib_n1, refractive
index of the core rib_n2, refractive index of the substrate rib_n3, height of the rib
rib_h, thickness of the silicon layer away from the rib rib_t, and width of the rib
rib_w. These parameters are as consistent as possible with those shown in Figure
6.8. The reason for the rib_ prefix is to avoid using common variable names that
may accidentally get overwritten with different information later in the code. The
third set of parameters defines everything that is needed to calculate the grid. The
first parameter nmax is the largest refractive index that will be assigned to any cells
on the grid. This is needed in order to determine the smallest wavelength the analy-
sis will be required to resolve, λ min = λ 0/nmax. The second parameter is NRES. This
is the number of points that will be used to resolve the shortest wavelength λ min.
Higher values will improve accuracy by resolving the problem with more points,
but the calculations will require more memory and take more time to run. Values
in the range of 10 to 40 are typical, but it is necessary to test for convergence to be
sure that sufficient resolution is being used. Last, it is necessary to put some space
around the rib waveguide so that the guided mode decays to zero before reaching
the boundary. This allows simple Dirichlet boundary conditions to be used. Peri-
odic boundary conditions cannot be used since the guided mode is not periodic.
SPACER is an array containing four numbers that define how much space there will
be from the edge of the waveguide to the four grid boundaries. The first number in
SPACER is the amount of space on the left of the waveguide, the second number is
the amount of space on the right, the third number is the amount of space above,
and the fourth number is the amount of space below. In the code, the air superstrate
will occupy the entire spacer region above the waveguide. The substrate with refrac-
tive index n3 will occupy the entire spacer region below the waveguide. The last
parameter defined in the dashboard is the number of modes to calculate NMODES. If
the grid has 200 by 100 points, 20,000 modes will be calculated unless specified
otherwise. Calculation time is greatly improved when only a subset is calculated.
In this case, three modes will be calculated. If the number of supported modes is
to be determined, NMODES will need to be increased until the additional modes are
clearly not guided modes. Identifying which modes are guided and which are not
will be discussed near the end of this section.
The next section of code from lines 35 to 66 calculates the grid for the wave-
guide analysis. This includes the number of cells on the grid, Nx and Ny, as well as
the grid resolution parameters, dx and dy. The first thing in this section is to calcu-
late preliminary values for the grid resolution parameters. The parameters dx and
dy will be adjusted in the second step. Lines 40 and 41 set the preliminary value
for both dx and dy equal to the minimum wavelength lam0/nmax divided by NRES.
This calculation does not consider the dimensions of the waveguide at all so it is
highly likely that the dimensions will not match the grid perfectly. In fact, at this
point in the code, the width of the rib is 36.13 cells wide. Since it is not possible to
fill in a fraction of a cell, the simulation will not accurately represent the width of
the rib. Lines 43 to 47 adjust dx and dy so that the most critical dimensions of the
waveguide are represented exactly by an integer number of cells on the grid. This
practice greatly improves the convergence rate of the simulation so it will be pos-
sible to achieve high accuracy with a minimum number of cells on the grid. To do
this, a critical dimension is chosen for each axis. For the x-direction, the critical
dimension is chosen to be rib_w because it was the only dimension to choose. Given
the critical dimension, the number of cells representing that dimension is calculated
and rounded up to the nearest integer according to nx = ceil(rib_w/dx). The
resolution parameter is then adjusted by recalculating it as the critical dimension
divided by the number of cells just calculated according to dx = rib_w/nx. When
done correctly, rib_w will be exactly equal to nx*dx. For the y-direction, it is not
clear whether rib_t or rib_h is the critical dimension so rib_t was chosen. The
number of cells representing this dimension is calculated and rounded up to the
nearest integer according to ny = ceil(rib_t/dy). The resolution parameter is
then adjusted by recalculating it as the critical dimension divided by the number of
cells just calculated according to dy = rib_t/ny. When done correctly, rib_t will
exactly equal ny*dy. Some experimentation with the analysis can give clues about
what may be the most important dimension to resolve exactly. After this step, both
dx and dy will usually be slightly smaller than they were initially calculated. Next,
the size of the grid is calculated on lines 49 to 56. First, the physical width of the
grid Sx is calculated on line 50 as the leftmost SPACER region plus the width of the
rib plus the rightmost SPACER region. From this, the numerical size of the grid, or the
number of grid cells wide, is calculated on line 51 by dividing the physical width by
the cell size and rounding up to the nearest integer. Due to the rounding operation,
the physical size of the grid may be slightly off so it is recalculated on line 52 as the
number of cells wide multiplied by the cell size. The same actions are performed
for the vertical size of the grid from lines 54 to 56, but the size of the waveguide is
the height of the rib plus the thickness of the silicon layer. At this point, the grid is
calculated. If needed, the 2× grid parameters are calculated followed by the axis
vectors to be used for graphics and visualization.
The next section of code from lines 68 to 98 builds the rib waveguide onto
the Yee grid. This is done by building the rib waveguide onto the 2× grid and then
extracting the permittivity and permeability tensor arrays on the Yee grid from the
2× grid. Before anything is added to the 2× grid, the permittivity and permeability
arrays ER2 and UR2 on the 2× grid are initialized to air on lines 73 and 74. Observe
that the refractive index is squared because it is relative permittivity that must be
assigned to points on the grid, not the refractive index. The two are related through
ε r = n2. Forgetting to square the refractive index is one of the most common mistakes
made in photonic FDFD simulations.
The second task is to calculate the array indices of where the structures of the
waveguide begin and end on the 2× grid. This is implemented on lines 76 to 84.
The overall grid strategy for this is illustrated in Figure 6.9 showing the spacer
regions around the rib waveguide, the refractive indices, and the array indices. It
is highly recommended to draw a figure like this before building anything onto a
grid. Observe that nx1 and nx2 are the array indices for where the rib part of the
waveguide begins and ends in the x-direction. The array index nx1 is calculated as
one plus the number the cells wide of the leftmost spacer region. The +1 is included
so that the left side of the device is outside of the left spacer region. There is no need
to get nx1 exact to anything. What is important is that nx2 is located correctly rela-
tive to nx1. The array index nx2 is calculated as nx1 plus the number of cells wide
for the rib round(rib_w/dx) rounded to the nearest integer minus one. As described
in Chapter 1, the minus one is required so that the dimension is not one cell greater
Figure 6.9 Grid strategy for modeling a rib waveguide on the 2× grid.
than intended. While one cell may seem small and insignificant, being one cell off
can greatly affect the convergence rate and accuracy of some devices. Similarly, the
vertical array indices ny1, ny2, ny3, ny4, and ny5 are calculated.
From here, it is an easy task to assign permittivity values to the 2× grid. The
rib is added first on line 87, followed by the silicon layer on line 88, followed by the
substrate on line 89. There is no need to assign values for the superstrate because the
array ER2 was initialized with the relative permittivity of the superstrate. Observe
on line 89 the array is filled from ny5 to Ny2 in the y-direction because Ny2 is the
array index for the bottom of the grid. The last task from lines 91 to 98 is to extract
the tensors arrays on the Yee grid from the 2× arrays. ERxx, ERyy, and ERzz are
extracted from ER2 while URxx, URyy, and URzz are extracted from UR2.
With the grid setup and waveguide constructed onto the Yee grid, it is time to
perform the FDFD analysis of the waveguide. This section of code from lines 100
to 141 is generic, and the same code can be used to calculate the hybrid modes of
any waveguide. Before the matrices for the eigenvalue problem can be calculated,
the tensor arrays must be converted to diagonal matrices. For ERxx, this is done by
reshaping the array to a column vector via ERxx(:), declaring it as a sparse matrix
via sparse(ERxx(:)), and then inserting it as a diagonal into a square matrix via
diag(sparse(ERxx(:))). This last step creates a sparse matrix by default. It is very
important not to reverse the order of the sparse() and diag() commands as this
will temporarily create a full matrix that will consume a lot of memory and take a
long time to process if not crash the computer. The same operation is done for all
the material tensor arrays to convert them to diagonal matrices. In this code, the
same variable names are used so the two-dimensional arrays are overwritten by
the diagonal matrices. Next, the derivative matrices are constructed on lines 112 to
117 by calling the function yeeder2d() described in Chapter 4. NS is an array con-
taining the size of the grid Nx and Ny, RES is an array containing the grid resolution
parameters dx and dy, and BC is an array containing numbers that define the bound-
ary conditions to be used. For waveguide analysis, it is common to use Dirichlet
boundary conditions so BC is set to [0 0]. The formulation used normalized grid
coordinates so the input argument RES is multiplied by the free space wavenumber
k0 to pass normalized grid resolution terms to yeeder2d().
Given the diagonal materials matrices and the derivative matrices, the matrices
for the eigenvalue problem are calculated on lines 119 to 123. This is done by first
calculating the intermediate matrices P and Q and then calculating the matrix for the
eigenvalue problem as P*Q. Rather than waste memory storing the P*Q matrix, the
product is used as the input argument to eigs() on line 127. The function eigs()
is built into MATLAB to solve eigenvalue problems of sparse matrices. There are
many different ways this function can be used and many different options for using
it. For this example, three input arguments are passed to the function. The first input
argument is the matrix P*Q. The second input argument is the number of modes to
calculate from the eigenvalue problem. The parameter NMODES was defined in the
dashboard to be 3, so three modes will be calculated that have eigenvalues clos-
est to the value given as the third input argument. Thus, the third input argument
needs to be set to the best guess for the eigenvalues of the guided modes. Recall
from Chapter 2 for dielectric waveguides that the effective refractive index is close
to the average refractive index calculated over the area of the guided mode. Given
that the modes reside mostly inside of the silicon material, n2 is a decent estimate
of the effective refractive index of the guided modes. However, the eigenvalues are
not the effective refractive index. From (6.43) and (6.46), the eigenvalue that would
correspond to an effective index of n2 is
g! 2 ≈ −n22 (6.65)
The function eigs() will then return two matrices that are called Exy and D2 in
the MATLAB code. If there are M total cells on the grid, the eigenvector matrix Exy
will have 2M rows and NMODES number of columns. Each column in Exy contains
the ex and ey column vectors from (6.41). The matrix D2 will be NMODES×NMODES
and contain the eigenvalues along its center diagonal. Eigenvectors and eigenvalues
come in pairs, so the mth column in Exy corresponds to the eigenvalue in the mth
diagonal position of D2. For three modes, these matrices have the form below.
⎡ g! 2 0 0 ⎤
⎡ ⎡ e x,1 ⎤ ⎡ e x,2 ⎤ ⎡ e x,3 ⎤⎤ ⎢ 1 ⎥
E xy = ⎢⎢ ⎥⎢ ⎥⎢ ⎥⎥ D2 = ⎢ 0 g! 22 0 ⎥ (6.66)
⎢ ⎢⎣ e y,1 ⎥⎦ ⎢⎣ e y,2 ⎥⎦ ⎢⎣ e y,3 ⎥⎦ ⎥⎦ ⎢ 0 0 g! 2 ⎥
⎣
⎢⎣ 3 ⎥⎦
⎡ g! 0 0 ⎤
⎢ 1 ⎥
D= D = ⎢ 0 g! 2 0 ⎥
2
(6.67)
⎢ 0 0 g!3 ⎥
⎣ ⎦
Figure 6.10 First three eigenmodes from the FDFD analysis of a rib waveguide. Gray shading
conveys field amplitude and black arrows convey polarization. The first two modes are guided
modes because their power is confined to the rib region. The third mode is not a guided mode
because it has power increasing away from the rib region.
The first three eigenmodes calculated from this analysis and the effective
refractive index for each are shown in Figure 6.10. In this figure, the gray shading
conveys the amplitude of the electric field calculated as sqrt(Ex.^2 + Ey.^2).
Simply by inspecting the images of the modes, it is evident that only the first two
modes are guided by the rib waveguide. This is evident because the field power of
these modes is clearly confined to the vicinity of the rib. The third eigenmode has
power increasing away from the rib and reaching a maximum value at the grid
boundary. This is not a mode guided by the rib waveguide so it can be concluded
that this rib waveguide supports only two modes. It is generally desired to adjust
the design of the waveguide so that only a single mode is supported and this finite-
difference analysis is a great tool for doing this.
So, what is the meaning of the third eigenmode? Dirichlet boundary conditions
were used so it is almost like the rib waveguide is encased inside of a very large
metal waveguide. It is not exactly a metal waveguide because the two boundaries
where Dirichlet boundary conditions were applied to the magnetic fields make those
boundaries a perfect magnetic conductor (PMC). At the other two boundaries,
Dirichlet boundary conditions were applied to the electric fields so those boundaries
have a perfect electric conductor (PEC). Only a PEC acts like a true metal. The third
eigenmode calculated by this analysis is a mode guided by the larger waveguide,
but this does not have any physical meaning related to the rib waveguide and is
just ignored.
Figure 6.11 Dielectric slab waveguide where n2 > n1 and n2 > n3.
of generality, the propagation direction is set to the z-direction and the cross section
of the waveguide is placed in the x-direction. The figure shows the waveguide, the
coordinate axes, dimensions, and refractive indices. To support guided modes, the
core must have a refractive index higher than both the substrate and superstrate.
The substrate and superstrate can have different refractive indices, but both must
be less than the core refractive index in order to form a waveguide. The thickness
a of the core is the only dimension needed to define the slab waveguide. If n1 ≠ n3,
there will be some minimum value of a below which the slab waveguide will not
support any guided modes. The dimension b is provided to ensure the superstrate
and substrate regions are large enough to accurately analyze the waveguide. Dirichlet
boundary conditions were used at the extreme top and bottom of the grid. These
must be sufficiently far away from the core so that the guided modes decay to zero
well before reaching the boundaries of the grid. Typically, b > 3λ 0. For this analy-
sis, the top spacer region will be the medium above the core filled with refractive
index n1 and the bottom spacer region will be the medium below the core filled
with refractive index n3.
The analysis will be performed at the free space wavelength λ 0 = 1.55 μm. The
superstrate will be air (n1 = 1.0), the core region will be silicon nitride (n2 = 2.0),
and the substrate will be fused silica (n3 = 1.5). The thickness of the slab will be a =
1500 nm. A correct choice for b will be determined through simulation, but a good
guess to start with is three wavelengths b = 3λ 0. The MATLAB code to analyze this
slab waveguide can be downloaded at https://empossible.net/fdfdbook/ and is called
Chapter6_slabwaveguide.m. The program starts with a header that is identical to the
header for the rib waveguide discussed previously, except that the first line conveys
this code was given a different name. The header initializes MATLAB and defines
the units that will be used. For this analysis, micrometers was set to 1 because it
is a photonics simulation with dimensions closest to this scale.
The next section of the code from lines 12 to 32 is the dashboard. The dash-
board contains all of the hard-coded numbers that define and control the simu-
lation. First, the free space wavelength lam0, followed by whether it is E or H
modes to be analyzed. To calculate E modes, the mode parameter should be set
to MODE = ‘E.’ To calculate H modes, the mode parameter should be set to MODE
= ‘H.’ The second set of parameters defines everything that is needed about the
slab waveguide. This includes the refractive index of the superstrate n1, refractive
index of the core n2, refractive index of the substrate n3, and thickness of the core
a. Observe that the parameter b is not defined here because b is not a parameter
that defines the slab waveguide. Instead, it is a simulation parameter that must be
made sufficiently large so that the grid boundaries are far enough away that the
modes guided by the slab are calculated accurately. A sufficient amount of space
must be placed between the waveguide and the Dirichlet boundary conditions, just
like for the rib waveguide analysis. The third set of parameters defines everything
that is needed to calculate the grid. The first parameter nmax is the largest refrac-
tive index that will be assigned to any cells on the grid. This is needed in order to
determine the smallest wavelength the analysis will be required to resolve, λmin =
λ0/nmax. The second parameter is NRES. This is the number of points that will be
used to resolve the shortest wavelength λmin. Higher values of NRES will improve
accuracy by resolving the problem with more points, but the calculations will take
longer and require more memory to run. Values in the range of 10 to 40 are typi-
cal, but it is necessary to test for convergence to be sure that sufficient resolution
is being used. Last, the parameter b defines the amount of space to include outside
of the core to ensure the guided modes decay to zero before reaching the boundary
of the grid. This allows simple Dirichlet boundary conditions to be used. The last
parameter defined in the dashboard is the number of modes to calculate, NMODES.
If the grid has 200 cells, 200 eigenmodes will be calculated unless specified oth-
erwise. It is most efficient to calculate only a subset of the modes because in most
simulations the vast majority of eigenmodes are not modes guided by the slab and
have no physical meaning related to the slab waveguide. In this case, four modes
will be calculated. If the number of supported modes is to be determined, NMODES
will need to be increased until the additional modes are clearly not guided modes.
The next section of code from lines 35 to 56 calculates the one-dimensional
grid that will be used to represent the slab waveguide. The first thing in this section
is to calculate the first guess at the grid resolution parameter dx. This is the first
guess because dx is refined in the second step. The grid resolution dx is set equal
to the minimum wavelength lam0/nmax divided by NRES. This calculation does not
consider the thickness of the slab waveguide so it is highly unlikely that the dimen-
sions will fit on the grid perfectly. In fact, at this point in the code, the core is 19.35
cells. Since it is not possible to fill in a fraction of a cell, the simulation is not able
to accurately represent the thickness of the core. The second step in this section
of the code adjusts dx so that the thickness of the slab is represented exactly by an
integer number of cells on the grid. Adjusting dx in this manner greatly improves
the convergence rate of the simulation so it will be possible to achieve high accuracy
with a minimum number of points on the grid. To do this, line 42 calculates the
number of cells currently representing the thickness of the core and rounds it up to
the nearest integer. The resolution parameter dx is adjusted on line 43 by recalcu-
lating it as the slab thickness divided by the number of cells just calculated. After
this step, dx will be slightly smaller than it was initially calculated. Next, the size
of the grid is calculated on lines 45 and 46. First, the physical size of the grid Sx is
calculated as two regions of thickness b and one region of thickness a. From this,
line 47 calculates the total number of grid cells by dividing the physical size by the
cell size and rounding up to the nearest integer. Due to the rounding operation,
the physical size of the grid Sx may be slightly off so line 48 recalculates it as the
number of cells wide times the cell size. If needed, lines 54 to 56 calculate the 2×
grid parameters followed by the axis arrays to be used for graphics and visualiza-
tion. The 2× grid is used here for illustration purposes and consistency, but it is less
common to use the technique for slab waveguide analysis.
The next section code from lines 58 to 81 builds the slab waveguide onto the
one-dimensional Yee grid. This is done by building the slab waveguide onto the 2×
grid and then extracting the permittivity and permeability tensor arrays on the Yee
grid from the 2× grid. Before anything is built onto the 2× grid, the permittivity and
permeability arrays ER2 and UR2 on the 2× grid are initialized to air. The second
task is to calculate the array indices nx1 and nx2 of where the core begins and
ends on the 2× grid, respectively. The overall grid strategy for this is illustrated in
Figure 6.12. The array index nx1 is calculated as one plus the number of the cells
comprising the superstrate of size b. There is no need to get nx1 exact to anything.
It is most important to calculate nx2 correctly relative to nx1. The array index nx2
is calculated as nx1 plus the number of cells for the slab rounded to the nearest
integer minus one. With the calculated array indices, the slab waveguide is built
onto the 2× grid on lines 71 to 73. Line 71 adds the superstrate from point 1 up
to point nx1−1. Line 72 adds the core from point nx1 to point nx2. Line 73 adds
the substrate from point nx2+1 all the way down to point Nx2. Observe that the
refractive index is being squared. That is because it is the relative permittivity that
is being assigned to points on the grid where ε r = n2 . The last task is to extract the
tensor arrays on the Yee grid from the 2× arrays. ERxx, ERyy, and ERzz are extracted
from ER2 while URxx, URyy, and URzz are extracted from UR2.
With the grid setup and slab waveguide built onto the Yee grid, it is time to per-
form the FDFD analysis. The section of code from lines 83 to 115 is generic, and the
same code can be used to calculate the eigenmodes of any slab waveguide. Before
the matrices for the eigenvalue problem can be built, the material tensor arrays must
be converted into diagonal matrices using the same procedure followed in the rib
waveguide analysis. The happens on lines 88 to 93. Next, lines 96 to 100 construct
the derivative matrices by calling the function yeeder2d() described in Chapter 4.
NS is an array containing the size of the grid. To build derivative matrices for the one-
dimensional grid used here, the size of the grid in the y-direction is set to 1 by making
NS=[Nx 1]. The resolution array is set to RES=[dx 1], but the specific numerical value
given for dy does not matter since it is not used. The formulation used normalized grid
coordinates so the input argument RES is multiplied by the free space wavenumber
k0 to pass normalized grid resolution terms to yeeder2d(). The boundary condition
array is set to BC=[0 0], but the boundary conditions for the y-axis boundaries also
do not matter because the y derivative matrices are not used in this analysis.
Given the diagonal materials matrices and the derivative matrices, the matrices
for the generalized eigenvalue problem Ax = λ Bx can be constructed. The matrices A
and B are constructed differently depending on whether it is the E mode or H mode
to be calculated. For the E mode, the matrices are constructed from (6.58). For the
H mode, the matrices are constructed from (6.64). Be cautious because it is easy
to forget to invert the URxx or ERxx matrices or including the negative sign when
calculating B, only to get incorrect eigenmodes. The function eigs() is built into
MATLAB to solve eigenvalue problems of sparse matrices. For this example, four
input arguments are passed to the function. The first two input arguments are the A
and B matrices. The third input argument NMODES was defined in the dashboard and
is the number of eigenmodes to be calculated. The parameter NMODES was defined
in the dashboard to be 4, so four modes will be calculated that have eigenvalues
closest to the value given as the fourth input argument to eigs(). Thus, the fourth
input argument is set to the best guess for the eigenvalues of the guided modes.
Given that the modes reside mostly inside of the core region, n2 is a good estimate
of the effective refractive index of the guided modes. However, the eigenvalues are
not directly the effective refractive index. From (6.43) and (6.46), the eigenvalue
that would correspond to an effective index of n2 is
g! 2 ≈ −n22 (6.68)
From here, the function eigs() returns two matrices that are called Fy and D2
in the MATLAB code. If there are Nx points on the grid, the eigenvector matrix
Fy will have Nx rows and NMODES number of columns. Each column in Fy contains
either the ey column vectors for the E mode or the h! y column vectors for the H
mode. The eigenvector matrix was given the symbol F instead of E or H because
it could represent either electric or magnetic fields. The matrix D2 will be of size
NMODES×NMODES and contain the eigenvalues along its diagonal. When four modes
are calculated for the E mode, these matrices have the form below.
⎡ g!12 0 0 0 ⎤
⎢ ⎥
2 ⎢ 0 g! 22 0 0 ⎥
D = ⎢ (6.70)
0 0 g!32 0 ⎥
⎢ ⎥
⎢ 0 0 0 g! 42 ⎥
⎣ ⎦
The square of the normalized complex propagation constant has no meaning
so it is common practice to first calculate the square root of the eigenvalue matrix
to calculate the normalized complex propagation constants of the modes.
⎡ g!1 0 0 0 ⎤
⎢ ⎥
0 g! 2 0 0 ⎥
D= D2 = ⎢ (6.71)
⎢ 0 0 !g 3 0 ⎥
⎢ 0 0 0 g! 4 ⎥
⎢⎣ ⎥⎦
The effective refractive index of the guided modes is readily calculated from
the normalized complex propagation constants simply by multiplying by −j. At the
same time, the effective refractive indices are stored in a one-dimensional array
NEFF instead of a diagonal matrix by extracting the diagonal from the eigenvalue
matrix and then multiplying by −j.
Before the finite-difference analysis of the slab waveguide can be considered
complete, a convergence study must be performed. Typically, this is a plot of the
effective refractive index of the guided modes as a function of the NRES parameter
and as a function of the spacer region parameter b. Acceptable convergence was
found at NRES=20 and b=3*lam0. Any remaining steps after calculating the modes
are considered postprocessing. This may include calculating the field components
not directly calculated by solving the eigenvalue problem, visualizing the modes,
or something else.
The MATLAB code to visualize the fields in the eigenvector matrix extends
from lines 117 to 145. The other field components associated with the modes are not
calculated or visualized because almost all information about the mode is contained
in just ey for the E mode and just h! y for the H mode. First, the figure window is
prepared for visualization by clearing it and declaring a “hold on” statement that
allows multiple graphic elements to be superimposed. First, the core of the slab
waveguide is drawn to the figure window as a rectangle using MATLAB’s fill()
function. Two arrays x and y are calculated and passed to this function that contain
the vertices working around the perimeter of the rectangle. The rectangle is drawn
as a light color of gray as 0.8*[1 1 1]. After the core is drawn, the eigenmodes are
drawn on top of this so that they can be visualized in relation to the geometry of the
slab waveguide. To space the modes more easily, the eigenmodes are normalized so
that the maximum value is 1. A for loop then draws the modes one at a time. The
parameter x0 is calculated to be the horizontal position of where the mode profile
will be plotted. Two lines are drawn to visualize the mode. First is a thick white
line and the second is a narrower blue line. This trick gives the line a white glow
that will allow the mode profile to stand out regardless of what colors are drawn
in the background to represent the waveguide. The lines are then labeled with the
effective refractive index of the mode using MATLAB’s text() function.
The first six eigenmodes calculated from this analysis and the effective refractive
indices are shown in Figure 6.13 for the E mode and Figure 6.14 for the H mode.
Inspection of these results shows that only three modes are supported by the slab
waveguide for both E and H modes. This is obvious for two reasons. First, the field
power for the guided modes is clearly confined to the vicinity of the core. The last
three eigenmodes have power increasing away from the core so they are not modes
guided by the slab. Second, the effective refractive indices of the unguided modes are
less than or equal to the substrate refractive index. Guided modes have the majority of
their power in the core, leading to effective refractive indices greater than the refractive
indices outside of the core. Like with the rib waveguide analysis, the unguided modes
are actually modes guided by the larger waveguide that are artificially formed when
using Dirichlet boundary conditions at the grid boundaries. These do not have a
physical meaning related to the slab waveguide and should be ignored.
Figure 6.13 First six eigenmodes from E mode analysis of a slab waveguide.
Figure 6.14 First six eigenmodes from H mode analysis of a slab waveguide.
(
Ey ( x, y ) = ey ( x ) exp − jk0neff y ) (6.72)
After the complex field is calculated, lines 142 to 193 create the GIF anima-
tion following Chapter 1. Lines 145 to 147 of the main loop add the phase to the
mode. This is the phase that will animate the mode. Lines 149 to 151 clear the fig-
ure window and issue the hold on command so that the field can be superimposed
with the slab waveguide. The field is plotted using the pcolor() command on lines
153 to 155. The slab waveguide is drawn in white directly on top of this using the
fill() command. In order to see the field, the slab waveguide is given a level of
transparency. The levels of transparency are calculated on lines 157 to 164 to con-
vey the relative refractive indices of the slab waveguide. The higher the refractive
index, the less transparent. The three sections of the slab waveguide are drawn on
lines 166 to 172. Lines 174 to 178 finish the figure and force the graphics to draw.
Lines 180 to 192 capture a frame and add it to the GIF animation. Line 193 ends
the main loop and the visualization is finished.
Figure 6.15 shows a single frame from the animation. The mode moves from
left to right. The GIF animation can be inserted into a website or a presentation and
Figure 6.15 Single frame from an animation of the second-order slab waveguide mode.
is a very effective and interesting way to showcase the results of a slab waveguide
calculation. Static images are quick and easy to generate, but are boring. You can
stand above your competition by showing simple animations like this instead of
static images.
6.3.4 Convergence
The most important step in any simulation is to perform a convergence study. To do
this, identify all of the parameters in the code that can be adjusted to improve the
accuracy and examine how the simulation results change as these parameters are
varied. From this data, values for the parameters are identified where the simulation
results are acceptable and calculation time is still sufficiently fast. To demonstrate,
data will be presented for a convergence study of the rib waveguide covered previ-
ously. First, to study grid resolution, the effective refractive index of the fundamen-
tal mode was plotted as the grid resolution parameter NRES was increased from 1
to 40. A typical convergence study will exhibit some sort of asymptotic behavior
as the result converges to a final value. However, increasing grid resolution also
increases simulation time and the memory required to perform the simulation.
Both the effective refractive index and simulation time as a function of NRES are
shown in Figure 6.16. Convergence seems to begin at around NRES=10. This value
Figure 6.16 Convergence study of grid resolution for rib waveguide analysis.
for NRES can be used when only rough results are needed from the simulation. It is
common to perform most of the preliminary simulations or start an optimization
with such a choice for NRES. However, as a preliminary design is being refined, it
is best to operate farther out on the convergence curve. A value of around NRES=30
seems to be a point where minimal improvement in the effective index is achieved
while simulation time increases significantly. This would be a good point to obtain
a final result for a design.
The grid resolution is not the only parameter to study convergence. There are
also the spacer regions to study in order to determine how big they need to be. Figure
6.17 shows the effective refractive index of the fundamental mode and the simula-
tion time to analyze the rib waveguide as a function of b. Preliminary convergence
is observed somewhere around 0.4λ 0 to 0.5λ 0 that is sufficient for obtaining fast
and rough results. A spacer region approaching 1.0λ 0 is better for higher accuracy.
Convergence studies are a form of parameter sweep where the results of the
analysis are plotted as some parameter is varied over a range of values. In this case, it
was the NRES and b parameters that were varied. If the FDFD code is written correctly
using a dashboard, the convergence study is as easy as wrapping all of the code after
the dashboard into a big for loop that iterates over all of the different values of NRES
or b. Other parameters sweeps are just as easy and the topic is covered in Chapter
9. It is important not to make any conclusions about the results of a simulation
until convergence is studied and achieved. Convergence is rarely discussed in the
literature and it is always assumed that the results provided are well converged. In
commercial software, convergence studies are often done automatically for the user.
Figure 6.17 Convergence study of spacer region for rib waveguide analysis.
the sense that they are confined to a plane. In the context of FDFD, the numeri-
cal approach to calculate surface waves is identical to calculating modes in slab
waveguides. Therefore, the MATLAB code described previously can be used here
to calculate a surface wave. In the photonics community, a type of surface wave
called an SPP is of great interest for subwavelength optics [9, 10] and has found
many applications including sensors, waveguides, light sources, solar cells, and much
more [11, 12]. An SPP is supported at the interface of a good metal and a dielectric.
It involves a coupling between electromagnetic fields in the dielectric with oscil-
lations of electrons in the metal. Figure 6.18 shows the geometry for calculating
SPPs at the interface of two materials. These materials can be set to a dielectric and
a metal just through proper choice of the relative permittivities ε r,d and ε r,m. The
dimensions b1 and b2 are not part of the definition of the structure supporting the
SPP. These are numerical parameters that must be large enough to encompass the
entire surface wave so that the top and bottom mediums look semi-infinite to the
analysis. Also shown in this figure is a typical SPP confined at the interface. The
mode decays exponentially in both directions away from the interface and typically
decays more quickly on the metal side.
Boundary conditions require that the electric field tangential to a metal be
equal to zero at the interface. The electric field of the E mode in FDFD is entirely
tangential to the interface. If the electric field for the E mode is zero, this mode
cannot describe SPPs. For this reason, it is only the H mode in FDFD that can
describe SPPs. For an interface to support an SPP, the dielectric constant must have
an opposite sign on either side of the interface [9]. The most common configuration
er,d er,m
g! 2 ≈ − (6.74)
er,d + er,m
For this example, the dielectric was set to fused silica with ε r,d = 2.31 and the
metal was set to silver where ε r,m ≈ −9.98 − j0.26 at a wavelength of λ 0 = 500 nm.
Given these values, the theoretical effective refractive index of the SPP was calculated
to be neff = 1.73 − j0.0068 using (6.73).
The MATLAB code for calculating SPPs can be downloaded at https://empos-
sible.net/fdfdbook/. The file is named Chapter6_spp.m. The code is essentially the
same as that used for slab waveguide analysis. The header extends from lines 1 to
10 and only differs on line 1 where the name of the file is “Chapter6_spp.m.” The
dashboard extends from lines 12 to 27. Line 17 defines the free space wavelength
to be 500 nm. Lines 19 to 23 define the material properties and the dimensions of
the superstrate and substrate. The parameter erd defines the relative permittivity
of the dielectric on the top and the parameter erm defines the relative permittivity
of the metal on the bottom. The dimensions of the top and bottom mediums, b1
and b2, must be large enough to fully encompass the surface wave. The results of
the simulation were found to converge when the dimensions were set to b1 = 2λ 0
and b2 = 1λ 0. The grid parameters are defined on lines 25 to 27. The maximum
refractive index nmax is calculated from the maximum real part of the relative per-
mittivities of the two mediums. The parameter NRES controls the grid resolution
and is the number of points per wavelength the grid will have. This parameter is
set to a value of 200 in the code provided, which is at the very start of where the
analysis begins to converge.
Lines 29 to 47 calculate the grid for the problem. Line 34 calculates the grid
resolution dx as the minimum wavelength lam0/nmax divided by NRES. There is no
need to snap the grid to any critical dimension because there are no dimensions
for this simulation. The dimensions b1 and b2 should not affect the properties of
the surface wave at all if they are large enough, so there is no need to resolve these
with an exact number of grid cells. Lines 36 to 39 calculate the size of the grid.
The physical size Sx is simply the sum of the sizes of the top and bottom mediums
b1+b2. Lines 41 to 43 calculate the axis array xa that defines the positions of the
points along the grid. The value of b1 is subtracted on line 43 to make xa=0 at the
interface between the two mediums. The 2× grid parameters are calculated on lines
45 to 47. The 2× grid is useful for this simulation because the H mode has two
electric field components at different positions on the grid.
The two mediums are built onto the grid on lines 49 to 68. First, lines 53 to 55
initialize the arrays ER2 and UR2 to all ones. Second, lines 57 to 60 incorporate the
top and bottom mediums into the array ER2. The variable nx calculated on line 58
represents the array index for the bottom of the top medium. Line 59 fills in the
points on the grid representing the top medium and line 60 fills in the points repre-
senting the bottom medium. Third, lines 62 to 65 extract the material tensor arrays
ERxx, ERzz, and URyy on the Yee grid from the 2× arrays on the 2× grid. Since it is
only the H mode that will ever be of interest in this code, the other material tensor
arrays ERyy, URxx, and URzz were not calculated.
The FDFD analysis of the surface wave is performed on lines 67 to 91. First,
lines 71 to 74 diagonalize the material tensor arrays ERxx, ERzz, and URyy. Second,
lines 76 to 81 build the derivative matrices needed to build the eigenvalue problem.
Third, the matrices A and B for the generalized eigenvalue problem are calculated on
lines 83 to 85. These are the same matrices used for slab waveguide analysis. Fourth,
lines 87 to 91 solve the generalized eigenvalue problem. Line 88 calculates the target
eigenvalue. In this case, the exact eigenvalue is known and is calculated using (6.74).
The generalized eigenvalue problem is solved using the built-in function eigs() on
line 89. Only a single mode is calculated because there are no higher-order modes
when dealing with surface waves. The effective refractive index of the surface wave
is calculated on lines 90 and 91 exactly how it was for slab waveguide analysis.
At this point in the code, the analysis is finished. Lines 93 to 118 visualize the
surface wave by superimposing it onto the top and bottom mediums. The effective
refractive index is reported in the title of the figure. Lines 97 to 99 clear the figure
window and issue the hold on command so the surface wave can be superimposed
onto the top and bottom mediums. Lines 101 to 106 draw the top and bottom
mediums using the fill() command. This is done before plotting the surface
wave so that the mediums appear behind the surface wave. Lines 108 to 111 plot
the surface wave. Line 109 normalizes the wave so it has unit amplitude. Line 110
draws a wide white line and then line 111 draws a narrower blue line. These two
lines together give the blue line a nice white outline that helps it stand out over the
colors in the background. Lines 113 to 118 finish the plot and give the plot its title
with the effective refractive index.
While the MATLAB program is complete, the simulation is not finished until
a convergence study is performed. This is particularly important for SPPs that con-
verge slowly. Figure 6.19 shows a convergence study performed for the calculation
of the SPP. The figure shows the real and imaginary parts of the effective refractive
index as a function of the grid resolution parameter NRES. Preliminary convergence
was observed at around NRES=200. Very slow convergence to the theoretical values
is observed above this. The very fine grid resolution is typical for SPP simulations.
The results produced by the MATLAB code for two different points along the
convergence trend are shown in Figure 6.20. Both produce a similar field profile,
but the effective refractive index differs the most. The theoretical value for the effec-
tive refractive index of this SPP is neff = 1.7335 − j0.006794. Observe that the field
decays most quickly in the metal. This is a typical behavior of SPPs.
Analysis of transmission lines is nothing more than rigorous hybrid mode analysis
followed by some additional postprocessing steps to calculate the transmission line
parameters. Very often at radio frequencies, metals are specified solely in terms of
Figure 6.20 Results from SPP calculation for two different values of NRES.
their conductivity σ and dielectrics are specified in terms of their dielectric con-
stant ε r and loss tangent tan δ . However, the FDFD analysis describes all materials
in terms of their complex permittivity and complex permeability. From Chapter 2,
the complex relative permittivity εr̃ of a metal can be estimated from just the con-
ductivity σ as
s
e!r ≅ 1 + (6.75)
jwe0
Furthermore, the complex relative permittivity εr̃ of a dielectric can be calculated
from the real-valued dielectric constant ε r and the loss tangent tan δ according to
⎡ hx ⎤ 1 ⎡ ex ⎤
⎢ ⎥= Q⎢ ⎥ (6.77)
⎢⎣ h y ⎥⎦ − jh0g ⎢⎣ e y ⎥⎦
!
Given the electric fields in the vicinity of the transmission line, the potential
difference V0 between
! the two conductors is calculated from a line integral of
the electric field E from the conductor at higher potential to the conductor at
lower potential.
L2 !
!
V0 = ∫ E i dℓ (6.78)
L1
Given the denormalized magnetic fields in the vicinity of the transmission line,
the current I0 through each of the conductors
! is calculated from a closed-contour
line integral of the magnetic field H around one of the conductors.
! !
∫ H i dℓ
I0 = # (6.79)
L
It follows that the characteristic impedance Z 0 is the voltage V0 divided by the
current I0.
V0
Z0 = (6.80)
I0
The complex propagation constant γ is calculated by denormalizing the normal-
ized propagation constant γ ̃ that was calculated from the eigenvalue.
g = k0g! (6.81)
Recall from Chapter 2 that the distributed transmission line parameters R, L,
G, and C are related to the characteristic impedance Z 0 and complex propagation
constant γ through
R + jwL
Z0 = (6.82)
G + jwC
g = (R + jwL ) (G + jwC )
(6.83)
R = Re ⎡⎣ gZ0 ⎤⎦ (6.84)
1
L= Im ⎡⎣ gZ0 ⎤⎦ (6.85)
w
⎡g ⎤
G = Re ⎢ ⎥ (6.86)
⎣ Z0 ⎦
1 ⎡g ⎤
C = Im ⎢ ⎥ (6.87)
w ⎣ Z0 ⎦
To demonstrate, the microstrip transmission line illustrated in Figure 6.21
will be simulated at 1.0 GHz and the transmission line parameters R, L, G, and C
will be calculated from the results. The microstrip is formed from copper onto an
FR-4 substrate. The width of the copper line is 1 mm and its thickness is 35 μm.
The thickness of the substrate between the ground plane and the line is 0.5 mm.
At 1.0 GHz, copper has a conductivity of 5.8 × 107 Ω ⋅ m and FR-4 has a dielectric
constant of 4.4 and a loss tangent of 0.03.
Figure 6.21 Geometry of a microstrip transmission line. For this example, w = 1 mm,
h = 0.5 mm, t = 35 μm, ε r = 4.4, tanδ = 0.03, and σ = 5.8 × 107 Ω ⋅ m.
The MATLAB code that analyzes the microstrip depicted in Figure 6.21 can
be downloaded at https://empossible.net/fdfdbook/. The file is named Chapter6_
microstrip.m. The majority of the code follows the ordinary hybrid mode analysis
covered previously so only key differences in the MATLAB code will be discussed.
The dashboard extends from lines 25 to 52. For source parameters, it is only the
operating frequency that is defined and the free space wavelength is calculated from
it. The material properties are defined from lines 34 to 41 in three parts. The first
part defines the conductivity sigma of the copper and then calculates the complex
dielectric constant erm from that. The second part defines the properties of the FR-4
in terms of the dielectric constant er and loss tangent tand. From these, the complex
dielectric constant erd is calculated. Last, the dielectric constant era of the material
above the microstrip is defined as air. The dimensions of the microstrip are defined
from lines 43 to 46 where w is the width, h is the thickness of the dielectric, and t
is the thickness of the microstrip line. Last, the grid parameters are defined from
lines 49 to 52. A new parameter NDIM is defined that specifies how many cells the
minimum feature size should be resolved with. For the microstrip line as defined,
this minimum dimension is width w in the x-direction and conductor thickness t
in the y-direction. For the microstrip, no spacer region is needed below the line due
to the presence of the ground plane. For this reason, the spacer region below the
line was set to a size of zero.
The grid is calculated on lines 54 to 93. Compared to the rib waveguide analysis,
there is an extra step here to ensure the minimum dimensions are resolved by at least
NDIM number of points. This happens from lines 62 to 73. Building the microstrip
onto the Yee grid is performed on lines 95 to 130. Note that the 2× grid was not
used here because the rectangular geometry of the microstrip makes it easy to assign
permittivity values directly to the tensor arrays ERxx, ERyy, and ERzz.
The finite-difference analysis from lines 132 to 176 is nearly identical to that
of the rib waveguide but has two key differences. The first difference is the guess
taken for the estimate of the eigenvalue of the lowest order mode. The incorpora-
tion of metals into the analysis makes estimating the eigenvalue for the fundamental
mode more difficult than it was for dielectric waveguides. Line 159 uses (6.88) to
estimate the effective relative permittivity of a microstrip transmission line [13].
er + 1 er − 1
er,eff ≅ − (6.88)
2 2 1 + 12 h/w
The last section of code from lines 178 to 228 postprocesses the fields calculated
by the FDFD analysis to calculate the transmission line parameters and to visualize
the field. Lines 183 to 184 use the array indices calculated ! when building the
microstrip to perform the line integration of the electric field E illustrated in Figure
6.22(a). This step calculates the potential difference V0 between the ground plane
and the microstrip line using (6.78). In this case, the positive direction is downward,
consistent with the coordinates chosen for the analysis. The voltage V0 calculated
on line 184 is a complex number because it has an amplitude and a phase. Lines
186 to 192 also use the array indices calculated! when building the microstrip to
perform a line integration of the magnetic field H that completely encircles the top
conductor as illustrated in Figure 6.22(b). This step calculates the current I0 through
the line using (6.79) and is also a complex number because it has an amplitude and
a phase. The variable s defined on line 187 defines the number of cells away from
the microstrip line the path of integration should take. Lines 188 to 191 calculate
the line integral above the line, to the right of the line, below the line, and to the
left of the line, respectively. Line 192 sums the integrals to get total current I0, but
negative signs are used where the integrations happen in the opposite direction of
the Cartesian coordinates used in the analysis.
At this point, the difficult calculations are finished. Line 195 calculates the
characteristic impedance Z0 of the line directly from the voltage V0 and current I0
that was just calculated using (6.80). The complex propagation constant gamma is
calculated on line 196 from the normalized complex propagation constant gamman
using (6.81). The effective refractive index is then calculated on line 197 from the
Figure 6.22 (a) Line integral of the electric field to calculate the potential difference between
conductors. (b) Closed-contour line integral of the magnetic field to calculate the current
through the line.
Parameter Value
Z0 50.5 + j0.60 Ω
γ 0.52 + j37.7 m–1
R 3.75 Ω/m
L 303 H/m
G 19.2 n/Ω ⋅ m
C 119 pF/m
neff 1.80
εr,eff 3.24
imaginary part of gamman. Lines 199 to 203 calculate the distributed transmission
line parameters R, L, G, and C using (6.84) to (6.87).
The last step in the code displays the results of the FDFD analysis. Lines 205
to 213 display the numerical values for the transmission line parameters in the
command window. Lines 216 and 217 calculate the magnitude of the electric field
and normalize it to have a maximum value of one. Lines 219 to 230 visualize the
electric field magnitude using MATLAB’s pcolor() function.
After the program is written and runs correctly, it is a big mistake to assume the
simulation is finished and the answer it gives is correct. A convergence study must be
performed and the program must be benchmarked with known cases. The example
given in this section can be used to benchmark your own code. In the dashboard,
there are three variables that all affect the accuracy of the analysis. These are NRES
that controls grid resolution relative to wavelength, NDIM that controls grid resolution
relative to the minimum dimension, and SPACER that controls how much space to
place around the device. Acceptable results were found for the values given in the
dashboard and the transmission line parameters that come from the analysis are
summarized in Table 6.1.
References
[1] Rumpf, R. C., “Improved Formulation of Scattering Matrices for Semi-Analytical Methods
That Is Consistent with Convention,” Progress in Electromagnetics Research, Vol. 35,
2011, pp. 241–261.
[2] Qiu, M., “Effective Index Method for Heterostructure-Slab-Waveguide-Based Two-
Dimensional Photonic Crystals,” Applied Physics Letters, Vol. 81, No. 7, 2002, pp.
1163–1165.
[3] Chan, S. P., et al., “Single-Mode and Polarization-Independent Silicon-On-Insulator
Waveguides with Small Cross Section,” Journal of Lightwave Technology, Vol. 23, No.
6, 2005, p. 2103.
[4] Lousteau, J., et al., “The Single-Mode Condition for Silicon-on-Insulator Optical Rib
Waveguides with Large Cross Section,” Journal of Lightwave Technology, Vol. 22, No.
8, 2004, pp. 1923–1929.
[5] Rickman, A., G. Reed, and F. Namavar, “Silicon-on-Insulator Optical Rib Waveguide
Loss and Mode Characteristics,” Journal of Lightwave Technology, Vol. 12, No. 10, 1994,
pp. 1771–1776.
[6] Vivien, L., et al., “Polarization-Independent Single-Mode Rib Waveguides on Silicon-on-
Insulator for Telecommunication Wavelengths,” Optics Communications, Vol. 210, No.
1–2, 2002, pp. 43–49.
[7] Miller, S., Optical Fiber Telecommunications, New York: Elsevier, 2012.
[8] Polo, J., T. Mackay, and A. Lakhtakia, Electromagnetic Surface Waves: A Modern
Perspective: Newnes, 2013.
[9] Pitarke, J., et al., “Theory of Surface Plasmons and Surface-Plasmon Polaritons,” Reports
on Progress in Physics, Vol. 70, No. 1, 2006, p. 1.
[10] Zayats, A. V., I. I. Smolyaninov, and A. A. Maradudin, “Nano-Optics of Surface Plasmon
Polaritons,” Physics Reports, Vol. 408, No. 3–4, 2005, pp. 131–314.
[11] Welford, K., “Surface Plasmon-Polaritons and Their Uses,” Optical and Quantum
Electronics, Vol. 23, No. 1, 1991, pp. 1–27.
[12] Zhang, J., L. Zhang, and W. Xu, “Surface Plasmon Polaritons: Physics and Applications,”
Journal of Physics D: Applied Physics, Vol. 45, No. 11, 2012, p. 113001.
[13] El-Refaei, H., D. Yevick, and I. Betty, “Stable and Noniterative Bidirectional Beam
Propagation Method,” IEEE Photonics Technology Letters, Vol. 12, No. 4, 2000, pp.
389–391.
[14] Pozar, D. M., Microwave Engineering, Hoboken, NJ: John Wiley & Sons, 2011.
A photonic band diagram is a fast and simple, yet incomplete, description of the
electromagnetic properties of a periodic structure. It is essentially a map of the
frequencies of the modes that are allowed to! propagate through a periodic structure
as a function of the Bloch wave vector b. The construction of a photonic band
diagram is illustrated in Figure 7.1. It starts by drawing the BZ, highlighting the
IBZ, and identifying the key points of symmetry around the IBZ, as depicted in
the top-left of Figure 7.1. From there, a path is chosen around the perimeter of the
IBZ that passes through the key points of symmetry. In this case, it was chosen
to start at the origin Γ , progress to the key point X, then up to the key point M,
and then back to Γ . The bottom-left of Figure 7.1 shows this path unfolded into a
straight line. The unfolded path becomes the horizontal axis of the photonic band
diagram. Working through this path in small increments, each point corresponds
to a different Bloch wave vector. For each Bloch wave vector, the periodic structure
is analyzed by solving the wave equation as an eigenvalue problem. The eigenvalues
obtained from the solution convey the frequencies of the modes that are supported
by the photonic crystal. These frequencies are plotted vertically above the point
along with the horizontal axis corresponding to the current Bloch wave vector. If
enough points are used along the horizontal axis, the discrete frequencies align
to form the photonic bands. In the formulation presented in Section 7.2, k02 is the
eigenvalue and is interpreted as frequency squared. It may seem odd to interpret the
free space wavenumber k0 as frequency, but it is related to frequency ω through k0
199
Figure 7.2 Concept of IFCs and relation to the photonic bands. (a) Full bands calculated
throughout entire BZ. (b) Three IFCs constructed from the second band.
Figure 7.2(a). To understand how the full bands relate back to the photonic band
diagram, the IBZ and key points of symmetry were added to this figure.
Instead of viewing the full photonic band diagram, as shown in Figure 7.2(a),
it is more common to plot just the IFCs. Figure 7.2(b) illustrates how the IFCs are
constructed from the full bands and how they are typically visualized. For clarity,
only the second band is shown. Three planes representing three fixed frequencies
slice through the second band. The IFCs are the lines formed where the constant
frequency planes intersect the bands. The intersection lines are shown by themselves
at the bottom of Figure 7.2(b). The lines at the bottom show how IFCs are typically
visualized. If more constant-frequency planes are added, more IFC lines will appear.
It is very important to understand how the IFCs relate back to the full bands and
how the full bands relate back to the photonic band diagram.
The following sections explain how to calculate the photonic bands using the
FDFD method for rectangular lattices. It is shown how to calculate and plot both
photonic band diagrams and IFCs. Calculating photonic bands of oblique lattices like
hexagonal photonic crystals requires modification to the basic FDFD algorithm [3,
4] that falls outside of the scope of this book. It is possible to choose a rectangular
unit cell that perfectly represents a hexagonal lattice when arrayed. Analyzing this
lattice, however, does not sufficiently enforce the phase conditions for a hexagonal
array. Incorrect bands will be calculated if this is attempted.
The starting point in FDFD for photonic band calculations is Maxwell’s curl equa-
tions expanded into Cartesian coordinates. In these equations, the magnetic field
" "
is normalized according to H! = − jh0H. The grid coordinates are not normalized
because k0 will be the output of the algorithm and will not be known until the algo-
rithm finishes. From Chapter 4 for two-dimensional analysis, the matrix equations
when frequency is not known were
Deyez = k0 µ xx h! x (7.2)
−Dexez = k0 µ yy h! y (7.3)
For photonic band calculations, the derivative matrices must incorporate peri-
odic boundary
! conditions (PBCs)
! at all boundaries. For the PBCs, the Bloch wave
vector b is used in place of kinc for the phase terms. Observe that (7.2) to (7.7)
have separated into two independent sets of matrix equations. The first set will be
called the E mode (TM) because the set only contains a single electric field term ez
and the final equation to be solved will have only this term.
Deyez = k0 µ xx h! x (7.9)
−Dexez = k0 µ yy h! y (7.10)
(
− Dhx µ −1De + Dhy µ −1
yy x xx y )
De ez = k02 ε zz ez
(7.11)
1 −1 e
h! x = µ De (7.12)
k0 xx y z
1
h! y = − µ −1De e (7.13)
k0 yy x z
the eigenvalues that are obtained. If it is desired to calculate the field ez of the Bloch
modes, it becomes necessary to calculate the eigenvectors. Equations (7.12) and (7.13)
are only needed if h! x or h! y field components are desired to be calculated from ez.
The second set of equations from (7.2) to (7.7) will be called the H mode (TE)
because the set only contains a single magnetic field term h! z and the final equation
to be solved will have only this term.
(
− Dex ε −1Dh + Dey ε −1
yy x xx y )
Dh h! z = k02 µ zz h! z
(7.17)
1 −1 h !
ex = ε D h (7.18)
k0 xx y z
1 −1 h !
ey = − ε D h (7.19)
k0 yy x z
Equation (7.17) is the eigenvalue problem to be solved to calculate H mode (TE)
bands. The eigenvalue is k02 and the eigenvectors are h! z . Equations (7.18) and (7.19)
are only needed if ex or ey field components are desired to be calculated from h! z .
Calculating photonic bands using FDFD consists of three major steps, as illustrated
in Figure 7.3. Step 1 calculates everything that is needed for the FDFD analysis to
happen and starts by initializing MATLAB. It is followed by the dashboard, the
section of code where all of the simulation parameters are defined. After the dash-
board, the setup moves on to calculating the grid, which includes the number of
cells and the resolution. With the grid calculated, a single unit cell of the periodic
structure is built onto the grid producing the tensor arrays ERxx, ERyy, ERzz, URxx,
URyy, and URzz used by the FDFD method. Ordinary photonic bands apply only
to photonic crystals of an infinite extent. This can be modeled in FDFD with just
a single unit cell as long as PCBs are used at all boundaries. After converting the
material arrays to diagonal matrices, the setup moves on to calculate the list of Bloch
wave vectors that will each be simulated separately. For photonic band diagrams,
this entails choosing a path around the IBZ and resolving the path with enough
steps that the eigenvalues will form continuous bands when they are plotted. For
IFCs, the list of Bloch wave vectors will fill the entire area of the IBZ.
With the simulation setup, the code performs the actual FDFD analysis. It is
composed of a large loop that iterates over the list of Bloch wave vectors calculated
in the setup. The first task
! inside of this loop is
! to build the derivative matrices where
the Bloch wave vector b is used in place of kinc for the PBCs. The second task is to
calculate the A and B matrices of the eigenvalue problem from the diagonal materials
matrices and the derivative matrices. The eigenvalue problem is constructed from
(7.11) for the E mode (TM) or from (7.17) for the H mode (TE). The third task is to
solve the eigenvalue problem for just the eigenvalues using the MATLAB function
eigs(). It should be mentioned that the corresponding eigenvectors can also be
calculated if it is desired to know the fields. The eigenvalues are recorded in an array
before the loop repeats. It is usually bad practice to calculate the eigenvalues of all
the eigenmodes. Instead, it is more numerically efficient to calculate only a small
set corresponding to the lowest-order eigenmodes. It is rare for the higher-order
modes of a photonic crystal to be used because the bands are so dense it is hard to
isolate them for practical use. This is accomplished by calculating only the smallest
eigenvalues. MATLAB makes obtaining a solution like this very easy.
After the eigenvalues are calculated for each Bloch wave vector, they are
normalized according to (7.1). If the eigenvectors were also calculated, the other
field components can be calculated at this point if they are needed. For photonic
band diagrams, only the eigenvalues are required. The results are then visualized in a
professional photonic band diagram. It is the convention in photonic band diagrams
to illustrate the BZ with the IBZ highlighted and the key points of symmetry labeled
so that the horizontal axis can be interpreted. Sometimes a picture of the lattice is
also provided.
Figure 7.4 Square lattice for photonic band calculation. For this device, r = 0.48a, ε hole = 1.0,
and ε fill = 12.0.
The second group of code in this dashboard defines all of the parameters related to
the numerical calculations. This includes the size of the grid used to build the unit
cell Nx and Ny, the approximate number of points to be used along the horizontal
axis of the band diagram NBETA, the number of photonic bands to calculate for each
mode NBANDS, and the maximum normalized frequency wnmax to show on the band
diagram. A convergence study is needed in order to determine how many points
should be used on the grid. It is recommended to start with values like Nx=Ny=10
until the code is working to ensure it runs fast while the code is being developed.
It is similarly recommended to start with a low value for NBETA around 20 to 50.
This number does not affect the accuracy of the simulation at all, but higher values
will resolve the bands more finely. Published band diagrams usually contain at least
200 points. It is only necessary to calculate as many bands as will appear below
the maximum frequency to be displayed wnmax. This usually puts NBANDS on the
order of 5 to 10. The higher-order bands (10th band and above) tend to get crazy
and are rarely of interest in practice. wnmax is set to focus the attention of the band
diagram on just the bands of interest.
The MATLAB code to calculate the grid optimized to represent the unit cell
resides in lines 24 to 41. The number of points, Nx and Ny, was specified in the
dashboard so the only remaining parameters to calculate for the Yee grid are the
resolution parameters dx and dy. Given the size of the unit cell a, the resolution
parameters are easily calculated as dx=a/Nx and dy=a/Ny. From these, the 2× grid
parameters Nx2, Ny2, dx2, and dy2 are calculated followed by the grid axes and a
meshgrid on the 2× grid. Observe that the meshgrid is centered at (0, 0) by center-
ing both axis vectors xa2 and ya2 about zero.
The next step is to build a single unit cell on the grid. The MATLAB code that
performs this operation resides in lines 42 to 65. The unit cell is constructed on
the 2× grid due to the curved geometry. Line 47 builds a circle of radius r centered
in the array ER2. At this point, the array ER2 contains ones inside of the circle and
zeros outside. For FDFD analysis, line 48 converts the array ER2 to numerical values
of relative permittivity. Line 49 sets the relative permeability to all ones. Given the
unit cell on the 2× grid, the next group of code extracts the material tensor arrays
ERxx, ERyy, ERzz, URxx, URyy, and URzz that are defined on the standard Yee grid.
The last group of code in this section visualizes the ER2 array to the first of three
subplots in the current figure window.
The next step in the code is to calculate the list of Bloch wave vectors that steps
around the perimeter of the IBZ in small increments. This is perhaps the most
difficult part of the band calculation and the code to do this extends from lines 66 to
102. Lines 71 and 72 calculate the reciprocal lattice vectors T1 and T2 that describe
the symmetry and size of the BZ [2]. There are only two lattice vectors because it is
a two-dimensional lattice being analyzed. The reciprocal lattice vector !T1 is in the
x-direction and its magnitude is set equal to the width of the full BZ, ⎪ T1⎪ = 2π ∕a.
Reciprocal lattice vector T2 !is in the y-direction and its magnitude is set equal to
the height of the full BZ, ⎪ T2⎪ = 2π ∕a. Lines 75 to 77 calculate the key points of
symmetry at the vertices of the IBZ. These are G, X, and M. It is a good practice to
calculate the key points of symmetry from the reciprocal lattice vectors, as is done
here. The key point Γ (G in MATLAB) is always at the center of the BZ so it is set
equal to position zero. The key point X is located at the far-right side of the BZ. This
along the center diagonal of a square sparse matrix using diag(). All of this could
also have been accomplished using the spdiags() function built into MATLAB.
The last task before entering the main loop is to initialize the arrays that will store
the band data. The first array WNTE will store the normalized frequencies for the
TE mode and the second array WNTM will store the normalized frequencies for the
TM mode.
The MATLAB code for the main loop that calculates the band data resides
from lines 119 to 147. The main loop iterates nbeta from a value of 1 up to NBETA,
which is the total number of points along the horizontal axis of the photonic band
diagram. The first step in the main loop is to fetch the Bloch wave vector for the
current iteration from the array BETA and store it in the variable beta. The second
step is to build the derivative matrices that will be used to calculate the eigenvalue
problems for both TE and TM modes. The derivative matrices are different for each
iteration because the Bloch wave vector is different for each iteration and is used for
the PBCs. The third and fourth steps build and solve the eigenvalue problems for
the TE and TM modes separately and store the results in the arrays WNTE and WNTM.
The TM mode analysis builds the A and B matrices for the generalized eigenvalue
problem according to (7.11). The TE mode analysis builds the A and B matrices for
the generalized eigenvalue problem according to (7.17). Otherwise, these two pieces
of code are identical. The eigenvalue problem is solved using the MATLAB function
eigs() that solves sparse eigenvalue problems. The function eigs() is given four
input arguments. The first two input arguments are the matrices A and B that define
the generalized eigenvalue problem being solved. The third input argument is the
number of eigenvalues to calculate, which was defined as NBANDS in the dashboard.
The fourth input argument is a value that the solver will find eigenvalues closest
to. A value of zero is given here in order to find the eigenvalues of the lowest-order
photonic bands. The function eigs() is able to calculate both eigenvalues and
eigenvectors, but only the eigenvalues are needed for a photonic band diagram.
For this reason, only a single output variable is given. The function eigs() runs
much faster when it recognizes that it does not have to calculate eigenvectors. The
eigenvalues are then sorted in ascending order because there are times when the
2
order of the eigenmodes is scrambled. The raw eigenvalues are in the form of k0,i and
stored in the array WNTM for the TM modes and in the array WNTE for the TE modes.
When the main loop finishes the calculations, the eigenvalues are normalized to put
them in the form of ω n,i = a/ λ 0,i. This happens in lines 150 and 151.
The last task in the code is to draw the photonic band diagram from all of the
data calculated in the program so far. The MATLAB code that draws a simple band
diagram extends from lines 153 to 174. The figure window was divided into three
subplots and the band diagram is drawn into the second and third subplots combined.
This is done using the subplot(1,3,2:3) command so that the band diagram is
given more space than the diagram of the unit cell. After this, the bands are drawn
using discrete points, which looks better than continous lines when few points are
used. When many points are used to construct the band diagram, continuous lines
look good as well. The plot command is given the array of numbers 1:NBETA to use
as the horizontal axis. The last set of code formats the view of the graphics. The
x-axis limits are set to 1 and NBETA. The y-axis limits are set to 0 and wnmax that
was defined in the dashboard. It would be improper to label the horizontal axis with
the numbers ranging from 1 to NBETA. Instead, the horizontal axis should be labeled
with the key points of symmetry placed at the correct locations. This is accomplished
using the set() command. The first input argument gca gets the properties of the
current axes that are to be changed. The first property to be changed is XTick which
are the tick mark locations along the horizontal axis where labels will be inserted.
The tick marks were previously calculated and stored in the array KT. The second
property to be changed is XTickLabel which is a sequence of strings containing the
labels to put at the tick marks. These were defined previously in the sequence KL.
After this, the x- and y-axes are labeled and the diagram is given a title.
The figure created by the MATLAB code described above is provided in Figure
7.5. This is very typical of the type of informal graphics a person would use dur-
ing their day-to-day analysis work. It is good to always visualize the unit cell along
with the band data to ensure any changes to the unit cell are incorporated correctly.
Dressing up the graphics any more than this for casual work is not needed and will
slow down the code.
The results shown in Figure 7.5 are little more than an indication that the code
runs without error. It is not any kind of indication that the results are correct. A
convergence study must be performed along with a benchmark simulation to build
confidence that the results are correct and accurate. A convergence study examines
the position of the bands as the grid resolution is increased by increasing the number
of points Nx and Ny. After plotting two band diagrams calculated from different
values of Nx and Ny, it was observed that the first band for the TE mode fluctuated
the most at the midpoint between X and M along ! the horizontal
! !axis. Figure 7.6
plots the normalized frequency of this band at b = 0.5T1 + 0.25T2 for increasing
values of Nx and Ny. Convergence seems to first happen at around Nx=Ny=20.
Given that convergence occurs for values of Nx and Ny greater than 20, the final
band diagram was calculated and a more professional photonic band diagram was
created. This band diagram can be used for you to benchmark your own code.
While simple and functional, the band diagram in Figure 7.5 is not appropriate for
publication. In this diagram, the TE and TM bands can barely be distinguished
from each other. Font sizes and line widths should be adjusted to be more visible.
The band diagram should also show the BZ, IBZ, and the key points of symmetry.
A professional band diagram depicting the same band data is provided in Figure
7.7. In this figure, the small bandgap appearing in the frequency range 0.46 ≤ ω n ≤
0.47 is highlighted in gray across the band diagram. If the lattice is not drawn
somewhere else, as shown in Figure 7.4, it is recommended to provide a picture of
the lattice as an inset in the band diagram.
Figure 7.7 Professional photonic band diagram for the lattice described in Figure 7.4.
version of the code described previously that calculated photonic band diagrams. The
header where MATLAB is initialized and the parameters describing the photonic
crystal are identical to the previous code. There is a slightly different set of parameters
that control the FDFD simulation from lines 19 to 24. The number of points on the
Yee grid Nx and Ny is defined directly in the dashboard. In addition, the number of
discrete points that will be used to fill in the IBZ with band data is defined through
the variables NBx and NBy. The more points used, the more accurately resolved the
IFCs will be. NBANDS defines how many bands are stored in memory. It is usually
only the lower-order bands that are of interest so this number should be kept small.
Lines 25 to 65 calculate the grid and build the unit cell of the photonic crystal
onto that grid. This code is identical to that for calculating photonic bands. Lines 66
to 80 calculate the list of Bloch wave vectors like before, but the list is constructed
differently. For photonic band diagrams, the list of Bloch wave vectors marched
around the perimeter of the IBZ. For IFCs, the list of Bloch wave vectors must fill
the entire area of the BZ. A fast and efficient IFC calculator will only analyze the
lattice at points within the IBZ. All other points in the BZ can be copied from a
point within the IBZ. To start, a meshgrid of all of the points throughout the entire
BZ is calculated on lines 71 to 73. The Bloch wave vector components are stored
in the arrays BX and BY. Line 76 calculates ind_ibz that contains all of the array
indices of Bloch wave vectors in BETA that resides within the IBZ. Lines 77 and
78 convert the linear array indices in ind_ibz to two-dimensional array indices
where all the points of the BZ are viewed as elements in a two-dimensional array.
Last, line 79 determines the total number of points in the IBZ from the length of
the array ind_ibz.
At this point, two small tasks must be performed before the FDFD analysis.
Lines 85 to 91 form the diagonal materials matrices that will be used to build the
eigenvalue problems. Then, lines 93 to 95 initialize the arrays where the band data
will be stored. WNTE will store the normalized frequencies for the TE mode while
WNTM will store the normalized frequencies for the TM mode.
The main loop from lines 97 to 127 calculates and stores the band data for all
points within the IBZ. Line 103 of the main loop fetches the next Bloch wave vector
from the list. Lines 105 to 109 call the yeeder2d() function to build the derivative
matrices. The Bloch wave vector is given as an input argument to incorporate the
correct PBCs. Lines 112 to 117 calculate the TM mode bands and store the data
in the array WNTM. Lines 112 and 113 build the A and B matrices of the generalized
eigenvalue problem Ax = λ Bx in (7.11). Line 114 solves the generalized eigenvalue
problem and returns the eigenvalues in the array D. Since only the eigenvalues are
returned from the call to eigs(), the eigenvalues are returned in a linear array
instead of a matrix. Line 115 calculates k0 from the eigenvalue k02 and drops any
small imaginary component that may exist due to numerical error. Line 116 then
sorts the eigenvalues in increasing order so that the lowest order modes are first.
Line 117 normalizes the eigenvalues according to (7.1) and stores them in WNTM.
The process is repeated for TE mode analysis in lines 120 to 125 and the results
are stored in WNTE. The primary difference is the calculation of the matrices A and
B that come from (7.17).
The main loop only calculated the band data within the IBZ. To visualize the
band data more intuitively, the band data throughout the entire BZ is constructed
from the band data within just the IBZ. This is done for speed and efficiency because
only the points within the IBZ have to be analyzed. This is performed on lines 130
to 144 by iterating through the bands and unfolding the data for both TE and TM
modes. Line 133 grabs the data for the current TE band. The array wn spans the
entire BZ, but at this point, only the points in wn that lie within the IBZ contain
actual band data. Line 134 unfolds the IBZ data to fill a quadrant of the BZ in the
array wn. However, doing this doubled the diagonal elements so line 135 corrects
this. Lines 136 and 137 mirror the band data from the quadrant to fill the entire
BZ. The complete array wn is then copied back into the array WNTE, overwriting the
original data in this array. This unfolding procedure is repeated for the TM mode
on lines 140 to 145.
The final portion of the code visualizes the IFCs for the first two TE and TM
mode bands. Lines 152 to 161 plot the IFCs for the first TE band. Line 154 fetches
the band data into the array wn. Line 155 calculates an array of 20 numbers that
extend from the lowest value in wn to the highest value in wn. The numbers in this
array will become the frequency values where the IFCs are drawn. Line 156 calls
MATLAB’s contour() function that calculates and plots the IFC lines. Lines 157 to
161 format and label the plot to look professional. Lines 163 to 172 repeat this for
Figure 7.8 Unit cell and IFCs for the first two TE and TM bands for the lattice described in Figure 7.4.
the second TE band. Lines 174 to 194 repeat all of this for the first two TM bands.
The figure created by the MATLAB code described above is provided in Figure 7.8.
Like before, the results shown in Figure 7.8 are little more than an indication
that the code runs without error. A convergence study must be performed along
with a benchmark simulation to build confidence that the results are correct and
accurate. It was previously shown that convergence occurs for values of Nx and Ny
above 20. In this code, Nx=Ny=60 was used with little impact on speed and a more
professional set of IFCs was created to showcase the results. This data can be used
for you to benchmark your own IFC code and is provided in Figure 7.9.
The IFCs are much more useful than the photonic band diagram for analyzing
the dispersion properties of photonic crystals. For example, flat IFCs lead to a
phenomenon called self-collimation where beams are forced to propagate along a
single direction without spreading [2, 5, 6]. The direction of self-collimation will be
perpendicular to the flat IFC. After inspection of the IFCs in Figure 7.9, flat IFCs
can be identified for each of the four cases. The first TM band will self-collimate at
around ω n = 0.217 because the IFC is flat for waves propagating along the diagonals.
Identifying the normalized frequency more precisely is more easily accomplished
using color or by experimenting with which contours are drawn. In this case, self-
collimation will occur for waves propagating diagonally through the lattice because
the bands are flat in the diagonal directions. This normalized frequency will be used
in Chapter 8 where a self-collimating photonic crystal is simulated. The first TE
References
[1] Joannopoulos, J. D., et al., Molding the Flow of Light, Princeton, NJ: Princeton Univ.
Press, 2008.
[2] Rumpf, R. C., “Engineering the Dispersion and Anisotropy of Periodic Electromagnetic
Structures,” Solid State Physics, Vol. 66, 2015, pp. 213–300.
[3] Aghaie, K. Z., S. Fan, and M. J. Digonnet, “Birefringence Analysis of Photonic-Bandgap
Fibers Using the Hexagonal Yee’s Cell,” IEEE J. of Quantum Electronics, Vol. 46, No.
6, 2010, pp. 920–930.
[4] Guo, S., et al., “Photonic Band Gap Analysis Using Finite-Difference Frequency-Domain
Method,” Optics Express, Vol. 12, No. 8, 2004, pp. 1741–1746.
[5] Digaum, J. L., et al., “Tight Control of Light Beams in Photonic Crystals with Spatially-
Variant Lattice Orientation,” Optics Express, Vol. 22, No. 21, 2014, pp.
25788–25804.
[6] Rumpf, R. C., and J. J. Pazos, “Optimization of Planar Self-Collimating Photonic Crystals,”
Journal of the Optical Society of America A, Vol. 30, No. 7, 2013, pp. 1297–1304.
215
Dey′ez = µ xx h! x (8.7)
−Dex′ez = µ yy h! y (8.8)
Observe that these equations have decoupled into two independent sets of equa-
tions. Equations (8.7), (8.8), and (8.12) contain ez, h! x and h! y , and describe the E
mode (TM polarization). A matrix wave equation in terms of just ez is derived by
solving (8.7) for h! x , solving (8.8) for h! y , and substituting both of these expressions
into (8.12). This gives
(D h −1 e
µ D
x′ yy x′
+ Dhy′ µ −1 De + ε zz ez = 0
xx y′ )
(8.13)
h! x = µ −1 De e
xx y′ z
(8.14)
h! y = −µ
µ −1De e
yy x′ z
(8.15)
Equations (8.9) to (8.11) contain h! z , ex, and ey, and describe the H mode (TE
polarization). A matrix wave equation in terms of just h! z is derived by solving
(8.10) for ex, solving (8.11) for ey, and substituting both of these expressions into
(8.9). This gives
(D e −1 h
ε D
x′ yy x′
+ Dey′ ε −1 Dh + µ zz h! z = 0
xx y′ )
(8.16)
e x = ε −1 Dh h!
xx y′ z
(8.17)
e y = −εε −1Dh h!
yy x′ z
(8.18)
In standard form Af = b, the matrix wave equations are written as
A ee z = 0 (8.19)
A h h! z = 0 (8.20)
where
Equations (8.19) and (8.20) are not solvable because all they do is enforce Maxwell’s
equations. No source, or excitation, has been defined from which to calculate the
fields. Injecting sources into an FDFD simulation can be complicated and confusing.
In this book, a very simple and powerful technique will be used that makes injecting
sources and postprocessing the fields easy. Over the years, the author and his research
team have come to call this the QAAQ technique [1], pronounced as “quack” like
the sound made by a duck.
The TF/SF technique identifies points on the grid as either a total-field (TF)
quantity or a scattered-field (SF) quantity [1–3]. TF quantities contain both the
source and the fields scattered by the device being simulated. SF quantities contain
only fields scattered from a device and not the source. In the physical world, every-
thing is TF. When the finite-difference equations are written for each point on the
grid, some finite-difference equations adjacent to the interface between TF and SF
regions will contain both TF and SF quantities. Equations must contain only SF
quantities or only TF quantities, not both. The source is injected when the finite-
difference equations are corrected.
The following sections will describe the QAAQ technique in detail, but a
summary is described here to put all of the implementation steps in context. First,
the source field is calculated across the entire grid and reshaped into a column
vector fsrc. Second, the SF masking matrix Q is constructed to identify all of the SF
cells on the grid. Third, the column vector b that describes the source is calculated
according to b = (QA − AQ)fsrc, where A is the wave matrix. Now the matrix wave
equation has the form Af = b which can be solved as f = A–1b. That is it!
The column vectors bTF and bSF come from quantities known at the start of the
simulation so they can both be given numerical values and moved to the right-hand
side of the equation. This gives an expression for the overall source vector b.
Af = b (8.31)
Furthermore, (8.23) and (8.24) are substituted into (8.30) to put the equation for b
completely in terms of the original source function fsrc. After simplifying, the result
is the famous QAAQ equation.
b = ( QA − AQ ) fsrc (8.32)
In this equation, A is the wave matrix derived previously. At first glance, it might
seem that this equation will always give b = 0. However, recall from Chapter 1 that
the order of matrix multiplication cannot be reversed so QA ≠ AQ and the source
vector b will not be all zeros. When considering E and H modes in FDFD, it may
make more sense to write the QAAQ equation as follows.
A h h! z = bh (
bh = QA h − A hQ fsrc )
(8.34)
With the source vector calculated, the fields can be solved for the E and H modes
according to
ez = Ae−1be (8.35)
h! z = A −1b (8.36)
h h
It should be noted that the QAAQ equation will work regardless of the grid
used or the order of accuracy of the finite differences. In fact, the QAAQ equation
can be applied to other numerical techniques like the finite element method when
node elements are used. This is because the specifics of the underlying math and
the locations of the points on the grid were not part of the derivation.
The source function fsrc, SF masking matrix Q, and source vector b for a plane
wave source are provided in Figure 8.1. Each of these has been reshaped back to a
two-dimensional grid to visualize them in the most meaningful way. The shaded
Figure 8.1 Representative data from QAAQ technique: (a) source function, (b) scattered-field
masking function just prior to becoming a diagonal matrix, and (c) source vector reshaped to a
two-dimensional array for visualization.
regions in the Q array are cells identified to be in the SF. Observe that the source
vector b is only non-zero in the cells immediately adjacent to the TF/SF interface
because these are the cells that required corrections to the finite-difference equations.
⎣ ( )
fsrc ( x, y ) = exp ⎡ − j kx,inc x + ky,inc y ⎤
⎦
(8.37)
In the MATLAB equation above, the variables X and Y are the meshgrid
parameters for the Yee grid. Figure 8.2(b) shows a cylindrical wave source. This
can be used to model radiation from a dipole or as a quick and easy source to excite
waves in all directions at the same time. The analytical equation and MATLAB
code to calculate a cylindrical source function are
1
fsrc ( x, y ) = exp ( − jkr ) (8.38)
r
R = sqrt(X.^2 + Y.^2);
fsrc = exp(-1i*k*R)./sqrt(R);
Figure 8.2(c) shows a Gaussian beam source. This source has many applications
including when it is desired to only illuminate one part of a device or when the
simulation is to be more consistent with experiments. Gaussian beams are excellent
for visualizing things like refraction and excitation of surface waves. The analytical
equation and MATLAB code to calculate this source function are given below.
Incorporating an angle theta for the Gaussian beam is very easy and only requires
Figure 8.2 Common source functions in FDFD: (a) plane wave, (b) cylindrical wave, (c)
Gaussian beam, and (d) guided mode.
that the meshgrid from which the source is calculated to be rotated by the desired
angle theta. Rotating meshgrids were described in more detail in Chapter 1.
⎡ ⎛ x ⎞2 ⎤
fsrc ( x, y ) = exp ⎢ − ⎜ ⎟ ⎥ exp ( − jky ) (8.39)
⎢⎣ ⎝ w ⎠ ⎥⎦
[TH,R] = cart2pol(X,Y);
[XR,YR] = pol2cart(TH+theta,R);
fsrc = exp(-(XR/W).^2).*exp(-1i*k*YR);
Equation (8.39) is a highly simplified form of the more general equation for
a Gaussian beam [4]. Therefore, the Gaussian beam used here is not a rigorous
solution to Maxwell’s equations and does not include the divergence or radial phase
of a true Gaussian beam. Extra care must be given when injecting this source. The
Gaussian beam can be injected without problems as long it is injected from a single
TF/SF interface that is mostly perpendicular to the beam. This will be demonstrated
in Section 8.4.3 where a photonic crystal will be illuminated by a Gaussian beam.
Figure 8.2(d) shows a guided wave source. This source is used whenever it is
desired to excite a waveguide with one of its guided modes in order to simulate
guided-wave devices. For many waveguides, no analytical expression exists for the
guided mode. In these cases, a waveguide mode calculation from Chapter 6 can be
performed in the cross section of the grid at the input of the waveguide. This will
require the FDFD algorithm to be modified to perform a slab waveguide analysis
when calculating the source field. After the desired mode is calculated, the source
field is calculated by extrapolating the mode across the grid in the +x-direction by
adding phase according to the effective refractive index as exp(−jk0 neff x). When
done correctly, the mode should look as if it has propagated across the entire grid
through a uniform waveguide. In this case, a second-order guided mode is being
launched in the +x-direction and a slab waveguide analysis from Chapter 6 was
used to calculate the mode.
Figure 8.3 Examples of good and poor TF/SF choices for a Gaussian beam source: (a) source
field, (b) ideal TF/SF, (c) poor TF/SF #1, (d) poor TF/SF #2, and (e) poor TS/SF #3.
the beam observed in the TF region is distorted and waves are observed in the SF
region that will produce errors in postprocessing calculations. While a Gaussian
beam was demonstrated here, it is straightforward to apply these same principles
to all sources.
After proper TF and SF regions are chosen, a discrete function Q is constructed
on a grid that identifies each cell as either TF or SF. Points filled with 0’s indicate TF
cells while points filled with 1’s indicate SF cells. The same techniques discussed in
Chapter 1 can be used to build the array Q. From there, the SF masking matrix Q
is constructed by reshaping the discrete Q function into a one-dimensional array,
declaring it as sparse, and then placing it along the diagonal of a matrix. The
MATLAB code to perform this diagonalization is
Q = diag(sparse(Q(:)));
The order of the functions in the above code is critical. If the order of diag()
and sparse() is swapped, there will be a moment when a very large full matrix is
formed in memory. This will be very slow and require a lot of memory if it does
not crash the program entirely.
Solving this expression for the factor ψ and recognizing that k0 = ω /c 0 gives
2 2
1 ⎡ 2 ⎛ k Δx ⎞ ⎤ ⎡ 2 ⎛ ky Δy ⎞ ⎤
y = ⎢ sin ⎜ x ⎟ ⎥ + ⎢ sin ⎜ ⎟⎥ (8.41)
k0n ⎣ Δx ⎝ 2 ⎠⎦ ⎢⎣ Δy ⎝ 2 ⎠ ⎥⎦
It is possible !to perfectly cancel numerical dispersion for a wave propagating in
the direction of k = kxâx + kyây in two steps. First, the factor ψ is calculated using
(8.41). In MATLAB, the variable ψ will be given the name psi. Second, after build-
ing the materials onto the grid, the relative permittivity ER2 and relative permeability
UR2 arrays are each adjusted by the factor psi across the entire grid according to
Observe that both the permittivity ER2 and permeability UR2 are adjusted by
the same factor psi. This happens because it is actually the refractive index n that
must be adjusted by the factor psi and ψ n = ymryer . If the 2× grid is not used,
the individual tensor elements must all be scaled by the factor ψ according to
Figure 8.4 illustrates the utility of compensating for numerical dispersion. Both
simulations in this figure are identical, other than one compensates for numerical
Figure 8.4 Illustration of compensating for numerical dispersion with a plane wave source at
NRES = 10. (a) No dispersion compensation leads to numerical error at the far side of the TF/SF
interface. (b) Compensating for numerical dispersion eliminates the numerical error of the source
at the TF/SF interface.
dispersion while the other does not. Each simulation launches a plane wave
through a vacuum with a square TF region at the center of the simulation. The
grid resolution was chosen to be NRES=10 to ensure numerical dispersion is easily
observed. Figure 8.4(a) shows the field calculated by the simulation when numerical
dispersion is present. Observe the wave in the SF region in the lower-right part of
the simulation. No wave should be observed here because no device is present to
scatter waves. This wave is the numerical error that arises because the simulated
wave and analytical source wave become out of phase. The TF/SF corrections made
to the finite-difference equations cannot cancel the waves in the far SF region. The
numerical error is the most serious at the points on the far side of the grid where
the phase difference is most severe. The numerical error wave appearing in the SF
region should not be there and so it will lead to more errors if the fields in the SF
region are postprocessed to calculate transmission, scattering pattern, or something
else from the simulation. Figure 8.4(b) shows the field calculated by the same
simulation but numerical dispersion has been compensated. The numerical error
has been completely eliminated.
Even though this technique only perfectly cancels numerical dispersion for a
single direction, it still reduces numerical dispersion in all directions. This is one
argument why it is best to make the grid resolution parameters dx and dy nearly equal
to each other. If no single direction is the most important, consider compensating
for a wave propagating at an angle of 22.5° off of the x-axis. This provides a good
compromise between the extremes of numerical dispersion that tend to be maximum
in the x- and y-directions and minimum in the diagonal directions.
Section 2.9 from Chapter 2 discussed how reflection and transmission from
diffraction gratings are handled in the context of diffraction orders. All periodic
structures in FDFD can be handled as a diffraction grating to calculate reflection
and transmission. In the discussion from Chapter 2, the surface of the grating was
in the xy plane, and the diffraction orders carried power away from the device in the
+z- and −z-directions. This was illustrated in Figures 2.6 and 2.7. In the coordinate
system chosen for two-dimensional FDFD simulations, the surface of the diffraction
grating will be in the xz plane, and the diffraction orders will carry power away from
the grating in the +y- and −y-directions. For this reason, the equations derived for
calculating diffraction efficiency, reflectance, and transmittance require modification
in order to be consistent with! the new coordinates.
The source wave vector kinc incident at angle θ inc lies in the xy plane, so kz,inc
= 0 and the kx,inc and ky,inc components are calculated as
In this case, the incident wave encounters a diffraction grating that leads to an
infinite expansion for the x components of the wave vectors associated with the
diffraction orders. Boundary conditions require that this expansion is the same for
both reflected and transmitted diffraction orders so kx,ref(m) = kx,trn(m) = kx(m).
The expansion is calculated as
2p
kx ( m ) = kx,inc − m (8.52)
Λ
where Λ is the period of the grating and m is the diffraction order. The longitudinal
components of the wave vectors of the diffraction orders may be different on the
reflection side and transmission side because the medium can be different on each
side. For this reason, they must be calculated separately using the dispersion relation
written for both sides.
ky,ref ( m ) = − (k n )
0 ref
2
− kx2 ( m )
(8.53)
(k0ntrn )
2
ky,trn ( m ) = − kx2 ( m ) (8.54)
When the simulation finishes, the field is analyzed to calculate the complex
amplitudes of the diffraction orders in three steps. First, the fields are extracted from
the cross section of the grid at both the reflection and transmission planes. For the
E mode (TM polarization) these are Ez,ref(x) and Ez,trn(x). Second, the phase tilt due
to an oblique angle of incidence is removed. Recall that Bloch modes in periodic
structures have the form of an amplitude function times a phase function. Since the
source is a plane wave with unit amplitude, any cross section of the source gives the
phase function of the Bloch mode. To isolate the amplitude portion of the Bloch
mode in both the reflection and transmission planes, the fields extracted from the
grid are divided by the cross section of the source exp(−jkx,inc x).
(
aref ( x ) = Ez,ref ( x ) ÷ exp − jkx,inc x )
(8.55)
atrn ( x ) = Ez,trn ( x ) ÷ exp ( − jk x,inc
x)
Third, the amplitudes of the diffraction orders are calculated from the discrete
Fourier transform of the amplitude functions calculated in (8.55). Using a fast Fou-
rier transform (FFT) algorithm, these are calculated as
2
E0,trn ( m) ⎡m k ( m) ⎤
TDE ( m) = Re ⎢ r,ref y,trn ⎥ (8.58)
E0,inc
2
⎢⎣ mr,trn ky,inc ⎥⎦
For the H mode (TE polarization), the complex amplitudes of the diffraction
orders on the reflection and transmission sides are written as H! 0,ref (m) and H! 0,trn (m),
respectively. In Chapter 2, these were vector quantities, but for the H mode in FDFD
the magnetic field has only a z component. From these, the diffraction efficiencies
are calculated as
2
H! 0,ref ( m) ⎡ k ( m) ⎤
RDE ( m) = 2
Re ⎢− y,ref ⎥ (8.59)
H! 0,inc ⎢⎣ ky,inc ⎥⎦
2
H! 0,trn ( m) ⎡e k ( m) ⎤
TDE ( m) = Re ⎢ r,ref y,trn ⎥ (8.60)
H! 0,inc
2
⎢⎣ er,trn ky,inc ⎥⎦
Observe the negative sign inserted into (8.53) that is canceled by the negative
signs inserted into (8.57) and (8.59). It is a habit for many computational scientists
to avoid doing any calculations that are just undone later in the code. For this rea-
son, some people drop all of these negative signs in their FDFD codes so that ky,ref
is always a positive number.
A block diagram for a basic FDFD method for scattering analysis is shown in Fig-
ure 8.5. It is composed of six major steps that are each composed of a sequence of
smaller steps. First, the simulation begins by initializing MATLAB, defining the
units to be used in the simulation and defining any constants that may be needed
later in the code. The second major step is the all-important dashboard where all of
the parameters are defined that control all aspects of the simulation. This includes
parameters that describe the source, the device dimensions and material properties,
and parameters that control numerical aspects such as grid resolution and perfectly
matched layer (PML) size.
The real work begins in the third major step where the grid is constructed.
All the following steps will operate on this grid. A first guess is made at the grid
resolution parameters dx and dy by resolving the minimum wavelength λ min by N
points. The minimum wavelength is the free space wavelength of the simulation λ 0
divided by the maximum refractive index nmax found anywhere on the grid.
l0
Δx = Δy = (8.61)
nmax N
This calculation of grid resolution ignores the dimensions of a device. Some
dimensions are very critical to model accurately on the grid, such as the period of
a periodic structure and the groove depth of a diffraction grating. The next step
in FDFD that greatly improves accuracy and convergence rate is to adjust the grid
resolution parameters Δx and Δy so that critical dimensions are represented exactly
by an integer number of grid cells. From here, the grid resolution parameters are
fixed so the next thing is to determine the size of the grid in terms of width Sx and
height Sy. The physical size is determined first with enough space included to fit the
device being simulated, absorbing boundaries, and any extra space around the device
that may be needed. The total number of cells on the grid, Nx and Ny, is calculated
by dividing the physical size by the grid resolution. At this point, the grid has been
calculated, and from these parameters, the 2× grid parameters are calculated. The
last step is to calculate the grid axes and meshgrid parameters if they are needed.
With the grid calculated, the next major step is to build the device onto the grid.
For many devices, especially those with curved geometries, it is advantageous to
build them using the 2× grid technique. Regardless, the process starts by initializing
both the relative permittivity ε r(x,y) and the relative permeability μ r(x,y) to vacuum.
The device is constructed onto the 2× grid and visualized. It is an excellent practice
to visualize as much as possible in the code for troubleshooting, verification, and
learning the algorithm better. At this point, the uniaxial PML (UPML) is incorporated
while the device is still on the 2× grid. It is very convenient to build the UPML onto
the 2× grid. The function addupml2d() is written to incorporate the UPML and
extract the material arrays for the standard Yee grid. The last step is to form the
diagonal material matrices from the material arrays.
With the device constructed onto the grid, finally, it !is time to implement the
FDFD method. It starts by calculating the wave vector kinc of the incident wave.
This is needed for the periodic boundary conditions (PBCs) in the derivative matrices
as well as in postprocessing to calculate reflectance and transmittance. After the
incident wave vector, the derivative matrices are constructed by calling the function
yeeder2d() that was described in Chapter 4. Given the materials matrices and
derivative matrices, the wave matrix A is calculated using (8.21) for the E mode (TM
polarization) or using (8.22) for the H mode (TE polarization). Next, the source
field fsrc is calculated, followed by the SF masking matrix Q, and then finally the
source vector b using the QAAQ equation in (8.32). All of the steps so far in the
FDFD algorithm run relatively quickly. It is the next single line of code that is the
slowest computation where the field is calculated by solving f=A\b. When this is
finished, it is always a good practice to visualize the field. Correct fields are generally
smooth and continuous. Any sort of noise or spikes in the solution is an indication
that something may be wrong. Keep in mind that the field may be discontinuous at
the TF/SF interface because the source is not present in the SF region but is present
in the TF region.
At this point, the FDFD algorithm is finished and the program can move on to
postprocessing the simulation results. A common postprocessing flow is analyzing
transmission and reflection from a periodic structure so that is what is shown in
the block diagram. Here, the simulated field is analyzed to calculate the diffraction
efficiencies of all of the diffraction orders as well as the overall reflectance and
transmittance. The first step is to extract the material properties where the reflected
and transmitted fields are to be analyzed on the grid. Second, the wave vector
expansion for the diffraction orders is calculated, including both the tangential
and longitudinal components of the wave vectors. Third, the cross section of the
field on the reflected side of the device is extracted from the grid above the TF/SF
interface inside of the SF region. The cross section of the field on the transmitted
side of the device is extracted from the grid just above the bottom UPML. Fourth,
from all of the information calculated so far, the diffraction efficiency of each of
the diffraction orders is calculated. Last, the overall reflectance is calculated by
adding all of the diffraction efficiencies of the reflected diffraction orders. The
overall transmittance is calculated by adding all of the diffraction efficiencies of
the transmitted diffraction orders.
Figure 8.6 Standard sequence of simulations for a newly written FDFD code.
the TF/SF interface. The specific values for reflectance and transmittance should
be within a fraction of a percent. At NRES=10, a working FDFD simulation may
calculate numbers like R = 5.910 –5 and T = 0.998. If anything wrong is detected
when simulating transmission through a vacuum, the mistake will be easier to find
and better-educated guesses for values of intermediate parameters can be made
with such a simple simulation.
Next, an angle of incidence is incorporated, perhaps θ inc = 30°, as depicted in
Figure 8.6(b). This is mostly to test that the PBCs are working correctly. If everything
is correct, the field should look like what is shown in Figure 8.7(a). The source wave
is visible in the TF region below the TF/SF interface, and no wave is visible in the SF
region above the TF/SF interface. This simulation should produce 0% reflectance and
100% transmittance with a numerical error well under 1%. When there is a mistake
in the code, the field may look like what is shown in Figure 8.7(b). The field below
the TF/SF interface does not resemble a pure plane wave, indicating that at least one
additional wave is present that is interfering with the source wave. A wave is also
visible above the TF/SF interface that is likely the same wave that is interfering with
the source wave below the TF/SF interface. Since a reflected wave is observed in the
TF region, it is most likely the bottom PML that is reflecting and not necessarily
a problem with the TF/SF source. For this case, the reflectance was calculated to
be 20% and transmittance calculated to be 195% at NRES=20, clearly an incorrect
simulation result. Keep an open mind when troubleshooting because backward
waves could be due to a problem with the TF/SF source, a problem with the PML,
a problem with the boundary conditions, or something else entirely. Most errors
at this stage all produce fields that look much like what is shown in Figure 8.7(b).
After the FDFD code can simulate vacuum correctly, the next thing is to move
the TF/SF interface to around two cells below the top PML and then build a single
material interface onto the grid. This is illustrated in Figure 8.6(c). In this case,
the Fresnel equations discussed in Chapter 2 can be used to verify the simulation
results are correct. First, the bottom half of the grid can be filled with ε r = 9.0. For
normal incidence, this should produce exactly 25% reflectance and 75% transmit-
tance. The most common mistake here is not calculating the diffraction efficiency
of the transmitted diffraction orders correctly because that equation contains extra
terms that are easily missed. Next, swap the permittivity and permeability such that
ε r = 1.0 and μ r = 9.0 and ensure the simulation still gives 25% reflectance and 75%
transmittance. Next, set ε r = μ r = 3.0 in the bottom half of the grid and verify reflec-
tance is near 0% and transmittance is near 100%. This case produces no reflections
because the impedance is constant throughout the grid. Next, incorporate an angle
of incidence and repeat various combinations of ε r and μ r, as illustrated in Figure
8.6(d). Using the Fresnel equations, an infinite number of simple simulations are
possible. Choose a few simple ones and then move on.
Next, it is best to simulate an asymmetric diffraction grating like the one that
will be simulated in Section 8.4.2. An asymmetric diffraction grating is illustrated in
Figure 8.6(e) and is an excellent device to verify that the diffraction orders are being
handled correctly in the FDFD code. The same asymmetric diffraction grating is
simulated again, but with an angle of incidence incorporated, as illustrated in Figure
8.6(f). The last simulation recommended for testing new codes is a wavelength (or
frequency) sweep of a guided-mode resonance filter (GMRF), as illustrated in Figure
Figure 8.7 (a) Correct simulation where the source wave in the TF region is visible and no
backward wave is observed. (b) Example where bottom UPML is not working correctly and
reflections are observed.
8.6(g, h). GMRFs are extremely sensitive devices. If anything is wrong in the code,
a GMRF will tend to amplify the problem so that more types of mistakes can be
identified and corrected. This type of simulation is a form of parameter sweep that
will be discussed in Chapter 9.
The first device that will be discussed in detail in the following sections is an
asymmetric diffraction grating that can serve as a device to use for benchmarking.
The second device that will be simulated is a self-collimating photonic crystal illu-
minated by a Gaussian beam source. This simulation will illustrate how information
from photonic band calculations can be used in a scattering simulation. The last
simulation will be an OIC. It will make multiple uses of slab waveguide analysis to
reduce the OIC to two dimensions, to calculate the source, and finally to analyze
reflection and transmission from the circuit.
extruded in the z-direction. In addition, the space above and below the diffraction
grating will be assumed to be semi-infinite. This means the superstrate material
ε r1 will extend off to infinity above the grating and the substrate material ε r2 will
extend off to infinity below the grating. This example will have air above the grat-
ing so ε r1 = 1.0. The dielectric constant of the diffraction grating was chosen to be
ε r2 = 9.0. It is good to benchmark using devices with higher permittivity to better
exercise the code. The period of the grating was chosen to be 1.5 cm so that a few
diffraction orders will exist above and below the diffraction grating when simulated
at a frequency of 30 GHz. When designing this problem, it was observed there was
a more even distribution of power among the diffraction orders when the grating
depth was set to 1.0 cm. This value was chosen to make the design more suitable
for benchmarking. Changing the grating depth away from this value will change
the diffraction efficiencies of the diffraction orders.
Figure 8.8 (Right) shows the grid strategy used to simulate most periodic struc-
tures in FDFD. Only a single unit cell in the x-direction has to be stored in memory
and simulated. PBCs at the x-axis boundaries make the grating appear to be infi-
nitely periodic in the x-direction. The device itself is built onto the grid so that the
grating resides close to the center of the grid vertically. UPMLs are placed at the
y-axis boundaries to absorb outgoing waves. Spacer regions are included above
and below the grating to ensure that any evanescent fields decay very close to zero
before touching the UPMLs. Evanescent fields are fields that extend outside of the
device, but are not propagating waves and stay confined to the surface of the device.
They are sort of a temporary place for electromagnetic power before coupling into
Figure 8.8 (Left) Perspective view of a sawtooth diffraction grating. (Right) FDFD grid strategy
for the same sawtooth diffraction grating.
a diffraction order and escaping the device. The top UPML and a few rows of cells
below the top UPML have been made the SF. The rest of the cells on the grid are TF.
The MATLAB code to simulate this diffraction grating using FDFD can be
downloaded at https://empossible.net/fdfdbook/. The file is called Chapter8_
sawtooth.m. The header for the program extends from lines 3 to 29 where MATLAB
is initialized, units are defined, and electromagnetic constants are defined in terms
of the specified units. Lines 4 to 6 initialize MATLAB by closing all of the figure
windows, clearing the command window, and then clearing all variables from
memory. In lines 9 to 23, the units for the simulation are defined. Here meters and
seconds were set to 1. This is typical for microwave simulations, but for optical
simulations consider setting micrometers to 1. It is a good practice to have all
numbers in a simulation as close to the numerical value of 1 as possible. Proper
selection of the scale of the units is a good way to do this. Last, lines 26 to 29
calculate various electromagnetic constants that may be used in the simulation
including free space permittivity e0, free space permeability u0, free space impedance
N0, and the speed of light in vacuum c0. This is usually the author’s standard header
for all simulations so the units and constants are all defined even if they end up
not being used.
The code extending from lines 31 to 54 is called the dashboard. This is where all
aspects of the program are controlled. All hard-coded numbers go in this section and
no work is to be performed here. After the dashboard, never hard-code any numbers.
Perform all operations relative to variables defined in the dashboard. Lines 35 to 40
define everything that is needed about the plane wave source. This includes frequency
f0, angle of incidence theta, and which electromagnetic mode (E or H) to simulate
stored in the variable MODE. Consider taking the opportunity to calculate the vacuum
wavelength lam0 and free space wavenumber k0 at this stage because sometimes
other numbers in the dashboard are calculated using these parameters. Lines 42 to
46 define everything that is needed about the diffraction grating including the period
L, depth d, relative permittivity of the superstrate er1, and relative permittivity of the
substrate er2. It is often best to sketch the device on paper and define the variables on
that sketch much like what is shown in Figure 8.8. Lines 48 to 53 define parameters
associated with the numerical aspects of FDFD. NRES defines the resolution of the
grid as the number of grid cells per minimum wavelength. SPACER is an array of
two numbers that define how much space should be included above and below the
diffraction grating. For ordinary scattering simulations, usually, a quarter to a half
wavelength is sufficient. Some devices can exhibit large evanescent fields, such as
resonant devices or devices operating near a diffraction order cutoff or a guided
mode cutoff. For these devices, the spacer regions should be made larger so that
the evanescent fields do not extend into the UPML regions. NPML is an array of two
numbers that define the numerical size of the UPML regions at the top and bottom
of the grid, respectively. ermax is an intermediate parameter that determines the
maximum relative permittivity that will be placed onto the grid. nmax is calculated
from ermax and is the maximum refractive index that will be placed onto the grid.
This is needed to determine the shortest wavelength in the simulation from which
the grid resolution will be calculated. If there were any relative permeability, there
would be a urmax parameter defined and this would be used in addition to ermax
for the calculation of nmax. After the dashboard, no more hard-coded numbers
should ever be used!
At this point, the real work for FDFD can begin. The first major task is to
calculate a grid that is optimized for analyzing the device defined in the dashboard.
This happens from lines 55 to 88. Lines 60 and 61 make the first guess at grid
resolution. It sets the grid resolution parameters dx and dy so that the smallest
wavelength in the simulation is resolved by NRES number of points. Lines 64 to 68
adjust dx and dy so that the critical dimensions of the device are resolved exactly
by an integer number of grid cells. For diffraction gratings, the period L is almost
always chosen to be the critical dimension in the x-direction. The calculation L/dx
is the number of cells it would take to resolve the period L on the current grid.
Since the period was not considered in the calculation of dx, L/dx is most likely
not an integer. This is rounded up to the nearest integer to calculate nx. At this
point, nx is interpreted as the number of cells it is desired to represent the period
exactly. To make this happen, the resolution parameter dx is recalculated as L/nx.
This same procedure is done for the critical dimension in the y-direction. For
the diffraction grating, the grating depth d was chosen as the critical dimension.
Only a single critical dimension can be chosen for each direction for a uniform
grid. Now the grid resolution is finalized and will not be adjusted again. Lines
70 to 77 calculate both the physical size and numerical size of the grid that will
contain the device and simulated fields. The physical size in the x-direction is Sx
while the physical size in the y-direction is Sy. The typical calculation steps are:
(1) define physical size to include the spacer regions, (2) calculate the total number
of cells to encompass this region plus the UPML regions, and (3) recalculate the
physical size so that it includes the UPML regions. At this point, the Yee grid is
calculated. The next step is to calculate the 2× grid, which describes the same
physical space as the Yee grid, but with twice as many points. Nx2 and Ny2 describe
how many points the 2× grid contains in the x- and y-directions, respectively.
dx2 and dy2 are the grid resolution parameters for the 2× grid. Then, the grid
axes xa and ya for the Yee grid are calculated along with the grid axes xa2 and
ya2 for the 2× grid. These are one-dimensional arrays that contain the position
of each cell on the grid. Last, the meshgrid parameters X and Y for the Yee grid
are calculated. If needed, the meshgrid parameters X2 and Y2 for the 2× grid can
also be calculated here.
After an optimized grid is calculated, lines 90 to 127 build the device onto this
grid, add the UPML and form the diagonal materials matrices. Lines 94 to 96 ini-
tialize the relative permittivity ER2 and relative permeability UR2 on the 2× grid. The
array ER2 is set to all values of er1 throughout the entire 2× grid. The array UR2 is
set to all values of 1. Lines 98 to 106 build the asymmetric sawtooth geometry onto
the 2× grid. The variable ny1 represents the array index in the y-direction of the
top of the diffraction grating. It is calculated to be below the top UPML, below the
top spacer region, and one extra cell vertically in case both the UPML and spacer
region are defined to be zero. Note that the size of the top UPML is multiplied by
two on line 99. That is because the array NPML contains the size of the UPML on
the Yee grid, but the device is being constructed on the 2× grid. The variable ny2
represents the array index in the y-direction of the bottom of the diffraction grating.
It is calculated as the array position ny1, plus the number of cells the grating tooth
is tall, minus one cell. After this, a loop is performed that iterates ny from the top
ny1 to the bottom ny2 of the grating tooth. Line 102 calculates the variable f to go
from 0 to 1 as the loop progresses from the top to the bottom of the grating tooth.
However, it is best to not have f be exactly equal to 0 or 1 because that would be
an unused layer. Given f, nx is calculated on line 103 to be the number of cells
wide the grating tooth is at the vertical position defined by ny. Line 104 sets the
points in ER2 to a value er2 that resides inside of the grating tooth. After the loop
finishes, line 108 assigns all points in ER2 below the grating tooth to be er2, repre-
senting the semi-infinite substrate. At this point, the device is constructed onto the
2× grid and it is visualized on lines 110 to 115. Lines 118 and 119 call the function
addupml2d() that incorporates the UPML onto the grid and extracts the six Yee
grid materials arrays ERxx, ERyy, ERzz, URxx, URyy, and URzz. Last, lines 121 to 127
form the sparse diagonal materials matrices that will be used in the next section of
code to build the wave matrix A.
It is finally time to perform FDFD! This starts by calculating the source wave
vector. Line 134 calculates the refractive index in the semi-infinite region above the
diffraction grating. Lines 135 and 136 calculate the x and y components of the source
wave vector incident at angle theta. Line 137 assembles the wave vector components
into a single vector. Lines 139 to 143 call the function yeeder2d() to build the four
derivative matrices. Line 142 defines PBCs at the x-axis boundaries and Dirichlet
boundary conditions at the y-axis boundaries. If the UPML is functioning correctly,
it should not matter what boundary conditions are used at the y-axis boundaries.
Given this, Dirichlet is chosen to avoid incorporating complex numbers into the
derivative matrices that can sometimes slow obtaining a solution. Observe on line
143, the grid resolution parameters in RES are multiplied by k0 and the incident
wave vector kinc is divided by k0 to build the derivative matrices with a normalized
grid. Lines 144 to 150 calculate the wave matrix A. An if statement is used to build
a different wave matrix depending on which electromagnetic mode was defined in
the dashboard through the variable MODE. Line 153 calculates the source field in the
array fsrc. This is the source wave calculated throughout the entire grid as if the
diffraction grating were not present. The source is given unit amplitude. Lines 155
to 159 build the SF masking matrix Q. Line 156 calculates ny to be the array index
for the location in the y-direction of the TF/SF interface. Line 157 initializes the
array Q to be all zeros, which makes Q identify all points on the grid as TF. Line 158
then sets all points in Q from the top of the grid down to ny to be all 1’s. This defines
the top portion of the grid above ny to be the SF region. Line 159 forms a sparse
diagonal matrix Q which is the SF masking matrix. Line 162 calculates the source
vector b using the QAAQ equation. Line 165 is the most intensive computational step
in FDFD and is also the shortest and simplest line of code in the entire program. It
is here that the matrix equation Af = b is solved for the field f via backward matrix
division. For the E mode, the field f represents the field component Ez while for
the H mode the field f represents the field component Hz. It was given the name f
to be generic and represent the field for both E and H modes. After solving, f is a
column vector so line 166 reshapes it back to the two-dimensional Yee grid, which
is Nx-by-Ny points. Lines 168 to 175 visualize the calculated field. It is always a good
practice to visualize the field because many problems can be identified and even
diagnosed just by examining the field. Expect to see a discontinuity of the field at
the TF/SF interface because the source is removed in the SF region.
With the field calculated, FDFD is finished and the program can move on to
postprocessing. For periodic structures, it is often more meaningful to calculate
reflection and transmission by analyzing the diffraction orders. A simpler way would
be to simply integrate the Poynting vector across the grid, but this circumvents
information from the diffraction orders that are very often quite meaningful. Lines
177 to 218 perform this postprocessing step and report the results. Lines 181 to
187 extract the material properties where the reflected and transmitted fields are
being analyzed and calculate the refractive index in these locations. Lines 189 to
193 calculate the wave vector components of all of the diffraction orders. Line 190
calculates an array m that contains the integer numbers of the diffraction orders in
the order that FDFD will calculate them. The limits were chosen to have Nx total
number of integers and to place the zero-order (i.e., m=0) at the correct position
for both odd and even values of Nx. Line 191 calculates an array kx that contains
the tangential components of the diffraction orders. These are the same for both
reflected and transmitted diffraction orders so only a single array is calculated
and used for both. The longitudinal components of the diffraction orders will be
different in the reflected and transmitted regions if the materials in these regions are
different. They are calculated separately on lines 192 and 193 as kyref and kytrn
using the dispersion relation for each medium. Line 196 extracts a cross section of
the field fref at a location just under the top UPML, but still in the SF region, and
removes the phase tilt due to an oblique angle of incidence. This location ensures
that any fields present at that location are solely reflected from the device. Line 197
extracts a cross section of the field ftrn at a location just above the bottom UPML
and removes the phase tilt. This location ensures that any field at this location is
transmitted through the device. Lines 200 and 201 calculate the complex amplitudes
of the diffraction orders. The array aref contains the complex amplitudes of the
reflected diffraction orders and the array atrn contains the complex amplitudes of
the transmitted diffraction orders. These terms are complex because they describe
both the amplitude and the phase of the diffraction orders. The phase tilt and the
phase of the diffraction orders are different quantities. The phase tilt is the phase
across the grid due to an oblique angle of incidence. The phase of a diffraction order
is its overall phase relative to the source.
Given the complex amplitudes and the material properties where the diffraction
orders are being analyzed, the diffraction efficiencies are calculated in the arrays RDE
and TDE. Line 204 calculates the array RDE that contains the diffraction efficiencies
of the reflected diffraction orders. This calculation is the same for both E and H
modes. Lines 205 to 209 calculate the array TDE that stores the diffraction efficiencies
of all the transmitted diffraction orders. The equation to calculate the diffraction
efficiencies of the transmitted diffraction orders is different for E and H modes.
An if statement is used to select the proper equation. In the end, the array TDE
will contain the diffraction efficiencies of the transmitted diffraction orders. After
the diffraction efficiencies are calculated, the overall reflectance REF is calculated
on line 212 by adding all of the diffraction efficiencies of the reflected diffraction
orders. The overall transmittance TRN is calculated on line 213 by adding all of the
Figure 8.9 Convergence study for FDFD analysis of sawtooth diffraction grating.
be rotated about the z-axis by 45°. The concept for the simulation is illustrated in
Figure 8.10. The left part of this figure shows the lattice that will be simulated. It
will be illuminated by a diverging Gaussian beam incident at an angle of 20°. This
angle was chosen to demonstrate that self-collimation will occur in the x-direction
regardless of the angle of incidence. Self-collimation for this lattice will fail if a large
enough angle of incidence is chosen. Observe the primitive unit cell simulated in
Chapter 7 is at a 45° angle relative to the x- and y-axes in this figure. To simplify
constructing this lattice on the Yee grid, an alternative unit cell is identified that
aligns with the x- and y-axes. The alternative unit cell has lattice spacing of b =
a 2, where a is the lattice spacing of the original unit cell analyzed in Chapter 7.
Recall from Chapter 7 that ε r1 = 1.0, ε r2 = 12.0, and r = 0.48a.
The grid strategy that will be used to simulate the photonic crystal is shown
in Figure 8.11. A lattice of approximately 60a × 40a will be centered in a grid. No
spacer regions will be used above and below the lattice because all waves should
be confined vertically to the center of the lattice. Spacer regions of size 6λ 0 will be
used on the left and right sides of the lattice to visualize the source and wave exiting
Figure 8.10 (Left) Self-collimating lattice to be simulated by FDFD. (Right) Alternative unit cell
used to build the lattice in FDFD.
the lattice. A diverging Gaussian beam will be launched at a 20° angle of incidence
and illuminate the center of the left face of the lattice. The TF/SF technique will
be used to launch the source and the TF/SF interface will span the perimeter of the
grid staying just outside of the UPMLs. It is not possible to use just a single TF/SF
interface at the left side of the grid because the source beam is wide enough that
it would overlap the top or bottom UPML. The TF/SF interface where sources are
injected cannot cross a UPML because the source functions do not account for decay
in the UPML. The sources must have zero amplitude where the TF/SF interface
crosses a UPML. To avoid the source overlapping the UPML in this simulation, the
TF/SF interface was made to form a square around the entire grid. The UPMLs will
be 20 cells large and be placed along all four grid boundaries.
The MATLAB code to simulate the self-collimating photonic crystal can be
downloaded at https://empossible.net/fdfdbook/. The file is called Chapter8_
photoniccrystal.m. Lines 1 to 9 are the header of the program where MATLAB
is initialized and units for the simulation are defined. In this case, only the units
of degrees are defined.
The dashboard for the simulation extends from lines 11 to 36. This is where all
of the hard-coded numbers are defined that control all aspects of the simulation.
Figure 8.11 Grid strategy for FDFD analysis of a self-collimating photonic crystal.
Lines 15 to 19 define everything that is needed about the source. This includes
the free space wavelength lam0, the free space wavenumber k0, the width of the
Gaussian beam bw, and the angle of incidence theta. lam0 is set to a value of 1.
Since no length units were used, it may not be clear what this value of 1 represents.
It represents whatever length scale you wish! That could be meters, micrometers,
inches, or even Martian units. It is only necessary to ensure that any other length
parameters be defined with the same units. See Chapter 2 for a discussion on scal-
ability in electromagnetics. An extremely narrow beam was chosen to get a nicely
diverging beam. The angle of incidence of the Gaussian beam was set to 20°. Lines
21 to 29 define everything that is needed about the photonic crystal. The normalized
frequency wn is set equal to 0.217 as identified from the IFCs in Chapter 7. From
this, the lattice constant a is calculated as the normalized frequency wn times the
operating wavelength lam0. The radius of the hole is defined relative to the lattice
constant as 0.48*a. er1 is the dielectric constant of the fill medium and er2 is the
dielectric constant of the photonic crystal. For this simulation, the fill medium is set
to air, but it is best to define it this way in the dashboard instead of hard-coding the
device to be air. The size of the overall lattice is Lx in the x-direction and Ly in the
y-direction. These were set to produce a lattice roughly 60a × 40a. Last, lines 30
to 35 define all numerical parameters. The parameter NRES controls the grid reso-
lution and is the number of grid cells per minimum wavelength. The array SPACER
defines four numbers that control the amount of physical space placed around the
outside of the photonic crystal. The first number in SPACER is the space on the left,
the second number is the space on the right, the third number is the space on the
top, and the fourth number is the space on the bottom. In this example, all four
dimensions are defined in terms of wavelength, which is often the best way to do
this. The same ordering of numbers appears in the array NPML to define the size of
the UPML at each boundary in terms of the number of grid points. A good nominal
value for the size of a UPML is around 20 cells and that is what is used here for all
boundaries. If this simulation was to be optimized for efficiency, consider reducing
the size of the UPMLs at the top and bottom boundaries knowing that very little
wave power will be incident on those boundaries. The last parameter is nmax, the
maximum refractive index found anywhere on the grid. It is used later to determine
the minimum wavelength in the simulation. Here, nmax is calculated through the
intermediate parameter ermax because all of the material properties were defined
in terms of relative permittivity.
After the dashboard, the real work can begin. Lines 37 to 71 perform the first
major task of calculating a grid that is optimized for the simulation defined in the
dashboard. Lines 42 and 43 calculate the first guess at the grid resolution param-
eters dx and dy that define the size of the cells on the Yee grid. This is calculated to
be the minimum wavelength divided by NRES. The minimum wavelength is the free
space wavelength lam0 divided by the maximum refractive index nmax. Next, the
grid resolution parameters are adjusted so as to resolve the unit cell with an exact
integer number of cells. This will allow a single unit cell to be arrayed across the
grid to build the photonic crystal. The unit cell used in Chapter 7 was the primitive
unit cell with lattice spacing a. An alternative unit cell is defined here for a lattice
that is rotated by 45° about the z-axis. This alternative unit cell has dimension b
the device has been constructed and is visualized to the figure window on lines 115
to 120. Line 123 incorporates the UPML using the function addupml2d() discussed
in Chapter 5. Last, lines 125 to 131 form the diagonal materials matrices that will
be used to calculate the wave matrix A.
It is now time to perform FDFD! Lines 137 to 141 build the derivative matrices
by calling the function yeeder2d() discussed in Chapter 4. Dirichlet boundary
conditions are defined at all boundaries in the array BC since there is a UPML at
each of the boundaries. Line 144 builds the wave matrix A for the E mode using the
materials matrices and the derivative matrices.
Next, the source field is calculated on lines 146 to 152. The concept of calculating
the source field fsrc is shown in Figure 8.12. Think of the source field as the field
that would result if there was no device built onto the grid. Figure 8.12(a) shows the
Gaussian beam across the grid without the angle of incidence built in. Figure 8.12(b)
shows the same Gaussian beam but with the 20° angle of incidence incorporated.
To incorporate the angle of incidence, the meshgrid is rotated on lines 148 to 150.
Line 148 calculates the ordinary meshgrid, line 149 converts the Cartesian meshgrid
to polar coordinates, and line 150 converts the polar coordinates back to Cartesian
after adding the angle of incidence theta to the angle meshgrid term. This allows
the simple Gaussian beam equation to be used on line 151 to calculate the source
field, but using the rotated meshgrid parameters. A real Gaussian beam diverges,
but is a more complicated function to calculate. A simple Gaussian beam can be
used as long as the source function is prevented from crossing the far-right TF/SF
interface. On the far-right side, the source function would not match the simulated
beam because the simulated beam diverges. Line 152 accomplishes this by setting
the source function to zero at all points to the right of the input face of the photonic
crystal. The meshgrid was set up so that X = 0 at the input face of the photonic
crystal. The final source field is shown in Figure 8.12(c). Figure 8.12(d) shows the
field calculated from a simulation without a photonic crystal to fully illustrate that
the source beam is diverging. It is a good practice to run a simulation without the
Figure 8.12 Calculation of the source field. (a) Source field with no rotation. (b) Source field
with 20° rotation. (c) Truncated source field with 20° rotation. (d) Simulated source field without
photonic crystal showing divergence.
device present to ensure that the code is working correctly up to that point. Problems
with the code can be more difficult to diagnose when the simulation results are
complicated by the presence of a device.
Next, the SF masking matrix Q is constructed on lines 154 to 161. A single
TF/SF interface running vertically through the left part of the grid is not sufficient
for this Gaussian beam source. If a large enough angle of incidence were used, the
Gaussian beam would run more vertically causing the beam to overlap the UPML
and move away from the TF/SF interface. Both of these will cause problems in the
FDFD simulation. To prevent these problems, the TF/SF interface is made into a
complete perimeter around the grid just outside of the UPML regions. This is shown
in Figure 8.11. Given Q, the source vector b is calculated using the QAAQ equation
on line 164. Do not confuse the source vector b with the unit cell dimension b. It is
an unfortunate reuse of the same variable name. Last, the matrix equation is solved
on line 167 to calculate the field f. It is reshaped back to the two-dimensional Yee
grid on line 168 so that it can be visualized and postprocessed.
The field calculated from the simulation is visualized from lines 170 to 190, and
the result is shown in Figure 8.13. Line 183 uses MATLAB’s contour() function to
superimpose the photonic crystal onto the fields. It draws the contour lines at the
edges of the photonic crystal lattice. It is a very good practice to combine the device
and simulated field into the same diagram in some manner. Much can be learned by
observing how the field interacts with the device and material interfaces. For this
example, the lattice is illuminated with a diverging beam incident at 20°. Despite
the beam’s divergence and angle of incidence, the beam inside of the lattice is self-
collimated and forced to propagate straight along the x-axis without diverging. When
the beam exits the lattice, the beam continues with essentially the same behavior
as it entered the lattice. In this simulation, nothing was done at the edges of the
photonic crystal to minimize reflections and the scattered waves can be observed in
the simulation. A reflected wave is observed at the input face of the lattice as well
as a self-collimated beam inside the lattice reflected from the output face.
To ensure the most reliable simulation possible, a convergence study should be
performed. It was observed that reasonable convergence was achieved at NRES = 20.
The grid strategy for this simulation is depicted in Figure 8.15. A UPML is
placed at all grid boundaries and will be 20 cells large. The input waveguide will
run the entire length of the grid in the x-direction. The second waveguide will run
parallel to the first waveguide, but its starting point will be some distance to the
right. The TF/SF interface will cross vertically through the grid just to the right of
the leftmost UPML. This is where the source will be injected into the input wave-
guide using the QAAQ technique.
A block diagram of the steps to simulate this OIC is provided in Figure 8.16.
The first three steps follow the ordinary FDFD algorithm summarized in Figure 8.5.
Before the OIC can be represented on a two-dimensional grid using the EIM, the
two effective refractive indices must be calculated. A first slab waveguide analysis
is performed for a slab waveguide defined by the vertical cross section off of the
rib waveguide. Given that the slab is illuminated with a vertically polarized mode,
the slab waveguide analysis must be H mode. The effective refractive index of the
fundamental mode from this analysis is recorded as neff,1. A second slab waveguide
analysis is performed for the H mode of a slab waveguide defined by the vertical
cross section on the rib waveguide. The effective refractive index of the fundamental
mode from this analysis is recorded as neff,2 . Now the OIC is constructed onto the
two-dimensional grid using neff,1 for locations off of the rib waveguide and n eff,2
for locations on the rib waveguide. It is now that a third slab waveguide analysis is
performed in the cross section of the grid perpendicular to the input waveguide. This
is calculated for the E mode and the fundamental mode is selected for the source.
The source function is created by calculating the fundamental mode across the entire
grid, adding phase at each position x according to exp(−jk0 neff x). Otherwise, the
FDFD analysis follows that of Figure 8.5 and is performed for the E mode. When
the simulation is finished, the field at the output is analyzed by weighing it against
all of the modes in the cross section of the waveguide. From this, transmission
and reflection are calculated. The last step is to visualize the fields calculated by
the simulation.
The MATLAB code to simulate this device can be downloaded at https://
empossible.net/fdfdbook/ and is called Chapter8_directionalcoupler.m. The
header for the function extends from lines 1 to 9. The first line is the name of the
MATLAB program. Lines 4 to 6 initialize MATLAB by closing any open figure
window, clearing the command window, and clearing all variables from memory.
Lines 8 and 9 define the units of the program. Being a photonics simulation, the only
unit defined here is micrometers, but it is often useful to also define nanometers.
Lines 11 to 36 comprise the dashboard of the program where all parameters are
defined that control the simulation. The source parameters are defined on lines 16
and 17 to include the free space wavelength lam0 and the free space wavenumber
k0. The parameters describing the dimensions and material properties of the rib
waveguide are defined from lines 19 to 25 just how they were in Chapter 6. Lines
27 to 30 define parameters specific to the directional coupler. This includes the
length of space L1 between the start of the input waveguide and the start of the
second waveguide, the length of the second waveguide L2, and the gap distance g
between the two waveguides. Observe that these are defined in terms of the source
wavelength lam0 instead of absolute dimensions. Using this approach, the OIC will
behave the same regardless of the chosen wavelength. If a parameter sweep is to be
performed, these parameters should be defined in terms of a design wavelength, not
the wavelength of the simulation. Last, lines 32 to 38 define all of the parameters
related to the numerical aspects of the simulation. NRES defines the resolution of the
simulation as the number of points per minimum wavelength. SPACER contains four
numbers identifying how much physical space there should be on all four sides of the
OIC. NPML contains a similar set of four numbers defining the size of the UPML at
each grid boundary in terms of the number of points. nmax is the maximum refractive
index occurring anywhere in the simulation. This is needed to later determine the
minimum wavelength that must be resolved by NRES cells.
With all of the parameters controlling the simulation defined, the first task is to
calculate a grid that is optimized for the device to be simulated. The grid is calculated
from lines 38 to 69 and starts by calculating the grid resolution parameters dx and
dy. They are calculated as the smallest wavelength in the simulation lam0/nmax
divided by NRES. This calculation does not consider at all the device dimensions
so it is entirely probable that critical dimensions are not represented exactly by an
integer number of cells on the grid. Having critical dimensions represented exactly
this way improves the accuracy and convergence rate of the simulation. To address
this, lines 46 to 60 adjust the grid resolution parameters dx and dy so that the
width of the rib waveguide is represented exactly by an integer number of cells. To
adjust dx, first nx is calculated as the number of cells that should exactly represent
the width of the rib. This is calculated as the width of the rib waveguide divided
by dx and then rounding up to the nearest integer. At this point, dx is adjusted by
recalculating it as the width of the rib divided by nx. Lines 49 and 50 repeat this
same calculation to adjust dy.
At this point, the grid resolution parameters dx and dy are fixed and will not be
changed again. The next step is to calculate both the physical size of the grid and
the number of points. Lines 53 to 55 do this for the x-direction. Sx is the physical
size of the grid in the x-direction and is calculated as the spacer regions plus the two
lengths of waveguide L1 and L2 defined in the dashboard. Observe that the order of
the terms to calculate Sx on line 53 matches where the dimensions lie on the grid.
This practice helps to ensure all dimensions are included and nothing is forgotten.
Nx is the number of cells of the grid in the x-direction and is calculated as Sx/dx
plus the UPML regions on the left and right sides of the grid. Line 55 recalculates
the physical size of the grid Sx because the UPMLs were not included in the first
calculation of Sx. The same three steps are repeated to calculate Sy and Ny that
represent the physical and numerical sizes of the grid in the y-direction.
With the grid parameters calculated and optimized for simulating the device
defined in the dashboard, the 2× grid parameters are calculated. This includes the
number of points Nx2 and Ny2 as well as the grid resolution parameters dx2 and
dy2. The last step in the grid calculation is calculating the axis arrays for both the
Yee grid, xa and ya, and the 2× grid, xa2 and ya2.
Before the device can be constructed onto the grid, the effective refractive
indices must be calculated that accurately represent the three-dimensional OIC in
two dimensions. Lines 71 to 175 perform two-slab waveguide analyses to determine
these. Following Figure 6.6, the first slab waveguide is constructed as a vertical cross
section through the OIC away from the rib waveguide. Lines 75 to 124 perform this
analysis following the same procedure discussed in Chapter 6 for slab waveguides.
The fundamental mode of the rib waveguide is vertically polarized indicating that
it is the H modes of the slab waveguide that must be calculated. Here the slab
waveguides have modes propagating in the +x-direction and the uniform direction
is y. Line 124 records the effective refractive index neff1 of the fundamental mode
away from the rib waveguide. Similarly, lines 126 to 175 perform the same analysis
of the vertical cross section through the rib waveguide. Line 175 records the effective
refractive index neff2 of the fundamental mode on the rib waveguide. The output
of this entire section of code is the two effective refractive indices neff1 and neff2.
With the grid calculated and the two effective indices calculated for the EIM,
lines 177 to 215 build the OIC onto the grid, incorporate the UPMLs and form the
diagonal materials matrices. Lines 182 and 183 initialize the relative permittivity
and relative permeability arrays on the 2× grid. The relative permittivity array ER2
is initialized to all values of neff1^2 so that it is only the ribs described by neff2^2
that must be incorporated. The effective refractive index is squared to convert the
refractive index to relative permittivity. The relative permeability array UR2 is set
to all ones. Lines 185 to 188 add the input waveguide to the array ER2. To do this,
the array indices of the vertical start and stop positions are calculated as ny1 and
ny2. Given these, the input waveguide is added across the grid in the x-direction
on line 188. A similar procedure is used to add the second waveguide in lines 190
to 194. One difference for the second waveguide is that the array index nx where
the waveguide starts in the x-direction is also calculated. The second waveguide is
added to ER2 on line 194. At this point, the array ER2 is finished and lines 196 to
201 visualize the two-dimensional model of the OIC. It is always a good practice
to visualize the arrays UR2 and ER2 to verify they represent the device correctly.
With the 2× grid arrays UR2 and ER2 constructed correctly, line 204 incorporates
the UPML and returns the materials arrays on the Yee grid ERxx, ERyy, ERzz, URxx,
URyy, and URzz. Lines 206 to 212 form the diagonal materials matrices that will be
used to calculate the wave matrix A in a later step.
With the device modeled onto the grid, the next step is to analyze the input
waveguide in order to calculate the source mode. This calculation is necessary
because the source is a guided mode. This happens on lines 214 to 243 where a third
slab waveguide analysis is performed of the cross section of the input waveguide.
Line 219 calculates the array index nx where the cross section is to be obtained.
Lines 220 to 222 do several things all at once. They extract the cross section of
the waveguide, extract the points from the 2× grid to the Yee grid, and form the
diagonal materials matrices for the slab waveguide analysis. Lines 224 to 228 build
the derivative matrices for the slab waveguide analysis. Dirichlet boundary conditions
are used. Lines 230 to 232 build the eigenvalue problem which is then solved on
lines 234 to 238. To be consistent with polarization, this slab is analyzed for the E
mode. Observe on line 235 that the A and B matrices of the generalized eigenvalue
problem are converted to full matrices, the command eig() is called instead of
eigs(), and no other input arguments are given. This is done because it is necessary
to calculate all of the eigenmodes from the eigenvalue problem to correctly analyze
reflected and transmitted fields. Since all of the modes are being calculated, there
is no need to specify the number of modes to calculate or give an estimate for the
eigenvalue. The eigenmodes are sorted in descending order of the real part of the
effective refractive indices. This places the fundamental mode in the first position.
Lines 241 to 243 extract both the field profile and the effective refractive index of
the fundamental mode. Observe that the eigenvector matrix Ez is recorded so that
it can be used later to calculate reflection and transmission.
Figure 8.17 Visualization of the source field fsrc for a guided mode.
combination of the eigenvectors in V. If the amplitudes of all the modes are stored
in a column vector a, then the overall field is f = Va. In the case of the FDFD simula-
tion, the overall field f is found from the simulation and it is the amplitudes stored
in a that need to be calculated. This is found by solving the matrix equation for a
to get a = V–1f. The fraction of power reflected into the fundamental mode R of the
input waveguide is calculated on line 292. The fraction of power transmitted in the
fundamental mode T of the input waveguide is calculated on line 293. These are
somewhat analogous to the reflectance and transmittance terms calculated in the
diffraction grating example. Depending on the circuit being analyzed, this R and T
will rarely obey conservation because power is often scattered out of the waveguides
or coupled into higher-order modes. The semicolons were left off of lines 292 and
293 so that the results are reported to the command window.
The very last step is to visualize the simulated results. This happens on lines 295
to 317. The field is visualized using the pcolor() function to obtain nice-looking
smooth fields. The device is superimposed using the contour() function.
References
[3] Umashankar, K., and A. Taflove, “A Novel Method to Analyze Electromagnetic Scattering
of Complex Objects,” IEEE Trans. on Electromagnetic Compatibility, Vol. EMC-24, No.
4, 1982, pp. 397–405.
[4] Saleh, B. E., and M. C. Teich, Fundamentals of Photonics, Hoboken, NJ: John Wiley &
Sons, 2019.
[5] Taflove, A., and S. C. Hagness, Computational Electrodynamics: The Finite-Difference
Time-Domain Method, Norwood, MA: Artech House, 2005.
[6] Hunsperger, R. G., Integrated Optics, New York: Springer, 1995.
[7] Hardy, A., and W. Streifer, “Coupled Mode Theory of Parallel Waveguides,” Journal of
Lightwave Technology, Vol. 3, No. 5, 1985, pp. 1135–1146.
[8] Haus, H. A., and W. Huang, “Coupled-Mode Theory,” Proceedings of the IEEE, Vol. 79,
No. 10, 1991, pp. 1505–1518.
[9] Huang, W.-P., “Coupled-Mode Theory for Optical Waveguides: An Overview,” Journal
of the Optical Society of America A, Vol. 11, No. 3, 1994, pp. 963–983.
[10] Yariv, A., “Coupled-Mode Theory for Guided-Wave Optics,” IEEE J. of Quantum
Electronics, Vol. 9, No. 9, 1973, pp. 919–933.
[11] Cohn, S. B., and R. Levy, “History of Microwave Passive Components with Particular
Attention to Directional Couplers,” IEEE Trans. on Microwave Theory and Techniques,
Vol. 32, No. 9, 1984, pp. 1046–1054.
[12] Levy, R., “Directional Couplers,” Advances in Microwaves, Vol. 1, 1966, pp. 115–209.
[13] Lu, J.-T., et al., “Terahertz Pipe-Waveguide-Based Directional Couplers,” Optics Express,
Vol. 19, No. 27, 2011, pp. 26883–26890.
Chapter 9 discusses how to modify the MATLAB code for finite-difference fre-
quency-domain (FDFD) in order to perform parameter sweeps. Different types of
parameter sweeps are discussed along with best practices. As a first example, the
response of a guided-mode resonance filter (GMRF) [1–4] is simulated as a func-
tion of wavelength in the range 1.4 μm < λ 0 < 1.5 μm. For the second example, the
geometry of a terahertz polarizer will be optimized and its response will be plotted
as a function of frequency.
Parameter sweeps are probably the most powerful tool in existence for analyzing and
designing electromagnetic and photonic devices. The concept is simple. The results
of a simulation are plotted as some variable is varied over a range of values. The
most common parameter sweep is probably transmission and reflection plotted as
a function of frequency. From parameter sweeps, trends can be determined, device
dimensions can be optimized, and discoveries can be made!
Parameter sweeps are as simple as placing a big for loop around the FDFD
code and recording the results as the loop iterates. This is incredibly easy to do if
proper dashboard discipline is being practiced. Careful thought should be given
about what steps in the FDFD algorithm are included inside of the loop. Steps that
produce the same result throughout the parameter sweep should be moved outside
of the loop if at all possible.
Block diagrams of common parameter sweeps are shown in Figure 9.1. First,
Figure 9.1(a) shows a block diagram summarizing the major steps in ordinary FDFD.
This is provided so that the modifications required for different parameter sweeps
can be more easily identified. Figure 9.1(b) shows a block diagram for a wavelength
(or frequency) parameter sweep that is by far the most common type of parameter
sweep. While it is possible to rebuild the grid and device for each wavelength, it
is not recommended because this practice will lead to a jagged response. Instead,
the grid and device should be constructed prior to the loop that is based on the
worst case requiring the finest resolution. This is usually the shortest wavelength
or highest frequency in the sweep. All other steps to implement the FDFD method
appear inside of the loop.
Another type of parameter sweep involves changing a dimension associated
with the device being simulated. This type of parameter sweep is used very often
to optimize the performance of a device. Figure 9.1(c) shows the flow of steps for
255
The biggest trick to make parameter sweeps easy and utilize simpler code is to
write a generic function that performs the FDFD analysis. By putting as much of
the FDFD code into the generic function as possible, the parameter sweep itself
becomes very short and simple. Having a generic function to implement the FDFD
method is useful for other things because programs can concentrate on building
devices and analyzing the results.
An excellent device to perform a parameter sweep for is a GMRF [1–4]. A
GMRF is both a diffraction grating [5] and a slab waveguide [6] at the same time.
For most frequencies, a GMRF behaves as an ordinary dielectric slab and exhibits
a slow and weak response in terms of transmission and reflection. Then, over a
very narrow range of frequencies, one of the diffraction orders from the diffraction
grating is able to couple power from the applied wave into a mode guided in the slab
and the transmission and reflection from the GMRF change abruptly. GMRFs are
incredibly sensitive to dimensions and material properties so if anything is wrong
with the FDFD code, a GMRF simulation will tend to amplify it. For this reason,
GMRFs are excellent devices for benchmarking and practicing FDFD simulations.
GMRFs are also very interesting and useful devices to study!
The GMRF that will be simulated is illustrated in Figure 9.2. The device itself
is a slab waveguide with a diffraction grating at its core. There is no requirement
where the diffraction grating has to reside relative to the slab waveguide as long as
they are close enough to be electromagnetically coupled. For a wavelength sweep,
the spacer regions are set to half of the maximum wavelength in the sweep. This is
a good choice if nothing else is known. However, if there is any apriori knowledge
of the resonant wavelength, the spacer regions could be set to half of the resonant
wavelength. It is the resonant wavelength that will have the largest evanescent fields
because this is the wavelength of the guided mode. Regardless, no evanescent fields
should be allowed to extend into the UPMLs. The simulation will calculate reflec-
tance and transmittance in the range 1.4 μm < λ 0 < 1.5 μm.
Figure 9.2 GMRF and representation on a two-dimensional FDFD grid. This device has f = 0.5,
n1 = 1.0, n2 = 1.4, n L = 1.9, n H = 2.1, d1 = 265 nm, d2 = 380 nm, and L = 870 nm. The product fL is
the physical width of the high-index region.
DAT = fdfd2d(DEV,SRC);
In a sense, demo_gmrf.m will be the first half of the original program fdfd2d_
proto.m while fdfd2d() will be the second half. Most of the work in creating the
two new MATLAB programs entails changing variable names to accommodate
the use of structures.
The overall grid strategy for simulating periodic structures that fdfd2d() will
assume is illustrated in Figure 9.3. Periodic boundary conditions (PBCs) are used
at the x-axis boundaries to model a device that is infinitely periodic in the x-direc-
tion. UPMLs are located at the y-axis boundaries to absorb outgoing waves. The
device itself is located near the center of the grid vertically. A top spacer region is
inserted above the device to allow sufficient space for the field to be visualized and
to prevent evanescent fields from entering the top PML. A bottom spacer region
is inserted below the device for the same reasons. The source is injected into the
simulation in the +y-direction at the TF/SF interface. The TF/SF interface can be
placed anywhere between the top PML and the device, but cannot overlap either of
these. For this example, the TF/SF interface is placed just a few cells below the top
PML but it can be located lower than this if it is desired to visualize more of the SF.
Immediately below the top PML is the reflection plane where the reflected waves
are analyzed. It must be located in the SF region so it can be placed anywhere above
the TF/SF interface and below the top PML. Immediately above the bottom, PML
is the transmission plane where the transmitted waves are analyzed. The location
of the transmission plane can be anywhere between the bottom of the device and
the bottom PML but not overlapping either of these.
The MATLAB code for the generic function fdfd2d() can be downloaded at
https://empossible.net/fdfdbook/. The first line is the function heading required
by MATLAB where the input arguments and output arguments are defined. The
commented section from lines 2 to 27 is what will be displayed to the command
window when help fdfd2d is typed at the command prompt. It is strongly
recommended to include a header like this in all functions in order to remember
Figure 9.3 Grid strategy assumed by the fdfd2d() function for simulating periodic structures
with FDFD.
how to use them at a later time. In this header, the input and output arguments
along with their fields are listed in the header. The structure DEV will contain the
arrays ER2 and UR2 to define what is to be simulated in a generic way. DEV will also
contain RES with the grid resolution parameters dx and dy and NPML with the size
of the UPML at the top and bottom of the grid. The function will always simulate
periodic structures so no UPML is used on the left and right sides of the grid. The
structure SRC will contain the free space wavelength lam0, the angle of incidence
theta, and the mode MODE to be simulated that will be either an “E” or an “H.”
It is strongly recommended to avoid having redundant input arguments. For
example, it would be a huge mistake to make the grid size parameters Nx and Ny
be input arguments. That is because these can be determined from the inside of
the fdfd2d() function from the size of either ER2 or UR2. Having redundant input
arguments creates extra work and the potential for mistakes.
The section from lines 29 to 56 is a new section that is needed to extract all
of the required FDFD parameters from the input arguments. Line 34 determines
the size of the 2× grid from the size of the ER2 array. Lines 36 to 45 calculate the
remaining grid parameters and the meshgrid for the Yee grid. Line 48 calculates
the free space wavenumber. Lines 51 to 56 extract the material properties of the
external regions. These are needed to calculate the source and to calculate reflection
and transmission.
The FDFD method is implemented from lines 62 to 105. This code is essentially
unchanged from Chapter 8. The simulated field is then postprocessed to analyze
reflection and transmission. This analysis appears from lines 107 to 135. Other than
using the variables inside of the structures, the code is identical to that discussed
in Chapter 8.
Observe that this fdfd2d() function is generic in the sense that it does not
have to know anything about the device being simulated. As long as the device is
to be simulated with PBCs on the left and right boundaries, this same code can
simulate virtually any periodic structure. Not only does this function allow for
easy parameter sweeps, it can also simplify code intended to simulate devices at
just a single frequency by eliminating all of the FDFD steps. It is a very versatile
and useful function to have!
and ny2 are the array indices of the top and bottom of the top layer of the GMRF.
The variables ny3 and ny4 are the array indices of the top and bottom of the grating
layer. Last, the variables ny5 and ny6 are the array indices of the top and bottom of
the bottom layer of the GMRF. Given all of these array indices, lines 94 to 98 build
the GMRF into the ER2 array. The array ER2 is visualized from lines 100 to 105 to
the first subplot of a figure window that is five subplots wide. The field calculated
during the simulation will be displayed to the second subplot and the reflection and
transmission spectra will be displayed in the third to fifth subplot spaces.
The wavelength sweep is implemented in the next section of the code from lines
107 to 152. Line 112 defines the structure field RES that contains the grid resolution
parameters dx and dy. Lines 115 to 117 initialize the three arrays where the response
of the device will be stored. REF will contain the overall reflectance calculated for
each wavelength in the array LAMBDA, TRN will contain the overall transmittance,
and CON will contain the power conservation that is reflectance plus transmittance.
It is always best practice to plot the conservation in addition to reflectance and
transmittance because this is a great indicator of the health and accuracy of the
simulation. It should be within 1% of 100% for all frequencies. Sometimes larger
errors arise around wavelengths that correspond to the cutoff of a diffraction order
where waves are propagating nearly parallel to the x-axis. The wavelength sweep
itself occurs from lines 119 to 152 inside of a for loop. For important loops, consider
using a bit more significant comment like what is on lines 119 to 121. Line 122
starts the for loop to progress the variable nlam from a value of 1 at the start of the
sweep to a value of NLAM at the end of the sweep. The first step inside of the loop is
on line 125 where the free space wavelength lam0 is set for the current simulation.
Line 128 then performs the FDFD simulation at this wavelength. Lines 131 to 133
record the result. This is very simple code that demonstrates how easy parameter
sweeps become when there exists a generic function to perform the simulation! The
rest of the code in the loop simply visualizes the results. Lines 135 to 140 visualize
the field calculated at each wavelength in the second subplot. Lines 143 to 151 plot
the reflection and transmission spectrum as they are calculated. It is very good
practice to visualize the device, field, and spectra during the sweep. These are the
key things to visualize to catch errors and monitor the status of the simulation.
As discussed in previous chapters, having code that runs without error is not
sufficient to simulate a device. A convergence study must be performed. If nothing is
known about the device, convergence can be checked at the shortest wavelength that
will typically converge last. If anything is known about the device, convergence can
be checked at the resonant wavelength that usually exhibits the slowest convergence.
It is even possible to track the center position of resonance of the GMRF and plot that
as a function of NRES. Regardless of how it is done, make performing a convergence
study standard practice!
This device was found to converge somewhere between NRES=20 and NRES=40.
Figure 9.4 shows the reflection, transmission, and conservation lines for a wavelength
sweep performed with NRES=40 for the E mode at two different angles of incidence.
A narrow resonance is observed around λ 0 = 1.5 μm for normal incidence. For the
very small angle of incidence of 2.5°, the resonance split into two resonances observed
around λ 1 = 1.465 μm and λ 2 = 1.53 μm. GMRFs are very sensitive devices!
Figure 9.4 Spectral response of the GMRF in Figure 9.2 for the E mode at two different angles
of incidence.
Figure 9.5 Geometry of the polarizer presented in [7] along with the direction of TE and TM
polarization. The optimized design has a = 4.0 μm, t = 200 nm, w = 2.0 μm, and d = 1.5 μm. The
dielectric constant of the substrate is ε r = 11.8 and the gold is made a perfect electric conductor
(PEC).
because there are two layers of wires at different heights, and the interaction between
the two produces the broadband and high extinction ratio that the device exhibits.
When the electric field is polarized parallel to the wires, the field is able to push
the free charges along the wires and the device acts much like a solid metal surface,
reflecting the wave. This is called the transverse electric
! (TE) polarization because
the electric field is transverse to the grating vector K that defines the period and
direction of the grooves. When the electric field is polarized perpendicular to the
wires [transverse magnetic (TM) polarization], the free charges in the wires are
constrained in the perpendicular direction and the device acts more like a dielectric,
allowing the wave to transmit. This is called the ! TM polarization because the
magnetic field is transverse to the grating vector K.
The extinction ratio ξ is the transmittance TTM of the TM wave that transmits
through the polarizer divided by the transmittance TTE of the TE wave blocked by
the polarizer.
TTM
x= (9.1)
TTE
floor() by two, multiplying the result of floor() by two, and then adding one.
nx2 is the ending index which should also be an odd number for the same reason.
Since nx was calculated to be an even number, nx2 is guaranteed to be odd. In the
y-direction, ny1 and ny2 are the start and stop array indices of the top metal layer
and ny3 and ny4 are the start and stop array indices of the bottom metal layer.
These are also calculated in a way that ensures they are odd numbers. Given the
start and stop array indices, lines 133 to 137 build the polarizer onto the 2× grid.
Just prior to simulation, line 140 defines the remaining field DEV.RES that
specifies the resolution parameters dx and dy to the function fdfd2d(). From there,
the E mode (TE polarization) is simulated on lines 142 and 143 and the results are
recorded on lines 145 to 147. Similarly, the H mode (TM polarization) is simulated
on lines 150 and 151 and the results are recorded on lines 152 to 154. Lines 156 to
158 calculate the extinction ratio on a linear scale in the array ER and also calculate
it on a decibel (dB) scale in the array ER_dB. Lines 160 to 179 visualize the fields for
each mode and plot the extinction ratio as the simulation is running. It is always
a good practice to visualize the intermediate results of a parameter sweep as it is
running because errors can often be caught early on without having to wait for the
parameter sweep to finish.
The results of the parameter sweep are shown in Figure 9.6 and were obtained
with NRES=200. It is typical for simulations of subwavelength metallic devices to
require high values of NRES. In [7], a value of d = 1.5 μm was chosen for the
grating depth.
Given a design, a second parameter sweep was performed for this device to plot
transmittance and extinction ratio as a function of frequency from 0.6 THz up to
3.0 THz. The simulation results shown in Figure 9.7 for this sweep were obtained
at NRES=200. The MATLAB code for this parameter sweep can be downloaded at
https://empossible.net/fdfdbook/ and is called Chapter9_polarizer_freq.m.
Most simulation problems are more easily diagnosed when performing parameter
sweeps than they are when simulating a single case at a single frequency. Figure
9.8 illustrates three common problems in FDFD that can be identified through the
power conservation versus frequency response. The first common problem is when
the absorbing boundaries are not working correctly. To demonstrate this, a vacuum
was simulated and the PMLs were forced to produce some reflections by making
them only four cells large. Reflections from the boundaries cause standing waves
that tend to produce a slow-rolling response in the power conservation. The solid
black line in Figure 9.8 shows the power conservation line for an FDFD simulation
of a vacuum where the bottom PML is partially reflecting.
A second common problem is insufficient grid resolution. This tends to produce a
power conservation that steadily worsens with increasing frequency, as demonstrated
by the line with long dashes in Figure 9.8 that is also a simulation of a vacuum. This
happens because the lower frequencies have longer wavelengths that are resolved with
less numerical error by the grid. To mitigate this, it is not recommended to adjust
the resolution of the grid for different frequencies because this will lead to jagged
response lines. Instead, calculate the grid based on worst cases, such as the smallest
dimensions and highest frequencies, and use the same grid for all frequencies. It is
always best in parameter sweeps to keep the simulations as similar as possible to
avoid jagged response lines.
A third common problem happens when the spacer regions are made too small.
This tends to produce localized spikes in the power conservation, usually around
the cutoff frequencies of diffraction orders. The dotted line in Figure 9.8 shows the
frequency response of the sawtooth diffraction grating presented in Chapter 8. The
solid vertical lines in the figure identify where the diffraction orders have cutoff
frequencies. Observe that the spikes in the conservation line correspond to the cutoff
frequencies. Diffraction orders near cutoff can produce large evanescent fields or
waves propagating near parallel to the x-axis. Neither of these are handled well by
diffraction order calculations or by the PMLs at the y-axis boundaries. Virtually
all numerical methods have similar problems resolving the response of periodic
structures near cutoff frequencies. Making the spacer regions too large will not
hurt the accuracy of the simulation, but the simulations will require more memory
and take a longer time to run.
References
[1] Barton, J. H., et al., “All-Dielectric Frequency Selective Surface for High Power Microwaves,”
IEEE Trans. on Antennas and Propagation, Vol. 62, No. 7, 2014, pp. 3652–3656.
[2] Magnusson, R., and Y. H. Ko, “Guided-Mode Resonance Nanophotonics: Fundamentals
and Applications” p. 992702.
[3] Mehta, A. A., et al., “Guided Mode Resonance Filter as a Spectrally Selective Feedback
Element in a Double-Cladding Optical Fiber Laser,” IEEE Photonics Technology Letters,
Vol. 19, No. 24, 2007, pp. 2030–2032.
[4] Rumpf, R. C., et al., “Guided-Mode Resonance Filter Compensated to Operate on a
Curved Surface,” Progress in Electromagnetics Research, Vol. 40, 2013, pp. 93–103.
[5] Loewen, E. G., and E. Popov, Diffraction Gratings and Applications: CRC Press, 2018.
[6] Okamoto, K., Fundamentals of Optical Waveguides: Academic Press, 2006.
[7] Deng, L., et al., “Extremely High Extinction Ratio Terahertz Broadband Polarizer Using
Bilayer Subwavelength Metal Wire-Grid Structure,” Applied Physics Letters, Vol. 101,
No. 1, 2012, p. 011101.
matrices can make calculating big and complicated matrices much simpler. To fin-
ish the formulation, incorporating sources using the TF/SF method and solving the
final matrix equation by iteration is discussed.
1 ∂Ez 1 ∂Ey
sy ∂y
−
sz ∂z (
= k0 mxx H! x + mxy H! y + mxz H! z ) (10.1)
1 ∂Ez
1 ∂Ex
sz ∂z
−
sx ∂x (
= k0 myx H! x + myy H! y + myz H! z ) (10.2)
1 ∂Ey
sx ∂x
−
1 ∂Ex
sy ∂y (
= k0 mzx H! x + mzy H! y + mzz H! z ) (10.3)
1 ∂H! z 1 ∂H! y
sy ∂y
−
sz ∂z (
= k0 exx Ex + exy Ey + exz Ez ) (10.4)
1 ∂H! x 1 ∂H! z
sz ∂z
−
sx ∂x (
= k0 eyx Ex + eyy Ey + eyz Ez ) (10.5)
1 ∂H! y 1 ∂H! x
sx ∂x
−
sy ∂y (
= k0 ezx Ex + ezy Ey + ezz Ez ) (10.6)
In the above equations, μ mn and ε mn are the tensor elements of permeability and
permittivity, respectively. The terms sx, sy, and sz are the complex stretching param-
eters associated with the SCPML. From here, the grid is normalized according to
x′ = k0 x, y′ = k0 y, and z′ = k0 z to arrive at the final form of the analytical equations.
1 ∂Ez 1 ∂Ey
− = mxx H! x + mxy H! y + mxz H! z (10.7)
sy ∂ y′ sz ∂z′
1 ∂Ex 1 ∂Ez
− = myx H! x + myy H! y + myz H! z (10.8)
sz ∂z′ sx ∂ x′
1 ∂Ey 1 ∂Ex
− = mzx H! x + mzy H! y + mzz H! z (10.9)
sx ∂ x′ sy ∂ y′
1 ∂H! z 1 ∂H! y
− = exx Ex + exy Ey + exz Ez (10.10)
sy ∂ y′ sz ∂z′
1 ∂H! x 1 ∂H! z
− = eyx Ex + eyy Ey + eyz Ez (10.11)
sz ∂z′ sx ∂ x′
1 ∂H! y 1 ∂H! x
− = ezx Ex + ezy Ey + ezz Ez (10.12)
sx ∂ x′ sy ∂ y′
Now (10.7) to (10.12) must be made discrete. Writing these equations in dis-
crete form is trickier than it was in previous chapters due to the PML terms and
the incorporation of general anisotropy. Start by taking a guess at expressing (10.7)
in a discrete form where the partial derivatives are approximated using central
finite differences.
Ez − Ez Ey − Ey
1 i,j+1,k i,j,k 1 i,j,k+1 i,j,k
−
sy
Hx
Δy sz
Hx
Δz
i,j,k
(10.13)
i,j,k
are located at entirely different locations than H! x . To correct this, the products
i,j,k
!
mxy H! y and mxz Hz are interpolated at the location of H! x . These interpolations are
i,j,k
essentially the average value from the surrounding four points.
Ez − Ez Ey − Ey
1 i,j+1,k i,j,k 1 i,j,k+1 i,j,k
−
sy
Hx
Δ y′ sz
Hx
Δz ′
i,j,k i,j,k
= mxx i,j,k H! x
i,j,k
1 Ex i,j,k+1 − Ex i,j,k 1 Ez − Ez
i+1,j,k i,j,k
− (10.17)
sz
Hy
Δz ′ sx i,j,k
Hy
Δ x′
i,j,k
1 H! z − H! z 1 H! y − H! y
i,j,k i,j−1,k i,j,k i,j,k−1
Ex
− Ex (10.19)
sy Δyʹ sz Δ zʹ
i,j,k i,j,k
1 H! x − H! x 1 H! z − H! z
i,j,k i,j,k−1 i,j,k i−1,j,k
− (10.20)
sz
Ey
Δz ′ Ey
sx i,j,k Δ x′
i,j,k
H! y − H! y H! x − H! x
1 i,j,k i−1,j,k 1 i,j,k i,j−1,k
− (10.21)
Ez
sx i,j,k Δ x′ sy
Ez
Δ y′
i,j,k
Inspection of (10.16) to (10.18) shows that μ xx, μ yx, and μ zx should be defined
at the same points as H! x . Similarly, μ xy, μ yy, and μ zy should be defined at the same
points as H! y and μ xz, μ yz, and μ zz should be defined at the same points as H! z .
Inspection of (10.19) to (10.21) shows that ε xx, ε yx, and ε zx should be defined at the
same points as Ex. Similarly, ε xy, ε yy, and ε zy should be defined at the same points
as Ey and ε xz, ε yz, and ε zz should be defined at the same points as Ez.
SHx
y
Dey′ez − SHx
z
Dez′e y = µ xx h! x + R −x R +y µ xy h! y + R −x R +z µ xz h! z (10.22)
SHy Dez′e x − SHy Dex′ez = R −y R +x µ yx h! x + µ yy h! y + R −y R +z µ yz h! z (10.23)
z x
SHz
x
Dex′e y − SHz
y
Dey′e x = R −z R +x µ zx h! x + R −z R +y µ zy h! y + µ zz h! z (10.24)
SEx
y
Dhy′ h! z − SEx
z
Dhz′ h! y = ε xxe x + R +x R −y ε xye y + R +x R −z ε xz ez (10.25)
SEy Dhz′ h! x − SEy Dhx′ h! z = R +y R −x ε yxe x + ε yye y + R +y R −z ε yz ez (10.26)
z x
SEz
x
Dhx′ h! y − SEz
y
Dhy′ h! x = R +z R −x ε zxe x + R +z R −y ε zye y + ε zz ez (10.27)
Two new types of matrices have appeared in these equations compared to
what was presented in Chapter 4 due to incorporating the SCPML and performing
interpolations. The S terms are diagonal matrices containing the inverse of the PML
terms across the Yee grid along their diagonal. The term SyHx is a diagonal matrix
containing the sy–1(x,y,z) PML function at the locations of H! x . The other S
i,j,k
matrices are defined similarly. The R terms are matrices that perform interpolations
across the Yee grid and look very similar to the derivative matrices. The term R x+
interpolates a function by averaging the function with the value in the next cell
in the positive x-direction. The term R x– interpolates a function by averaging the
function with the value in the previous cell in the positive x-direction. The term
Ry+ interpolates a function by averaging the function with the value in the next cell
in the positive y-direction. The term Ry– interpolates a function by averaging the
function with the value in the previous cell in the positive y-direction. The term
R+z interpolates a function by averaging the function with the value in the next cell
in the positive z-direction. The term R z– interpolates a function by averaging the
function with the value in the previous cell in the positive z-direction.
∂Ez Ez − Ez
i+1,j,k i,j,k
≈ → Dex′ez (10.28)
∂ x′ Δ x′
An interpolation operation utilizes the same terms as (10.28), but adds the
terms instead of subtracting them, and divides by two instead of dividing by Δx′.
Ez + Ez
i+1,j,k i,j,k
Ez ≈ → R +xez (10.29)
i+0.5,j,k 2
In fact, when Dirichlet boundary conditions are used, the interpolation matri-
ces can be calculated directly from the derivative matrices. First, the absolute value
of every element in the derivative matrix is calculated to convert the subtraction
to an addition. Second, the new matrix is multiplied by the resolution parameter
Δx′ and then divided by two. From this, R x+, Ry+, and R+z can be calculated directly
from Dx′e
, Dye ′ , and Dez′ as
Δ x′ Δ y′ Δz ′
R +x = ⋅ Dex′ R +y = ⋅ Dey′ R +z = ⋅ Dez′ (10.30)
2 2 2
If periodic boundary conditions (PBCs) are used, the interpolation matrices can-
not be calculated from the derivative matrices because the absolute value operation
alters any complex numbers. A separate function must be written in MATLAB to
build the interpolation matrices when PBCs are used. The code to do this is nearly
identical to building derivative matrices. To make things easier, after R x+, Ry+, and
R z+ are calculated, the remaining interpolation matrices can be calculated directly
from them as follows.
( ) ( ) ( )
H H H
R −x = R +x R −y = R +y R −z = R +z (10.31)
Equation (10.31) is valid for both Dirichlet boundary conditions and PBCs. If
any other boundary conditions are used, be cautious as (10.31) may no longer be
valid. While (10.31) may look like how the derivative matrices were related, the
relation for interpolation matrices has no negative sign. Be careful!
These equations can be written in an even more compact block matrix form as follows.
"
!
Cee = [ µ ] h! (10.34)
"
!
C h = [ε ]e
h!
(10.35)
where
⎡ e ⎤
! ⎢ ⎥
x
e = ⎢ ey ⎥ (10.36)
⎢ ⎥
⎢⎣ ez ⎥⎦
⎡ h! ⎤
" ⎢ x ⎥
h! = ⎢ h! y ⎥ (10.37)
⎢ ⎥
⎢ h! z ⎥
⎣ ⎦
⎡ ε xx R +x R −y ε xy R +x R −z ε xz ⎤
⎢ ⎥
[ ε ] = ⎢ R+y R−x ε yx ε yy R+y R−z ε yz ⎥ (10.40)
⎢ + − + −
⎥
⎢ R z R x ε zx R z R y ε zy ε zz ⎥
⎣ ⎦
⎡ µ xx R −x R +y µ xy R −x R +z µ xz ⎤
⎢ ⎥
[ µ ] = ⎢ R−y R+x µ yx µ yy R−y R+z µ yz ⎥ (10.41)
⎢ − + − +
⎥
⎢ R z R x µ zx R z R y µ zy µ zz ⎥
⎣ ⎦
The column vectors ex, ey, and ez for the electric field components have been
!
assembled into the single-column vector e. The column vectors h! x , h! y , and h! z for
"
the magnetic field components have been assembled into the single-column vector h. !
The curl matrix operating on the electric fields is now written as C and includes the
e
SCPML terms. The curl matrix operating on the magnetic fields is written as Ch and
also includes the SCPML terms. The material tensors now contain the interpolation
matrices and are written as [εε ] and [μμ ].
From here, two different matrix wave equations can be derived and either
can be used to analyze a device. Unlike two-dimensional FDFD, these two wave
equations are not calculating two different modes. They are performing the" very
same analysis, just in terms of different fields. To start, (10.34) is solved for h! and
!
(10.35) is solved for e.
"
"
h! = [ µ ] Cee
−1
(10.42)
!
!
e = [ ε ] Ch h"
−1
(10.43)
!
A matrix wave equation in terms of just the electric fields e is derived by sub-
stituting (10.42) into (10.35).
(C [µµ ]
h −1
) !
Ce − [ ε ] e = 0
(10.44)
The matrix division by [μ μ ] in (10.44) can be very slow when calculating the wave
matrix, especially when the permeability is anisotropic. To speed computation, it
is helpful to describe the device from the beginning in terms of its impermeability
[ψ (x,y,z)] instead of its permeability [μ (x,y,z)]. These are related through [ψ (x,y,z)]
= [μ (x,y,z)] –1. If for some reason the permeability must be calculated first, the
impermeability can be calculated from the permeability using (10.45) [1]. This
equation is best implemented in MATLAB when the μ mn terms are arrays.
Using impermeability [ψ (x,y,z)], the wave matrix contains only matrix multi-
plications that are much faster and more efficient to calculate. The revised matrix
wave equation is
( !
Ch [ ψ ] Ce − [ ε ] e = 0)
(10.46)
Following
" a similar procedure, a matrix equation in terms of just the magnetic
fields h! is derived by substituting (10.43) into (10.34).
"
( −1
)
Ce [ ε ] C h − [ µ ] h! = 0
(10.47)
The matrix division in (10.47) is also very slow to calculate, especially when the
permittivity is anisotropic. In this case, it is helpful to describe the device in terms
of its impermittivity [ζ (x,y,z)] instead of its permittivity [ε (x,y,z)]. These are related
through [ζ (x,y,z)] = [ε (x,y,z)]–1. If for some reason the permittivity must be calculated
first, the impermittivity can be calculated from the permittivity using (10.48). This
equation is best implemented in MATLAB when the ε mn terms are arrays.
⎡ e e −e e exz ezy − exy ezz exy eyz − exz eyy ⎤
⎢ yy zz yz zy ⎥
⎢ eyz ezx − eyx ezz exx ezz − exz ezx exz eyx − exx eyz ⎥
⎢ ⎥
⎢ eyx ezy − eyy ezx exy ezx − exx ezy exx eyy − exy eyx ⎥
⎦
[z ] = e e e ⎣ − e e e − e e e − exy eyx ezz + exy eyz ezx + exz eyx ezy
(10.48)
xx yy zz xx yz zy xz yy zx
Using impermittivity [ζ (x,y,z)], the revised matrix wave equation contains
only multiplications.
!
(
Ch [ζ ] Ce − [ ε ] e = 0 )
(10.49)
Neither of the matrix wave equations derived above are yet solvable because a
source has not been incorporated.
The matrix wave equations derived above contain all three vector components of
the electric field (or magnetic field). Therefore, all three vector components of the
source must be calculated. When the electric field wave equation is being solved,
the components of the source field are E x,src(x,y,z), Ey,src(x,y,z), and Ez,src(x,y,z).
It is important to remember that the field components are at physically different
locations due to the staggering of the Yee grid. This must be taken into account when
calculating the source components because they will all have a slightly different phase.
After calculation, the three discrete functions are reshaped into the column vectors
!
ex,src, ey,src, and ez,src and assembled into a block column vector esrc according to
⎡ e ⎤
! ⎢ x,src ⎥
esrc = ⎢ e y,src ⎥ (10.50)
⎢ ⎥
⎢⎣ ez,src ⎥⎦
Each source field component has its own TF/SF regions. Qx is the SF masking
matrix for e x,src , Q y is the SF masking matrix for e y,src , and Qz is the SF mask-
ing matrix for e z,src. It is standard practice to build one matrix Qxyz and use
this same matrix for all field components (Qx = Q y = Qz = Qxyz). Given these,
the overall SF masking matrix Q is still a diagonal matrix as it was for two-
dimensional FDFD.
⎡ Q 0 0 ⎤ ⎡ Q xyz 0 0 ⎤
⎢ x ⎥ ⎢ ⎥
Q = ⎢ 0 Q y 0 ⎥ = ⎢ 0 Q xyz 0 ⎥ (10.51)
⎢ ⎥ ⎢ ⎥
⎢⎣ 0 0 Q z ⎦⎥ ⎢⎣ 0 0 Q xyz ⎥⎦
!
After calculating the source field esrc , the wave matrix A, and the SF masking
matrix Q, the source vector b is calculated using the standard QAAQ equation
introduced in Chapter 8.
!
b = ( QA − AQ ) esrc (10.52)
⎡ A11 0 0 ⎤
⎢ ⎥
0 A22
P = diag ( A ) = ⎢ ⎥ (10.54)
⎢ 0 ! 0 ⎥
⎢ 0 AMM ⎥
⎣ ⎦
tol = 1e-10;
maxit = 15000;
f0 = zeros(M,1); %M is number of rows in A
f = qmr(A,b,tol,maxit,[],[],f0);
In the above code, tol is the tolerance that controls how well converged the final
answer should be. The variable maxit sets the maximum number of iterations in
case the solver is failing to converge to a solution. The number of iterations required
to solve an FDFD problem can range from several hundred to many thousands,
depending on the size and complexity of the simulation. f0 is an initial guess for
the solution. Since the solution is completely unknown, it is set to all zeros in the
code above. When performing parameter sweeps, there may be some benefit to
seeding the current simulation with the results from the previous if the changes to
the problem are small from one step to the next in the sweep. The last line in the
code above solves the matrix equation using the qmr() solver.
If a graphical processing unit (GPU) is available to MATLAB, significant speed
gains can be achieved by performing the iteration on the GPU. MATLAB makes
this as easy as assigning the A and b terms to the GPU, calling the iterative solver,
and then gathering the solution f back from the GPU after the solution is obtained.
When the arrays are assigned to the GPU, the iterative solver in MATLAB auto-
matically knows to solve them on the GPU. Representative code to solve Af = b
iteratively on a GPU in MATLAB is
tol = 1e-10;
maxit = 15000;
f0 = zeros(M,1); %M is number of rows in A
A = gpuArray(A);
b = gpuArray(B);
f = qmr(A,b,tol,maxit,[],[],f0);
f = gather(f);
When a structure is periodic in both the x- and y-directions, the structure can be
analyzed as a crossed grating as discussed in Chapter 2. Calculating reflection and
transmission will be performed through the diffraction orders. It is a straightforward
extension of how this calculation was done for two-dimensional simulations ! in
Chapter 8. For three-dimensional simulations, the source wave vector kinc is
described by the angles θ inc and ϕ inc as
2p
kx ( m, n ) = kx,ref ( m, n ) = kx,trn ( m, n ) = kx,inc − m (10.58)
Λx
2p
ky ( m, n ) = ky,ref ( m, n ) = ky,trn ( m, n ) = ky,inc − n (10.59)
Λy
kz,ref ( m, n ) = − (k n )
0 ref
2
− kx2 ( m, n ) − ky2 ( m, n )
(10.60)
(k0ntrn )
2
kz,trn ( m, n ) = − kx2 ( m, n ) − ky2 ( m, n ) (10.61)
When the simulation is finished, the field is analyzed to calculate the complex
amplitudes of the diffraction orders in the same three steps it was for two-dimen-
sional simulations. First, the fields are extracted from the cross sections of the grid
at both the reflection and transmission planes. These are ⟨E x,ref(x,y)⟩, ⟨Ey,ref(x,y)⟩,
⟨Ez,ref(x,y)⟩, ⟨E x,trn(x,y)⟩, ⟨Ey,trn(x,y)⟩ and ⟨Ez,trn(x,y)⟩. The x, y, and z field com-
ponents reside at different locations on the grid so they must be interpolated at a
common point. The angled-bracket operation ⟨ ⟩ represents the field components
interpolated at the origins of the Yee cells. Second, the phase tilt due to an oblique
angle of incidence is removed to isolate the envelope term of the Bloch modes. A
cross section of the source wave will be used as the phase tilt in this calculation
so that exp[−j(kx,inc x + ky,incy)] does not have to be calculated again. The envelope
functions are calculated according to
(
ax,ref ( x, y ) = Ex,ref ( x, y ) ÷ exp ⎡ − j kx,inc x + ky,inc y ⎤
⎣ ⎦ )
ay,ref ( x, y ) = Ey,ref ( x, y ) ÷ exp ⎡ − j ( k x + ky,inc y )⎤ (10.62)
⎣ x,inc ⎦
az,ref ( x, y ) = Ez,ref ( x, y ) ÷ exp ⎡ − j ( k x + ky,inc y )⎤
⎣ x,inc ⎦
(
ax,trn ( x, y ) = Ex,trn ( x, y ) ÷ exp ⎡ − j kx,inc x + ky,inc y ⎤
⎣ ⎦ )
ay,trn ( x, y ) = Ey,trn ( x, y ) ÷ exp ⎡ − j ( k x + ky,inc y )⎤ (10.63)
⎣ x,inc ⎦
az,trn ( x, y ) = Ez,trn ( x, y ) ÷ exp ⎡ − j ( k x + ky,inc y )⎤
⎣ x,inc ⎦
Third, the complex amplitudes of the diffraction orders are calculated from
the discrete Fourier transform of the amplitude functions calculated in (10.62) and
(10.63). Using a two–dimensional fast Fourier transform (FFT) algorithm, these
are calculated as
Given the complex amplitudes of the diffraction orders, the diffraction efficien-
cies are calculated using the equations derived in Chapter 2. These are
2
E0,ref ( m, n ) ⎡ k ( m, n ) ⎤
RDE ( m, n ) = 2 Re ⎢ − z,ref ⎥ (10.66)
E0,inc ⎢⎣ kz,inc ⎥⎦
2
E0,trn ( m, n) ⎡m k ( m, n) ⎤
TDE ( m, n) = Re ⎢ r,ref z,trn ⎥ (10.67)
⎣ mr,trn
2
E0,inc kz,inc ⎦
Equations (10.66) and (10.67) are used when it is the electric field being solved
by FDFD. If instead it is the magnetic field being solved, the diffraction efficiency
calculations are
2
H! 0,ref ( m, n ) ⎡ k ( m, n ) ⎤
RDE ( m, n ) = 2 Re ⎢ − z,ref ⎥ (10.68)
H! 0,inc ⎢⎣ kz,inc ⎥⎦
2
H! 0,trn ( m, n) ⎡e k ( m, n) ⎤
TDE ( m, n) = Re ⎢ r,ref z,trn ⎥ (10.69)
⎣ er,trn
2
H! 0,inc kz,inc ⎦
Figure 10.1 Standard sequence of simulations for a newly written 3D FDFD code. (a) and
(b) Simulations in a vacuum. (c) and (d) Simulations of a single interface. (e) and (f) Simulations
of an asymmetric diffraction grating. (g) and (h) Simulations of a guided-mode resonance filter
(GMRF).
After the FDFD code can simulate vacuum correctly, the next thing is to move the
TF/SF interface five or so cells below the top PML and then build a single material
interface onto the grid. This is illustrated in Figure 10.1(c) that also shows an LP
wave at normal incidence. In this case, the Fresnel equations discussed in Chapter 2
can be used to verify the simulation results are correct. First, fill the bottom half
of the grid with ε r = 9.0 and μ r = 1.0. For normal incidence, this causes exactly
25% reflectance and 75% transmittance. The most common mistake here is not
calculating the diffraction efficiency of the transmitted diffraction orders correctly
because that equation contains extra terms that are easily missed. After this, swap
the permittivity and permeability such that ε r = 1.0 and μ r = 9.0 and ensure the
simulation still gives 25% reflectance and 75% transmittance. Next, set ε r = μ r =
3.0 and verify reflectance is near 0% and transmittance is near 100%. This case
produces no reflections because the impedance is constant throughout the grid.
Figure 10.2 (a) Correct simulation where source wave is linearly polarized and at normal
incidence. (b) Correct simulation where source wave is circularly polarized and incident
at θ = ϕ = 30°.
Next, incorporate an angle of incidence along with circular polarization and repeat
various combinations of ε r and μ r, as illustrated in Figure 10.1(d). Using the Fresnel
equations, an infinite number of simple simulations are possible. Simulate a few
simple cases and then move on.
Next, it is best to simulate an asymmetric diffraction grating. An asymmet-
ric diffraction grating is illustrated in Figure 10.1(e) and is an excellent device to
verify that the diffraction orders are being handled correctly in the FDFD code.
The same asymmetric diffraction grating simulated in Chapter 8 can be repeated
for three-dimensional simulations as well. The grating can be rotated by 90° to
verify the diffraction orders are being handled correctly in the x- and y- directions
independently. The same asymmetric diffraction grating is simulated again, but
with an angle of incidence incorporated, as illustrated in Figure 10.1(f). The last
simulation for testing new codes is a wavelength (or frequency) sweep of a GMRF,
as illustrated in Figure 10.1(g) and (h). GMRFs are extremely sensitive devices. If
anything is wrong in the code, a GMRF will tend to amplify the problem so that
even small mistakes can be identified and corrected. This type of simulation will
be performed in Section 10.5.3 for a crossed-grating GMRF.
Figure 10.3 Grid strategy assumed by the fdfd3d() function for simulating periodic structures
with FDFD.
above the bottom PML are the transmission planes where the transmitted waves
will be analyzed. Two planes are needed because the z component of the field will
have to be interpolated between two values in the z-direction. The device itself is
located near the center of the grid vertically with spacer regions placed above and
below the device. It is up to the function calling the fdfd3d() function to add the
spacer regions.
The MATLAB code for the generic fdfd3d() function can be downloaded at
https://empossible.net/fdfdbook/. The header extends from lines 2 to 41 and is what
is displayed in the command window if “help fdfd3d” is typed at the command
prompt. Lines 47 and 48 define the tolerance and a maximum number of iterations
that should be allowed when attempting to obtain a solution by iteration. Line 48
defines an anonymous function that forms a diagonal matrix from an array.
The input arguments are processed from lines 53 to 133. There are two ways
the program that calls fdfd3d() can define the device to be simulated. The first
option is to build the device into the isotropic 2× grid arrays DEV.ER2 and DEV.
UR2. The second option is to define all of the tensor elements for the permittivity
and/or the permeability. Lines 57 to 62 take this option into account to determine
the size of the grid. If the field ER2 exists in the structure DEV, the size of the grid is
determined from the size of DEV.ER2. If the field ER2 does not exist in the structure
DEV, the size of the grid is determined from the size of DEV.ER2xx. Lines 64 to 73
calculate the rest of the grid parameters. Lines 75 to 79 calculate the axis arrays and
the meshgrid for the 2× grid because the meshgrid is needed to calculate the source
field. It is standard practice to center the x- and y-axis arrays at zero, as is done
on lines 76 and 77. The z-axis array calculated on line 78 is not centered this way.
Line 82 calculates the free space wavenumber k0 from the free space wavelength
SRC.lam0. Lines 84 to 87 calculate the matrix size M as well as the zeros ZZ and
identity matrices I. Lines 89 to 110 form the diagonal materials matrices for all of
the tensor elements of the relative permittivity. If the materials are specified in DEV.
ER2, the tensor is defined as diagonally anisotropic entirely from ER2. Otherwise,
the tensor elements are specified and are individually diagonalized. This is repeated
for the relative permeability from lines 112 to 133.
The FDFD algorithm is implemented from lines 135 to 242. It starts by extract-
ing the material properties from the top and bottom parts of the grid on lines 139
to 145. Lines 147 to 162 calculate the PML terms and form the diagonal matrices
that incorporate the SCPML into the curl matrices. Lines 164 to 173 calculate
the wave vectors needed for the PBCs and for calculating reflection and trans-
mission. The incident wave vector is calculated using (10.55) to (10.57). Lines
175 to 179 call the yeeder3d() function to build the derivative matrices for the
three-dimensional Yee grid. Lines 181 to 184 calculate the interpolation matrices
directly from the derivative matrices using (10.30). Now that the interpolation
matrices are calculated, matrices are constructed for the materials tensors accord-
ing to (10.40) and (10.41) on lines 186 to 192. The curl matrices are calculated
from lines 194 to 201 using (10.38) and (10.39). This lets the wave matrix A be
calculated on line 201.
The next few sections of code lead up to building the source vector b. Lines
203 to 213 calculate the electric field polarization vector P following Section 2.7
in Chapter 2. From the polarization vector, lines 215 to 220 calculate all three
vector components of the source field and assemble them into the column vector
fsrc. Observe how these calculations are implemented using the 2× grid so that
the phase and positions of the field components on the Yee grid are accounted for.
Lines 222 to 227 build the SF masking matrix Q, where the SF region is made to
cover the PML at the top of the grid plus an additional three cells. The three cells
are to leave room for analyzing the reflected waves. Given all of this, the source
vector b is calculated on line 230 using the QAAQ equation.
All of this runs relatively quickly. Lines 232 to 237 are where the field is solved
and is the most computationally intensive step in the fdfd3d() function. Here,
the A and b terms are assigned to a GPU for faster calculation. The iterative solver
bicg() recognizes the matrices are stored on the GPU and the iterative algorithm
is performed on the GPU. If no GPU is present, lines 234, 235, and 237 should be
deleted and the iterative solver will run on the CPU. After the field is solved, the x,
y, and z components of the field throughout the entire grid are extracted from the
solution on lines 239 to 242. The spaces added in lines 240 and 241 are ignored by
MATLAB and are inserted simply to align the equations to have clean code.
At this point, the FDFD simulation is finished and the rest of the fdfd3d()
function postprocesses the fields to calculate reflection and transmission. This occurs
on lines 244 to 309. Lines 248 to 257 extract the fields from the top and bottom of
the grid, just outside of the SCPML regions. Observe that the z components of the
fields are extracted from two slices through the grid. The fields are staggered on
the Yee grid so in order to combine them for calculations they must be interpolated
to common points on the grid. For this purpose, the origins of the Yee cells are
chosen. Lines 259 to 278 perform these interpolations. Lines 280 to 287 remove
the phase tilt from the fields following (10.62) and (10.63). This is done because
it is the envelope term that should be Fourier transformed following (10.64) and
(10.65). Lines 289 to 300 perform the Fourier transforms to calculate the complex
amplitudes of the diffraction orders. Observe that the results from the FFTs are
shifted using fftshift() to move the zero-order term to the center of the array,
and then divided by the total number of points Nx*Ny in the FFT to make the values
true Fourier coefficients. Lines 294 and 300 calculate the output arrays DAT.s11
and DAT.s21 that contain the complex reflection and transmission coefficients of
the diffraction orders. These terms will be used in the parameter retrieval described
in Section 10.5.5 but are useful any time the amplitude and phase of the diffraction
orders are of interest. Lines 302 and 304 calculate the diffraction efficiencies of all
the diffraction orders using (10.66) and (10.67). These are summed on lines 307
and 308 to calculate the overall reflectance and transmittance.
Figure 10.4 Crossed-grating GMRF and how it is represented on an FDFD grid. This device has
a = 3.7 cm, t = 1.5 cm, f = 0.5, ε r1 = 1.0, ε r2 = 2.0, ε rL = 3.0, and ε rH = 5.0.
unit cell is illustrated in the right part of Figure 10.4. The GMRF is composed of
a core region of relative permittivity ε rL = 3.0 that hosts a periodic array of holes
filled with relative permittivity ε rH = 5.0. The relative permittivity above the crossed
grating is ε r1 = 1.0 and below the crossed-grating is ε r2 = 2.0. Both mediums above
and below the crossed-grating are assumed to be semi-infinite. The thickness of the
grating layer is t = 1.5 cm and the radius r of the holes is chosen so that they occupy
a fraction of the area defined by f. The equation to calculate r from f is
f
r = a (10.70)
p
It is desired to simulate this device using FDFD to calculate and plot its reflectance
and transmittance from 4.5 to 5.5 GHz. The device is illuminated with a right
circular polarized (RCP) wave at normal incidence. To perform a parameter sweep,
the function fdfd3d() will be used so the only tasks left for the main program are
calculating the grid, building the device, and controlling the parameter sweep. The
generic function makes parameter sweeps very easy!
The MATLAB code that performs the parameter sweep of the GMRF can
be downloaded at https://empossible.net/fdfdbook/. The file is called Chapter10_
GMRF.m. The header extends from lines 1 to 25 and includes initializing MATLAB,
defining the units, and defining the constants. The all-important dashboard extends
from lines 27 to 56 and defines all of the parameters that control the simulation. The
source parameters are defined on lines 31 to 39. A frequency sweep is defined from
4.5 to 5.5 GHz with 500 frequency points used in the array FREQ. It is common to
use many frequency points when simulating GMRFs because these devices tend to
exhibit very narrowband and abrupt spectral behavior. The source is an RCP wave
at normal incidence so lines 38 and 39 calculate the transverse electric (TE) and
transverse magnetic (TM) components. These are made to have equal amplitude but
a factor of 1i was included to make the components 90° out of phase. Lines 41 to
48 define all of the material properties and dimensions of the GMRF as illustrated
in Figure 10.4. Lines 50 to 56 define the grid parameters. NRES defines the number
of grid cells to resolve the minimum wavelength. DEV.NPML is an array of two num-
bers that define the size of the SCPML at the z-axis boundaries of the grid. ermax
is the maximum relative permittivity found anywhere on the grid and is calculated
by determining the maximum value of the relative permittivity terms defining the
GMRF. From this, nmax is the maximum refractive index anywhere on the grid and
is calculated from ermax as sqrt(ermax). lam_max is the maximum wavelength in
the simulation and is calculated as the speed of light divided by the minimum fre-
quency in the simulation. SPACER is an array of two numbers specifying the size of
the regions between the device and the PMLs above and below. It was found from
trial-and-error that one wavelength of the maximum wavelength was the minimum
amount of space needed for this simulation. The guided mode in a dielectric GMRF
can extend outside of the device. The evanescent field from a device should not be
allowed to touch the PML or it will excite a propagating wave inside of the PML
that provides an escape path for power that is not accounted for by the simulation.
The grid is calculated from lines 58 to 101. For the x- and y-directions, the
grid resolution was snapped to the period of the GMRF. In the z-direction, the grid
resolution was snapped to the height of the core of the GMRF. Lines 103 to 120
build the materials arrays that define the GMRF on the 2× grid. Since PBCs are
used, only a single unit cell has to be constructed onto the grid. Lines 107 to 109
initialize the relative permittivity array DEV.ER2 and the relative permeability array
DEV.UR2 to all ones to represent air. The grating is added throughout the entire 2×
grid on lines 111 to 114. Line 112 calculates the radius r of the hole from the fill
factor f using (10.70). Lines 116 to 120 overwrite the cells above and below the
actual grating layer with the correct values for relative permittivity. The entire grid
above the grating is filled with er1 while the entire grid below the grating is filled
with er2. Observe that the centering algorithm was not used here to position the
grating layer because that would not be correct if the two spacer regions were set
to different sizes. Instead, the starting index of the grating layer is set to a position
below the top PML and below the top spacer region. The number of cells in the
top PML was multiplied by two because the GMRF is being constructed on the 2×
grid that contains twice as many cells.
The frequency sweep is performed from lines 122 to 174. Line 127 defines the last
remaining field of DEV, which is DEV.RES that stores the grid resolution parameters
dx, dy, and dz. Lines 129 to 132 initialize the arrays that will store the reflectance
REF, transmittance TRN, and power conservation CON calculated during the sweep.
The loop for the actual frequency sweep extends from line 137 to 174. The first step
in the loop is on lines 139 to 141 where the next frequency to simulate is grabbed
from the array FREQ. From this, the free space wavelength SRC.lam0 is set to the
speed of light divided by the frequency. Line 144 calls the fdfd3d() function that
performs the simulation. This function was described in detail in Section 10.5.2.
When the simulation for the current iteration finishes, lines 146 to 149 record the
response in the arrays REF, TRN, and CON. Lines 151 to 159 visualize the field as it is
being calculated. Lines 161 to 172 plot the response as the simulation is running.
Visualizing the fields and spectral response while the parameter sweep is being
calculated is very good practice. Many times when problems with the code arise
during the sweep, they can be caught early without having to wait for the entire
sweep to be completed.
The reflectance, transmittance, and power conservation of the GMRF are plotted
in Figure 10.5(b). Convergence for this device was found to start at around NRES=20.
The device exhibits relatively low background reflection with two narrow regions
of very high reflection. These occur at frequencies where the grating couples the
applied wave into guided modes. From the spectrum, these resonances are observed
around 4.9 and 5.2 GHz. The field is visualized at 4.9 GHz in Figure 10.5(a) using
MATLAB’s slice() function along with a wireframe image of the crossed grating.
A guided mode is clearly observed.
Figure 10.5 (a) Electric field component Ey visualized on resonance at 4.9 GHz.
(b) Transmittance, reflectance, and power conservation response for the GMRF.
the Jerusalem cross is shown in Figure 10.7. This FSS will use acrylonitrile butadiene
styrene (ABS) plastic as the substrate material and perfect electric conductors (PECs)
for the metal elements. It is possible to modify the matrix equation Af = b in order
Figure 10.6 Frequency selective surface composed of a periodic array of Jerusalem cross
elements.
Figure 10.7 Geometry of the frequency selective surface element. This design has a = 9.95 mm,
h = 3.16 mm, s1 = 1.0 mm, s2 = 0.9 mm, w = 4.5 mm, and d = 2.32 mm. The substrate is ABS
plastic with ε r = 2.5.
to force the electric fields in the metals to be exactly zero to implement the PEC
conductors. However, it is much easier to simply set the relative permittivity to a
very large value, like ε r,PEC ≈ 106, where the metals are located on the grid. The
specific dimensions for the element are given in the figure caption.
The MATLAB code to simulate the FSS can be downloaded at https://empossible.
net/fdfdbook/ and is called Chapter10_FSS.m. The program is very similar to the
code for the crossed grating GMRF. The header extends from lines 1 to 25 and
includes initializing MATLAB, defining the units, and defining the constants to be
used in the simulation. The all-important dashboard extends from lines 27 to 58
and defines all of the parameters that control the simulation. The source parameters
are defined on lines 31 to 39. A frequency sweep is defined from 8.0 to 12.0 GHz
with 50 frequency points in the array FREQ. The source is a TE-polarized wave and
observe that SRC.theta is set to 30° and SRC.phi is set to 60° in order to practice
simulating waves at an oblique angle of incidence. Lines 41 to 47 define all of the
dimensions of the FSS element as described in Figure 10.7. The material properties
are defined on lines 49 and 50. The dielectric constant of the ABS plastic substrate
is erd=2.5 and the dielectric constant of the metal is set to erm=1e6. This simulation
could just as easily have accounted for the loss in the materials through a complex
permittivity. Lines 52 to 58 define the grid parameters. NRES defines the number of
grid cells to resolve the minimum wavelength. Convergence was found at around
NRES=80, but this simulation was performed at NRES=100. DEV.NPML is an array of
two numbers that define the size of the SCPML at the z-axis boundaries of the
grid. nmax is the maximum refractive index found anywhere on the grid and was
simply set to sqrt(erd) since the ABS plastic substrate is the only dielectric in this
simulation other than air. lam_max is the maximum wavelength in the simulation
and is calculated as the speed of light divided by the minimum frequency in the
simulation. SPACER is an array of two numbers specifying the size of the spacer
regions between the device and PMLs. It was found from trial-and-error that 0.2
of the largest wavelength was sufficient.
The grid is calculated from lines 60 to 107. For the x- and y-directions, the
grid resolution was snapped to the period of the FSS. In the z-direction, the grid
resolution was snapped to the thickness of the substrate. Lines 109 to 154 build
the material arrays that define the FSS on the 2× grid. Since PBCs are used, only a
single unit cell has to be constructed onto the grid. Lines 113 to 115 initialize the
relative permittivity array DEV.ER2 and the relative permeability array DEV.UR2 to
all ones to represent air. The substrate is added on lines 117 to 120. Observe that
the centering algorithm was not used here because that would not be correct if the
two spacer regions were set to different sizes. Instead, the starting index of the
substrate nz1 was to be at a position below the top PML and below the top spacer
region. The number of cells in the top PML was multiplied by two because the FSS
is being constructed on the 2× grid that contains twice as many cells. Also, observe
that the argument of the round() operation is divided by two and then multiplied
by two on the outside of the round() operation. This ensures the resulting integer
is an even number. When the value of 1 is added to this even number, the starting
index nz1 becomes an odd number. This was done to place the tangential field
components as the first field components in the ABS plastic. The concept of using
odd and even array indices to place metals onto the Yee grid is discussed in the
Appendix. The FSS element is constructed onto the grid in four steps from lines
122 to 151. First, lines 123 to 132 calculate the physical positions of the edges of
the FSS element working left to right. Lines 134 to 141 calculate the array indices
on the 2× grid of these physical positions. Lines 143 to 149 populate an array ER2
with zeros and ones in the pattern of the FSS element. Line 151 converts the zeros
and ones to the actual relative permittivity values that need to be placed onto the
grid. The FSS element is added to the DEV.ER2 array on line 154.
The frequency sweep is performed from lines 156 to 207. Line 161 defines the
last remaining field of DEV, which is DEV.RES, that stores the grid resolution param-
eters dx, dy, and dz. Lines 163 to 166 initialize the arrays that will store the reflec-
tance REF, transmittance TRN, and power conservation CON calculated during the
sweep. The loop for the actual frequency sweep extends from lines 168 to 207. The
first step in the loop is on lines 173 to 175 where the next frequency to simulate is
grabbed from the array FREQ. From this, the free space wavelength SRC.lam0 is set
to the speed of light divided by the frequency. Line 178 calls the fdfd3d() function
that performs the simulation at the current frequency. The fdfd3d() function is
described in detail in Section 10.5.2. When the simulation finishes, lines 180 to 183
record the response in the arrays REF, TRN, and CON. Lines 185 to 205 visualize the
response as the simulation is running. This is a very good practice because many
problems arising during the sweep can be caught early on without having to wait
for the entire sweep to be completed. Line 200 calculates the transmittance on a
decibel (dB) scale. This is a very common practice when the response of a device
varies over many orders of magnitude.
The transmittance of the FSS is plotted on a decibel (dB) scale as a function of
frequency in Figure 10.8. The figure shows transmittance for two different cases.
The first case is a TE-polarized wave at normal incidence and the second case is a
TE-polarized wave incident at θ = 30° and ϕ = 60°. Despite the angle of incidence,
Figure 10.8 Transmittance of a TE-polarized wave from a frequency selective surface at two
different angles of incidence.
the center frequency of the dip in transmittance is stable. Convergence for this
device was found to start at around NRES=80, but the results shown in the figure
were obtained at NRES=100.
Figure 10.9 Geometry of the left-handed metamaterial in [32]. This design has a = 2.5 mm,
h = 0.25 mm, w 1 = 0.14 mm, w 2 = 0.2 mm, L1 = 1.5 mm, L 2 = 2.2 mm, and g = 0.3 mm. The
substrate is FR-4 with a dielectric constant ε r = 4.4 and loss tangent tanδ = 0.02. The metal is
copper with conductivity σ = 5.8 × 107 Ω ⋅ m.
Figure 10.10 Parameter retrieval from a left-handed metamaterial. (a) FDFD simulation of
scattering from a metamaterial unit cell of period a. (b) FDFD simulation of scattering from a
homogeneous slab of thickness a.
concept of the retrieval process is illustrated in Figure 10.10. From the reflection
and transmission simulated using FDFD, the effective properties of the metamaterial
will be retrieved using the Nicolson–Ross–Weir (NRW) method [33, 34]. If correct
effective properties are retrieved, then a homogeneous slab of material having these
same properties and occupying the same space will produce the same reflection
and transmission.
Retrieving the effective properties of the metamaterial via the NRW method
begins with the analytical analysis of scattering from a homogeneous slab in air.
The scattering parameters for a wave normally incident onto this slab are
S11 =
(1 − t 2 ) r (10.71)
1 − r 2t 2
S21 =
(1 − r2 ) t (10.72)
1 − r 2t 2
heff − h0
r = (10.73)
heff + h0
(
t = exp jk0neff a ) (10.74)
coefficient of the forward direction. The parameter r is the complex reflection coef-
ficient of the first air-to-slab interface and is not the overall reflection coefficient
from the slab. The parameter t quantifies the phase accumulated by a wave from
one pass through the slab using the positive sign convention.
Calculating the effective properties of the slab starts by simulating a single unit
cell to obtain values for the scattering parameters S11 and S 21. Given the scattering
parameters, (10.71) to (10.74) are solved for neff and η eff. First, (10.71) and (10.72)
are solved for r and t to get
2 2
1 − S21 + S11
X = (10.75)
2S11
r = X± X2 − 1 (10.76)
S11 + S21 − r
t = (10.77)
1 − ( S11 + S21 ) r
The parameter X is just an intermediate parameter with no physical meaning.
Assuming the slab is composed of a passive material that cannot exhibit gain, the
sign of the square-root in (10.76) is chosen so that ⎪r⎪2 ≤ 1. Given r and t, (10.73) and
(10.74) are solved for n eff and η eff. The inversion of (10.74) can be difficult because
it leads to an infinite number of possible answers. Taking the natural logarithm of
(10.74) gives ln(t) = j(k0 na ± 2π m) where any integer m leads to a different solution,
called branches [35, 36]. For thin slabs, m = 0 can be chosen to get
1+ r
heff = h0 (10.78)
1− r
lnt
neff = (10.79)
jk0 a
Recognizing that η eff = h0 mr,eff /er,eff and n eff = h0 mr,eff er,eff , the effective
relative permittivity ε r,eff and effective relative permeability μ r,eff can be calculated
from neff and η eff according to
neff h0
er,eff = (10.80)
heff
neff heff
mr,eff = (10.81)
h0
Performing parameter retrieval is an excellent way to reduce the numerical
complexity of simulating devices composed of metamaterials or other subwavelength
structures [29, 30, 32]. It is very difficult or impossible to calculate the effective
properties of diffracting structures like photonic crystals and gratings [37].
Diffracting structures involve more physics than just an effective permittivity and
permeability. FDFD simulations of devices described well by effective permittivity
and permeability can be performed more efficiently simply by assigning the effective
properties to the grid. This avoids having to build complicated structures onto the
grid and having to use very fine grid resolution to resolve the small features of the
metamaterials themselves. Most often, simulations using just the effective properties
can get away with many fewer points on the grid. Performing an FDFD simulation
using just the effective properties of metamaterials will be demonstrated in Section
10.5.6 to simulate an invisibility cloak designed by TO.
The MATLAB code that performs the FDFD simulation and NRW parameter
retrieval can be downloaded at https://empossible.net/fdfdbook/. The file is called
Chapter10_metamaterial.m. The header extends from lines 1 to 25 and nothing
is different from the other codes. The dashboard extends from lines 27 to 63. The
source parameters are defined in lines 31 to 39. f1 and f2 are the starting and ending
frequency for the frequency sweep, NFREQ is the number of frequency points to use,
and FREQ is the array containing all of the frequencies to simulate in the parameter
sweep. It is good practice to resolve the response with enough frequency points so
that the phase can be unwrapped accurately. The simulation is performed at nor-
mal incidence so both SRC.theta and SRC.phi are set to zero. For this simulation,
the TM polarization is selected to place the magnetic field parallel to the axis of
the loops. Lines 41 to 48 define the dimensions of the metamaterial as described in
Figure 10.9. The material properties are specified in terms of the electrical conduc-
tivity sigma for the metal and the dielectric constant er and loss tangent tand for
the dielectric. From these, the complex relative permittivity for both materials is
calculated on lines 50 to 56. Last, the grid parameters are defined from lines 58 to
63. Convergence was found to begin at around NRES=100. The results that will be
discussed below were obtained at NRES=120. That is, 120 grid cells per wavelength.
Lines 65 to 110 calculate a grid optimized for simulating this metamaterial. The
grid resolution is snapped to match the period of the metamaterial. Lines 112 to
170 build the unit cell of the metamaterial onto the 2× grid. First, lines 116 to 118
initialize both the relative permittivity array DEV.ER2 and the relative permeability
array DEV.UR2 to all ones to represent air. The FR-4 substrate is added to the grid
on lines 120 to 127 using the centering algorithm covered in Chapter 1. Observe
in these calculations that the centering algorithm has been modified so that the
arguments inside of the rounding operations are divided by two and then multiplied
by two on the outside. This ensures an even number of cells is calculated. When
one is added to an even number an odd number is always obtained. This is being
done so that the metals are added to cells on the grid at odd array indexes because
these correspond to the field components parallel to the metals. This trick is used
throughout this section of code. The wire is added at the back edge of the substrate
on lines 129 to 132 using the same modified centering algorithm. Lines 134 to
151 add the outer ring in three steps, also making use of the modified centering
algorithm. Lines 135 to 142 add a large square of metal covering the entire area of
the outer ring. Lines 143 to 147 subtract a smaller square to form the ring. Lines
147 to 151 remove more metal to add the gap to form the split ring. Lines 153 to
170 add the inner ring following the same procedure used to build the outer ring.
The frequency sweep is performed from lines 172 to 234. Line 177 defines the
DEV.RES data structure that stores the grid resolution parameters dx, dy, and dz. Lines
179 to 184 initialize the arrays where the frequency response will be stored. S11 is
the complex reflection coefficient, S21 is the complex transmission coefficient, REF is
reflectance, TRN is transmittance, and CON is the power conservation. The frequency
sweep itself is performed from lines 186 to 234. It is a typical parameter sweep,
except around lines 200 to 209 where the S11 and S21 parameters are recorded. It
is critical to calculate phase as if the phase of the source is zero immediately on the
entrance face of the unit cell and to calculate reflection and transmission with the
phase that is immediately on the exit face of the unit cell. The function fdfd3d(),
however, launches the wave from some distance away and also calculates reflection
and transmission at some distance away. Lines 205 and 206 of the code remove
this extra phase by dividing the exponential terms. It is also possible to modify the
fdfd3d() function to place the TF/SF interface and reflection and transmission
record planes at the edge of the device, but it was desired to use the generic fdfd3d()
function as it is without any modifications.
At this point, the FDFD simulation is finished and parameter retrieval can
begin. This is considered postprocessing. While not shown in the code, it is a good
practice to save the simulation results at this point. This allows the results of the
long simulation to be quickly loaded from memory to work on coding the param-
eter retrieval section. The parameter retrieval extends from lines 236 to 282 and
all of the data is plotted from lines 284 to 346. The NRW method in the literature
was derived using the positive sign convention for waves, but the FDFD method in
this book is based on the negative sign convention. Lines 240 to 242 calculate the
complex conjugate of the S11 and S21 scattering parameters to reverse the phase
and be compatible with positive sign convention equations. In MATLAB and many
other programming languages, the phase portion ϕ of a complex number is kept in
the range −π ≤ ϕ ≤ π . If the phase exceeds these limits, an integer multiple of 2π is
added or subtracted so that the phase falls within this range. This is called wrapping
and leads to nonphysical discontinuities in the phase response that causes prob-
lems with the parameter retrieval algorithm. To fix this, lines 244 to 263 unwrap
the phase so that it does not exhibit discontinuities caused by wrapping. Line 266
calculates the intermediate variable X using (10.75). Lines 268 to 272 calculate the
reflection coefficient r using (10.76) while also resolving the sign so that ⎪r⎪ 2 ≤ 1.
The transmission coefficient t is calculated on line 274 using (10.77). From here,
lines 276 to 278 calculate the effective impedance eta and effective refractive index
neff using (10.78) and (10.79), respectively. The last step in the parameter retrieval
happens on lines 280 to 282 where the effective relative permittivity er and effec-
tive permeability ur are calculated using (10.80) and (10.81), respectively. Lines 284
to 346 plot all of the data calculated from the simulation and parameter retrieval.
The results of the simulation and the parameter retrieval are shown in Figure
10.11 for NRES=120 and match well with what was obtained in [32]. Fundamentally,
FDFD calculates reflection and transmission from the metamaterial unit cell as shown
in Figure 10.10(a). Everything else is calculated from these results. The reflectance
and transmittance as a function of frequency are plotted in Figure 10.11(a). Observe
that conservation is not obeyed due to the loss incorporated into the simulation. Even
when the loss is to be incorporated, it is good practice to run a preliminary simulation
with loss set to zero to ensure conservation is obeyed. Violation of conservation is
a strong indication of a problem with the code, such as the spacer regions being too
small or the PML not working correctly. The phase component of the reflection
and transmission coefficients was unwrapped to form continuous lines and plotted
in Figure 10.11(b). It is from the S11 and S21 terms that the effective refractive index
neff and effective impedance η eff of the metamaterial were calculated using (10.75) to
(10.79). These parameters as a function of frequency are plotted in Figure 10.11(c, d).
Observe that the effective refractive index is negative in the vicinity of 10.6 GHz. A
medium with a negative refractive index is said to be left-handed because the electric
and magnetic fields obey a left-hand rule instead of a right-hand rule like in ordinary
media. Note the imaginary part of the effective refractive index in Figure 10.11(c)
is largest in the vicinity of the negative refractive index. This is a critical problem
with metamaterials. They often exhibit very high losses at the same frequencies they
would be most useful. Figure 10.11(e, f) shows the effective relative permittivity ε r,eff
and effective relative permeability μ r,eff, respectively. Observe that both of these
parameters are simultaneously negative where there is a negative refractive index.
Figure 10.11 Results of parameter retrieval. Metamaterial has a negative index of refraction
around 10.6 GHz.
Figure 10.12 Grid strategy to simulate an invisibility cloak designed using TO.
are defined that control the simulation. The source is defined on lines 18 to 21.
lam0 is the free space wavelength, theta is the angle of the source wave, and P is
the polarization vector. The polarization is set to the z-direction corresponding to
a vertically polarized source.
Lines 33 to 58 calculate the grid. The primary difference in this section com-
pared to previous chapters is that nmax is not used to calculate the grid resolution.
In general, TO devices can have extreme refractive indices and it is possible it could
approach infinity or zero for some devices. For this reason, nmax is not used because
it could lead to an unfeasible grid.
The invisibility cloak is constructed from lines 60 to 139. Lines 64 to 73 initialize
all nine tensor elements for permittivity to free space. There is no need to initialize
the permeability because the permeability will just be set equal to the permittiv-
ity. Lines 75 to 104 are where the permittivity values for the invisibility cloak are
calculated. A double loop is used to iterate through every point on the 2× grid. For
each point, lines 79 and 80 calculate the cylindrical coordinate parameters ρ and ϕ .
The condition R1 < ρ < R 2 checks if the current point in the iteration resides inside
of the cloak. If so, the permittivity tensor for the cloak is calculated at that point.
Otherwise, it moves on to the next iteration of the double loop. Inside of the cloak,
the three diagonal elements of the permittivity tensor are calculated in cylindrical
coordinates according to [44]
⎡ r−R ⎤
⎢ 1
0 0 ⎥
⎢ r ⎥
⎢ ⎥
r
⎡⎣ er ( r, f, z ) ⎤⎦ = ⎢⎢ 0 0 ⎥
⎥ (10.82)
r − R1
⎢ ⎥
⎢ 2
⎛ R2 ⎞ r − R1 ⎥
⎢ 0 0 ⎜⎝ R − R ⎟⎠ ⎥
⎢⎣ 2 1
r ⎥⎦
References
[24] Sohail, I., et al., “A Linear to Circular Polarization Converter Based on Jerusalem-Cross
Frequency Selective Surface,” 2013 7th European Conference on Antennas and Propagation,
Gothenburg, Sweden, April 8–12, 2013, pp. 2141–2143.
[25] Tsao, C.-H., and R. Mittra, “Spectral-Domain Analysis of Frequency Selective Surfaces
Comprised of Periodic Arrays of Cross Dipoles and Jerusalem Crosses,” IEEE Trans. on
Antennas and Propagation, Vol. 32, No. 5, 1984, pp. 478–486.
[26] Cai, W., and V. M. Shalaev, Optical Metamaterials, New York: Springer, 2010.
[27] Cui, T. J., D. R. Smith, and R. Liu, Metamaterials, New York: Springer, 2010.
[28] Simovski, C., “Material Parameters of Metamaterials (A Review),” Optics and Spectroscopy,
Vol. 107, No. 5, 2009, pp. 726–753.
[29] Avila, J., et al., “Optimization and Characterization of Negative Uniaxial Metamaterials,”
Progress in Electromagnetics Research C, Vol. 74, 2017, pp. 111–121.
[30] Garcia, C. R., et al., “3D Printing of Anisotropic Metamaterials,” Progress in
Electromagnetics Research Letters, Vol. 34, 2012, pp. 75–82.
[31] Jahani, S., and Z. Jacob, “All-Dielectric Metamaterials,” Nature Nanotechnology, Vol.
11, No. 1, 2016, pp. 23–36.
[32] Smith, D., et al., “Electromagnetic Parameter Retrieval from Inhomogeneous Metamaterials,”
Physical Review E, Vol. 71, No. 3, 2005, p. 036617.
[33] Nicolson, A., and G. Ross, “Measurement of the Intrinsic Properties of Materials by
Time-Domain Techniques,” IEEE Trans. on Instrumentation and Measurement, Vol. 19,
No. 4, 1970, pp. 377–382.
[34] Vicente, A. N., G. M. Dip, and C. Junqueira, “The Step by Step Development of NRW
Method,” 2011 SBMO/IEEE MTT-S International Microwave and Optoelectronics
Conference, Natal, Brazil, October 29–1 November 2011, pp. 738–742.
[35] Alu, A., “First-Principles Homogenization Theory for Periodic Metamaterials,” Physical
Review B, Vol. 84, No. 7, 2011, p. 075153.
[36] Perrins, W., and R. McPhedran, “Metamaterials and the Homogenization of Composite
Materials,” Metamaterials, Vol. 4, No. 1, 2010, pp. 24–31.
[37] Schwartz, B. T., and R. Piestun, “Dynamic Properties of Photonic Crystals and Their
Effective Refractive Index,” Journal of the Optical Society of America B, Vol. 22, No. 9,
2005, pp. 2018–2026.
[38] Kundtz, N. B., D. R. Smith, and J. B. Pendry, “Electromagnetic Design with Transformation
Pptics,” Proceedings of the IEEE, Vol. 99, No. 10, 2010, pp. 1622–1633.
[39] Kwon, D.-H., and D. H. Werner, “Transformation Electromagnetics: An Overview of the
Theory and Applications,” IEEE Antennas and Propagation Magazine, Vol. 52, No. 1,
2010, pp. 24–46.
[40] Ward, A., and J. B. Pendry, “Refraction and Geometry in Maxwell’s Equations,” Journal
of Modern Optics, Vol. 43, No. 4, 1996, pp. 773–793.
[41] Eric A. Berry, R. C. R., “Generating Spatially-Variant Metamaterial Lattices Designed
from Spatial Transforms,” Progress in Electromagnetics Research, Vol. 92, 2020, pp.
103–113.
[42] Choudhury, B., and R. Jha, “A Review of Metamaterial Invisibility Cloaks,” Computers,
Materials & Continua, Vol. 33, No. 3, 2013, pp. 275–303.
[43] Landy, N., and D. R. Smith, “A Full-Parameter Unidirectional Metamaterial Cloak for
Microwaves,” Nature Materials, Vol. 12, No. 1, 2013, pp. 25–28.
[44] Schurig, D., et al., “Metamaterial Electromagnetic Cloak at Microwave Frequencies,”
Science, Vol. 314, No. 5801, 2006, pp. 977–980.
This section will describe some basic best practices for assigning material values to
the Yee grid. When metal structures, or structures with high permittivity contrast,
are built onto the grid, it is best to have the first electric field component immedi-
ately inside of the metal structure be tangential to the edge of the structure. For E
mode simulations, all electric fields will always be tangential to the edges because
the electric field is always perpendicular to the plane of the structure. More care
must be taken when performing H mode simulations with metals. This practice
makes it easier for the Yee grid to satisfy the boundary conditions at the interface
of the metal. Doing this will improve the rate of convergence of a simulation con-
taining metals and high-permittivity structures. Figure A.1 demonstrates two ways
to place a square metal element onto the Yee grid. The ideal placement is shown in
Figure A.1(a) where the electric field components immediately inside of the square
are tangential to the edge of the square. Figure A.1(b) shows the same metal element
placed poorly onto the grid. It has electric field components immediately inside of
the square that are normal to the edge of the square. The second case will converge
more slowly than the first case. The practice described here is easy for rectangular
shapes, but is more difficult or impossible when curved shapes are built onto the grid.
When curved shapes are needed, you may be forced to accept slower convergence.
From the above discussion, placing metals on grids might be more intuitively
done by directly populating the Yee grid arrays ERxx, ERyy, and ERzz. If the 2×
grid technique is to be used, the array indices where structures are placed onto the
Figure A.1 (a) Ideal placement of a metal square onto a Yee grid where tangential electric field
components are immediately inside the metal. (b) Poor placement of a metal square onto a Yee
grid where electric field immediately inside metal is not tangential.
305
grid must be more carefully considered. Observe from Figure A.1(a) that the square
patch of metal starts and ends on odd array indices on the 2× grid. The material
outside of the square patch starts and stops on even array indices. The array index
nx can be forced to be even or odd using (A.1) and (A.2). The same can be done for
any other array index such as ny or nz. Equation (A.1) divides nx by two and then
multiplies by two to get essentially the original value of nx. However, the quantity
is rounded after dividing by two to get the nearest integer. Multiplying any integer
by two will always give an even number. Equation (A.1) will give the closest even
number to the original value of nx. Equation (A.2) essentially uses the same equa-
tion but adds one to always give an odd number. The floor() command is used
instead of round() in order to get the odd number closest to the original value of
nx after one is added. It is common to incorporate these equations into the various
techniques described in Chapter 1, such as the centering algorithm.
When curved dielectric structures are built onto the grid, the edge of the struc-
ture will cut through some of the grid cells. A simple technique to improve conver-
gence rate is to assign the average permittivity (or permeability) to these cells that
are partly filled. For example, if 70% of a cell is occupied by relative permittiv-
ity 2.5 and 30% is occupied by relative permittivity 6.0, the value that should be
assigned to the cell is (0.70)(2.5) + (0.30)(6.0) = 3.55. A simple way to accomplish
this is illustrated in Figure A.2. The technique involves three separate grids that
all represent the same physical space. These are the Yee grid, the 2× grid contain-
ing twice as many cells as the Yee grid, and a high-resolution grid containing even
more cells than the 2× grid. In this example, the high-resolution grid has five times
the number of cells than does the 2× grid. Figure A.2(a) shows the Yee grid, the
2× grid, and a cylinder constructed onto the high-resolution grid. The next step is
to blur the high-resolution grid using a rectangular blur function that is 5×5 cells
wide. Figure A.2(d) shows the blur function centered on the high-resolution grid.
The blurring operation is performed as a convolution using two-dimensional fast
Fourier transforms (FFTs). The FFT of the high-resolution grid is multiplied by the
FFT of the blurring function. The inverse FFT is calculated from the product to get
the blurred function on the high-resolution grid as shown in Figure A.2(b). After
the blurring operation, the points on the high-resolution grid that fall at the center
of the 2× grid cells are the correct weighted averages. The cells on the 2× grid are
assigned these weighted averages.
Figure A.2 Simple method to average the permittivity (or permeability) at the edges of
curved boundaries. Thick lines show the Yee grid cells and the dashed lines show the 2× grid
cells. (a) Cylinder constructed into a high-resolution grid overlaid onto Yee grid and 2× grid.
(b) High-resolution cylinder after blurring operation. (c) Materials assigned to 2× grid after being
extracted from the high-resolution grid. (d) The blur function on the high-resolution grid.
Figure A.3 Summary of the Yee grids and discrete form of Maxwell’s equations with doubly diagonally
anisotropic media.
Figure A.4 Summary of both the uniaxial and the stretched-coordinate perfectly matched layer
absorbing boundaries.
Figure A.5 Summary of the formulation and implementation of FDFD for waveguide analysis. Slab
waveguide analysis is shown in multiple orientations.
Figure A.6 Summary of the formulation and implementation of FDFD for scattering analysis.
Figure A.7 Summary of the formulation of FDFD for photonic band analysis.
1-D One-Dimensional
2-D Two-Dimensional
3-D Three-Dimensional
ABS Acrylonitrile Butadiene Styrene
BZ Brillouin Zone
CEM Computational Electromagnetics
CP Circular Polarization
CPU Central Processing Unit
EIM Effective Index Method
EMF Electromotive Force
FDFD Finite-Difference Frequency-Domain
FDM Finite-Difference Method
FDTD Finite-Difference Time-Domain
FEM Finite Element Method
FSS Frequency Selective Surface
GMRF Guided-Mode Resonance Filter
GPU Graphical Processing Unit
IBZ Irreducible Brillouin Zone
IFC Isofrequency Contour
KCL Kirchoff’s Current Law
KVL Kirchoff’s Voltage Law
LCP Left Circular Polarization
LHI Linear, Homogeneous, and Isotropic
LP Linear Polarization
NRW Nicolson–Ross–Weir
OIC Optical-Integrated Circuit
PBC Periodic Boundary Condition
PEC Perfect Electric Conductor
PMC Perfect Magnetic Conductor
PML Perfectly Matched Layer
313
315
A C
Absorbing boundary calcpml3d() function, 155–59
about, 141 Centering algorithm, 17–19
development, 141–42 Channel waveguides
doubly diagonally anisotropic, 143 about, 63
SCPML, 153–59, 309 geometry of translational object, 162
UPML, 143–47, 309 guided modes in, 63–64
Acronyms and abbreviations, this book, 313–14 slab waveguide comparison, 64
Acrylonitrile butadiene styrene (ABS) plastic, 291 See also Waveguides
addupml2d() function Characteristic impedance, 68, 193
about, 149–50 Circles, adding to grids, 20–22
initialization, 150 Circular polarization (CP), 47
MATLAB program, 150–53 Coaxial transmission lines, 66
using, 150–53 Coefficients, terms, 4
Algebra, MATLAB and, 3–8 Complex permittivity, 36
Amplitude function, 114 Complex propagation constant, 65, 67, 193, 195
Anisotropic materials, 37–38 Composite rotation matrix, 41
Anisotropy, 269 Computational electromagnetics (CEM)
Arrays about, xv, xix
binary, converting, 25 convergence studies in, 256
complex, visualization of data in, 31–32 importance of, xiii
defined, 8 modeling, xiv
indexing, 8 process block diagram, xx
lattice to build into, 13 sweeping parameters and variables, xiv
MATLAB and, 10 Condition number, 278
matrices versus, 8, 9 Constitutive relations, 34
meshgrid, 20 Continuous functions, 10
visualization of data in, 29 Contour() function, 245, 252
Asymmetric diffraction gratings, 232, 284 Convergence
Attenuation coefficient, 45, 65, 68 about, xx, 11
FDFD codes and, 14
B grid resolution and, 187–88
Backward division, 8 rate, 176, 181, 230, 249
Biaxial materials, 39 slow, 13, 18
Bloch modes, 200 testing for, 174, 181
Bloch wave vectors, 199, 206, 207 tracking, xiii
Block matrix, 7, 91, 165, 275 Convergence studies
Boolean operations, 23–25 about, 11–12, 256
Boundary conditions in computational electromagnetics, 256
diffraction orders and, 227 of grid resolution, 187
Dirichlet, 81–82, 83, 91, 108–11 importance of, 187–88
numerical, 81–82 parameter sweeps and, 188
periodic, 82, 85, 112–19 photonic bands, 209–10, 212
Brillouin zones (BZs), 199, 200 point use on grid, 206
317
L GPU, 279
Lattice vectors, 199 ideal structure of a program, 2–3
Left circular polarization (LCP), 47–48 IFC calculation, 210–13
Linear, homogeneous, and isotropic (LHI) media invisibility cloak, 300–302
dispersion relation in, 49 metal polarizer analysis, 266–67
electromagnetic waves in, 45–48 metamaterials, 296–98
Maxwell’s equations for, 135 microstrip analysis, 194–97
Linear polarization (LP), 47–48 numerical differentiation, 80–81
Lorentz force law, 35 OIC directional coupler, 247–48
Loss tangent, 37 periodic boundary conditions, 85
photonic band calculation, 205–10
M rib waveguide analysis, 173
Magnetic field intensity, 34 sawtooth diffraction grating, 235
Magnetic flux density, 34, 35 self-collimating photonic crystal, 241
Magnetic permeability, 34 slab waveguide analysis, 180–85
Material dispersion, 34 source function calculation, 220
MATLAB SPP calculation, 189–92
about, 3 start and stop array indices, 17
array indexing, 8–10 three-dimensional grids, 25–26
backward division, 8 visualization of data in arrays, 28–29
Boolean operations in, 24 visualization of three-dimensional ellipsoid, 30
commas and, 5 yeeder3d() function, 128
forward division, 8 Matrices
grid parameters in, 10–15 about, 3–4
grid setup in, 8–15 arrays versus, 8, 9
implementation for calculating SPPs, 188–92 block, 7, 91, 165, 275
implementation of rib waveguide analysis, defined, 8
172–79 diagonals of, 6
implementation of slab waveguide analysis, 179 identity, 4, 7, 278
linear algebra and, 3–8 manipulating rows and columns in, 5
matrix, 3–4 rotation, 39–40, 41
matrix division in, 5 sparse, 6, 111, 125, 224
meshgrid technique, 19–23 special, 6–7
postdivision, 8 tables of numbers, 5
predivision, 8 using, 4
sparse matrices and, 111 variables as, 8
UPML implementation in, 149–53 zero, 6–7, 124–25
MATLAB codes Matrix algebra, 8
addupml2d() function, 150–53 Matrix differential equations
animated GIF, 32 converting to, 86
building an ellipse into an array, 21–22 solving, 87–89
building rotated ellipse, 22 Matrix division, 5, 92, 277
building small matrices, 7 Matrix equations
calcpml3d() function, 155–59 block, 275
crossed-grating GMRF, 288 coupled, 164
cylindrical source function calculation, 220 differential, 86–89
diagonalization, 223–24 preconditioning, 278
Dirichlet boundary conditions, 83–84 three-dimensional, 275–77
downloading, xiv for two-dimensional scattering analysis,
fdfd2d() function, 258–60 215–17
fdfd3d()function, 286 wave, 275–79
FDFD program in, 1–3 MATrix LABoratory. See MATLAB
frequency selective surfaces (FSSs), 292 Matrix wave equation
fyeeder2d() function, 124 deriving, 276
GMRF simulation, 260–62 direct solution of, 278
For further information on these and other Artech House titles, including previously considered
® ®
out-of-print books now available through our In-Print-Forever (IPF ) program, contact: