FDTD Method For em With MATLAB Simulations
FDTD Method For em With MATLAB Simulations
The Finite-Difference
Time-Domain Method for
Electromagnetics
R
with MATLAB Simulations
Atef Z. Elsherbeni
and
Veysel Demir
Contents
Preface xxi
Author Acknowledgements xxv
Acknowledgement of Reviewers xxvii
vii
fdtd_fm SPIB005-Elsherbeni & Demir November 24, 2008 20:7
viii Contents
Contents ix
7.4 FDTD Updating Equations for PML and MATLAB Implementation 196
7.4.1 PML Updating Equations—Two-Dimensional TEz
Case 196
7.4.2 PML Updating Equations—Two-Dimensional TMz
Case 199
7.4.3 MATLAB Implementation of the Two-Dimensional FDTD
Method with PML 201
7.5 Simulation Examples 215
7.5.1 Validation of PML Performance 215
7.5.2 Electric Field Distribution 219
7.5.3 Electric Field Distribution Using DFT 225
7.6 Exercises 229
x Contents
Contents xi
List of Figures
1.1(a). Approximation of the derivative of f (x) at x by finite differences: forward
difference. 4
1.1(b). Approximation of the derivative of f (x) at x by finite differences: backward
difference. 5
1.1(c). Approximation of the derivative of f (x) at x by finite differences: central
difference. 5
1.2(a). f (x), f (x), and differences between f (x) and finite difference approximations
of f (x) for x = π/5 and x = π/10. f (x) = sin(x)e −0.3x 8
1.2(b). f (x), f (x), and differences between f (x) and finite difference approximations
of f (x) for x = π/5 and x = π/10: f (x) = cos(x)e −0.3x − 0.3 sin(x)e −0.3x
and finite difference approximations of f (x) for x = π/5. 8
1.2(c). f (x), f (x), and differences between f (x) and finite difference approximations
of f (x) for x = π/5 and x = π/10: error( f (x)) for x = π/5. 9
1.2(d). f (x), f (x), and differences between f (x) and finite difference approximations
of f (x) for x = π/5 and x = π/10: error( f (x)) for x = π/10. 9
1.3. Sample points of f (x). 13
1.4. A three-dimensional FDTD computational space composed of (Nx × Ny × Nz )
Yee cells. 14
1.5. Arrangement of field components on a Yee cell indexed as (i, j, k). 14
1.6. Material parameters indexed on a Yee cell. 16
1.7. Field components around E x (i, j, k). 16
1.8. Field components around Hx (i, j, k). 18
1.9. Explicit FDTD procedure. 22
1.10. Two-dimensional T E z FDTD field components. 24
1.11. Two-dimensional T Mz FDTD field components. 25
1.12. One-dimensional FDTD—positions of field components E y and Hz . 27
1.13. One-dimensional FDTD — positions of field components E z and Hy . 28
1.14(a). Snapshots of a one-dimensional FDTD simulation: fields observed after 100
time steps. 29
1.14(b). Snapshots of a one-dimensional FDTD simulation: fields observed after 300
time steps. 30
1.14(c). Snapshots of a one-dimensional FDTD simulation: fields observed after 615
time steps. 30
1.14(d). Snapshots of a one-dimensional FDTD simulation: fields observed after 700
time steps. 31
2.1. The time–space domain grid with error propagating with λ = 1/2. 34
2.2. The time–space domain grid with error propagating with λ = 1. 35
2.3. The time–space domain grid with error propagating with λ = 2. 35
2.4. Maximum magnitude of E z in the one-dimensional problem space for
simulations with t = 3.3356 ps and t = 3.3357 ps. 37
2.5(a). Maximum magnitude of E z in the one-dimensional problem space for
simulations with x = 1 mm and x = 4 mm: simulation with x = 1 mm. 40
xiii
fdtd_fm SPIB005-Elsherbeni & Demir November 24, 2008 20:7
List of Figures xv
4.17. Unit step voltage source waveform and sampled voltage. 139
4.18. Dimensions of 50 stripline. 140
4.19. A 50 stripline terminated by a resistor. 141
4.20. A circuit composed of a voltage source, a capacitor, and a diode. 141
5.1(a). A sinusoidal waveform excited for 4 seconds: x(t). 144
5.1(b). A sinusoidal waveform excited for 4 seconds: X(ω) magnitude. 145
5.2(a). A sinusoidal waveform excited for 8 seconds: x(t). 145
5.2(b). A sinusoidal waveform excited for 8 seconds: X(ω) magnitude. 146
5.3(a). A Gaussian waveform and its Fourier transform: g(t). 147
5.3(b). A Gaussian waveform and its Fourier transform: G(ω) magnitude. 148
5.4. Gaussian waveform shifted by t0 = 4.5τ in time. 149
5.5(a). Normalized derivative of a Gaussian waveform and its Fourier transform: g(t). 150
5.5(b). Normalized derivative of a Gaussian waveform and its Fourier transform: G(ω)
magnitude. 151
5.6(a). Cosine Gaussian waveform and its Fourier transform: g(t). 152
5.6(b). Cosine Gaussian waveform and its Fourier transform: G(ω) magnitude. 153
5.7(a). A Gaussian waveform and its Fourier transform: g(t). 161
5.7(b). A Gaussian waveform and its Fourier transform: G(ω). 162
5.7. A Gaussian waveform and its Fourier transform: g(t) recovered from G(ω). 162
5.8. An RLC circuit. 163
5.9. Time-domain response, Vo , compared with source waveform, Vs . 166
5.10(a). Frequency-domain response of source waveform Vs and output voltage Vo :
Fourier transform of Vs . 166
5.10(b). Frequency-domain response of source waveform Vs and output voltage Vo :
Fourier transform of Vo . 167
(ω)
5.11. Transfer function T(ω) = VVos (ω) . 167
6.1. An N-port network. 170
6.2(a). A microstrip low-pass filter terminated by a voltage source and a resistor on
two ends: three-dimensional view. 171
6.2(b). A microstrip low-pass filter terminated by a voltage source and a resistor on
two ends: dimensions. 171
6.3(a). S-parameters of the microstrip low-pass filter: S11 . 176
6.3(b). S-parameters of the microstrip low-pass filter: S21 . 177
6.4. Sampled voltage at the second port of the microstrip low-pass filter. 177
6.5. Sampled voltage at the second port of the microstrip low-pass filter with
σ e = 0.2. 178
6.6(a). S-parameters of the microstrip low-pass filter with σ e = 0.2: S11 . 179
6.6(b). S-parameters of the microstrip low-pass filter with σ e = 0.2: S21 . 179
6.7. The geometry and dimensions of a microstrip quarter-wave transformer
matching a 100 line to 50 line. 180
6.8. The S11 and S21 of the microstrip quarter-wave transformer circuit. 181
6.9. The problem space for the low-pass filter with absorbers on the xn, xp, yn, y p,
and zp sides. 185
7.1. The field decomposition of a T E z polarized plane wave. 188
7.2. The plane wave transition at the interface between two PML media. 190
7.3. The loss distributions in two-dimensional PML regions. 192
fdtd_fm SPIB005-Elsherbeni & Demir November 24, 2008 20:7
List of Tables
1.1. Finite difference formulas for the first- and second-order derivatives where the
function f with the subscript i is an abbreviation of f (x). Similar notation can
be implemented for f (x + x), f (x + 2x), etc., as shown in Fig. 1.3. FD,
forward difference. BD, backward difference. CD, central difference. 13
12.1. CPU versus GPU feature comparison. 370
12.2. Brook program flow. 374
xix
fdtd_fm SPIB005-Elsherbeni & Demir November 24, 2008 20:7
fdtd_fm SPIB005-Elsherbeni & Demir November 24, 2008 20:7
Preface
The contents of this book have evolved gradually and carefully from many years of teaching gradu-
ate level courses in computational electromagnetics generally, and the FDTD method specifically,
at The University of Mississippi. Also, the first author, Atef Elsherbeni, has further refined and
developed the materials by teaching numerous short courses on the FDTD method at various
educational institutions and at a growing number of international conferences. The theoretical,
numerical, and programming experience of the second author, Veysel Demir, has been a crucial
factor in bringing the book to successful completion.
OBJECTIVE
The objective of the book is to introduce the powerful Finite-Difference Time-Domain method
to students and interested researchers and readers. An effective introduction is accomplished
using a step-by-step process that builds competence and confidence in developing complete
working codes for the design and analysis of various antennas and microwave devices. This book
will serve graduate students, researchers, and those in industry and government who are using
other electromagnetics tools and methods for the sake of performing independent numerical
confirmation. No previous experience with finite-difference methods is assumed of readers to use
this book.
IMPORTANT TOPICS
USE OF MATLAB
The development of the working code is based on the MATLAB programming language due
to its relative ease of use, widespread availability, familiarity to most electrical engineers, and its
powerful capabilities for providing graphical outputs and visualization. The book illustrates how
the key FDTD equations are derived, provides the final expressions to be programmed, and also
includes sample MATLAB codes developed for these equations. MATLAB version 7.5 (R2007b)
is used for the development of the M-files provided with this book.
xxi
fdtd_fm SPIB005-Elsherbeni & Demir November 24, 2008 20:7
xxii Preface
The book includes a CD-ROM which contains the MATLAB M-files for all programming
examples shown in the text as well as all book figures in full-color. Readers may wish to check
the publisher’s web page for additional examples or other electronic files and figures that may be
added in the future: www.scitechpub.com/FDTDtext.htm
KEY STRENGTHS
The strengths of the book can be summarized in four points:
r First, the derivations of the FDTD equations are presented in an understandable, detailed,
and complete manner, which makes it easy for beginners to grasp the FDTD concepts.
Further to that point, regardless of the different treatments required for various objects,
such as dielectrics, conductors, lumped elements, active devices, or thin wires, the FDTD
updating equations are provided with a consistent and unified notation.
r Second, many three-dimensional figures are presented to accompany the derived equations.
This helps readers visualize, follow, and link the components of the equations with the
discrete FDTD spatial domain.
r Third, it is well known that readers usually face difficulties while developing numerical
tools for electromagnetics applications even though they understand the theory. Therefore,
we introduce in this book a top-down software design approach that links the theoretical
concepts with program development and helps in constructing an FDTD simulation tool as
the chapters proceed.
r Fourth, fully worked out practical examples showing how the MATLAB codes for each
example is developed to promote both the understanding and the visualization of the example
configuration, its FDTD parameters and setup procedure, and finally the frequency and/or
time domain corresponding solutions.
At the end of each chapter, readers will find a set of exercises that will emphasize the key
features presented in that chapter. Since most of these exercises require code developments and
the orientation of geometries and sources can be chosen arbitrarily, a suggested configuration of
each in almost all of these exercises is provided in a three dimensional figure.
The authors hope that with this coverage of the FDTD method, along with the supplied
MATLAB codes in a single book, readers will be able to learn the method, to develop their own
FDTD simulation tool, and to start enjoying, with confidence, the simulation of a variety of
electromagnetic problems.
The CD should start by itself when inserted in a personal computer CD or DVD drive; however,
due to the many different configurations of personal computers, if the auto-run function does not
start, a double click on the file “index.html” will get it started. Links to all chapters and appendices
will show up in the first page. By clicking on any of these links the reader will be directed to the
appropriate chapter list of figures and code listings of the examples covered in that chapter.
INSTRUCTOR RESOURCES
Upon adopting this book as the required text, instructors are entitled to obtain the solutions of the
exercises located at the end of each chapter. Most of these solutions are in the form of MATLAB
M-files and can be obtained by contacting the publisher.
fdtd_fm SPIB005-Elsherbeni & Demir November 24, 2008 20:7
Preface xxiii
Author Acknowledgements
The authors would like to first thank God for giving us the endurance to initiate and complete this
book. Many thanks go to our family members for their support, patience, and sacrifice during the
preparation and completion of this book. The authors greatly acknowledge the contribution of
Matthew J. Inman to Chapter 12, “Graphical Processing Unit Acceleration of Finite-Difference
Time-Domain.” They would also like to thank Branko Kolundzija for providing a copy of WIPL-D
software package to use for verifications for some of the presented examples.
The first author acknowledges the support and advice over many years of the late Charles
E. Smith. Without his continuous encouragement and support this book would have not been
finalized. He also thanks many of his colleagues, postdoctoral fellows and visiting scholars who
worked with him in topics related to FDTD, the graduate students who participated in translating
ideas into reality, and the undergraduate students who participated in research projects with
this author, in particular, Allen Glisson, Fan Yang, Abdel-Fattah A. Elsohly, Joe LoVetri, Veysel
Demir, Matthew J. Inman, Chun-Wen Paul Huang, Clayborne D. Taylor, Mohamed Al Sharkawy,
Vicente Rodriguez-Pereyra, Jianbing (James) Chen, Adel M. Abdin, Bradford N. Baker, Asem
Mokaddem, Liang Xu, Nithya L. Iyer, Shixiong Dai, Xuexun Hu, Cuthbert Martindale Allen,
Khaled Elmahgoub, and Terry Gerald.
The authors thank Dudley Kay and Susan Manning of SciTech Publishing for their encour-
agement, patience, and useful suggestions during the course of the development of the manuscript
and production of the book.
xxv
fdtd_fm SPIB005-Elsherbeni & Demir November 24, 2008 20:7
fdtd_fm SPIB005-Elsherbeni & Demir November 24, 2008 20:7
Acknowledgement of Reviewers
SciTech Publishing and the authors gratefully acknowledge the time and expertise of the technical
reviewers who assisted in the development of this book. Their comments helped the authors to
enhance the presentations of the formulations and the MATLAB implementations. Close reading
of technical manuscripts in draft form is no small task, and the suggestions provided both from
academic and industry experts surely benefit all who will use this book to further their knowledge
of the Finite-Difference Time-Domain method in their studies and work.
xxvii
fdtd_fm SPIB005-Elsherbeni & Demir November 24, 2008 20:7
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
1
Introduction to FDTD
Computational electromagnetics (CEM) has evolved rapidly during the past decade to a point
where now extremely accurate predictions can be given for a variety of electromagnetic problems,
including the scattering cross-section of radar targets and the precise design of antennas and
microwave devices. In general, commonly used CEM methods today can be classified into two
categories. The first is based on differential equation (DE) methods, whereas the second is based
on integral equation (IE) methods. Both IE and DE solution methods are based on the applications
of Maxwell’s equations and the appropriate boundary conditions associated with the problem to be
solved. The integral equation methods in general provide approximations for integral equations
in terms of finite sums, whereas the differential equation methods provide approximations for
differential equations as finite differences.
In previous years, most numerical electromagnetic analysis has taken place in the frequency
domain where time-harmonic behavior is assumed. Frequency domain was favored over time
domain because a frequency-domain approach is more suitable for obtaining analytical solutions
for canonical problems, which are used to verify the numerical results obtained as a first step
before depending on a newly developed numerical method for generating data for real-world
applications. Furthermore, the experimental hardware available for making measurements in past
years was largely confined to the frequency-domain approach.
The recent development of faster and more powerful computational resources allowed for more
advanced time-domain CEM models. More focus is directed toward differential equation time-
domain approaches as they are easier to formulate and to adapt in computer simulation models
without complex mathematics. They also provide more physical insight to the characteristics of
the problems.
Therefore, an in-depth analysis and implementation of the commonly used time-domain dif-
ferential equation approach, namely, the finite-difference time-domain (FDTD) method for CEM
applications, is covered in this book, along with applications related to antenna designs, microwave
filter designs, and radar cross-section analysis of three-dimensional targets.
The FDTD method has gained tremendous popularity in the past decade as a tool for solving
Maxwell’s equations. It is based on simple formulations that do not require complex asymptotic
or Green’s functions. Although it solves the problem in time, it can provide frequency-domain re-
sponses over a wide band using the Fourier transform. It can easily handle composite geometries
consisting of different types of materials including dielectric, magnetic, frequency-dependent,
nonlinear, and anisotropic materials. The FDTD technique is easy to implement using paral-
lel computation algorithms. These features of the FDTD method have made it the most at-
tractive technique of computational electromagnetics for many microwave devices and antenna
applications.
1
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
2 Introduction to FDTD
FDTD has been used to solve numerous types of problems arising while studying many appli-
cations, including the following:
r scattering, radar cross-section
r microwave circuits, waveguides, fiber optics
r antennas (radiation, impedance)
r propagation
r medical applications
r shielding, coupling, electromagnetic compatibility (EMC), electromagnetic pulse (EMP)
protection
r nonlinear and other special materials
r geological applications
r inverse scattering
r plasma
∂D
=
∇×H
+ J, (1.1a)
∂t
∂ B
∇ × E = −
− M, (1.1b)
∂t
∇·D = ρe , (1.1c)
∇ · B = ρm , (1.1d)
= ε E,
D (1.2a)
B = µ H,
(1.2b)
where ε is the permittivity, and µ is the permeability of the material. In free space
We only need to consider curl equations (1.1a) and (1.1b) while deriving FDTD equations
because the divergence equations can be satisfied by the developed FDTD updating equations
[1]. The electric current density J is the sum of the conduction current density Jc = σ e E and
the impressed current density Ji as J = Jc + Ji . Similarly, for the magnetic current density,
M =M i , where M
c + M c = σ m H.
Here σ e is the electric conductivity in siemens per meter, and
σ m is the magnetic conductivity in ohms per meter. Upon decomposing the current densities in
(1.1) to conduction and impressed components and by using the constitutive relations (1.2) we
can rewrite Maxwell’s curl equations as
∇×H = ε ∂ E + σ e E + Ji , (1.3a)
∂t
∂H
∇ × E = −µ − σmH −M i. (1.3b)
∂t
This formulation treats only the electromagnetic fields E and H and not the fluxes D and B.
All four constitutive parameters ε, µ, σ e , and σ m are present so that any linear isotropic material
can be specified. Treatment of electric and magnetic sources are included through the impressed
currents. Although only the curl equations are used and the divergence equations are not part
of the FDTD formalism, the divergence equations can be used as a test on the predicted field
response, so that after forming D = ε E and B = µ H from the predicted E and H fields, the
resulting D and B must satisfy the divergence equations.
Equation (1.3) is composed of two vector equations, and each vector equation can be de-
composed into three scalar equations for three-dimensional space. Therefore, Maxwell’s curl
equations can be represented with the following six scalar equations in a Cartesian coordinate
system (x, y, z):
∂ Ex 1 ∂ Hz ∂ Hy
= − − σx E x − Ji x ,
e
(1.4a)
∂t εx ∂y ∂z
∂ Ey 1 ∂ Hx ∂ Hz
= − − σ ye E y − Ji y , (1.4b)
∂t εy ∂z ∂x
∂ Ez 1 ∂ Hy ∂ Hx
= − − σze E z − Ji z , (1.4c)
∂t εz ∂ x ∂y
∂ Hx 1 ∂ Ey ∂ Ez
= − − σx Hx − Mi x ,
m
(1.4d)
∂t µx ∂z ∂y
∂ Hy 1 ∂ Ez ∂ Ex
= − − σ y Hy − Mi y ,
m
(1.4e)
∂t µy ∂ x ∂z
∂ Hz 1 ∂ Ex ∂ Ey
= − − σz Hz − Mi z .
m
(1.4f)
∂t µz ∂ y ∂x
The material parameters εx , ε y , and εz are associated with electric field components E x , E y , and
E z through constitutive relations Dx = εx E x , Dy = ε y E y , and Dz = εz E z , respectively. Similarly,
the material parameters µx , µ y , and µz are associated with magnetic field components Hx , Hy , and
Hz through constitutive relations Bx = µx Hx , B y = µ y Hy , and Bz = µz Hz , respectively. Similar
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
4 Introduction to FDTD
decompositions for other orthogonal coordinate systems are possible, but they are less attractive
from the applications point of view.
The FDTD algorithm divides the problem geometry into a spatial grid where electric and
magnetic field components are placed at certain discrete positions in space, and it solves Maxwell’s
equations in time at discrete time instances. This can be implemented by first approximating
the time and space derivatives appearing in Maxwell’s equations by finite differences and next
by constructing a set of equations that calculate the values of fields at a future time instant from
the values of fields at a past time instant, therefore constructing a time marching algorithm that
simulates the progression of the fields in time [2].
An arbitrary continuous function can be sampled at discrete points, and the discrete function
becomes a good approximation of the continuous function if the sampling rate is sufficient relative
to the function’s variation. Sampling rate determines the accuracy of operations performed on the
discrete function that approximates the operations on the continuous functions as well. However,
another factor that determines the accuracy of an operation on a discrete function is the choice of
the discrete operator. Most of the time it is possible to use more than one way of performing an
operation on a discrete function. Here we will consider the derivative operation.
Consider the continuous function given in Fig. 1.1(a–c), sampled at discrete points. The ex-
pression for the derivative of f (x) at point x can be written as
f (x + x) − f (x)
f (x) = lim . (1.5)
x→0 x
f (x + ∆x)
f (x − ∆x)
f (x)
x − ∆x x x + ∆x
Figure 1.1 (a) Approximation of the derivative of f (x ) at x by finite differences: forward difference.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
f (x + ∆x)
f (x − ∆x)
f (x)
x − ∆x x x + ∆x
Figure 1.1 (b) Approximation of the derivative of f (x ) at x by finite differences: backward difference.
f (x + ∆x)
f (x − ∆x)
f (x)
x − ∆x x x + ∆x
Figure 1.1 (c) Approximation of the derivative of f (x ) at x by finite differences: central difference.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
6 Introduction to FDTD
However, since x is a nonzero fixed number, the derivative of f (x) can be approximately
taken as
f (x + x) − f (x)
f (x) ≈ . (1.6)
x
The derivative of f (x) is the slope of the dashed line as illustrated in Fig. 1.1(a). Equation (1.6) is
called the forward difference formula since one forward point f (x + x) is used to evaluate f (x)
together with f (x).
It is evident that another formula for an approximate f (x) can be obtained by using a backward
point f (x − x) rather than the forward point f (x + x) as illustrated in Fig. 1.1(b), which can
be written as
f (x) − f (x − x)
f (x) ≈ . (1.7)
x
This equation is called the backward difference formula due to the use of the backward point
f (x − x).
The third way of obtaining a formula for an approximate f (x) is by averaging the forward
difference and backward difference formulas, such that
f (x + x) − f (x − x)
f (x) ≈ . (1.8)
2x
Equation (1.8) is called the central difference formula since both the forward and backward points
around the center one are used. The line representing the derivative of f (x) calculated using the
central difference formula is illustrated in 1.1(c). It should be noted that the value of the function
f (x) at x is not used in central difference formula.
Examination of Fig. 1.1 immediately reveals that the three different schemes yield different
values for f (x), with an associated amount of error. The amount of error introduced by these
difference formulas can be evaluated analytically by using the Taylor series approach. For instance,
the Taylor series expansion of f (x + x) can be written as
where O(x) represents the error term. The most significant term in O(x) is x/2, and the
order of x in this most significant term is one. Therefore, the forward difference formula is
first-order accurate. The interpretation of first-order accuracy is that the most significant term in
the error introduced by a first-order accurate formula is proportional to the sampling period. For
instance, if the sampling period is decreased by half, the error reduces by half.
A similar analysis can be performed for evaluation of the error of the backward formula starting
with the Taylor series expansion of f (x − x):
The first term on the right-hand side of (1.13) is the same as the backward difference formula
and the sum of the rest of the terms represents the error introduced by the backward difference
formula to the exact derivative of f (x), such that
f (x) − f (x − x)
f (x) = + O(x). (1.14)
x
The order of x in the most significant term of O(x) is one; hence the backward difference
formula is first-order accurate.
The difference between the Taylor series expansions of f (x + x) and f (x − x) can be
expressed using (1.9) and (1.12) as
2(x)3
f (x + x) − f (x − x) = 2x f (x) + f (x) + . . . . (1.15)
6
where the first term on right-hand side is the same as the central difference formula given in (1.8)
and the order of x in the most significant term of the error O((x)2 ) is two; hence the central
difference formula is second-order accurate. The interpretation of second-order accuracy is that the
most significant term in the error introduced by a second-order accurate formula is proportional
to the square of sampling period. For instance, if the sampling period is decreased by half, the
error is reduced by a factor of four. Hence, a second-order accurate formula such as the central
difference formula is more accurate than a first-order accurate formula.
For an example, consider a function f (x) = sin(x)e −0.3x as displayed in Fig. 1.2(a). The exact
first-order derivative of this function is
8 Introduction to FDTD
0.8
0.6
0.4
0.2
f (x)
−0.2
−0.4
−0.6
−0.8
−1
0 5 10 15
x
Figure 1.2 (a) f (x ), f (x ), and differences between f (x ) and finite difference approximations of f (x ) for x =
π/5 and x = π/10: f (x ) = sin(x )e −0.3x
1
exact
0.8 forward difference
backward difference
0.6 ∆x = π/5 central difference
0.4
0.2
f (x)
−0.2
−0.4
−0.6
−0.8
−1
0 5 10 15
x
Figure 1.2 (b) f (x ), f (x ), and differences between f (x ) and finite difference approximations of f (x ) for x =
π/5 and x = π/10: f (x ) = cos(x )e −0.3x − 0.3 sin(x )e −0.3x and finite difference approximations of
f (x ) for x = π/5.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
0.2
forward difference
0.15 ∆x = π/5 backward difference
central difference
0.1
−0.05
−0.1
−0.15
−0.2
0 5 10 15
x
Figure 1.2 (c) f (x ), f (x ), and differences between f (x ) and finite difference approximations of f (x ) for x =
π/5 and x = π/10: error( f (x )) for x = π/5.
0.2
forward difference
0.15 ∆x = π/10 backward difference
central difference
0.1
error [f (x)]
0.05
−0.05
−0.1
−0.15
−0.2
0 5 10 15
x
Figure 1.2 (d) f (x ), f (x ), and differences between f (x ) and finite difference approximations of f (x ) for x =
π/5 and x = π/10: error( f (x )) for x = π/10.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
10 Introduction to FDTD
This function f (x) is sampled with a sampling period x = π/5, and approximate derivatives
are calculated for f (x) using the forward difference, backward difference, and central difference
formulas. The derivative of the function f (x) and its finite difference approximations are plotted
in Fig. 1.2(b). The errors introduced by the difference formulas, which are the differences between
f (x) and its finite difference approximations, are plotted in Fig. 1.2(c) for the sampling interval
x = π/5. It is evident that the error introduced by the central difference formula is smaller than
the errors introduced by the forward difference and backward difference formulas. Furthermore,
the errors introduced by the difference formulas for the sampling period x = π/10 are plotted in
Fig. 1.2(d). It can be realized that as the sampling period is halved, the errors of the forward
difference and backward difference formulas are halved as well, and the error of the central
difference formula is reduced by a factor of four.
The MATLAB code calculating f (x) and its finite difference derivatives, and generating the
plots in Fig. 1.2 is shown in Listing 1.1.
Listing 1.1 MATLAB code generating Fig. 1.2(a–d)
1 % c r e a t e e x a c t f u n c t i o n and i t s d e r i v a t i v e
N e x a c t = 3 0 1 ; % number o f s ample p o i n t s f o r e x a c t f u n c t i o n
3 x e x a c t = l i n s p a c e ( 0 , 6 * pi , N e x a c t ) ;
f e x a c t = s i n ( x e x a c t ) . * exp ( − 0 . 3 * x e x a c t ) ;
5 f d e r i v a t i v e e x a c t = c o s ( x e x a c t ) . * exp ( − 0 . 3 * x e x a c t ) . . .
−0.3 * s i n ( x e x a c t ) . * exp ( − 0 . 3 * x e x a c t ) ;
7
dx a = pi / 5 ;
25 f derivative f o r w a r d a = zeros (1 , N a ) ;
f derivative backward a = zeros (1 , N a ) ;
27 f derivative c e n t r a l a = zeros (1 , N a ) ;
f derivative f o r w a r d a ( 1 : N a −1) = . . .
29 (f a ( 2 : N a )− f a ( 1 : N a − 1 ) ) / d x a ;
f derivative backward a (2: N a ) = . . .
31 (f a ( 2 : N a )− f a ( 1 : N a − 1 ) ) / d x a ;
f derivative c e n t r a l a ( 2 : N a −1) = . . .
33 (f a ( 3 : N a )− f a ( 1 : N a − 2 ) ) / ( 2 * d x a ) ;
35
37 % and i t s f i n i t e d i f f e r e n c e d e r i v a t i v e s
N b = 6 1 ; % number o f p o i n t s f o r p i / 1 0 s a m p l i n g p e r i o d
39 x b = l i n s p a c e ( 0 , 6 * pi , N b ) ;
f b = s i n ( x b ) . * exp ( − 0 . 3 * x b ) ;
41 f d e r i v a t i v e b = c o s ( x b ) . * exp ( − 0 . 3 * x b ) . . .
−0.3 * s i n ( x b ) . * exp ( − 0 . 3 * x b ) ;
43 dx b = pi / 1 0 ;
f d e r i v a t i v e f o r w a r d b = zeros (1 , N b ) ;
45 f derivative backward b = zeros (1 , N b ) ;
f d e r i v a t i v e c e n t r a l b = zeros (1 , N b ) ;
47 f d e r i v a t i v e f o r w a r d b ( 1 : N b −1) = . . .
( f b ( 2 : N b )− f b ( 1 : N b − 1 ) ) / d x b ;
49 f derivative backward b (2: N b ) = . . .
( f b ( 2 : N b )− f b ( 1 : N b − 1 ) ) / d x b ;
51 f d e r i v a t i v e c e n t r a l b ( 2 : N b −1) = . . .
( f b ( 3 : N b )− f b ( 1 : N b − 2 ) ) / ( 2 * d x b ) ;
53
% p l o t e x a c t d e r i v a t i v e o f t h e f u n c t i o n and i t s f i n i t e d i f f e r e n c e
55 % d e r i v a t i v e s using pi /5 sampling period
figure ( 2 ) ;
57 plot ( x exact , f d e r i v a t i v e e x a c t , ’ k ’ , . . .
x a ( 1 : N a − 1 ) , f d e r i v a t i v e f o r w a r d a ( 1 : N a − 1 ) , ’ b−− ’ , . . .
59 x a ( 2 : N a ) , f d e r i v a t i v e b a c k w a r d a ( 2 : N a ) , ’ r −. ’ , . . .
x a ( 2 : N a − 1 ) , f d e r i v a t i v e c e n t r a l a ( 2 : N a − 1 ) , ’ : ms ’ , . . .
61 ’ MarkerSize ’ ,4 , ’ linewidth ’ , 1 . 5 ) ;
s e t ( gca , ’ F o n t S i z e ’ , 1 2 , ’ f o n t w e i g h t ’ , ’ demi ’ ) ;
63 a x i s ( [ 0 6 * p i −1 1 ] ) ;
g r i d on ;
65 legend ( ’ e x a c t ’ , ’ forward d i f f e r e n c e ’ , . . .
’ backward d i f f e r e n c e ’ , ’ c e n t r a l d i f f e r e n c e ’ ) ;
67 x l a b e l ( ’ $x$ ’ , ’ I n t e r p r e t e r ’ , ’ l a t e x ’ , ’ F o n t S i z e ’ , 1 6 ) ;
ylabel ( ’ $f ’ ’ ( x ) $ ’ , ’ I n t e r p r e t e r ’ , ’ l a t ex ’ , ’ FontSize ’ ,16);
69 t e x t ( pi , 0 . 6 , ’ $ \ D e l t a x = \ p i / 5 $ ’ , ’ I n t e r p r e t e r ’ , . . .
’ l a t e x ’ , ’ f o n t s i z e ’ , 1 6 , ’ B a c k g r o u n d C o l o r ’ , ’w ’ , ’ E d g e C o l o r ’ , ’ k ’ ) ;
71
figure ( 3 ) ;
79 p l o t ( x a ( 1 : N a − 1 ) , e r r o r f o r w a r d a ( 1 : N a − 1 ) , ’ b−− ’ , . . .
x a ( 2 : N a ) , e r r o r b a c k w a r d a ( 2 : N a ) , ’ r −. ’ , . . .
81 x a ( 2 : N a − 1 ) , e r r o r c e n t r a l a ( 2 : N a − 1 ) , ’ : ms ’ , . . .
’ MarkerSize ’ ,4 , ’ linewidth ’ , 1 . 5 ) ;
83
s e t ( gca , ’ F o n t S i z e ’ , 1 2 , ’ f o n t w e i g h t ’ , ’ demi ’ ) ;
85 a x i s ( [ 0 6 * p i −0.2 0 . 2 ] ) ;
g r i d on ;
87 l e g e n d ( ’ f o r w a r d d i f f e r e n c e ’ , ’ backward d i f f e r e n c e ’ , . . .
’ central difference ’ );
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
12 Introduction to FDTD
89 x l a b e l ( ’ $x$ ’ , ’ I n t e r p r e t e r ’ , ’ l a t e x ’ , ’ F o n t S i z e ’ , 1 6 ) ;
ylabel ( ’ error $ [ f ’ ’ ( x ) ] $ ’ , ’ Interpreter ’ , ’ latex ’ , ’ FontSize ’ ,16);
91 t e x t ( pi , 0 . 1 5 , ’ $ \ D e l t a x = \ p i / 5 $ ’ , ’ I n t e r p r e t e r ’ , . . .
’ l a t e x ’ , ’ f o n t s i z e ’ , 1 6 , ’ B a c k g r o u n d C o l o r ’ , ’w ’ , ’ E d g e C o l o r ’ , ’ k ’ ) ;
93
figure ( 4 ) ;
101 p l o t ( x b ( 1 : N b − 1 ) , e r r o r f o r w a r d b ( 1 : N b − 1 ) , ’ b−− ’ , . . .
x b ( 2 : N b ) , e r r o r b a c k w a r d b ( 2 : N b ) , ’ r −. ’ , . . .
103 x b ( 2 : N b − 1 ) , e r r o r c e n t r a l b ( 2 : N b − 1 ) , ’ : ms ’ , . . .
’ MarkerSize ’ ,4 , ’ linewidth ’ , 1 . 5 ) ;
105
s e t ( gca , ’ F o n t S i z e ’ , 1 2 , ’ f o n t w e i g h t ’ , ’ demi ’ ) ;
107 a x i s ( [ 0 6 * p i −0.2 0 . 2 ] ) ;
g r i d on ;
109 l e g e n d ( ’ f o r w a r d d i f f e r e n c e ’ , ’ backward d i f f e r e n c e ’ , . . .
’ central difference ’ );
111 x l a b e l ( ’ $x$ ’ , ’ I n t e r p r e t e r ’ , ’ l a t e x ’ , ’ F o n t S i z e ’ , 1 6 ) ;
ylabel ( ’ error $ [ f ’ ’ ( x ) ] $ ’ , ’ Interpreter ’ , ’ latex ’ , ’ FontSize ’ ,16);
113 t e x t ( pi , 0 . 1 5 , ’ $ \ D e l t a x = \ p i / 1 0 $ ’ , ’ I n t e r p r e t e r ’ , . . .
’ l a t e x ’ , ’ f o n t s i z e ’ , 1 6 , ’ B a c k g r o u n d C o l o r ’ , ’w ’ , ’ E d g e C o l o r ’ , ’ k ’ ) ;
Values of the function f (x) at two neighboring points around x have been used to obtain a
second order accurate central difference formula to approximate f (x). It is possible to obtain
formulas with higher orders of accuracy by including a larger number of neighboring points in
the derivation of a formula for f (x). However, although there are FDTD formulations developed
based on higher-order accurate formulas, the conventional FDTD is based on the second-order
accurate central difference formula, which is found to be sufficiently accurate for most electro-
magnetics applications and simple in implementation and understanding.
It is possible to obtain finite-difference formulas for approximating higher-order derivatives as
well. For instance, if we take the sum of the Taylor series expansions of f (x + x) and f (x − x)
using (1.9) and (1.12), we obtain
(x)4
f (x + x) + f (x − x) = 2 f (x) + (x)2 f (x) + f (x) + . . . . (1.17)
12
After rearranging the equation to have f (x) on the left-hand side, we get
Three-Dimensional FDTD 13
Table 1.1 Finite difference formulas for the first- and second-order derivatives where the function f with
the subscript i is an abbreviation of f (x ). Similar notation can be implemented for f (x + x ),
f (x + 2x ), etc., as shown in Fig. 1.3. FD, forward difference. BD, backward difference. CD, central
difference.
Using (1.18) we can obtain a central difference formula for the second-order derivative f (x) as
In 1966, Yee originated a set of finite-difference equations for the time-dependent Maxwell’s curl
equations system [2]. These equations can be represented in discrete form, both in space and
time, employing the second-order accurate central difference formula. As mentioned before, the
electric and magnetic field components are sampled at discrete positions both in time and space.
The FDTD technique divides the three-dimensional problem geometry into cells to form a grid.
Figure 1.4 illustrates an FDTD grid composed of (Nx × Ny × Nz ) cells. A unit cell of this grid is
called a Yee cell. Using rectangular Yee cells, a stepped or “staircase” approximation of the surface
x − 2∆x x − ∆x x x + ∆x x + 2∆x
14 Introduction to FDTD
and internal geometry of the structure of interest is made with a space resolution set by the size
of the unit cell.
The discrete spatial positions of the field components have a specific arrangement in the Yee
cell, as demonstrated in Fig. 1.5. The electric field vector components are placed at the centers
of the edges of the Yee cells and oriented parallel to the respective edges, and the magnetic field
vector components are placed at the centers of the faces of the Yee cells and are oriented normal
Figure 1.5 Arrangement of field components on a Yee cell indexed as (i, j, k).
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Three-Dimensional FDTD 15
to the respective faces. This provides a simple picture of three-dimensional space being filled
by an interlinked array of Faraday’s law and Ampere’s law contours. It can be easily noticed in
Fig. 1.5 that each magnetic field vector is surrounded by four electric field vectors that are curling
around the magnetic field vector, thus simulating Faraday’s law. Similarly, if the neighboring cells
are also added to the picture, it would be apparent that each electric field vector is surrounded
by four magnetic field vectors that are curling around the electric field vector, thus simulating
Ampere’s law.
Figure 1.5 shows the indices of the field components, which are indexed as (i, j, k), associated
with a cell indexed as (i, j, k). For a computational domain composed of uniform Yee cells having
dimension x in the x direction, y in the y direction, and z in the z direction, the actual
positions of the field components with respect to an origin coinciding with the position of the
node (1, 1, 1) can easily be calculated as
The FDTD algorithm samples and calculates the fields at discrete time instants; how-
ever, the electric and magnetic field components are not sampled at the same time instants.
For a time-sampling period t, the electric field components are sampled at time instants
0, t, 2t, . . . , nt, . . . ; however, the magnetic field components are sampled at time instants
1
2
t, (1 + 12 )t, . . . , (n + 12 )t, . . . . Therefore, the electric field components are calculated at in-
teger time steps, and magnetic field components are calculated at half-integer time steps, and they
are offset from each other by t/2. The field components need to be referred by not only their spa-
tial indices which indicate their positions in space, but also by their temporal indices, which indicate
their time instants. Therefore, a superscript notation is adopted to indicate the time instant. For
instance, the z component of an electric field vector positioned at ((i − 1)x, ( j − 1)y, (k −
0.5)z) and sampled at time instant nt is referred to as E zn (i, j, k). Similarly, the y component
of a magnetic field vector positioned at ((i − 0.5)x, ( j − 1)y, (k − 0.5)z) and sampled at time
n+ 1
instant (n + 12 )t is referred to as Hy 2 (i, j, k).
The material parameters (permittivity, permeability, electric, and magnetic conductivities) are
distributed over the FDTD grid and are associated with field components; therefore, they are
indexed the same as their respective field components. For instance, Fig. 1.6 illustrates the indices
for the permittivity and permeability parameters. The electric conductivity is distributed and
indexed the same as the permittivity, and the magnetic conductivity is distributed and indexed the
same as the permeability.
Having adopted an indexing scheme for the discrete samples of field components in both time
and space, Maxwell’s curl equations (1.4) that are given in scalar form can be expressed in terms
of finite differences. For instance, consider again (1.4a):
∂ Ex 1 ∂ Hz ∂ Hy
= − − σx E x − Ji x .
e
∂t εx ∂y ∂z
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
16 Introduction to FDTD
The derivatives in this equation can be approximated by using the central difference formula
with the position of E x (i, j, k) being the center point for the central difference formula in space
and time instant (n + 12 )t as being the center point in time. Considering the field component
positions given in Fig. 1.7, we can write
Three-Dimensional FDTD 17
n+ 12 n+ 12
E xn+1 (i, j, k) − E xn (i, j, k) 1 Hz (i, j, k) − Hz (i, j − 1, k)
=
t εx (i, j, k) y
n+ 12 n+ 12
1 Hy (i, j, k) − Hy (i, j, k − 1)
−
εx (i, j, k) z
σxe (i, j, k) n+ 12 1 n+ 1
− E x (i, j, k) − Ji x 2 (i, j, k). (1.20)
εx (i, j, k) εx (i, j, k)
It has already been mentioned that the electric field components are defined at integer time steps;
however, the right-hand side of (1.20) includes an electric field term at time instant (n + 12 )t, that
n+ 1
is, E x 2 (i, j, k). This term can be written as the average of the terms at time instants (n + 1)t
and nt, such that
Using (1.21) in (1.20) and arranging the terms such that the future term E xn+1 (i, j, k) is kept on
the left-side of the equation and the rest of the terms are moved to the right-hand side of the
equation, we can write
The form of (1.23) demonstrates how the future value of an electric field component can be
calculated by using the past values of the electric field component, the magnetic field com-
ponents, and the source components. This form of an equation is called an FDTD updating
equation. Updating equations can easily be obtained for calculating E yn+1 (i, j, k) starting from
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
18 Introduction to FDTD
(1.4b) and E zn+1 (i, j, k) starting from (1.4c) following the same methodology that has been used to
obtain (1.23).
Similarly, updating equations can be obtained for magnetic field components following the
same methodology. However, while applying the central difference formula to the time derivative
of the magnetic field components, the central point in time shall be taken as nt. For instance,
(1.4c), which is
∂ Hx 1 ∂ Ey ∂ Ez
= − − σxm Hx − Mi x ,
∂t µx ∂z ∂y
can be approximated using finite differences based on the field positions (as shown in
Fig. 1.8) as
n+ 12 n− 12
Hx (i, j, k) − Hx (i, j, k) 1 E yn (i, j, k + 1) − E yn (i, j, k)
=
t µx (i, j, k) z
1 E zn (i, j + 1, k) − E zn (i, j, k)
−
µx (i, j, k) y
σxm (i, j, k) n 1
− H (i, j, k) − Mn (i, j, k). (1.24)
µx (i, j, k) x µx (i, j, k) i x
n+ 1
After some manipulations, the future term Hx 2 (i, j, k) in (1.24) can be moved to the left-hand
side and the other terms can be moved to the right-hand side such that
Three-Dimensional FDTD 19
2t n
− E z (i, j + 1, k) − E zn (i, j, k)
2µx (i, j, k) + tσx (i, j, k) y
m
2t
− Mn (i, j, k). (1.25)
2µx (i, j, k) + tσxm (i, j, k) i x
n+ 1
This equation is the 1updating equation for Hx 2 (i, j, k). Similarly, updating equations can easily
n+ n+ 1
be obtained for Hy 2 (i, j, k) starting from (1.4e) and Hz 2 (i, j, k) starting from (1.4f ) following
the same methodology used to obtain (1.25).
Finally, equations (1.4a)–(1.4f ) can be expressed using finite differences and can be arranged to
construct the following six FDTD updating equations for the six components of electromagnetic
fields by introduction of respective coefficient terms:
where
2εx (i, j, k) − tσxe (i, j, k)
Ce xe (i, j, k) = ,
2εx (i, j, k) + tσxe (i, j, k)
2t
Ce xhz (i, j, k) = ,
2εx (i, j, k) + tσxe (i, j, k) y
2t
Ce xhy (i, j, k) = − ,
2εx (i, j, k) + tσxe (i, j, k) z
2t
Ce x j (i, j, k) = − .
2εx (i, j, k) + tσxe (i, j, k)
where
2ε y (i, j, k) − tσ ye (i, j, k)
Ce ye (i, j, k) = ,
2ε y (i, j, k) + tσ ye (i, j, k)
2t
Ce yhx (i, j, k) = ,
2ε y (i, j, k) + tσ ye (i, j, k) z
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
20 Introduction to FDTD
2t
Ce yhz (i, j, k) = − ,
2ε y (i, j, k) + tσ ye (i, j, k) x
2t
Ce y j (i, j, k) = − .
2ε y (i, j, k) + tσ ye (i, j, k)
E zn+1 (i, j, k) = Ce ze (i, j, k) × E zn (i, j, k)
n+ 1 n+ 1
+ Ce zhy (i, j, k) × Hy 2 (i, j, k) − Hy 2 (i − 1, j, k)
n+ 1 n+ 1
+ Ce zhx (i, j, k) × Hx 2 (i, j, k) − Hx 2 (i, j − 1, k)
n+ 12
+ Ce zj (i, j, k) × Ji z (i, j, k), (1.28)
where
where
Three-Dimensional FDTD 21
n+ 12 n− 1
Hy (i, j, k) = C hyh (i, j, k) × Hy 2 (i, j, k) + C hye z (i, j, k)
× E zn (i + 1, j, k) − E zn (i, j, k) + C hye x (i, j, k)
× E xn (i, j, k + 1) − E xn (i, j, k) + C hym (i, j, k) × Miny (i, j, k), (1.30)
where
2µ y (i, j, k) − tσ ym (i, j, k)
C hyh (i, j, k) = ,
2µ y (i, j, k) + tσ ym (i, j, k)
2t
C hye z (i, j, k) = ,
2µ y (i, j, k) + tσ ym (i, j, k) x
2t
C hye x (i, j, k) = − ,
2µ y (i, j, k) + tσ ym (i, j, k) z
2t
C hym (i, j, k) = − .
2µ y (i, j, k) + tσ ym (i, j, k)
n+ 12 n− 12
Hz (i, j, k) = C hzh (i, j, k) × Hz (i, j, k)
+ C hze x (i, j, k) × E xn (i, j + 1, k) − E xn (i, j, k)
+ C hze y (i, j, k) × E yn (i + 1, j, k) − E yn (i, j, k)
+ C hzm (i, j, k) × Minz (i, j, k), (1.31)
where
2µz (i, j, k) − tσzm (i, j, k)
C hzh (i, j, k) = ,
2µz (i, j, k) + tσzm (i, j, k)
2t
C hze x (i, j, k) = ,
2µz (i, j, k) + tσzm (i, j, k) y
2t
C hze y (i, j, k) = − ,
2µz (i, j, k) + tσzm (i, j, k) x
2t
C hzm (i, j, k) = − .
2µz (i, j, k) + tσzm (i, j, k)
It should be noted that the first two subscripts in each coefficient refer to the corresponding
field component being updated. For three subscripts coefficients, the third subscript refers to
the type of the field or source (electric or magnetic) that this coefficient is multiplied by. For
four subscripts coefficients, the third and fourth subscripts refer to the type of the field that this
coefficient is multiplied by.
Having derived the FDTD updating equations, a time-marching algorithm can be constructed
as illustrated in Fig. 1.9. The first step in this algorithm is setting up the problem space—including
the objects, material types, and sources—and defining any other parameters that will be used during
the FDTD computation. Then the coefficient terms appearing in (1.26)–(1.31) can be calculated
and stored as arrays before the iteration is started. The field components need to be defined as
arrays as well and shall be initialized with zeros since the initial values of the fields in the problem
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
22 Introduction to FDTD
Start
Yes No
Stop Last iteration?
space in most cases are zeros, and fields will be induced in the problem space due to sources as the
iteration proceeds. At every step of the time-marching iteration the magnetic field components
are updated for time instant (n + 0.5)t using (1.29)–(1.31); then the electric field components
are updated for time instant (n + 1)t using (1.26)–(1.28). The problem space has a finite size, and
specific boundary conditions can be enforced on the boundaries of the problem space. Therefore,
the field components on the boundaries of the problem space are treated according to the type of
boundary conditions during the iteration. The types of boundary conditions and the techniques
used to integrate them into the FDTD algorithm are discussed in detail in Chapters 7 and 8. After
the fields are updated and boundary conditions are enforced, the current values of any desired field
components can be captured and stored as output data, and these data can be used for real-time
processing or postprocessing to calculate some other desired parameters. The FDTD iterations
can be continued until some stopping criteria are achieved.
Two-Dimensional FDTD 23
field distributions in one of the dimensions, a simplified set of updating equations can be obtained
starting from the Maxwell’s curl equations system (1.4). Since there is no variation in one of
the dimensions, the derivative terms with respect to that dimension vanish. For instance, if the
problem is z dimension independent, equations (1.4) reduce to
∂ Ex 1 ∂ Hz
= − σx E x − Ji x ,
e
(1.32a)
∂t εx ∂ y
∂ Ey 1 ∂ Hz
= − − σ ye E y − Ji y , (1.32b)
∂t εy ∂x
∂ Ez 1 ∂ Hy ∂ Hx
= − − σze E z − Ji z , (1.32c)
∂t εz ∂ x ∂y
∂ Hx 1 ∂ Ez
= − − σx Hx − Mi x ,
m
(1.32d)
∂t µx ∂y
∂ Hy 1 ∂ Ez
= − σ y Hy − Mi y ,
m
(1.32e)
∂t µy ∂ x
∂ Hz 1 ∂ Ex ∂ Ey
= − − σz Hz − Mi z .
m
(1.32f)
∂t µz ∂ y ∂x
One should notice that equations (1.32a), (1.32b), and (1.32f ) are dependent only on the terms E x ,
E y , and Hz , whereas equations (1.32c), (1.32d), and (1.32e) are dependent only on the terms E z ,
Hx , and Hy . Therefore, the six equations (1.32) can be treated as two separate sets of equations.
In the first set—(1.32a), (1.32b), and (1.32f )—all the electric field components are transverse to
the reference dimension z; therefore, this set of equations constitutes the transverse electric to z
case—T E z . In the second set—(1.32c), (1.32d), and (1.32e)—all the magnetic field components are
transverse to the reference dimension z; therefore, this set of equations constitutes the transverse
magnetic to z case—T Mz . Most two-dimensional problems can be decomposed into two separate
problems, each including separate field components that are T E z and T Mz for the case under
consideration. These two problems can be solved separately, and the solution for the main problem
can be achieved as the sum of the two solutions.
The FDTD updating equations for the T E z case can be obtained by applying the central
difference formula to the equations constituting the T E z case based on the field positions shown
in Fig. 1.10, which is obtained by projection of the Yee cells in Fig. 1.5 on the xy plane in the z
direction. The FDTD updating equations for the T E z case are therefore obtained as
n+ 1 n+ 1
E xn+1 (i, j ) = Ce xe (i, j ) × E xn (i, j ) + Ce xhz (i, j ) × Hz 2 (i, j ) − Hz 2 (i, j − 1)
n+ 12
+ Ce x j (i, j ) × Ji x (i, j ), (1.33)
where
2εx (i, j ) − tσxe (i, j )
Ce xe (i, j ) = ,
2εx (i, j ) + tσxe (i, j )
2t
Ce xhz (i, j ) = ,
2εx (i, j ) + tσxe (i, j ) y
2t
Ce x j (i, j ) = − .
2εx (i, j ) + tσxe (i, j )
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
24 Introduction to FDTD
n+ 1 n+ 1
E yn+1 (i, j ) = Ce ye (i, j ) × E yn (i, j ) + Ce yhz (i, j ) × Hz 2 (i, j ) − Hz 2 (i − 1, j )
n+ 12
+ Ce y j (i, j ) × Ji y (i, j ), (1.34)
where
2ε y (i, j ) − tσ ye (i, j )
Ce ye (i, j ) = ,
2ε y (i, j ) + tσ ye (i, j )
2t
Ce yhz (i, j ) = − ,
2ε y (i, j ) + tσ ye (i, j ) x
2t
Ce y j (i, j ) = − .
2ε y (i, j ) + tσ ye (i, j )
n+ 1 n− 1
Hz 2 (i, j ) = C hzh (i, j ) × Hz 2 (i, j ) + C hze x (i, j ) × E xn (i, j + 1) − E xn (i, j )
+ C hze y (i, j ) × E yn (i + 1, j ) − E yn (i, j ) + C hzm (i, j ) × Minz (i, j ), (1.35)
where
2µz (i, j ) − tσzm (i, j )
C hzh (i, j ) = ,
2µz (i, j ) + tσzm (i, j )
2t
C hze x (i, j ) = ,
2µz (i, j ) + tσzm (i, j ) y
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Two-Dimensional FDTD 25
2t
C hze y (i, j ) = − ,
2µz (i, j ) + tσzm (i, j ) x
2t
C hzm (i, j ) = − .
2µz (i, j ) + tσzm (i, j )
Since the FDTD updating equations for the three-dimensional case are readily available, they
can be used to derive (1.33), (1.34), and (1.35) by simply setting the coefficients including 1/z
to zero. Hence, the FDTD updating equations for the T Mz case can be obtained by eliminating
the term C hxe y (i, j, k) in (1.29) and eliminating the term C hye x (i, j, k) in (1.30) based on the field
positions shown in Fig. 1.11, such that
n+ 1 n+ 1
E zn+1 (i, j ) = Ce ze (i, j ) × E zn (i, j ) + Ce zhy (i, j ) × Hy 2 (i, j ) − Hy 2 (i − 1, j )
n+ 1 n+ 1
n+ 1
+ Ce zhx (i, j ) × Hx 2 (i, j ) − Hx 2 (i, j − 1) + Ce zj (i, j ) × Ji z 2 (i, j ), (1.36)
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
26 Introduction to FDTD
where
where
where
In the one-dimensional case there is no variation in the problem geometry and field distributions
in two of the dimensions. For instance, if the y and z dimensions have no variation, the deriva-
tive with respect to the y and z dimensions vanish in Maxwell’s curl equations. Therefore, the
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
One-Dimensional FDTD 27
It should be noted that (1.39a) and (1.39d) include time derivatives but not space derivatives.
Therefore, these equations do not represent propagating fields, hence the field components E x and
Hx , which only exist in these two equations, do not propagate. The other four equations represent
propagating fields, and both the electric and magnetic field components existing in these equations
are transverse to the x dimension. Therefore, transverse electric and magnetic to x (T E Mx ) fields
exist and propagate as plane waves in the one-dimensional case under consideration.
Similar to the two-dimensional case, the one-dimensional case as well can be decomposed
into two separate cases, since (1.39b) and (1.39f ), which include only the terms E y and Hz , are
decoupled from (1.39c) and (1.39e), which include only the terms E z and Hy . FDTD updating
equations can be obtained for (1.39b) and (1.39f ) using the central difference formula based on
the field positioning in one-dimensional space as illustrated in Fig. 1.12, such that
n+ 1 n+ 1
n+ 1
E yn+1 (i) = Ce ye (i) × E yn (i) + Ce yhz (i) × Hz 2 (i) − Hz 2 (i − 1) + Ce y j (i) × Ji y 2 (i), (1.40)
where
2ε y (i) − tσ ye (i)
Ce ye (i) = ,
2ε y (i) + tσ ye (i)
2t
Ce yhz (i) = − ,
2ε y (i) + tσ ye (i) x
2t
Ce y j (i) = − ,
2ε y (i) + tσ ye (i)
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
28 Introduction to FDTD
and
n+ 12 n− 12
Hz (i) = C hzh (i) × Hz (i) + C hze y (i) × E yn (i + 1) − E yn (i) + C hzm (i) × Minz (i), (1.41)
where
Similarly, FDTD updating equations can be obtained for (1.39c) and (1.39e) using the cen-
tral difference formula based on the field positioning in one-dimensional space as illustrated in
Fig. 1.13, such that
n+ 1 n+ 1
n+ 1
E zn+1 (i) = Ce ze (i) × E zn (i) + Ce zhy (i) × Hy 2 (i) − Hy 2 (i − 1) + Ce zj (i) × Ji z 2 (i), (1.42)
where
and
n+ 12 n− 12
Hy (i) = C hyh (i) × Hy (i) + C hye z (i) × E zn (i + 1) − E zn (i) + C hym (i) × Miny (i), (1.43)
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
One-Dimensional FDTD 29
Figure 1.14 (a) Snapshots of a one-dimensional FDTD simulation: fields observed after 100 time steps.
where
30 Introduction to FDTD
Figure 1.14 (b) Snapshots of a one-dimensional FDTD simulation: fields observed after 300 time steps.
Figure 1.14 (c) Snapshots of a one-dimensional FDTD simulation: fields observed after 615 time steps.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
One-Dimensional FDTD 31
Figure 1.14 (d) Snapshots of a one-dimensional FDTD simulation: fields observed after 700 time steps.
The current sheet is excited over a one-cell cross-section (i.e., 1 mm wide), which translates
Jz into a surface current density K z of magnitude 1 × 10−3 A/m. The surface current density
causes a discontinuity in magnetic field and generates Hy , which satisfies the boundary condition
−
→ −
→
K = n × H . Therefore, two waves of Hy are generated on both sides of the current sheet, each of
which has magnitude 5 × 10−4 A/m. Since the fields are propagating in free space, the magnitude
of the generated electric field is η0 × 5 × 10−4 ≈ 0.1885 V/m, where η0 is the intrinsic impedance
of free space (η0 ≈ 377).
Examining the listing of the one-dimensional FDTD code in Appendix A, one immediately
notices that the sizes of the arrays associated with E z and Hy are not the same. The one-dimensional
problem space is divided into nx intervals; therefore, there are nx + 1 nodes in the problem space
including the left and right boundary nodes. This code is based on the field positioning scheme
given in Fig. 1.13, where the E z components are defined at node positions and the Hy components
are defined at the center positions of the intervals. Therefore, arrays associated with E z have the
size nx + 1, whereas those associated with Hy have the size nx.
Another point that deserves consideration is the application of the boundary conditions. In
this problem the boundaries are PEC; thus, the tangential electric field component (E z in this
case) vanishes on the PEC surface. Therefore, this condition can be enforced on the electric field
component on the boundaries, E z (1) and E z (nx + 1), as can be seen in the code listing. Observing
the changes in the fields from time step 650 to 700 in Fig. 1.14 reveals the correct behavior of
the incident and reflected waves for a PEC plate. This is evident by the reversal of the direction
of the peak value of E z after reflection from the PEC boundaries, which represents a reflection
coefficient equal to −1 while the behavior of the reflected Hy component represents the reflection
coefficient that is equal to +1 as expected.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
32 Introduction to FDTD
1.6 EXERCISES
1.1 Follow the steps presented in Section 1.2 to develop the appropriate approximations for the
first derivative of a function with second-order accuracy using the forward and backward
difference procedure and fourth-order accuracy using the central difference procedure.
Compare your derived expressions with those listed in Table 1.1.
1.2 Update the MATLAB program in Listing 1.1 to regenerate Fig. 1.2 using the second-order
accurate forward and backward differences and the fourth-order accurate central difference
approximations for the same function.
1.3 Update the MATLAB program in Listing 1.1 to generate the corresponding figures to
Fig. 1.2, but for the second derivatives of the function. Use the approximate expressions in
the right column of Table 1.1 while updating the program.
1.4 The steps of the development of the updating equation for the x component of the electric
field are demonstrated in Section 1.3. Follow the same procedure to show the steps required
to develop the updating equations for the y and z components for the electric field. Pay
sufficient attention to the selection of the indices of each individual field component in your
expressions. The Yee cell presented in Fig. 1.6 should help you in understanding the proper
use of these indices.
1.5 Repeat Exercise 1.4, but this time for developing the updating equations for the magnetic
field components.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
2
Numerical Stability and Dispersion
The finite-difference time-domain (FDTD) algorithm samples the electric and magnetic fields at
discrete points both in time and space. The choice of the period of sampling (t in time, x, y,
and z in space) must comply with certain restrictions to guarantee the stability of the solution.
Furthermore, the choice of these parameters determines the accuracy of the solution. This section
focuses on the stability analysis. First, the stability concept is illustrated using a simple partial
differential equation (PDE) in space and time domain. Next, the Courant-Friedrichs-Lewy (CFL)
condition [3] for the FDTD method is discussed, accompanied by a one-dimensional FDTD
example.
∂u(x, t) ∂u(x, t)
+ = 0, u(x, t = 0) = u 0 (x), (2.1)
∂t ∂x
where u(x, t) is the unknown wave function and u 0 (x) is the initial condition at t = 0. Using the
PDE knowledge, the equation can be analytically solved:
A time-domain numerical scheme can be developed to solve above wave equation. First, u(x, t) is
discretized in both time and space domains:
xi = ix, i = 0, 1, 2, . . .
tn = nt, n = 0, 1, 2, . . .
uin = u(xi , tn ). (2.3)
Here, t and x are the time and space cell sizes. Then, the finite-difference scheme is used to
compute the derivatives, and the following equation is obtained:
33
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
5ε/8 -5ε/8
n+5
ε/2 ε/2 ε/2
n+4
ε/8 5ε/8 -5ε/8 -ε/8
n+3
ε/4 ε/2 ε/4
n+2
ε/2 -ε/2
n+1
ε
n
n-1 x
i-2 i-1 i i+1 i+2
Figure 2.1 The time–space domain grid with error ε propagating with λ = 1/2.
After a simple manipulation, a time-domain numerical scheme can be derived such that
n t
uin+1 = uin−1 + λ ui+1 − ui−1
n
, λ= . (2.5)
x
Figure 2.1 shows a time and space domain grid, where the horizontal axis represents the x axis
and the vertical axis denotes the t axis. The u values for time index denoted as n and n − 1 are all
assumed to be known. For simplicity we will assume that all these values are zeros. We will also
assume that at one x position denoted by the index i and at time denoted by the index n there is
a small error represented by the parameter . As the time evolves, a u value at n + 1 is computed
from two rows lower in accordance with equation (2.5).
Now let’s analyze the propagation of the assumed numerical error in this time domain
algorithm. Note that the error may result from a numerical truncation of a real number. When
λ = 1/2, the errors are shown in Fig. 2.1. The error will keep propagating in this time domain
algorithm; however, it can be observed that the errors are always bounded by the original error ,
whereas for the case when λ = 1, the maximum absolute value of the propagating error is of the
same value as the original error. This is clearly obvious from the errors propagating in Fig. 2.2.
On the contrary, when λ = 2, the propagation of error as shown in Fig. 2.3 will keep increasing
as time evolves. Finally, this error will be large enough and will destroy the actual u values. As a
result, the time-domain algorithm will not give an accurate result due to a very small initial error.
In summary, the numerical scheme in (2.5) is therefore considered conditionally stable. It is stable
for small λ values but unstable for large λ values, and the boundary of stability condition is λ = 1.
Numerical Stability 35
ε -ε
n+5
-ε ε -ε
n+4
ε -ε ε -ε
n+3
ε -ε ε
n+2
n+1 ε -ε
n ε
n-1 x
i-2 i-1 i i+1 i+2
Figure 2.2 The time–space domain grid with error ε propagating with λ = 1.
66ε 50ε
n+5
4ε -25ε 4ε
n+4
8ε 8ε -8ε -8ε
n+3
4ε 7ε 4ε
n+2
n+1 2ε -2ε
n ε
n-1 x
i-2 i-1 i i+1 i+2
Figure 2.3 The time–space domain grid with error ε propagating with λ = 2.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
such that
1
t ≤ , (2.6)
2 + +
1 1 1
c (x) (y)2 (z)2
where c is the speed of light in free space. Equation (2.6) can be rewritten as
1 1 1
c t 2
+ 2
+ ≤ 1. (2.7)
(x) (y) (z)2
For a cubical spatial grid where x = y = z, the CFL condition reduces to
x
t ≤ √ . (2.8)
c 3
One can notice in (2.6) that the smallest value among x, y, and z is the dominant factor
controlling the maximum time step and that the maximum time step allowed is always smaller
than min(x, y, z)/c .
In the one-dimensional case where y → ∞ and z → ∞ in (2.6), the CFL condition
reduces to
This equation implies that a wave cannot be allowed to travel more than one cell size in space
during one time step.
The existence of instability exposes itself as the development of divergent spurious fields in
the problem space as the FDTD iterations proceed. For instance, the one-dimensional FDTD
code presented in Chapter 1 simulates a problem space composed of cells having length x =
1 mm. Due to the one-dimensional CFL condition (2.9) the time increment must be chosen as
t ≤ 3.3356 ps. This code is run with the values of t = 3.3356 ps and t = 3.3357 ps, and the
maximum value of electric field magnitude is captured at every time step and plotted in Fig. 2.4.
The spikes of the electric field magnitude are due to the additive interference of the fields when
fields pass through the center of the problem space, and the nulls are due to the vanishing of
electric fields on PEC when the fields hit the PEC boundary walls. However, while the iterations
proceed, the electric field magnitude calculated by the simulation running with t = 3.3357 ps
starts to diverge. This examination demonstrates how a t value larger than the CFL limit gives
rise to instability in the FDTD computation.
The CFL stability condition applies to inhomogeneous media as well, since the velocity of
propagation in material media is smaller than c . However, numerical stability can be influenced
by other factors, such as absorbing boundary conditions, nonuniform spatial grids, and nonlinear
materials.
Even if the numerical solution is stable, satisfaction of the CFL condition does not guarantee
the numerical accuracy of the solution; it only provides a relationship between the spatial grid
size and the time step. One must still satisfy the sampling theory requirements with respect to the
highest frequency present in the excitation.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Numerical Dispersion 37
3
∆t = 3.3356 ps
∆t = 3.3357 ps
2.5
maximum Ez [V/m]
2
1.5
0.5
0
0 1 2 3 4 5 6
time [ns]
Figure 2.4 Maximum magnitude of E z in the one-dimensional problem space for simulations with t = 3.3356
ps and t = 3.3357 ps.
The FDTD method provides a solution for the behavior of fields that is usually a good approxima-
tion to the real physical behavior of the fields. The finite-difference approximation of derivatives
of continuous functions introduces an error to the solution. For instance, even in homogeneous
free space, the velocity of propagation of the numerical solution for a wave will generally differ
from c . Furthermore, it will vary with frequency, the spatial grid size, and direction of propagation
of the wave. The differing of phase velocities numerically obtained by the FDTD method from
the actual phase velocities is known as numerical dispersion.
For instance, consider a plane wave propagating in free space in the x direction, given by
∂2 ∂2
E z − µ0 ε0 E z = 0. (2.11)
∂ x2 ∂t 2
which is called the dispersion relation. The dispersion relation provides the connection between
the spatial frequency kx and the temporal frequency ω [4]. The dispersion relation (2.12) is
analytically exact.
A dispersion relation equation, which is called the numerical dispersion relation, can be obtained
based on the finite difference approximation of Maxwell’s curl equations as follows. For the one-
dimensional case previously discussed, the plane wave expressions E z (x, t) and Hy (x, t) satisfy the
Maxwell’s one-dimensional curl equations, which are given for the source-free region as
∂ Ez 1 ∂ Hy
= , (2.13a)
∂t ε0 ∂ x
∂ Hy 1 ∂ Ez
= . (2.13b)
∂t µ0 ∂ x
These equations can be rewritten using the central difference formula based on the field positioning
scheme in Fig. 1.13 as
n+ 12 n+ 12
E zn+1 (i) − E zn (i) 1 Hy (i) − Hy (i − 1)
= , (2.14a)
t ε0 x
n+ 12 n− 12
Hy (i) − Hy (i) 1 E zn (i + 1) − E zn (i)
= . (2.14b)
t µ0 x
The plane wave equations (2.10) are in continuous time and space, and they can be expressed in
discrete time and space with
The terms (2.15a), (2.15b), (2.15d), and (2.15e) can be used in (2.14a) to obtain
E0
[cos(kx ix − ω(n + 1)t) − cos(kx ix − ωnt)]
t
H0
= [cos(kx (i + 0.5)x − ω(n + 0.5)t) − cos(kx (i − 0.5)x − ω(n + 0.5)t)]. (2.16)
ε0 x
Numerical Dispersion 39
on the left-hand side of (2.16) with u = kx ix − ω(n + 0.5)t and v = 0.5t, and on the right-
hand side with u = kx ix − ω(n + 0.5)t and v = −0.5x, one can obtain
E0 −H0
sin(0.5ωt) = sin(0.5kx x). (2.17)
t ε0 x
Similarly, using the terms (2.15a), (2.15c), (2.15d), and (2.15f ) in (2.14b) leads to
H0 −E0
sin(0.5ωt) = sin(0.5kx x). (2.18)
t µ0 x
Combining (2.17) and (2.18) one can obtain the numerical dispersion relation for the one-
dimensional case as
1 ωt 2 1 kx x 2
sin = sin . (2.19)
c t 2 x 2
One should notice that the numerical dispersion relation (2.19) is different from the ideal dis-
persion relation (2.12). The difference means there is a deviation from the actual solution of a
problem and, hence, an error introduced by the finite-difference approximations to the numerical
solution of the problem. However, it is interesting to note that for the one-dimensional case,
if one sets t = x/c , (2.19) reduces to (2.12), which means that there is no dispersion error
for propagation in free space. However, this is of little practical use, since the introduction of a
material medium will again create dispersion.
So far, derivation of a numerical dispersion relation has been demonstrated for a one-
dimensional case. It is possible to obtain a numerical dispersion relation for the two-dimensional
case using a similar approach:
1 ωt 2 1 kx x 2 1 ky y 2
sin = sin + sin , (2.20)
c t 2 x 2 y 2
where there is no variation of fields or geometry in the z dimension. For the particular case where
x = y = , t = √ , and kx = k y ,
c 2
the ideal dispersion relation for the two-dimensional case can be recovered as
ω 2
kx2 + k2y = . (2.21)
c
The extension to the three-dimensional case is straightforward but tedious, yielding
1 ωt 2 1 kx x 2 1 ky y 2 1 kz z 2
sin = sin + sin + sin .
c t 2 x 2 y 2 z 2
(2.22)
Similar to the one- and two-dimensional cases, it is possible to recover the three-dimensional ideal
dispersion relation
ω 2
kx2 + k2y + kz2 = (2.23)
c
for specific choices of t, x, y, z, and angle of propagation.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Figure 2.5 (a) Maximum magnitude of E z in the one-dimensional problem space: simulation with x = 1 mm.
2
2
2
2
ω sin(ωt/2) kx sin(kx x/2) ky sin(ky y/2) kz sin(kz z/2)
= + + . (2.24)
2c (ωt/2) 2 (kx x/2) 2 (ky y/2) 2 (kz z/2)
Since limx→0 (sin(x)/x) = 1, (2.24) reduces to the ideal dispersion relation (2.23) when t → 0,
x → 0, y → 0, and z → 0. This is an expected result since when the sampling periods
approach zero, the discrete approximation turns into the continuous case. This also indicates that
if the temporal and spatial sampling periods t, x, y, and z are taken smaller, then the
numerical dispersion error reduces.
So far, we have discussed the numerical dispersion in the context of waves propagating in free
space. A more general discussion of numerical stability and dispersion, including the derivation of
two- and three-dimensional numerical dispersion relations, other factors affecting the numerical
dispersion, and strategies to reduce the associated errors, can be found in [1]. We conclude our
discussion with an example demonstrating the numerical dispersion.
Due to numerical dispersion, waves with different frequencies propagate with different phase
velocities. Any waveform is a sum of sinusoidal waves with different frequencies, and a waveform
does not maintain its shape while propagating since its sinusoidal components do not propagate
with the same velocity due to dispersion. Therefore, the existence of numerical dispersion exposes
itself as distortion of the waveform. For instance, Fig. 2.5 shows the electric and magnetic field
in the one-dimensional problem space calculated by the one-dimensional FDTD code presented
in Chapter 1. The problem space is 1 m wide, and t = 3 ps. Figure 2.5(a) shows the field
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Exercises 41
Figure 2.5 (b) Maximum magnitude of E z in the one-dimensional problem space: simulation with x = 4 mm.
2.3 EXERCISES
2.1 Using the one-dimensional MATLAB FDTD program listed in Appendix A, verify the
results presented in Fig. 2.5.
2.2 Update the one-dimensional FDTD MATLAB program such that the Gaussian pulse prop-
agates in a medium characterized with electric losses instead of free space. Observe the decay
of the amplitude of the propagating pulse and the effect of losses on the dispersion shown
in Fig. 2.5(b) at time = 3 ns.
2.3 Repeat Exercise 2.2, but with the introduction of magnetic losses in the medium, instead of
free space. Record your observations related to the pulse propagation at time = 3 ns.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
3
Building Objects in the Yee Grid
Throughout this book, while describing the concepts of the FDTD method we illustrate the con-
struction of an FDTD program as well. After completing this book, the reader should be able to
construct an FDTD program that can be used to solve three-dimensional electromagnetics prob-
lems of moderate difficulty. In this chapter, we start to provide the blocks of a three-dimensional
FDTD program.
We name the main MATLAB program file that runs an FDTD calculation as fdtd solve.
The MATLAB code in Listing 3.1 shows the contents of fdtd solve, in which the program
routines are named by their functions. Usually it is a good practice to divide a program into
functionally separable modules; this will facilitate the readability of the programs and will simplify
the debugging process. This file is not in the final form for a complete FDTD program; while
we proceed with the chapters we will add more routines with additional functions, will describe
the functions of the routines, and will provide partial code sections to illustrate the programming
of the respective concepts that have been described in the text. The program structures and
codes presented throughout this book are not necessarily samples of the most efficient ways of
programming the FDTD method; there are many ways of translating a concept into a program,
and readers can develop program structures or algorithms that they think are more efficient while
writing their own code. However, we tried to be as explicit as possible while linking the FDTD
concepts with the respective codes.
43
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
4 % d e f i n e t h e problem
define problem space parameters ;
6 define geometry ;
define sources and lumped elements ;
8 define output parameters ;
10 % i n i t i a l i z e t h e problem s p a c e and p a r a m e t e r s
initialize fdtd material grid ;
12 display problem space ;
display material mesh ;
14 if run simulation
initialize fdtd parameters and arrays ;
16 initialize sources and lumped elements ;
initialize updating coefficients ;
18 initialize boundary conditions ;
initialize output parameters ;
20 initialize display parameters ;
22 % FDTD t i m e m a r c h i n g l o o p
run fdtd time marching loop ;
24
In the FDTD algorithm, before the time-marching iterations are performed the problem
should be set up as the first step as indicated in the concise flow chart in Fig. 1.9. Problem setup
can be performed in two sets of routines: (1) routines that define the problem; and (2) routines
that initialize the problem space and FDTD parameters. The problem definition process consists
of construction of data structures that store the necessary information about the electromagnetic
problem to be solved. This information would include the geometries of the objects in the problem
space, their material types, electromagnetic properties of these material types, types of sources
and waveforms, types of simulation results sought from the FDTD computation, and some other
simulation parameters specific to the FDTD algorithm, such as the number of time steps, and
types of boundaries of the problem space. The initialization process translates the data structures
into an FDTD material grid and constructs and initializes data structures and arrays representing
the FDTD updating coefficients, field components, and any other data structures that would be
used during and after the FDTD iterations. In other words, it prepares the structural framework
for the FDTD computation and postprocessing.
Definition of Objects 45
for initialization of the FDTD procedure. In this chapter, we implement the subroutines defi-
ne problem space parameters, define geometry, and initialize fdtd material grid.
The contents of the subroutine define problem space parameters are given in Listing 3.2.
Listing 3.2 starts with the MATLAB command disp, which displays the string in its argument on
MATLAB’s command window. Here the string argument of disp indicates that the program is
executing the routine in which the problem space parameters are defined. Displaying this kind of
informative statement at various stages of the program indicates the progress of the execution as
well as helps for debugging any sources of errors if they exist.
Listing 3.2 define problem space parameters.m
1 d i s p ( ’ d e f i n i n g t h e problem s p a c e p a r a m e t e r s ’ ) ;
% A f a c t o r t h a t determines d u r a t i o n of a time s t e p
7 % wrt CFL l i m i t
courant factor = 0.9;
9
% A f a c t o r d e t e r m i n i n g t h e a c c u r a c y l i m i t o f FDTD r e s u l t s
11 number of cells per wavelength = 20;
13 % D i m e n s i o n s o f a u n i t c e l l i n x , y , and z d i r e c t i o n s ( m e t e r s )
dx = 2.4 e −3;
15 dy = 2.0 e −3;
dz = 2.2 e −3;
17
% ==<b o u n d a r y c o n d i t i o n s >========
19 % Here we d e f i n e t h e b o u n d a r y c o n d i t i o n s p a r a m e t e r s
% ’ pec ’ : p e r f e c t e l e c t r i c c o n d u c t o r
21 b o u n d a r y . t y p e x p = ’ pec ’ ;
boundary . a i r b u f f e r n u m b e r o f c e l l s x p = 5 ;
23
b o u n d a r y . t y p e x n = ’ pec ’ ;
25 boundary . a i r b u f f e r n u m b e r o f c e l l s x n = 5 ;
27 b o u n d a r y . t y p e y p = ’ pec ’ ;
boundary . a i r b u f f e r n u m b e r o f c e l l s y p = 10;
29
b o u n d a r y . t y p e y n = ’ pec ’ ;
31 boundary . a i r b u f f e r n u m b e r o f c e l l s y n = 5 ;
33 b o u n d a r y . t y p e z p = ’ pec ’ ;
boundary . a i r b u f f e r n u m b e r o f c e l l s z p = 5 ;
35
b o u n d a r y . t y p e z n = ’ pec ’ ;
37 boundary . a i r b u f f e r n u m b e r o f c e l l s z n = 0 ;
39 % ===< m a t e r i a l t y p e s >============
% Here we d e f i n e and i n i t i a l i z e t h e a r r a y s o f m a t e r i a l t y p e s
41 % eps r : relative permittivity
% mu r : relative permeability
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
43 % sigma e : e l e c t r i c c o n d u c t i v i t y
% sigma m : m a g n e t i c c o n d u c t i v i t y
45
% air
47 material types (1). eps r = 1;
material types (1). mu r = 1;
49 material types (1). sigma e = 0;
material types (1). sigma m = 0 ;
51 material types (1). color = [1 1 1];
53 % PEC : p e r f e c t e l e c t r i c c o n d u c t o r
material types ( 2 ) . eps r = 1;
55 m a t e r i a l t y p e s ( 2 ) . mu r = 1;
m a t e r i a l t y p e s ( 2 ) . s i g m a e = 1 e10 ;
57 m a t e r i a l t y p e s ( 2 ) . sigma m = 0 ;
material types ( 2 ) . color = [1 0 0];
59
% PMC : p e r f e c t m a g n e t i c c o n d u c t o r
61 material types ( 3 ) . eps r = 1;
m a t e r i a l t y p e s ( 3 ) . mu r = 1;
63 m a t e r i a l t y p e s ( 3 ) . sigma e = 0;
m a t e r i a l t y p e s ( 3 ) . sigma m = 1 e10 ;
65 material types ( 3 ) . color = [0 1 0];
67 % a dielectric
material types (4). eps r = 2.2;
69 material types (4). mu r = 1;
material types (4). sigma e = 0;
71 material types (4). sigma m = 0 . 2 ;
material types (4). color = [0 0 1];
73
% a dielectric
75 material types (5). eps r = 3.2;
material types (5). mu r = 1.4;
77 material types (5). sigma e = 0 . 5 ;
material types (5). sigma m = 0 . 3 ;
79 material types (5). color = [1 1 0];
The total number of time steps that the FDTD time-marching iterations will run for is defined
in line 4 of Listing 3.2 with the parameter number of time steps. Line 8 defines a parameter
named courant factor: a factor by which the duration of a time step is determined with respect
to the CFL stability limit as described in Chapter 2. In line 11 another parameter is defined with
the name number of cells per wavelength. This is a parameter by which the highest frequency
in the Fourier spectrum of a source waveform is determined for a certain accuracy level. This
parameter is described in more detail in Chapter 5, where the source waveforms are discussed.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Definition of Objects 47
On lines 14, 15, and 16 the dimensions of a unit cell constructing the uniform FDTD problem
grid are defined as parameters dx, dy, and dz, respectively.
One of the important concepts in the FDTD technique is the treatment of boundaries of the
problem space. The treatment of perfect electric conductor (PEC) boundaries was demonstrated
in Chapter 1 through a one-dimensional FDTD code. However, some types of problems may
require other types of boundaries. For instance, an antenna problem requires that the boundaries
simulate radiated fields propagating outside the finite problem space to infinity. Unlike a PEC
boundary, this type of boundary requires advanced algorithms, which is the subject of a separate
chapter. However, for now, we limit our discussion to PEC boundaries. A conventional FDTD
problem space composed of uniform Yee cells is a rectangular box having six faces. On lines
21–37 of Listing 3.2 the boundary types of these six faces are defined using a data structure called
boundary. The structure boundary has two types of fields: type and air buffer number of cells.
These field names have extensions indicating the specific face of the domain under consideration.
For instance, the extension xn refers to the face of the problem space for which the normal
vector is directed in the negative x direction, where n stands for negative direction. Similarly, the
extension zp refers to the face of the problem space for which the normal vector is directed in the
positive z direction, where p stands for positive direction. The other four extensions refer to four
other faces. The field type defines the type of the boundary under consideration, and in this case
all boundaries are defined as PEC by the keyword pec. Other types of boundaries are identified
with other keywords.
Some types of boundary conditions require that the boundaries be placed at a distance from
the objects. Most of the time this space is filled with air, and the distance in between is given
in terms of the number of cells. Hence, the parameter air buffer number of cells defines the
distance of the respective boundary faces of the rectangular problem space from the objects placed
in the problem space. If the value of this parameter is zero, it implies that the boundary touches
the objects.
Finally, we define different types of materials that the objects in the problem space are made of.
Since more than one type of material may be used to construct the objects, an array structure with
name material types is used as shown in lines 47–79 of Listing 3.2. An index i in material types(i)
refers to the i th material type. Later on, every object will be assigned a material type through
the index of the material type. An isotropic and homogeneous material type can be defined by its
electromagnetic parameters: relative permittivity εr , relative permeability µr , electric conductivity
σ e , and magnetic conductivity σ m ; hence, fields eps r, mu r, sigma e, and sigma m are used with
parameter material types(i), respectively, to define the electromagnetic parameters of i th material
type. In the given example code a very high value is assigned to material types(2).sigma e to
construct a material type simulating a PEC, and a very high value is assigned to material -
types(3).sigma m to construct a material type simulating a perfect magnetic conductor (PMC).
A fifth field color in material types(i) is optional and is used to assign a color to each material
type, which will help in distinguishing different material types when displaying the objects in the
problem space on a MATLAB figure. The field color is a vector of three values corresponding to
red, green, and blue intensities of the red, green, and blue (RGB) color scheme, respectively, with
each color scaled between 0 and 1.
While defining the material types it is a good practice to reserve some indices for some
common material types. Some of these material types are air, PEC, and PMC, and these material
types are indexed as 1, 2, and 3 in the material types structure array, respectively. Then we can
define additional parameters material type index air, material type index pec, and material -
type index pmc, which store the indices of these materials and can be used to identify them in
the program.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Definition of Objects 49
bricks = [ ] ;
4 spheres = [ ] ;
If MATLAB tries to access a parameter that does not exist in its workspace, it is going to fail and
stop the execution of the program. To prevent such a runtime error we define these arrays even
though they are empty.
So far we have defined an FDTD problem space and defined some objects existing in it.
Combining the definitions in Listings 3.2 and 3.3 we obtained a problem space, which is plotted
in Fig. 3.2. The dimensions of the cells in the grids in Fig. 3.2 are the same as the dimensions
of the unit cell making the FDTD grid. Therefore, it is evident that the boundaries are away
from the objects by the distances defined in Listing 3.2. Furthermore, the objects are placed in
the three-dimensional space with the positions and dimensions as defined in Listing 3.3, and their
colors are set as their corresponding material type colors.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Figure 3.2 An FDTD problem space and the objects defined in it.
In a three-dimensional FDTD problem space the field components are defined at discrete loca-
tions, and the associated material components are defined at the same locations as illustrated in
Figs. 1.5 and 1.6. The material components need to be assigned appropriate values representing
the media existing at the respective positions. However, the medium around a material component
may not be homogeneous, and some approximation strategies need to be adopted.
One of the strategies is to assume that each material component is residing at the center of a
cell. These cells are offset from the Yee cells, and we refer to them as material cells. For instance,
consider the z-component of permittivity shown in Fig. 3.3, which can be imagined as being at
the center of a material cell partially filled with two different media denoted by subscripts 1 and 2,
with permittivity values ε1 and ε2 . The simplest approach is to assume that the cell is completely
filled with medium 1 since the material component εz (i, j, k) resides in the medium 1. Therefore,
εz (i, j, k) can be assigned ε1 ; εz (i, j, k) = ε1 .
A better approach would include the effect of ε2 by employing an averaging scheme. If it is
possible to obtain the volume of each medium filling the material cell, a simple weighted volume
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Material Approximations 51
Figure 3.3 A cell around material component εz (i, j, k) partially filled with two media.
averaging can be used as employed in [5]. In the example case shown in Fig. 3.3, εz (i, j, k) can
be calculated as εz (i, j, k) = (V1 × ε1 + V2 × ε2 )/(V1 + V2 ), where V1 and V2 are the volumes of
medium 1 and medium 2 in the material cell, respectively.
In many cases calculation of the volume of each media in a cell may require tedious calculations,
whereas it may be much simpler to determine the medium in which a point resides. A crude
approximation to the weighted volume averaging scheme is proposed in [6], which may be useful
for such cases. In this approach, every cell in the Yee grid is divided into eight subcells, and
each material component is located in between eight subcells, as illustrated in Fig. 3.4. For every
Figure 3.4 A cell around material component εz (i, j, k) divided into eight subcells.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
subcell center point the respective medium can be determined and every subcell can be assigned the
respective medium material property. Then an effective average of the eight subcells surrounding
a material component can be calculated and assigned to the respective material component.
For instance, εz (i, j, k) in Fig. 3.4, for uniform cell sizes in the x, y, and z directions, can be
calculated as
ε1 + ε2 + ε3 + ε4 + ε5 + ε6 + ε7 + ε8
εz (i, j, k) = . (3.1)
8
The advantage of this method is that objects may be modeled with eight times the geometrical
resolution (two times in each direction) without increasing the size of the staggered grid and
memory requirements.
Figure 3.5 Material component εz (i, j, k) parallel to the boundary of two different media partially filling a
material cell.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Figure 3.6 Material component εz (i, j, k) normal to the boundary of two different media partially filling a
material cell.
where Dz is the electric displacement vector component in the z direction, which is assumed to be
uniform in cross-section, and A1 and A2 are the cross-section areas of the two media types in the
plane normal to Dz . The electric field components in the two media are E z1 and E z2 . The total
electric flux through the cell cross-section can be expressed as
where E z is the electric field component (i, j, k), which is assumed to be uniform in the cross-
section of the cell and associated with the permittivity εeff that is equivalent to εz (i, j, k). On the
boundary of the media the tangential components of the electric field are continuous such that
E z1 = E z2 = E z ; therefore, one can write
ε1 A1 + ε2 A2
ε1 A1 + ε2 A2 = εeff × (A1 + A2 ) ⇒ εeff = εz (i, j, k) = . (3.2)
(A1 + A2 )
Hence, an equivalent permittivity can be calculated for a material component parallel to the
interface of two different material types of permittivity ε1 and ε2 using (3.2), by which the electric
flux conservation is maintained.
For the case where the material component is normal to the media boundary we can employ
Faradays’s law in integral form based on the configuration in Fig. 3.6, which reads
d
E · dl = − B · d s
dt
= −x E x (i, j, k) + x E x (i, j + 1, k) + zE z (i, j, k) − zE z (i + 1, j, k),
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
where E z is the equivalent electric field vector component in the z direction, which is assumed
to be uniform in the boundary cross-section. However, in reality there are two different electric
field values, E z1 and E z2 , due to the different material types. We want to obtain E z to represent
the equivalent effect of E z1 and E z2 and εeff to represent the equivalent effect of ε1 and ε2 . The
electric field terms shall satisfy
l1 + l2 l1 l2 ε1 ε2 × (l 1 + l 2 )
= + ⇒ εeff = εz (i, j, k) = . (3.6)
εeff ε1 ε2 (l 1 ε2 + l 2 ε1 )
Hence, an expression for the equivalent permittivity has been obtained in (3.6), by which the
magnetic flux conservation is maintained.
The averaging schemes given by (3.2) and (3.6) are specific cases of the more general approaches
introduced in [7], [8], and [9].
It can be shown that these schemes can be employed for other material parameters as well. For
instance, the equivalent permeability µ can be written as
µ1 A1 + µ2 A2
µeff = , µ parallel to media boundary, (3.7a)
(A1 + A2 )
µ1 µ2 × (l 1 + l 2 )
µeff = , µ normal to media boundary. (3.7b)
(l 1 µ2 + l 2 µ1 )
These schemes serve as good approximations for low values of σ e and σ m as well, where they can
be written as
σ1e A1 + σ2e A2
σeff
e
= , σe parallel to media boundary, (3.8a)
(A1 + A2 )
σ1e σ2e × (l 1 + l 2 )
σeff
e
= , σe normal to media boundary, (3.8b)
(l 1 σ2e + l 2 σ1e )
and
σ1m A1 + σ2m A2
σeff
m
= , σm parallel to media boundary, (3.9a)
(A1 + A2 )
σ1m σ2m × (l 1 + l 2 )
σeff
m
= , σm normal to media boundary. (3.9b)
(l 1 σ2m + l 2 σ1m )
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Since the electric conductivity material components are defined at the same positions as the
permittivity components, the same averaging scheme can be employed to get the equivalent
Figure 3.7 Material component εz (i, j, k) located between four Yee cells filled with four different material types.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Figure 3.8 Material component µz (i, j, k) located between two Yee cells filled with two different material types.
σ e (i, j, k) + σ e (i − 1, j, k) + σ e (i, j − 1, k) + σ e (i − 1, j − 1, k)
σze (i, j, k) = . (3.11)
4
Unlike the permittivity and electric conductivity components, the material components as-
sociated with magnetic field components, permeability and magnetic conductivity, are located
between two cells and are oriented normal to the cell boundaries as illustrated in Fig. 3.8. In this
case we can use the relation (3.7b) to get µz (i, j, k) as
2 × µ(i, j, k) × µ(i, j, k − 1)
µz (i, j, k) = . (3.12)
µ(i, j, k) + µ(i, j, k − 1)
2 × σ m (i, j, k) × σ m (i, j, k − 1)
σzm (i, j, k) = . (3.13)
σ m (i, j, k) + σ m (i, j, k − 1)
Figure 3.9 A PEC plate with zero thickness surrounded by four σ e material components.
modeling techniques. Here we discuss a simple modeling technique that can be used to obtain
results with a reasonable accuracy for the majority of problems including thin strips where the
thin strips are PEC. Here we assume that the thin-strip thickness is zero, which is a reasonable
approximation since most of the time the strip thicknesses are much smaller than the cell sizes.
Furthermore, we assume that the strips are conforming to the faces of the Yee cells in the problem
space.
Consider the PEC plate with zero thickness as shown in Fig. 3.9, which conforms to the face
of the Yee cell with index (i, j, k). This plate is surrounded by four electric conductivity material
components, namely, σxe (i, j, k), σxe (i, j + 1, k), σ ye (i, j, k), and σ ye (i + 1, j, k). We can simply assign
the conductivity of PEC, σpec
e
, to these material components, such that
Therefore, any electric conductivity components surrounding and coinciding with PEC plates can
be assigned the conductivity of PEC to model zero-thickness PEC plates in the FDTD method.
Similarly, if a PEC object with thickness smaller than a cell size in two dimensions, such as
a thin conductor wire, needs to be modeled in the FDTD method, it is sufficient to assign the
conductivity of PEC to the electric conductivity components coinciding with the object. This
approach gives a reasonable approximation to a thin wire in the FDTD method. However, since
the field variation around a thin wire is large, the sampling of the fields at the discrete points
around the wire may not be accurate. Therefore, it is more appropriate to use more advanced
thin-wire modeling techniques, which take into account the wire thickness, for better accuracy. A
thin-wire modeling technique is discussed in Chapter 10.
At the beginning of this chapter we discussed how we can define the objects using data structures in
MATLAB. We use these structures to initialize the FDTD material grid; we create and initialize
three-dimensional arrays representing the components of the material parameters ε, µ, σ e , and
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
σ m . Then we assign appropriate values to these arrays using the averaging schemes discussed
in Section 3.4. Later on these material arrays will be used to calculate the FDTD updating
coefficients.
The routine initialize fdtd material grid, which is used to initialize the material arrays, is
given in Listing 3.4. The material array initialization process is composed of multiple stages;
therefore, initialize fdtd material grid is divided into functional subroutines. We describe the
implementation of these subroutines and demonstrate how the concepts described in Section 3.4
are coded.
% c a l c u l a t e problem s p a c e s i z e b a s e d on t h e o b j e c t
4 % l o c a t i o n s and b o u n d a r y c o n d i t i o n s
calculate domain size ;
6
12 % C r e a t e t h e 3D o b j e c t s i n t h e problem s p a c e by
% a s s i g n i n g i n d i c e s of material types in the c e l l s
14 % to material 3d space
16 % create spheres
create spheres ;
18
% create bricks
20 create bricks ;
22 % M a t e r i a l component a r r a y s f o r a problem s p a c e
% composed o f ( nx , ny , nz ) c e l l s
24 eps r x = o n e s ( nx , nyp1 , nzp1 ) ;
eps r y = o n e s ( nxp1 , ny , nzp1 ) ;
26 eps r z = o n e s ( nxp1 , nyp1 , nz ) ;
mu r x = o n e s ( nxp1 , ny , nz ) ;
28 mu r y = o n e s ( nx , nyp1 , nz ) ;
mu r z = o n e s ( nx , ny , nzp1 ) ;
30 sigma e x = z e r o s ( nx , nyp1 , nzp1 ) ;
sigma e y = z e r o s ( nxp1 , ny , nzp1 ) ;
32 sigma e z = z e r o s ( nxp1 , nyp1 , nz ) ;
sigma m x = z e r o s ( nxp1 , ny , nz ) ;
34 sigma m y = z e r o s ( nx , nyp1 , nz ) ;
sigma m z = z e r o s ( nx , ny , nzp1 ) ;
36
% c a l c u l a t e m a t e r i a l component v a l u e s by a v e r a g i n g
38 calculate material component values ;
40 % c r e a t e z e r o t h i c k n e s s PEC p l a t e s
create PEC plates ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
The first subroutine in Listing 3.4 is calculate domain size, the implementation of which is
given in Listing 3.5. In this subroutine the dimensions of the FDTD problem space are determined,
including the number of cells (Nx, Ny, and Nz) making the problem space. Once the number
of cells in the x, y, and z dimensions are determined, they are assigned to parameters nx, ny,
and nz. Based on the discussion in Section 3.4, we assume that every Yee cell is filled with a
material type. Then in line 10 of Listing 3.4 a three-dimensional array material 3d space with
size (Nx × Ny × Nz) is initialized with ones. In this array each element will store the index of
the material type filling the corresponding cell in the problem space. Since material 3d space
is initialized by the MATLAB function ones, all of its elements have the value 1. Referring to
Listing 3.2 one can see that material types(1) is reserved for air; therefore, the problem space is
initially filled with air.
% D e t e r m i n e t h e problem s p a c e b o u n d a r i e s i n c l u d i n g a i r b u f f e r s
36 fdtd domain . min x = fdtd domain . min x . . .
− dx * b o u n d a r y . a i r b u f f e r n u m b e r o f c e l l s x n ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
% D e t e r m i n i n g t h e problem space s i z e
50 fdtd domain . s i z e x = fdtd d o m a i n . max x − f d t d d o m a i n . m i n x ;
fdtd domain . s i z e y = fdtd d o m a i n . max y − f d t d d o m a i n . m i n y ;
52 fdtd domain . s i z e z = fdtd d o m a i n . max z − f d t d d o m a i n . m i n z ;
64 f d t d d o m a i n . max x = f d t d d o m a i n . m i n x + f d t d d o m a i n . s i z e x ;
f d t d d o m a i n . max y = f d t d d o m a i n . m i n y + f d t d d o m a i n . s i z e y ;
66 f d t d d o m a i n . max z = f d t d d o m a i n . m i n z + f d t d d o m a i n . s i z e z ;
cx = fdtd domain . c e l l c e n t e r c o o r d i n a t e s x ;
4 cy = fdtd domain . c e l l c e n t e r c o o r d i n a t e s y ;
cz = fdtd domain . c e l l c e n t e r c o o r d i n a t e s z ;
6
f o r i n d =1: n u m b e r o f s p h e r e s
8 % d i s t a n c e o f t h e c e n t e r s o f t h e c e l l s from t h e c e n t e r o f t h e s p h e r e
d i s t a n c e = s q r t ( ( spheres ( ind ) . c e n t e r x − cx ) . ˆ 2 . . .
10 + ( spheres ( ind ) . c e n t e r y − cy ) . ˆ 2 . . .
+ ( spheres ( ind ) . c e n t e r z − cz ) . ˆ 2 ) ;
12 I = f i n d ( d i s t a n c e <=s p h e r e s ( i n d ) . r a d i u s ) ;
m a t e r i a l 3 d s p a c e ( I ) = spheres ( ind ) . m a t e r i a l t y p e ;
14 end
clear cx cy cz ;
After this point we find the cells overlapping with the objects defined in define geometry
and assign the indices of the material types of the objects to the corresponding elements of
the array material 3d space. This procedure is performed in the subroutines create spheres,
which is shown in Listing 3.6, and create bricks, which is shown in Listing 3.7. With the given
implementations, first the spheres are created in the problem space, and then the bricks are
created. Furthermore, the objects will be created in the sequence as they are defined in de-
fine geometry. This means that if more than one object overlaps in the same cell, the object de-
fined last will overwrite the objects defined before. So one should define the objects accordingly.
These two subroutines (create spheres and create bricks) can be replaced by a more advanced
algorithm in which the objects can be assigned priorities in case of overlapping, and chang-
ing the priorities would be sufficient to have the objects created in the desired sequence in the
problem space.
Figure 3.10 An FDTD problem space and the objects approximated by snapping to cells.
For example, the array material 3d space is filled with the material parameter indices of
the objects that were defined in Listing 3.3 and displayed in Fig. 3.2. The cells represented by
material 3d space are plotted in Fig. 3.10, which clearly shows the staircased approximations of
the objects as generated by the subroutine display problem space, which is called in fdtd solve.
Then in initialize fdtd material grid we create three-dimensional arrays representing the
material parameter components εx , ε y , εz , µx , µ y , µz , σxe , σ ye , σze , σxm , σ ym , and σzm . Here the
parameters eps r x, eps r y, eps r z, mu r x, mu r y, and mu r z are relative permittivity and
relative permeability arrays, and they are initialized with 1. The electric and magnetic conductivity
arrays are initialized with 0. One can notice that the sizes of these arrays are not the same as they
correspond to the size of the associated field component. This is due to the specific positioning
scheme of the field components on the Yee cell as shown in Fig. 1.5. For instance, the distribution of
the x components of the electric field, E x , in a problem space composed of (Nx × Ny × Nz) cells is
illustrated in Fig. 3.11. It can be observed that there exist (Nx × Ny + 1 × Nz + 1) E x components
in the problem space. Therefore, in the program the three-dimensional arrays representing E x
and the material components associated with E x shall be constructed with size (Nx × Ny + 1 ×
Nz + 1). Hence, in Listing 3.4 the parameters eps r x and sigma e x are constructed with size
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Figure 3.11 Positions of the E x components on the Yee grid for a problem space composed of (N x × N y × N z)
cells.
(nx, ny p1, nzp1), where ny p1 is Ny + 1, and nzp1 is Nz + 1. Similarly, it can be observed in Fig.
3.12 that there exist (Nx + 1 × Ny × Nz) Hx components in the problem space. Therefore, in
Listing 3.4 the parameters mu r x and sigma m x are constructed with size (nxp1, ny, nz), where
nxp1 is Nx + 1.
Figure 3.12 Positions of the H x components on the Yee grid for a problem space composed of (N x × N y × N z)
cells.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Since we have created and filled the array material 3d space as the staircased representation
of the FDTD problem space and have initialized material component arrays, we can proceed
with assigning appropriate parameter values to the material component array elements based
on the averaging schemes discussed in Section 3.4 to form the material grid. This is done in
the subroutine calculate material component values; partial implementation of this subroutine is
shown in Listing 3.8. In Listing 3.8 calculations for the x components of the material component
arrays are illustrated; implementation of other components is left to the reader. Here one can notice
that eps r x, sigma e x, mu r x, and sigma m x are calculated using the forms of equations (3.10),
(3.11), (3.12), and (3.13), respectively.
% c r e a t i n g t e m p o r a r y 1D a r r a y s f o r s t o r i n g
4 % parameter v a l u e s of m a t e r i a l types
for ind = 1: s i z e ( m a t e r i a l t y p e s , 2 )
6 t e p s r ( ind ) = m a t e r i a l t y p e s ( ind ) . e p s r ;
t mu r ( ind ) = m a t e r i a l t y p e s ( i n d ) . mu r ;
8 t s i g m a e ( ind ) = m a t e r i a l t y p e s ( ind ) . sigma e ;
t s i g m a m ( i n d ) = m a t e r i a l t y p e s ( i n d ) . sigma m ;
10 end
12 % a s s i g n n e g l i g i b l y s m a l l v a l u e s t o t m u r and t s i g m a m where t h e y a r e
% z e r o i n o r d e r t o p r e v e n t d i v i s i o n by z e r o e r r o r
14 t m u r ( f i n d ( t m u r = = 0 ) ) = 1e −20;
t s i g m a m ( f i n d ( t s i g m a m = = 0 ) ) = 1e −20;
16
disp ( ’ C a l c u l a t i n g e p s r x ’ ) ;
18 % eps r x ( i , j , k ) i s average of four c e l l s
% ( i , j , k ) , ( i , j −1 , k ) , ( i , j , k − 1 ) , ( i , j −1 ,k −1)
20 e p s r x ( 1 : nx , 2 : ny , 2 : nz ) = . . .
0 . 2 5 * ( t e p s r ( m a t e r i a l 3 d s p a c e ( 1 : nx , 2 : ny , 2 : nz ) ) . . .
22 + t e p s r ( m a t e r i a l 3 d s p a c e ( 1 : nx , 1 : ny −1 ,2: nz ) ) . . .
+ t e p s r ( m a t e r i a l 3 d s p a c e ( 1 : nx , 2 : ny , 1 : nz − 1 ) ) . . .
24 + t e p s r ( m a t e r i a l 3 d s p a c e ( 1 : nx , 1 : ny −1 ,1: nz − 1 ) ) ) ;
disp ( ’ C a l c u l a t i n g sigma e x ’ ) ;
45 % sigma e x ( i , j , k ) i s average of four c e l l s
% ( i , j , k ) , ( i , j −1 , k ) , ( i , j , k − 1 ) , ( i , j −1 ,k −1)
47 s i g m a e x ( 1 : nx , 2 : ny , 2 : nz ) = . . .
0 . 2 5 * ( t s i g m a e ( m a t e r i a l 3 d s p a c e ( 1 : nx , 2 : ny , 2 : nz ) ) . . .
49 + t s i g m a e ( m a t e r i a l 3 d s p a c e ( 1 : nx , 1 : ny −1 ,2: nz ) ) . . .
+ t s i g m a e ( m a t e r i a l 3 d s p a c e ( 1 : nx , 2 : ny , 1 : nz − 1 ) ) . . .
51 + t s i g m a e ( m a t e r i a l 3 d s p a c e ( 1 : nx , 1 : ny −1 ,1: nz − 1 ) ) ) ;
disp ( ’ C a l c u l a t i n g mu r x ’ ) ;
73 % m u r x ( i , j , k ) i s a v e r a g e o f two c e l l s ( i , j , k ) , ( i −1 , j , k )
m u r x ( 2 : nx , 1 : ny , 1 : nz ) = . . .
75 2 * ( t m u r ( m a t e r i a l 3 d s p a c e ( 2 : nx , 1 : ny , 1 : nz ) ) . . .
. * t m u r ( m a t e r i a l 3 d s p a c e ( 1 : nx −1 ,1: ny , 1 : nz ) ) ) . . .
77 . / ( t m u r ( m a t e r i a l 3 d s p a c e ( 2 : nx , 1 : ny , 1 : nz ) ) . . .
+ t m u r ( m a t e r i a l 3 d s p a c e ( 1 : nx −1 ,1: ny , 1 : nz ) ) ) ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
96 disp ( ’ C a l c u l a t i n g sigma m x ’ ) ;
% s i g m a m x ( i , j , k ) i s a v e r a g e o f two c e l l s ( i , j , k ) , ( i −1 , j , k )
98 s i g m a m x ( 2 : nx , 1 : ny , 1 : nz ) = . . .
2 * ( t s i g m a m ( m a t e r i a l 3 d s p a c e ( 2 : nx , 1 : ny , 1 : nz ) ) . . .
100 . * t s i g m a m ( m a t e r i a l 3 d s p a c e ( 1 : nx −1 ,1: ny , 1 : nz ) ) ) . . .
. / ( t s i g m a m ( m a t e r i a l 3 d s p a c e ( 2 : nx , 1 : ny , 1 : nz ) ) . . .
102 + t s i g m a m ( m a t e r i a l 3 d s p a c e ( 1 : nx −1 ,1: ny , 1 : nz ) ) ) ;
The last step in constructing the material grid is to create the zero-thickness PEC plates in
the material grid. The subroutine create PEC plates shown in Listing 3.9 is implemented for this
purpose. The code checks all of the defined bricks for zero thickness and assigns their material’s
conductivity values to the electric conductivity components overlapping with them.
Using the code sections described in this section, the material grid for the material cell distri-
bution in Fig. 3.10 is obtained and plotted on three plane cuts for relative permittivity distribution
in 3.13(a) and for relative permeability distribution in 3.13(b). The effects of averaging can be
clearly observed on the object boundaries.
5 mtype = b r i c k s ( i n d ) . m a t e r i a l t y p e ;
s i g m a p e c = m a t e r i a l t y p e s ( mtype ) . s i g m a e ;
7
17 % f i n d the zero t h i c k n e s s b r i c k s
i f ( b l x == bux )
19 s i g m a e y ( b l x , b l y : buy −1 , b l z : buz ) = s i g m a p e c ;
s i g m a e z ( b l x , b l y : buy , b l z : buz −1) = s i g m a p e c ;
21 end
i f ( b l y == buy )
23 s i g m a e z ( b l x : bux , b l y , b l z : buz −1) = s i g m a p e c ;
s i g m a e x ( b l x : bux −1 , b l y , b l z : buz ) = s i g m a p e c ;
25 end
i f ( b l z == buz )
27 s i g m a e x ( b l x : bux −1 , b l y : buy , b l z ) = s i g m a p e c ;
s i g m a e y ( b l x : bux , b l y : buy −1 , b l z ) = s i g m a p e c ;
29 end
end
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
3.7 EXERCISES
3.1 The file fdtd solve is the main program used to run FDTD simulations. Open this subrou-
tine and examine its contents. It calls several subroutines that are not implemented yet. In
the code disable the lines 7, 8, and 14–27 by “commenting” these lines. Simply insert “%”
sign in front of these lines. Now the code is ready to run with its current functionality.
Open the subroutine define problem space parameters, and define the problem space
parameters. Set the cell size as 1 mm on a side, boundaries as ‘pec’, and air gap between the
objects and boundaries as 5 cells on all sides. Define a material type with index 4 having the
relative permittivity as 4, relative permeability as 2, electric conductivity as 0.2, and magnetic
conductivity as 0.1. Define another material type with index 5 having relative permittivity
as 6, relative permeability as 3, electric conductivity as 0.4, and magnetic conductivity as
0.2. Open the subroutine define geometry, and define the problem geometry. Define a brick
with size 5 mm × 6 mm × 7 mm, and assign material type index 4 as its material type. Figure
3.14(a) shows the geometry of the problem in consideration.
In the directory including your code files there are some additional files prepared as plot-
ting routines that you can use together with your code. These routines are called in fdtd solve
after the definition routines. Insert the command ‘show problem space = true;’ in line 9 of
fdtd solve temporarily to enable three-dimensional geometry display. Run the program
fdtd solve. The program will open a figure including a three-dimensional view of the geom-
etry you have defined and another program named as “Display Material Mesh” that helps you
examine the material mesh created for the defined geometry. For instance, Fig. 3.14(b) shows
the relative permittivity distribution of the FDTD problem space in three plane cuts gener-
ated by the program “Display Material Mesh.” Examine the geometry and the material mesh,
and verify that the material parameter values are averaged on the boundaries as explained in
Chapter 3.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Exercises 69
3.2 Consider the problem you constructed in Exercise 3.1. Now define another brick with size
3 mm × 4 mm × 5 mm, assign material type index 5 as its material type, and place it
at the center of the first brick. Run fdtd solve, and then examine the geometry and the
material mesh and verify that the material parameter values are averaged on the boundaries
as explained in Chapter 3.
Now change the definition sequence of these two bricks in define geometry; define the
second brick first with index 1 and the first brick as second with its index 2. Run fdtd -
solve, and examine the geometry and the material mesh. Verify that the smaller brick has
disappeared in the material mesh. With the given implementation of the program, the
sequence of defining the objects determines the way the FDTD material mesh is created.
3.3 Construct a problem space with the cell size as 1 mm on a side, boundaries as ‘pec’, and
air gap between the objects and boundaries as 5 cells on all sides. Define a brick as a PEC
plate with zero thickness placed between the coordinates given in millimeters as (0, 0, 0) and
(8, 8, 0). Define another brick as a plate with zero thickness, material type air, and placed
between the coordinates (3, 0, 0) and (5, 8, 0) as illustrated in Fig. 3.15(a), which shows the
geometry of the problem in consideration. Run fdtd solve, and then examine the geometry
and the material mesh. Examine the electric conductivity distribution, and verify that on the
boundary between the plates the material components are air as shown in Fig. 3.15(b).
3.4 Construct a problem space with the cell size as 1 mm on a side, boundaries as ‘pec’, and
air gap between the objects and boundaries as 5 cells on all sides. Define a brick as a PEC
plate with zero thickness placed between the coordinates given in millimeters as (0, 0, 0) and
(3, 8, 0). Define another brick as PEC plate and placed between the coordinates (5, 0, 0) and
(8, 8, 0). Run fdtd solve, and then examine the geometry and the material mesh. Examine
the electric conductivity distribution, and verify that on the boundaries of the plates facing
each other the material components are PEC.
Although the geometry constructed in this example is physically the same as the one in
Exercise 3.3, the material meshes are different since the ways the geometries are defined are
different.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
4
Active and Passive Lumped
Elements
Many practical electromagnetics applications require inclusion of lumped circuit elements. The
lumped elements may be active sources in the form of voltage and current sources or passive
in the form of resistors, inductors, and capacitors. Nonlinear circuit elements such as diodes
and transistors are also required to be integrated in the numerical simulation of antennas and
microwave devices. The electric current flowing through these circuit elements can be represented
by the impressed current density term, Ji , in Maxwell’s curl equation
= ε ∂ E + σ e E + Ji .
∇×H (4.1)
∂t
Impressed currents are used to represent sources or known quantities. In this sense, they are the
sources that cause the electric and magnetic fields in the computational domain [10]. A lumped
element component placed between two nodes is characterized by the relationship between the
voltage V across and the current I flowing between these two nodes. This relationship can be
incorporated into Maxwell’s curl equation (4.1) by expressing E in terms of V using
E = −∇V (4.2)
I= J · d s , (4.3)
S
where S is the cross-sectional area of a unit cell normal to the flow of the current I . These
equations can be implemented in discrete time and space and can be incorporated into (4.1), which
are expressed in terms of finite differences. Then, the finite-difference time-domain (FDTD)
updating equations can be obtained that simulate the respective lumped element characteristics.
In this chapter we discuss the construction of the FDTD updating equations for lumped
element components, and we demonstrate MATLAB implementation of definition, initialization,
and simulation of these elements.
71
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
(a) Voltage source with internal resistance (b) Voltage source without internal resis-
(soft source) tance (hard source)
Figure 4.2 Voltage sources placed between nodes (i, j, k) and (i, j, k + 1).
We want to place a voltage source with Vs volts magnitude and Rs ohms internal resistance between
nodes (i, j, k) and (i, j, k + 1) as illustrated in Fig. 4.2(a), where Vs is a time-varying function with
a predetermined waveform. The voltage–current relation for this circuit can be written as
V + Vs
I= , (4.6)
Rs
where V is the potential difference between nodes (i, j, k) and (i, j, k + 1). The term V can
be expressed in terms of E z using (4.2), which translates to
in discrete form at time instant (n + 0.5)t. Current I is the current flowing through the surface
enclosed by the magnetic field components in Fig. 4.1, which can be expressed in terms of Ji z
using (4.3) as
1 n+ 12
I n+ 2 = xy Ji z (i, j, k). (4.8)
One should notice that V in (4.7) is evaluated at time instant (n + 0.5)t, which corresponds
to the required time instant of I and J dictated by (4.5). Inserting (4.7) and (4.8) in (4.6) one can
obtain
n+ 12 z 1 n+ 1
Ji z (i, j, k) = × E zn+1 (i, j, k) + E zn (i, j, k) + × Vs 2 . (4.9)
2xy Rs xy Rs
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Equation (4.9) includes the voltage–current relation for a voltage source tying Vs and Rs to electric
field components in the discrete space and time. One can use (4.9) in (4.5) and rearrange the terms
such that the future value of the electric field component E zn+1 can be calculated using other terms,
which yields our standard form updating equations such that
where
tz
2εz (i, j, k) − tσze (i, j, k) − Rs xy
Ce ze (i, j, k) = tz
,
2εz (i, j, k) + tσze (i, j, k) + Rs xy
2t
Ce zhy (i, j, k) = ,
tz
2εz (i, j, k) + tσze (i, j, k) + Rs xy
x
2t
Ce zhx (i, j, k) = − ,
tz
2εz (i, j, k) + tσze (i, j, k) + Rs xy
y
2t
Ce zs (i, j, k) = − .
tz
2εz (i, j, k) + tσze (i, j, k) + Rs xy
(Rs xy)
Equation (4.10) is the FDTD updating equation modeling a voltage source placed between the
nodes (i, j, k) and (i, j, k + 1), which is oriented in the z direction. The FDTD updating equations
for voltage sources oriented in other directions can easily be obtained following the same steps as
just illustrated.
The FDTD updating equation (4.10) is given for a voltage source with a polarity in the positive
z direction as indicated in Fig. 4.2(a). To model a voltage source with the opposite polarity, one
needs only to use the inverse of the voltage magnitude waveform by changing Vs to −Vs .
2 n+ 12
E zn+1 (i, j, k) = −E zn (i, j, k) − Vs (i, j, k). (4.11)
z
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
To conform with the general form of the FDTD updating equations, (4.11) can be expressed as
where
2
Ce ze (i, j, k) = −1, Ce zhy (i, j, k) = 0, Ce zhx (i, j, k) = 0, Ce zs (i, j, k) = − .
z
V
I = Is + . (4.13)
Rs
Figure 4.3 Lumped elements placed between nodes (i, j, k) and (i, j, k + 1).
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
1
Expressions of V in (4.7) and I n+ 2 in (4.8) can be used in (4.13), which yields in discrete time
and space
n+ 12 z 1 n+ 1
Ji z (i, j, k) = × E zn+1 (i, j, k) + E zn (i, j, k) + × Is 2 . (4.14)
2xy Rs xy
One can use (4.14) in (4.5) and rearrange the terms such that E zn+1 can be calculated using other
terms, which yields
where
tz
2εz (i, j, k) − tσze (i, j, k) − Rs xy
Ce ze (i, j, k) = tz
,
2εz (i, j, k) + tσze (i, j, k) + Rs xy
2t
Ce zhy (i, j, k) = ,
tz
2εz (i, j, k) + tσze (i, j, k) + Rs xy
x
2t
Ce zhx (i, j, k) = − ,
tz
2εz (i, j, k) + tσze (i, j, k) + Rs xy
y
2t
Ce zs (i, j, k) = − .
tz
2εz (i, j, k) + tσze (i, j, k) + Rs xy
xy
Equation (4.15) is the updating equation modeling a current source. One should notice that
n+ 12
(4.15) is the same as (4.10) except for the source term; that is, replacing the Vs (i, j, k) term in
n+ 1
(4.10) by Rs × Is 2 (i, j, k) yields (4.15).
The FDTD updating equation (4.15) is given for a current source with a current flowing in
the positive z direction as indicated in Fig. 4.3(a). To model a current source with the opposite
flow direction, one needs only to use the inverse of the current magnitude waveform by changing
Is to −Is .
4.1.4 Resistor
Having derived the updating equations for a voltage source or a current source with internal
resistance, it is straightforward to derive updating equations for a resistor. For instance, eliminating
the current source in Fig. 4.3(a) yields the resistor in Fig. 4.3(b). Hence, setting the source term
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
n+ 12
Is (i, j, k) in (4.15) to zero results the updating equation for a resistor as
where
tz
2εz (i, j, k) − tσze (i, j, k) − Rxy
Ce ze (i, j, k) = tz
,
2εz (i, j, k) + tσze (i, j, k) + Rxy
2t
Ce zhy (i, j, k) = ,
tz
2εz (i, j, k) + tσze (i, j, k) + Rxy
x
2t
Ce zhx (i, j, k) = − .
tz
2εz (i, j, k) + tσze (i, j, k) + Rxy
y
4.1.5 Capacitor
Figure 4.4(a) illustrates a capacitor with C farads capacitance. The voltage–current relation for
the capacitor can be written as
d V
I =C . (4.17)
dt
Figure 4.4 Lumped elements placed between nodes (i, j, k) and (i, j, k + 1).
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
1 V n+1 − V n
I n+ 2 = C . (4.18)
t
1
Using V in (4.7) and I n+ 2 in (4.8) together with (4.18), one can obtain
n+ 12 Cz
Ji z (i, j, k) = × E zn+1 (i, j, k) − E zn (i, j, k) . (4.19)
txy
One can use (4.19) in (4.5) and rearrange the terms such that E zn+1 can be calculated using other
terms, which yields the updating equation for a capacitor as
where
2t
Ce zhy (i, j, k) = ,
2εz (i, j, k) + tσze (i, j, k) + 2Cz
xy
x
2t
Ce zhx (i, j, k) = − .
2εz (i, j, k) + tσze (i, j, k) + 2Cz
xy
y
4.1.6 Inductor
Figure 4.4(b) illustrates an inductor with L henrys inductance. The inductor is characterized by
the voltage–current relation
dI
V=L . (4.21)
dt
This relation can be expressed in discrete time and space using the central difference formula at
time instant nt as
L n+ 1 1
V n = I 2 − I n− 2 . (4.22)
t
Using the discrete domain relation (4.7) and (4.8) one can obtain
n+ 12 n− 12 tz n
Ji z (i, j, k) = Ji z (i, j, k) + E (i, j, k). (4.23)
Lxy z
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
n+ 1
Since we were able to obtain an expression for Ji z 2 (i, j, k) in terms of the previous value of
the electric field1 component E zn (i, j, k) and the previous value of the impressed current density
n−
component Ji z 2 (i, j, k), we can use the general form of the FDTD updating equation (1.28)
without any modification, which is rewritten here for convenience as
where
2εz (i, j, k) − tσze (i, j, k)
Ce ze (i, j, k) = ,
2εz (i, j, k) + tσze (i, j, k)
2t
Ce zhy (i, j, k) = ,
2εz (i, j, k) + tσze (i, j, k) x
2t
Ce zhx (i, j, k) = − ,
2εz (i, j, k) + tσze (i, j, k) y
2t
Ce zj (i, j, k) = − .
2εz (i, j, k) + tσze (i, j, k)
One should notice that during the FDTD time-marching iteration, at every time step the new value
n+ 1 n− 1
of Ji z 2 (i, j, k) should be calculated by (4.23) using E zn (i, j, k) and Ji z 2 (i, j, k) before updating
E zn+1 (i, j, k) by (4.24).
Figure 4.5 Parallel PEC plates excited by a voltage source at one end and terminated by a resistor at the other
end.
to maintain the respective values of the lumped elements. For instance, consider the voltage source
in Fig. 4.5. To simulate this source, the electric field components E z (vis : vie, v j s : v j e, vks :
vke − 1) need to be updated as shown in Fig. 4.6. Hence, the total number of field components
needing to be updated is (vie − vis + 1) × (v j e − v j s + 1) × (vke − vks ). Therefore, the main
voltage source can be replaced by multiple voltage sources, each of which is associated with a
respective field component. Each individual voltage source in Fig. 4.6 then should be assigned a
voltage value Vs ,
Vs
Vs = , (4.25)
(vke − vks )
since the potential difference between the ends of the main voltage source in the z direction shall
be kept the same. If the main voltage source has an internal resistance Rs , it should be maintained
as well. Then the main resistance Rs will be represented by a network of (vie − vis + 1) ×
(v j e − v j s + 1) resistors connected in parallel where each element in this parallel combination
is made of (vke − vks ) series resistors. Therefore, the resistance for each source component
Figure 4.6 A voltage source distributed over a surface and a resistor distributed over a volume.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
(vie − vis + 1) × (v j e − v j s + 1)
Rs = Rs × . (4.26)
(vke − vks )
Having applied these modifications to Vs and Rs , the electric field components E z (vis : vie, v j s :
v j e, vks : vke − 1) can be updated using (4.10).
The same procedure holds for each individual resistor R at the other end of the parallel PEC
plates. Thus, the resistance R can be given as
(rie − ris + 1) × (r j e − r j s + 1)
R = R × , (4.27)
(rke − rks )
and (4.16) can be used to update the electric field components E z (ris : rie, r j s : r j e, rks : rke − 1).
Similarly, for an inductor with inductance L extending between the nodes (is , j s , ks ) and
(ie, j e, ke), the individual inductance L can be defined as
(ie − is + 1) × ( j e − j s + 1)
L = L × , (4.28)
(ke − ks )
and (4.24) can be used to update the electric field components E z (is : ie, j s : j e, ks : ke − 1).
For a capacitor with capacitance C extending between the nodes (is , j s , ks ) and (ie, j e, ke),
each individual capacitance C can be defined as
(ke − ks )
C = C × , (4.29)
(ie − is + 1) × ( j e − j s + 1)
and (4.19) can be used to update the electric field components E z (is : ie, j s : j e, ks : ke − 1).
A current source with magnitude Is and resistance Rs extending between the nodes (is , j s , ks )
and (ie, j e, ke) can be modeled by updating E z (is : ie, j s : j e, ks : ke − 1) using (4.15) after mod-
ifying Is and resistance Rs such that
Is
Is = , (4.30)
(ie − is + 1) × ( j e − j s + 1)
and
(vie − vis + 1) × (v j e − v j s + 1)
Rs = Rs × . (4.31)
(vke − vks )
One should notice that the equations given for modifying the lumped values are all for the
elements oriented in the z direction. The indexing scheme should be reflected appropriately to
obtain equations for lumped elements oriented in other directions.
4.1.8 Diode
Derivation of the FDTD updating equations of some lumped element circuit components have
been presented in previous sections. These circuit components are characterized by linear voltage–
current relations, and it is straightforward to model their behavior in FDTD by properly expressing
their voltage–current relations in discrete time and space. However, one of the strengths of the
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
(a) Diode oriented in the positive (b) Diode oriented in the nega-
z direction tive z direction
Figure 4.7 Diodes placed between nodes (i, j, k) and (i, j, k + 1).
FDTD method is that it is possible to model nonlinear components as well. In this section we
present the derivation of the updating equations for modeling a diode.
Figure 4.7(a) illustrates a diode placed between nodes (i, j, k) and (i, j, k + 1) in an FDTD
problem space. This diode allows currents flowing only in the positive z direction, as indicated by
direction of the current Id and characterized by the voltage–current relation
where q is the absolute value of electron charge in coulombs, k is Boltzmann’s constant, and T is
the absolute temperature in kelvins. This equation can be expressed in discrete form as
n+ 12 I0
[e (q z/2kT)(Ez (i, j,k)+Ez (i, j,k)) − 1],
n+1 n
Ji z (i, j, k) = (4.33)
xy
where the relation Vd = V = zE z is used. Equation 4.33 can be used in (4.5), which yields
n+ 12 n+ 12
E zn+1 (i, j, k) − E zn (i, j, k) 1 Hy (i, j, k) − Hy (i − 1, j, k)
=
t εz (i, j, k) x
n+ 12 n+ 12
1 Hx (i, j, k) − Hx (i, j − 1, k)
−
εz (i, j, k) y
σze (i, j, k) n+1
− E z (i, j, k) + E zn (i, j, k)
2εz (i, j, k)
I0
[e (q z/2kT)(Ez (i, j,k)+Ez (i, j,k)) − 1].
n+1 n
− (4.34)
εz (i, j, k)xy
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Ae Bx + x + C = 0, (4.36)
where
n
x = E zn+1 (i, j, k), A = −Ce zd (i, j, k)e B×Ez (i, j,k) , B = (q z/2kT),
n+ 1 n+ 1
C = Ce ze (i, j, k) × E zn (i, j, k) + Ce zhy (i, j, k) × Hy 2 (i, j, k) − Hy 2 (i − 1, j, k)
n+ 1 n+ 1
+ Ce zhx (i, j, k) × Hx 2 (i, j, k) − Hx 2 (i, j − 1, k) + Ce zd (i, j, k),
Here the parameters A and C are dependent on E zn (i, j, k). Therefore, at every time step the
terms A and C must be calculated using the past values of magnetic and electric field components,
and then (4.36) must be solved to obtain E zn+1 (i, j, k).
Equation (4.36) can easily be solved numerically by using the Newton-Raphson method, which
is one of the most widely used methods for finding roots of a nonlinear function. It is an iterative
process that starts from an initial point in the proximity of a root and approaches to the root by
the use of the derivative of the function. For instance, Fig. 4.8 shows a function for which we
want to find the value of x that satisfies f (x) = 0. We can start with an initial guess x0 as shown
in the figure. The derivative of the function f (x) at point x0 is the slope of the tangential line
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
60
f (x) = 2x − 10 + e0.4χ
50
40
f (x0 )
f (x0 )
f(x)
30
20
f (x1 )
10 f (x1 )
xn
0
x2 x1 x0
1 2 3 4 5 6 7 8 9 10
x
Figure 4.8 A function f (x ) and the points approaching to the root of the function iteratively calculated using the
Newton-Raphson Method.
passing through the point f (x0 ) and intersecting the x axis at point x1 . We can easily calculate
point x1 as
f (x0 )
x1 = x0 − . (4.37)
f (x0 )
Then x1 can be used as the reference point, and a second point x2 can be obtained similarly by
f (x1 )
x2 = x1 − . (4.38)
f (x1 )
As can be followed from Fig. 4.8, the new calculated x leads to the target point where f (x)
intersects with the x axis. Due to the high convergence rate of this procedure a point xn can be
achieved after couple of iterations, which is in the very close proximity of the exact root of the
function f (x). This iterative procedure can be continued until a stopping criteria or a maximum
number of iterations is reached. Such a stopping criteria can be given by
where is a very small positive number accepted as the error tolerance accepted for f (x) approx-
imately equals to zero.
It is very convenient to use the Newton-Raphson method to solve the diode equation (4.36),
since the nature of this equation does not allow local minima or maxima, which can be an obstacle
for the convergence of this method. Furthermore, the value of the electric field component
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
E zn (i, j, k) can be used as the initial guess for E zn+1 (i, j, k). Since the value of E z (i, j, k) will change
only a small amount between the consecutive time steps, the initial guess will be fairly close to the
target value, and it would take only a couple of Newton-Raphson iterations to reach the desired
solution.
The diode equation given by (4.36) is for a positive z-directed diode illustrated in Fig. 4.7(a),
which is characterized by the voltage–current relation (4.32). A diode oriented in the negative z
direction, as shown in 4.7(b), can be characterized by the voltage–current relation
and Vd = −V due to the inversion of the diode polarity. Therefore, one can reconstruct (4.34)
and (4.36) considering the reversed polarities of Vd and Id , which yields the updating equation for
a negative z-directed diode as
Ae Bx + x + C = 0, (4.41)
where
n
x = E zn+1 (i, j, k), A = −Ce zd (i, j, k)e B×Ez (i, j,k) , B = −(q z/2kT),
n+ 1 n+ 1
C = Ce ze (i, j, k) × E zn (i, j, k) + Ce zhy (i, j, k) × Hy 2 (i, j, k) − Hy 2 (i − 1, j, k)
n+ 1 n+ 1
+ Ce zhx (i, j, k) × Hx 2 (i, j, k) − Hx 2 (i, j − 1, k) + Ce zd (i, j, k),
Here, one should notice that only the coefficients B and Ce zd (i, j, k) are reversed when compared
with the respective coefficients of (4.36), and the rest of the terms are the same.
Due to the nonlinear nature of the diode voltage–current relation, it is not convenient to define
a diode extending over a number of cells in the FDTD problem grid. If a diode is going to be
placed between two nodes that are apart from each other more than one cell size, it is more
convenient to place the diode between two neighboring nodes and then to establish connection
between the other nodes by other means, (e.g., by thin wires). The thin-wires FDTD updating
procedure and equations are discussed in Chapter 10.
4.1.9 Summary
In this chapter we have provided the derivation of FDTD updating equations for model-
ing some common lumped element circuit components. We have shown the construction of
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
updating equations for components placed between two neighboring nodes and have illus-
trated how these components can be modeled if they extend over a number of cells on the
problem grid.
It is possible to obtain updating equations for the circuits composed of combinations of these
lumped elements; one only needs to obtain the appropriate voltage–current relations, express them
in discrete time and space, and establish the relation between the impressed current densities and
the field components. Then impressed current density terms can be used in the general form of
the updating equation to obtain the specific updating equations that model the lumped element
circuit under consideration.
voltage sources = [ ] ;
4 current sources = [ ] ;
diodes = [ ] ;
6 resistors = [];
inductors = [ ] ;
8 capacitors = [ ] ;
10 % d e f i n e s o u r c e waveform t y p e s and p a r a m e t e r s
w a v e f o r m s . s i n u s o i d a l ( 1 ) . f r e q u e n c y = 1 e9 ;
12 w a v e f o r m s . s i n u s o i d a l ( 2 ) . f r e q u e n c y = 5 e8 ;
waveforms . u n i t s t e p ( 1 ) . s t a r t t i m e s t e p = 50;
14
% voltage sources
16 % d i r e c t i o n : ’ xp ’ , ’ xn ’ , ’ yp ’ , ’ yn ’ , ’ zp ’ , o r ’ zn ’
% r e s i s t a n c e : ohms , m a g i t u d e : volts
18 v o l t a g e s o u r c e s ( 1 ) . min x = 0 ;
v o l t a g e s o u r c e s ( 1 ) . min y = 0 ;
20 v o l t a g e s o u r c e s ( 1 ) . min z = 0 ;
v o l t a g e s o u r c e s ( 1 ) . max x = 1 . 0 e −3;
22 v o l t a g e s o u r c e s ( 1 ) . max y = 2 . 0 e −3;
v o l t a g e s o u r c e s ( 1 ) . max z = 4 . 0 e −3;
24 v o l t a g e s o u r c e s ( 1 ) . d i r e c t i o n = ’ zp ’ ;
v o l t a g e s o u r c e s ( 1 ) . r e s i s t a n c e = 50;
26 v o l t a g e s o u r c e s ( 1 ) . magnitude = 1 ;
v o l t a g e s o u r c e s ( 1 ) . waveform type = ’ s i n u s o i d a l ’ ;
28 v o l t a g e s o u r c e s ( 1 ) . waveform index = 2;
30 % current sources
% d i r e c t i o n : ’ xp ’ , ’ xn ’ , ’ yp ’ , ’ yn ’ , ’ zp ’ , o r ’ zn ’
32 % r e s i s t a n c e : ohms , m a g i t u d e : amperes
c u r r e n t s o u r c e s ( 1 ) . m i n x = 30 * dx ;
34 c u r r e n t s o u r c e s ( 1 ) . m in y = 10 * dy ;
c u r r e n t s o u r c e s ( 1 ) . m i n z = 10 * dz ;
36 c u r r e n t s o u r c e s ( 1 ) . max x = 36 * dx ;
c u r r e n t s o u r c e s ( 1 ) . max y = 10 * dy ;
38 c u r r e n t s o u r c e s ( 1 ) . max z = 13 * dz ;
c u r r e n t s o u r c e s ( 1 ) . d i r e c t i o n = ’ xp ’ ;
40 current sources ( 1 ) . r e s i s t a n c e = 50;
c u r r e n t s o u r c e s ( 1 ) . magnitude = 1 ;
42 c u r r e n t s o u r c e s ( 1 ) . waveform type = ’ u n i t s t e p ’ ;
c u r r e n t s o u r c e s ( 1 ) . waveform index = 1;
44
% resistors
46 % direction : ’x ’ , ’y ’ , or ’ z ’
% resistance : ohms
48 resistors (1). min x = 7 . 0 e −3;
resistors (1). mi n y = 0;
50 resistors (1). min z = 0;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
% inductors
58 % direction : ’ x ’ , ’ y ’ , or ’ z ’
% inductance : henrys
60 inductors ( 1 ) . m i n x = 30 * dx ;
inductors ( 1 ) . m i n y = 10 * dy ;
62 inductors ( 1 ) . m i n z = 10 * dz ;
inductors ( 1 ) . max x = 36 * dx ;
64 inductors ( 1 ) . max y = 10 * dy ;
inductors ( 1 ) . max z = 13 * dz ;
66 inductors ( 1 ) . direction = ’x ’ ;
inductors ( 1 ) . i n d u c t a n c e = 1e −9;
68
% capacitors
70 % d i r e c t i o n : ’ x ’ , ’ y ’ , or ’ z ’
% capacitance : farads
72 c a p a c i t o r s ( 1 ) . m i n x = 30 * dx ;
c a p a c i t o r s ( 1 ) . m i n y = 10 * dy ;
74 c a p a c i t o r s ( 1 ) . m i n z = 10 * dz ;
c a p a c i t o r s ( 1 ) . max x = 36 * dx ;
76 c a p a c i t o r s ( 1 ) . max y = 10 * dy ;
c a p a c i t o r s ( 1 ) . max z = 13 * dz ;
78 capacitors ( 1 ) . direction = ’x ’ ;
c a p a c i t o r s ( 1 ) . c a p a c i t a n c e = 1e −12;
80
% diodes
82 % d i r e c t i o n : ’ xp ’ , ’ xn ’ , ’ yp ’ , ’ yn ’ , ’ zp ’ , o r ’ zn ’
d i o d e s ( 1 ) . m i n x = 30 * dx ;
84 d i o d e s ( 1 ) . m i n y = 10 * dy ;
d i o d e s ( 1 ) . m i n z = 10 * dz ;
86 d i o d e s ( 1 ) . max x = 36 * dx ;
d i o d e s ( 1 ) . max y = 10 * dy ;
88 d i o d e s ( 1 ) . max z = 13 * dz ;
d i o d e s ( 1 ) . d i r e c t i o n = ’ xp ’ ;
Another type of parameter that is required for time-domain simulation of sources is the type
of waveforms that the voltages and current sources generate as a function of time. For each
source, the voltage or current value generated at every time step can be stored as the waveform
in a one-dimensional array with the size of number of time steps. However, before associating
a waveform to a source, we can define the parameters specific to various types of waveforms
in a structure named waveforms as illustrated in Listing 4.1. There are various options for
constructing a waveform in FDTD. Some of the most common types of waveforms are Gaussian,
sinusoidal, cosine modulated Gaussian, and unit step. The definition and construction of these
waveforms will be the subject of Chapter 5. However, we provide a template here showing how
the waveform parameters can be defined. In Listing 4.1 two fields are defined in the parameter
waveforms: sinusoidal and unit step. Later on we can add new parameters representing other
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
types of waveforms. The parameters representing the waveform types are arrays of structures as
illustrated with the indices waveforms.sinuoidal(i) and waveforms.unit step(i). Each waveform
type has parameters representing its specific characteristics. Here frequency is a parameter for
the sinusoidal waveform waveforms.sinusoidal(i), whereas start time step is a parameter for the
waveform waveforms.unit step(i).
Having defined the types of waveforms and their parameters, we can associate them to the
sources by referring to them with the waveform type and waveform index in the source pa-
rameters voltage sources(i) and current sources(i). In the example code we assign the type of
the waveform ‘sinusoidal’ to voltage sources(1).waveform type, and the index of the sinusoidal
waveform waveforms.sinusoidal(2), which is 2, to voltage sources(1).waveform index. Sim-
ilarly, the type of the waveform ‘unit step’ is assigned to current sources(1).waveform type
and the index of the waveform waveforms.unit step(1), which is 1, is assigned to current -
sources(1).waveform index.
3 % constant parameters
e p s 0 = 8 . 8 5 4 1 8 7 8 1 7 e −12; % p e r m i t t i v i t y o f f r e e s p a c e
5 mu 0 = 4 * p i * 1 e −7; % p e r m e a b i l i t y o f f r e e s p a c e
c = 1 / s q r t ( mu 0 * e p s 0 ) ; % s p e e d o f l i g h t i n f r e e s p a c e
7
% time a r r a y
13 time = ( [ 1 : n u m b e r o f t i m e s t e p s ] −0.5)* dt ;
15 % C r e a t e and i n i t i a l i z e f i e l d and c u r r e n t a r r a y s
disp ( ’ c r e a t i n g f i e l d arrays ’ ) ;
17
Hx = zeros ( nxp1 , ny , nz ) ;
19 Hy = zeros ( nx , nyp1 , nz ) ;
Hz = zeros ( nx , ny , nzp1 ) ;
21 Ex = zeros ( nx , nyp1 , nzp1 ) ;
Ey = zeros ( nxp1 , ny , nzp1 ) ;
23 Ez = zeros ( nxp1 , nyp1 , nz ) ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
at the middle of the FDTD time steps. When a new simulation starts, the initial values of
electric and magnetic fields are zero. Therefore, the three-dimensional arrays representing
the vector components of the fields can be created and initialized using the MATLAB func-
tion zeros as illustrated in Listing 4.2. One can notice that the sizes of the arrays are not
the same due to the positioning scheme of field components on the Yee grid as discussed in
Section 3.5.
At this point one can ask if there are any arrays that need to be defined to represent impressed
currents. The answer is that we do not need to define any arrays representing the impressed
currents unless they are explicitly needed in an FDTD simulation. Throughout Chapter 4 we have
shown that the concept of impressed currents is used to establish the voltage–current relations for
the lumped element components and the final updating equations do not include the impressed
current terms except for the inductor. Therefore, we do not need to create three-dimensional
arrays expanded to the problem space to represent impressed current components. However,
for the case of the inductor, there exists an impressed electric current term. Since an inductor
would be expanding only over a couple of cells and only a small number of field components
need to be updated using the inductor updating equations, it is sufficient to create auxiliary arrays
representing these impressed currents that have the limited size based on the number of field
components associated with the respective inductors. The creation and initialization of these
arrays are performed in the subroutine where the updating coefficients of the lumped element
components are initialized.
% i n i t i a l i z e waveforms
11 initialize waveforms ;
13 % voltage sources
for ind = 1: n u m b e r o f v o l t a g e s o u r c e s
15 i s = round ( ( v o l t a g e s o u r c e s ( i n d ) . m i n x − fdtd domain . min x ) / dx ) + 1 ;
j s = round ( ( v o l t a g e s o u r c e s ( i n d ) . m i n y − fdtd domain . min y ) / dy ) + 1 ;
17 k s = round ( ( v o l t a g e s o u r c e s ( i n d ) . m i n z − fdtd domain . min z ) / dz ) + 1 ;
i e = round ( ( v o l t a g e s o u r c e s ( i n d ) . max x − fdtd domain . min x ) / dx ) + 1 ;
19 j e = round ( ( v o l t a g e s o u r c e s ( i n d ) . max y − fdtd domain . min y ) / dy ) + 1 ;
ke = round ( ( v o l t a g e s o u r c e s ( i n d ) . max z − fdtd domain . min z ) / dz ) + 1 ;
21 v o l t a g e s o u r c e s ( ind ) . i s = i s ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
sw i t ch ( v o l t a g e s o u r c e s ( i n d ) . d i r e c t i o n ( 1 ) )
29 case ’ x ’
n fields = ie − is ;
31 r m a g n i t u d e f a c t o r = ( 1 + j e − j s ) * ( 1 + ke − k s ) / ( i e − i s ) ;
case ’ y ’
33 n fields = je − js ;
r m a g n i t u d e f a c t o r = ( 1 + i e − i s ) * ( 1 + ke − k s ) / ( j e − j s ) ;
35 case ’ z ’
n f i e l d s = ke − k s ;
37 r m a g n i t u d e f a c t o r = ( 1 + i e − i s ) * ( 1 + j e − j s ) / ( ke − k s ) ;
end
39 i f strcmp ( v o l t a g e s o u r c e s ( ind ) . d i r e c t i o n ( 2 ) , ’ n ’ )
v magnitude factor = . . .
41 −1* v o l t a g e s o u r c e s ( i n d ) . m a g n i t u d e / n f i e l d s ;
else
43 v magnitude factor = . . .
1* v o l t a g e s o u r c e s ( i n d ) . magnitude / n f i e l d s ;
45 end
v o l t a g e s o u r c e s ( ind ) . resistance per component = . . .
47 r m a g n i t u d e f a c t o r * v o l t a g e s o u r c e s ( ind ) . r e s i s t a n c e ;
61 % current sources
for ind = 1: number of current sources
63 i s = round ( ( c u r r e n t s o u r c e s ( i n d ) . m i n x − fdtd domain . min x ) / dx ) + 1 ;
j s = round ( ( c u r r e n t s o u r c e s ( i n d ) . m i n y − fdtd domain . min y ) / dy ) + 1 ;
65 k s = round ( ( c u r r e n t s o u r c e s ( i n d ) . m i n z − fdtd domain . min z ) / dz ) + 1 ;
i e = round ( ( c u r r e n t s o u r c e s ( i n d ) . max x − fdtd domain . min x ) / dx ) + 1 ;
67 j e = round ( ( c u r r e n t s o u r c e s ( i n d ) . max y − fdtd domain . min y ) / dy ) + 1 ;
ke = round ( ( c u r r e n t s o u r c e s ( i n d ) . max z − fdtd domain . min z ) / dz ) + 1 ;
69 c u r r e n t s o u r c e s ( ind ) . i s = i s ;
c u r r e n t s o u r c e s ( ind ) . j s = j s ;
71 c u r r e n t s o u r c e s ( ind ) . ks = ks ;
c u r r e n t s o u r c e s ( ind ) . i e = i e ;
73 c u r r e n t s o u r c e s ( ind ) . j e = j e ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
c u r r e n t s o u r c e s ( i n d ) . ke = ke ;
75
sw i t ch ( c u r r e n t s o u r c e s ( i n d ) . d i r e c t i o n ( 1 ) )
77 case ’ x ’
n f i e l d s = ( 1 + j e − j s ) * ( 1 + ke − k s ) ;
79 r m a g n i t u d e f a c t o r = ( 1 + j e − j s ) * ( 1 + ke − k s ) / ( i e − i s ) ;
case ’ y ’
81 n f i e l d s = ( 1 + i e − i s ) * ( 1 + ke − k s ) ;
r m a g n i t u d e f a c t o r = ( 1 + i e − i s ) * ( 1 + ke − k s ) / ( j e − j s ) ;
83 case ’ z ’
n fields = (1 + ie − is ) * (1 + je − js ) ;
85 r m a g n i t u d e f a c t o r = ( 1 + i e − i s ) * ( 1 + j e − j s ) / ( ke − k s ) ;
end
87 i f strcmp ( c u r r e n t s o u r c e s ( ind ) . d i r e c t i o n ( 2 ) , ’ n ’ )
i magnitude factor = . . .
89 −1* c u r r e n t s o u r c e s ( i n d ) . m a g n i t u d e / n f i e l d s ;
else
91 i magnitude factor = . . .
1* c u r r e n t s o u r c e s ( i n d ) . magnitude / n f i e l d s ;
93 end
c u r r e n t s o u r c e s ( ind ) . resistance per component = . . .
95 r m a g n i t u d e f a c t o r * c u r r e n t s o u r c e s ( ind ) . r e s i s t a n c e ;
109 % resistors
for ind = 1: n u m b e r o f r e s i s t o r s
111 i s = round ( ( r e s i s t o r s ( i n d ) . m i n x − fdtd domain . min x ) / dx ) + 1 ;
j s = round ( ( r e s i s t o r s ( i n d ) . min y − fdtd domain . min y ) / dy ) + 1 ;
113 k s = round ( ( r e s i s t o r s ( i n d ) . m i n z − fdtd domain . min z ) / dz ) + 1 ;
i e = round ( ( r e s i s t o r s ( i n d ) . max x − fdtd domain . min x ) / dx ) + 1 ;
115 j e = round ( ( r e s i s t o r s ( i n d ) . max y − fdtd domain . min y ) / dy ) + 1 ;
ke = round ( ( r e s i s t o r s ( i n d ) . max z − fdtd domain . min z ) / dz ) + 1 ;
117 r e s i s t o r s ( ind ) . i s = i s ;
r e s i s t o r s ( ind ) . j s = j s ;
119 r e s i s t o r s ( ind ) . ks = ks ;
r e s i s t o r s ( ind ) . i e = i e ;
121 r e s i s t o r s ( ind ) . j e = j e ;
r e s i s t o r s ( i n d ) . ke = ke ;
123 sw i t ch ( r e s i s t o r s ( i n d ) . d i r e c t i o n )
case ’ x ’
125 r magnitude factor = (1 + je − j s ) * ( 1 + ke − k s ) / ( i e − i s ) ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
case ’ y ’
127 r magnitude factor = ( 1 + i e − i s ) * ( 1 + ke − k s ) / ( j e − j s ) ;
case ’ z ’
129 r magnitude factor = ( 1 + i e − i s ) * ( 1 + j e − j s ) / ( ke − k s ) ;
end
131 r e s i s t o r s ( ind ) . resistance per component = . . .
r magnitude factor * r e s i s t o r s ( ind ) . r e s i s t a n c e ;
133 end
135 % inductors
for ind = 1: number of inductors
137 i s = round ( ( i n d u c t o r s ( i n d ) . m i n x − f d t d d o m a i n . m i n x ) / dx ) + 1 ;
j s = round ( ( i n d u c t o r s ( i n d ) . m i n y − f d t d d o m a i n . m i n y ) / dy ) + 1 ;
139 k s = round ( ( i n d u c t o r s ( i n d ) . m i n z − f d t d d o m a i n . m i n z ) / dz ) + 1 ;
i e = round ( ( i n d u c t o r s ( i n d ) . max x − f d t d d o m a i n . m i n x ) / dx ) + 1 ;
141 j e = round ( ( i n d u c t o r s ( i n d ) . max y − f d t d d o m a i n . m i n y ) / dy ) + 1 ;
ke = round ( ( i n d u c t o r s ( i n d ) . max z − f d t d d o m a i n . m i n z ) / dz ) + 1 ;
143 i n d u c t o r s ( ind ) . i s = i s ;
i n d u c t o r s ( ind ) . j s = j s ;
145 i n d u c t o r s ( ind ) . ks = ks ;
i n d u c t o r s ( ind ) . i e = i e ;
147 i n d u c t o r s ( ind ) . j e = j e ;
i n d u c t o r s ( i n d ) . ke = ke ;
149 sw i t ch ( i n d u c t o r s ( i n d ) . d i r e c t i o n )
case ’ x ’
151 l m a g n i t u d e f a c t o r = ( 1 + j e − j s ) * ( 1 + ke − k s ) / ( i e − i s ) ;
case ’ y ’
153 l m a g n i t u d e f a c t o r = ( 1 + i e − i s ) * ( 1 + ke − k s ) / ( j e − j s ) ;
case ’ z ’
155 l m a g n i t u d e f a c t o r = ( 1 + i e − i s ) * ( 1 + j e − j s ) / ( ke − k s ) ;
end
157 i n d u c t o r s ( ind ) . inductance per component = . . .
l m a g n i t u d e f a c t o r * i n d u c t o r s ( ind ) . inductance ;
159 end
161 % capacitors
for ind = 1: number of capacitors
163 i s = round ( ( c a p a c i t o r s ( i n d ) . m i n x − f d t d domain . min x ) / dx ) + 1 ;
j s = round ( ( c a p a c i t o r s ( i n d ) . m i n y − f d t d domain . min y ) / dy ) + 1 ;
165 k s = round ( ( c a p a c i t o r s ( i n d ) . m i n z − f d t d domain . min z ) / dz ) + 1 ;
i e = round ( ( c a p a c i t o r s ( i n d ) . max x − f d t d domain . min x ) / dx ) + 1 ;
167 j e = round ( ( c a p a c i t o r s ( i n d ) . max y − f d t d domain . min y ) / dy ) + 1 ;
ke = round ( ( c a p a c i t o r s ( i n d ) . max z − f d t d domain . min z ) / dz ) + 1 ;
169 c a p a c i t o r s ( ind ) . i s = i s ;
c a p a c i t o r s ( ind ) . j s = j s ;
171 c a p a c i t o r s ( ind ) . ks = ks ;
c a p a c i t o r s ( ind ) . i e = i e ;
173 c a p a c i t o r s ( ind ) . j e = j e ;
c a p a c i t o r s ( i n d ) . ke = ke ;
175 sw i t ch ( c a p a c i t o r s ( i n d ) . d i r e c t i o n )
case ’ x ’
177 c magnitude factor = ( ie − is ) . . .
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
/ ((1 + j e − j s ) * ( 1 + ke − k s ) ) ;
179 case ’ y ’
c magnitude factor = ( je − js ) . . .
181 / ((1 + i e − i s ) * ( 1 + ke − k s ) ) ;
case ’ z ’
183 c magnitude f a c t o r = ( ke − k s ) . . .
/ ((1 + ie − is ) * (1 + je − js ) ) ;
185 end
c a p a c i t o r s ( ind ) . capacitance per component = . . .
187 c magnitude f a c t o r * c a p a c i t o r s ( ind ) . c a p a c i t a n c e ;
end
189
% diodes
193 for ind = 1: number of diodes
i s = round ( ( d i o d e s ( i n d ) . m i n x − fdtd domain . min x ) / dx ) + 1 ;
195 j s = round ( ( d i o d e s ( i n d ) . m i n y − fdtd domain . min y ) / dy ) + 1 ;
k s = round ( ( d i o d e s ( i n d ) . m i n z − fdtd domain . min z ) / dz ) + 1 ;
197 i e = round ( ( d i o d e s ( i n d ) . max x − fdtd domain . min x ) / dx ) + 1 ;
j e = round ( ( d i o d e s ( i n d ) . max y − fdtd domain . min y ) / dy ) + 1 ;
199 ke = round ( ( d i o d e s ( i n d ) . max z − fdtd domain . min z ) / dz ) + 1 ;
diodes ( ind ) . i s = i s ;
201 diodes ( ind ) . j s = j s ;
diodes ( ind ) . ks = ks ;
203 diodes ( ind ) . i e = i e ;
diodes ( ind ) . j e = j e ;
205 d i o d e s ( i n d ) . ke = ke ;
207 sw i t ch ( d i o d e s ( i n d ) . d i r e c t i o n ( 1 ) )
case ’ x ’
209 s i g m a e x ( i s +1: i e −1 , j s , k s ) = s i g m a p e c ;
case ’ y ’
211 s i g m a e y ( i s , j s +1: j e −1 , k s ) = s i g m a p e c ;
case ’ z ’
213 s i g m a e z ( i s , j s , k s +1: ke −1) = s i g m a p e c ;
end
215 end
Before initializing the sources, the source waveforms need to be initialized. Therefore, a
subroutine, initialize waveforms, is called in Listing 4.3 before initialization of lumped com-
ponents. The sample implementation of initialize waveforms is given in Listing 4.4, and this
subroutine will be expanded as new source waveform types are discussed in the following chap-
ter. In subroutine initialize waveforms for every waveform type the respective waveforms are
calculated as functions of time based on the waveform type specific parameters. Then the cal-
culated waveforms are stored in the arrays with the associated name waveform. For instance,
in Listing 4.4 the parameter waveforms.sinusoidal(i).waveform is constructed as a sinusoidal
waveform using sin(2π × f × t), where f is the frequency defined with the parameter wave-
forms.sinusoidal(i).frequency and t is the discrete time array time storing the time instants of the
time steps.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
3 % i n i t i a l i z e s i n u s o i d a l waveforms
f o r i n d =1: s i z e ( w a v e f o r m s . s i n u s o i d a l , 2 )
5 w a v e f o r m s . s i n u s o i d a l ( i n d ) . waveform = . . .
s i n ( 2 * pi * waveforms . s i n u s o i d a l ( ind ) . f r e q u e n c y * time ) ;
7 end
9 % i n i t i a l i z e u n i t s t e p waveforms
f o r i n d =1: s i z e ( w a v e f o r m s . u n i t s t e p , 2 )
11 s t a r t i n d e x = waveforms . u n i t s t e p ( ind ) . s t a r t t i m e s t e p ;
w a v e f o r m s . u n i t s t e p ( i n d ) . waveform ( 1 : n u m b e r o f t i m e s t e p s ) = 1 ;
13 w a v e f o r m s . u n i t s t e p ( i n d ) . waveform ( 1 : s t a r t i n d e x −1) = 0 ;
end
Once the waveform arrays are constructed for the defined waveform types they can be copied
to waveform fields of the structures of sources associated with them as demonstrated in Listing
4.3. For example, consider the code section in the loop initializing the voltage sources. The type
of source waveform is stored in voltage sources(ind).waveform type as a string, and the index
of the source waveform is stored in voltage sources(ind).waveform index as an integer number.
Here we employ the MATLAB function eval, which executes a string containing MATLAB
expression. We construct a string using the following expression:
w t s t r = v o l t a g e s o u r c e s ( ind ) . waveform type ;
w i s t r = num2str ( v o l t a g e s o u r c e s ( i n d ) . w a v e f o r m i n d e x ) ;
e v a l s t r = [ ’ a waveform = waveforms . ’ w t s t r ’ ( ’ w i s t r ’ ) . waveform ; ’ ] ;
which constructs the string eval str in the MATLAB workspace for the waveforms and the voltage
source voltage sources(1) defined in Listing 4.1 as
e v a l s t r = ’ a w a v e f o r m = w a v e f o r m s . s i n u s o i d a l ( 2 ) . waveform ; ’
Executing this string using eval as
eval ( e v a l s t r ) ;
creates a parameter a waveform in the MATLAB workspace, which has a copy of the waveform
that the voltage source voltage sources(1) is associated with. Then we can assign a waveform
to voltage sources(1).waveform after multiplying with a factor. This multiplication factor is
explained in the following paragraphs.
As discussed in Section 4.7 all the lumped element components except the diodes are assumed to
be distributed over surfaces or volumes extending over a number of cells. Therefore, a number of
field components require special updating due to the lumped elements associated with them. We
assume that the surfaces or volumes that the lumped elements are coinciding with are conforming
to the cells composing the FDTD problem space. Then we can identify the field components that
are associated with lumped components by the indices of the start node, (is , j s , ks ), coinciding
with the lower coordinates of the lumped component, and the indices of the end node, (ie, j e, ke),
coinciding with the upper coordinates of the lumped component, as illustrated in Fig. 4.6. There-
fore, for every lumped element, the start and end node indices are calculated and stored in the
parameters is, js, ks, ie, je, and ke as shown in Listing 4.3.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Based on the discussion in Section 4.7, if a lumped element is associated with more than one
field component, the value of the lumped element should be assigned to the field components
after a modification. Therefore, new parameters are defined in the structures representing the
lumped elements, which store the value of the lumped element per field component. For instance,
resistance per component is defined in voltage sources(i), which stores the resistance of the
voltage source per field component as calculated using the form of (4.26) by taking into account the
direction of the component. Similarly, for a resistor resistance per component is defined and
calculated by (4.27). For a current source resistance per component is defined and calculated
by (4.31). The parameter inductance per component is calculated by (4.28) for an inductor, and
capacitance per component is calculated by (4.29) for a capacitor.
Similarly, the voltage sources(i).voltage per e field is scaled using (4.25), and current -
sources(i).current per e field is scaled using (4.30). Furthermore, directions of these compo-
nents as well are taken into account in the scaling factors; if the direction is negative the scaling
factor is multiplied by −1. Meanwhile, parameters voltage sources(i).waveform, and current -
sources(i).waveform are constructed to store the main voltages and currents of the lumped
sources rather than the values used to update the associated field components.
We assume that a diode is defined as a one-dimensional object, such as a line section, extending
over a number of electric field components on the cell edges as illustrated in Fig. 4.9. Here
the diode is extending between the nodes (is , j s , ks ) and (ie, j e, ke)—hence the field components
E z (is , j s , ks : ke − 1), where ie = is and j e = j s . However, as discussed in Section 4.8, we update
only one of these field components, in this case E z (is , j s , ks ), using the diode updating equations,
and we establish an electrical connection between other nodes (is , j s , ks + 1) and (ie, j e, ke).
The easiest way of establishing the electrical connection is considering a PEC line between these
nodes. Therefore, we can assign conductivity of PEC to the material components associated
with the electric field components E z (is , j s , ks + 1 : ke − 1), which are σze (is , j s , ks + 1 : ke − 1).
Therefore, the necessary material components are assigned the conductivity of PEC in Listing
4.3 while initializing the diodes. A more accurate representation for a PEC line is presented
Chapter 10 where thin PEC wire updating equations will be developed.
3 % General e l e c t r i c f i e l d updating c o e f f i c i e n t s
% C o e f f i e c i e n t s updating Ex
5 Cexe = ( 2 * e p s r x * eps 0 − dt * sigma e x ) . . .
. / ( 2 * e p s r x * eps 0 + dt * sigma e x ) ;
7 C e x h z = ( 2 * d t / dy ) . / ( 2 * e p s r x * e p s 0 + d t * s i g m a e x ) ;
C e x h y = −(2 * d t / dz ) . / ( 2 * e p s r x * e p s 0 + d t * s i g m a e x ) ;
9
% C o e f f i e c i e n t s updating Ey
11 Ceye = ( 2 * e p s r y * eps 0 − dt * sigma e y ) . . .
. / ( 2 * e p s r y * eps 0 + dt * sigma e y ) ;
13 C e y h x = ( 2 * d t / dz ) . / ( 2 * e p s r y * e p s 0 + d t * s i g m a e y ) ;
C e y h z = −(2 * d t / dx ) . / ( 2 * e p s r y * e p s 0 + d t * s i g m a e y ) ;
15
% C o e f f i e c i e n t s updating Ez
17 Ceze = ( 2 * e p s r z * eps 0 − dt * sigma e z ) . . .
. / ( 2 * e p s r z * eps 0 + dt * sigma e z ) ;
19 C e z h y = ( 2 * d t / dx ) . / ( 2 * e p s r z * e p s 0 + d t * s i g m a e z ) ;
C e z h x = −(2 * d t / dy ) . / ( 2 * e p s r z * e p s 0 + d t * s i g m a e z ) ;
21
29 % C o e f f i e c i e n t s u p d a t i n g Hy
Chyh = ( 2 * m u r y * mu 0 − d t * s i g m a m y ) . . .
31 . / ( 2 * m u r y * mu 0 + d t * s i g m a m y ) ;
C h y e x = −(2 * d t / dz ) . / ( 2 * m u r y * mu 0 + d t * s i g m a m y ) ;
33 C h y e z = ( 2 * d t / dx ) . / ( 2 * m u r y * mu 0 + d t * s i g m a m y ) ;
35 % C o e f f i e c i e n t s u p d a t i n g Hz
Chzh = ( 2 * m u r z * mu 0 − d t * s i g m a m z ) ...
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
37 . / ( 2 * m u r z * mu 0 + d t * s i g m a m z ) ;
C h z e y = −(2 * d t / dx ) . / ( 2 * m u r z * mu 0 + d t * s i g m a m z ) ;
39 C h z e x = ( 2 * d t / dy ) . / ( 2 * m u r z * mu 0 + d t * s i g m a m z ) ;
41 % I n i t i a l i z e c o e f f i e c i e n t s f o r lumped e l e m e n t components
initialize voltage source updating coefficients ;
43 initialize current source updating coefficients ;
initialize resistor updating coefficients ;
45 initialize capacitor updating coefficients ;
initialize inductor updating coefficients ;
47 initialize diode updating coefficients ;
In Chapter 1 we obtained the set of equations (1.26)–(1.31) as the general form of the updating
equations. One can notice that the form of the updating equations obtained for the lumped
elements is the same as the general form. The only difference is that for some types of lumped
elements the terms associated with the impressed currents are replaced by some other terms; for
instance, for a voltage source the impressed current term is replaced by a voltage source term in
the updating equation. Furthermore, as discussed in Section 4.2.2, the impressed current terms in
(1.26)–(1.31) are used to establish the voltage–current relations for the lumped elements, and they
vanish in updating equations modeling media that does not include any lumped components.
Therefore, in an FDTD simulation before the time-marching iteration starts the updating
coefficients can be calculated for the whole problem space using the general updating equation
coefficients appearing in (1.26)–(1.31) and excluding the impressed current terms. Then the up-
dating coefficients can be recalculated only for the position indices where the lumped components
exist. The additional coefficients required for the lumped elements (e.g., voltage sources, current
sources, and inductors), can be calculated and stored in separate arrays associated with these com-
ponents. Then during the FDTD time-marching iterations, at every time step, the electric field
components can be updated using the general updating equations (1.26)–(1.31) excluding the im-
pressed current terms, and then the additional terms can be added to the electric field components
at the respective position indices where the lumped elements exist. In this section we illustrate the
implementation of the previous discussion in the MATLAB program. The vector type operation
in MATLAB is being used to efficiently generate these arrays.
In Listing 4.5 the updating coefficients, except for the impressed current terms, defined in the
general updating equations (1.26)–(1.31) are constructed using the material component arrays that
have been initialized in the subroutine initialize fdtd material grid. The sizes of the coefficient
arrays are the same as the sizes of the material component arrays that have been used to construct
them. Then the updating coefficients related to the lumped element components are constructed
in respective subroutines as shown in Listing 4.5.
4.2.4.1 Initialization of Voltage Source Updating Coefficients The updating coefficients related to the
voltage sources are constructed in the subroutine initialize voltage source updating coefficients
as implemented in Listing 4.6. The indices of the nodes identifying the positions of the voltage
sources, is, js, ks, ie, je, and ke, were determined while initializing the voltage sources as shown
in Listing 4.3. For instance, consider the z-directed voltage source defined between the nodes
(is , j s , ks ) and (ie, j e, ke) and the associated electric field components as illustrated in Fig. 4.10.
These indices of the nodes are used to identify the indices of the field components that need the
special updates due to the voltage sources. The indices of the field components are determined
by taking into account the directions of the voltage sources. Since these field components will be
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Figure 4.10 A z-directed voltage source defined between the nodes (i s, j s, ks ) and (i e, j e, ke).
accessed frequently, they can be stored in a parameter, field indices, associated with the voltage
sources for an easy access. The field components under consideration are usually accessed using
three index values, such as
C e z e ( i s : i e , j s : j e , k s : ke −1)
since the field arrays are three-dimensional. An alternative way of accessing an element of a
multidimensional array is to use the nice feature of MATLAB called linear indexing. Using linear
indexing the three indices of a three-dimensional array can be mapped to a single index. Therefore,
a single index would be sufficient. For the case where a number of elements need to be indexed,
a vector can be constructed in which each value holds the index of the respective element in the
three-dimensional array. Therefore, as shown in Listing 4.6, a temporary array of indices, fi, is
constructed using
f i = c r e a t e l i n e a r i n d e x l i s t ( e p s r z , i s : i e , j s : j e , k s : ke − 1 ) ;
Here create linear index list is a function that takes three parameters indicating the range of
indices of a subsection of a three-dimensional array and converts it to a one-dimensional linear
index array. While doing this conversion, it uses the MATLAB function sub2ind, which needs the
size of the three-dimensional array. Therefore, the first argument of create linear index list is the
three-dimensional array under consideration. The implementation of create linear index list is
given in Listing 4.7. After the linear indices array is constructed, instead of accessing a subsection
of an array by
C e z e ( i s : i e , j s : j e , k s : ke −1)
one can simply implement
Ceze ( f i )
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
3 for ind = 1: n u m b e r o f v o l t a g e s o u r c e s
i s = v o l t a g e s o u r c e s ( ind ) . i s ;
5 j s = v o l t a g e s o u r c e s ( ind ) . j s ;
ks = v o l t a g e s o u r c e s ( ind ) . ks ;
7 i e = v o l t a g e s o u r c e s ( ind ) . i e ;
j e = v o l t a g e s o u r c e s ( ind ) . j e ;
9 ke = v o l t a g e s o u r c e s ( i n d ) . ke ;
R = v o l t a g e s o u r c e s ( ind ) . resistance per component ;
11 i f ( R == 0 ) R = 1e −20; end
13 sw i t ch ( v o l t a g e s o u r c e s ( i n d ) . d i r e c t i o n ( 1 ) )
case ’ x ’
15 f i = c r e a t e l i n e a r i n d e x l i s t ( e p s r x , i s : i e −1 , j s : j e , k s : ke ) ;
a t e r m = ( d t * dx ) / ( R * dy * dz ) ;
17 Cexe ( f i ) = . . .
( 2 * e p s 0 * e p s r x ( f i )− d t * s i g m a e x ( f i )− a t e r m ) . . .
19 . / ( 2 * e p s 0 * e p s r x ( f i )+ d t * s i g m a e x ( f i )+ a t e r m ) ;
C e x h z ( f i )= ( 2 * d t / dy ) . . .
21 . / ( 2 * e p s r x ( f i ) * e p s 0+d t * s i g m a e x ( f i )+ a t e r m ) ;
C e x h y ( f i )= −(2 * d t / dz ) . . .
23 . / ( 2 * e p s r x ( f i ) * e p s 0 + d t * s i g m a e x ( f i )+ a t e r m ) ;
v o l t a g e s o u r c e s ( i n d ) . C e x s = −(2 * d t / ( R * dy * dz ) ) . . .
25 . / ( 2 * e p s r x ( f i ) * e p s 0+d t * s i g m a e x ( f i )+ a t e r m ) ;
case ’ y ’
27 f i = c r e a t e l i n e a r i n d e x l i s t ( e p s r y , i s : i e , j s : j e −1 , k s : ke ) ;
a t e r m = ( d t * dy ) / ( R * dz * dx ) ;
29 Ceye ( f i ) = . . .
( 2 * e p s 0 * e p s r y ( f i )− d t * s i g m a e y ( f i )− a t e r m ) . . .
31 . / ( 2 * e p s 0 * e p s r y ( f i )+ d t * s i g m a e y ( f i )+ a t e r m ) ;
C e y h x ( f i )= ( 2 * d t / dz ) . . .
33 . / ( 2 * e p s r y ( f i ) * e p s 0+d t * s i g m a e y ( f i )+ a t e r m ) ;
C e y h z ( f i )= −(2 * d t / dx ) . . .
35 . / ( 2 * e p s r y ( f i ) * e p s 0 + d t * s i g m a e y ( f i )+ a t e r m ) ;
v o l t a g e s o u r c e s ( i n d ) . C e y s = −(2 * d t / ( R * dz * dx ) ) . . .
37 . / ( 2 * e p s r y ( f i ) * e p s 0+d t * s i g m a e y ( f i )+ a t e r m ) ;
case ’ z ’
39 f i = c r e a t e l i n e a r i n d e x l i s t ( e p s r z , i s : i e , j s : j e , k s : ke − 1 ) ;
a t e r m = ( d t * dz ) / ( R * dx * dy ) ;
41 Ceze ( f i ) = . . .
( 2 * e p s 0 * e p s r z ( f i )− d t * s i g m a e z ( f i )− a t e r m ) . . .
43 . / ( 2 * e p s 0 * e p s r z ( f i )+ d t * s i g m a e z ( f i )+ a t e r m ) ;
C e z h y ( f i )= ( 2 * d t / dx ) . . .
45 . / ( 2 * e p s r z ( f i ) * e p s 0+d t * s i g m a e z ( f i )+ a t e r m ) ;
C e z h x ( f i )= −(2 * d t / dy ) . . .
47 . / ( 2 * e p s r z ( f i ) * e p s 0+d t * s i g m a e z ( f i )+ a t e r m ) ;
v o l t a g e s o u r c e s ( i n d ) . C e z s = −(2 * d t / ( R * dx * dy ) ) . . .
49 . / ( 2 * e p s r z ( f i ) * e p s 0+d t * s i g m a e z ( f i )+ a t e r m ) ;
end
51 v o l t a g e s o u r c e s ( ind ) . f i e l d i n d i c e s = f i ;
end
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
4 i s i z e = size ( i l i s t , 2 ) ;
j s i z e = size ( j l i s t , 2 ) ;
6 k size = size ( k list , 2 ) ;
number of indices = i s i z e * j s i z e * k size ;
8 I = zeros ( number of indices , 1 ) ;
J = zeros ( number of indices , 1 ) ;
10 K = zeros ( number of indices , 1 ) ;
ind = 1;
12 f o r mk = k l i s t ( 1 ) : k l i s t ( k s i z e )
f o r mj = j l i s t ( 1 ) : j l i s t ( j s i z e )
14 f o r mi = i l i s t ( 1 ) : i l i s t ( i s i z e )
I ( i n d ) = mi ;
16 J ( i n d ) = mj ;
K ( i n d ) = mk ;
18 ind = ind + 1;
end
20 end
end
22 f i = sub2ind ( s i z e ( array 3d ) , I , J , K ) ;
Once the field component indices needing special updates are determined as fi in Listing 4.6,
the respective components of the general updating coefficients are recalculated based on the voltage
source updating equations as given in (4.10).
n+ 12
One can notice that there exists an additional term in (4.10), given by Ce zs (i, j, k) × Vs (i, j, k),
n+ 1
for updating E zn+1 (i, j, k). The term Vs 2 (i, j, k) is the value of the voltage source waveform at
time instant (n + 12 ) × t, and this value is stored in the parameter voltage sources(i).waveform.
The other term Ce zs is the additional coefficient term for the voltage source. This term is con-
structed based on (4.10) as the parameter Cezs and associated with the respective voltage source
as voltage sources(i).Cezs. Similarly, if the voltage source updates the electric field compo-
nents E x the parameter voltage sources(i).Cexs can be constructed, whereas if the voltage
source updates E y the parameter voltage sources(i).Ceys can be constructed, based on the
direction of the voltage sources as implemented in Listing 4.6. Finally, the parameter voltage -
sources(i).field indices is constructed from fi. Then the parameter field indices are used to
access the respective field components while updating the electric field components during the
time-marching loop.
4.2.4.2 Initialization of Current Source Updating Coefficients The initialization of current source
updating coefficients is performed in the subroutine initialize current source updating -
coefficients, which is shown in Listing 4.8. The initialization of current source coefficients is
the same as the initialization of voltage source coefficients and follows the updating equation
given in (4.15).
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
sw i t ch ( c u r r e n t s o u r c e s ( i n d ) . d i r e c t i o n ( 1 ) )
14 case ’ x ’
f i = c r e a t e l i n e a r i n d e x l i s t ( e p s r x , i s : i e −1 , j s : j e , k s : ke ) ;
16 a t e r m = ( d t * dx ) / ( R * dy * dz ) ;
Cexe ( f i ) = . . .
18 ( 2 * e p s 0 * e p s r x ( f i )− d t * s i g m a e x ( f i )− a t e r m ) . . .
. / ( 2 * e p s 0 * e p s r x ( f i )+ d t * s i g m a e x ( f i )+ a t e r m ) ;
20 C e x h z ( f i )= ( 2 * d t / dy ) . . .
. / ( 2 * e p s r x ( f i ) * e p s 0+d t * s i g m a e x ( f i )+ a t e r m ) ;
22 C e x h y ( f i )= −(2 * d t / dz ) . . .
. / ( 2 * e p s r x ( f i ) * e p s 0 + d t * s i g m a e x ( f i )+ a t e r m ) ;
24 c u r r e n t s o u r c e s ( i n d ) . C e x s = −(2 * d t / ( dy * dz ) ) . . .
. / ( 2 * e p s r x ( f i ) * e p s 0+d t * s i g m a e x ( f i )+ a t e r m ) ;
26 case ’ y ’
f i = c r e a t e l i n e a r i n d e x l i s t ( e p s r y , i s : i e , j s : j e −1 , k s : ke ) ;
28 a t e r m = ( d t * dy ) / ( R * dz * dx ) ;
Ceye ( f i ) = . . .
30 ( 2 * e p s 0 * e p s r y ( f i )− d t * s i g m a e y ( f i )− a t e r m ) . . .
. / ( 2 * e p s 0 * e p s r y ( f i )+ d t * s i g m a e y ( f i )+ a t e r m ) ;
32 C e y h x ( f i )= ( 2 * d t / dz ) . . .
. / ( 2 * e p s r y ( f i ) * e p s 0+d t * s i g m a e y ( f i )+ a t e r m ) ;
34 C e y h z ( f i )= −(2 * d t / dx ) . . .
. / ( 2 * e p s r y ( f i ) * e p s 0 + d t * s i g m a e y ( f i )+ a t e r m ) ;
36 c u r r e n t s o u r c e s ( i n d ) . C e y s = −(2 * d t / ( dz * dx ) ) . . .
. / ( 2 * e p s r y ( f i ) * e p s 0+d t * s i g m a e y ( f i )+ a t e r m ) ;
38 case ’ z ’
f i = c r e a t e l i n e a r i n d e x l i s t ( e p s r z , i s : i e , j s : j e , k s : ke − 1 ) ;
40 a t e r m = ( d t * dz ) / ( R * dx * dy ) ;
Ceze ( f i ) = . . .
42 ( 2 * e p s 0 * e p s r z ( f i )− d t * s i g m a e z ( f i )− a t e r m ) . . .
. / ( 2 * e p s 0 * e p s r z ( f i )+ d t * s i g m a e z ( f i )+ a t e r m ) ;
44 C e z h y ( f i )= ( 2 * d t / dx ) . . .
. / ( 2 * e p s r z ( f i ) * e p s 0+d t * s i g m a e z ( f i )+ a t e r m ) ;
46 C e z h x ( f i )= −(2 * d t / dy ) . . .
. / ( 2 * e p s r z ( f i ) * e p s 0+d t * s i g m a e z ( f i )+ a t e r m ) ;
48 c u r r e n t s o u r c e s ( i n d ) . C e z s = −(2 * d t / ( dx * dy ) ) . . .
. / ( 2 * e p s r z ( f i ) * e p s 0+d t * s i g m a e z ( f i )+ a t e r m ) ;
50 end
c u r r e n t s o u r c e s ( ind ) . f i e l d i n d i c e s = f i ;
52 end
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
sw i t ch ( i n d u c t o r s ( i n d ) . d i r e c t i o n ( 1 ) )
14 case ’ x ’
f i = c r e a t e l i n e a r i n d e x l i s t ( e p s r x , i s : i e −1 , j s : j e , k s : ke ) ;
16 i n d u c t o r s ( i n d ) . C e x j = −(2 * d t ) . . .
. / ( 2 * e p s r x ( f i ) * e p s 0+d t * s i g m a e x ( f i ) ) ;
18 i n d u c t o r s ( ind ) . J i x = zeros ( s i z e ( f i ) ) ;
i n d u c t o r s ( i n d ) . C j e x = ( d t * dx ) / ( L * dy * dz ) ;
20 case ’ y ’
f i = c r e a t e l i n e a r i n d e x l i s t ( e p s r y , i s : i e , j s : j e −1 , k s : ke ) ;
22 i n d u c t o r s ( i n d ) . C e y j = −(2 * d t ) . . .
. / ( 2 * e p s r y ( f i ) * e p s 0+d t * s i g m a e y ( f i ) ) ;
24 i n d u c t o r s ( ind ) . J i y = zeros ( s i z e ( f i ) ) ;
i n d u c t o r s ( i n d ) . C j e y = ( d t * dy ) / ( L * dz * dx ) ;
26 case ’ z ’
f i = c r e a t e l i n e a r i n d e x l i s t ( e p s r z , i s : i e , j s : j e , k s : ke − 1 ) ;
28 i n d u c t o r s ( i n d ) . C e z j = −(2 * d t ) . . .
. / ( 2 * e p s r z ( f i ) * e p s 0+d t * s i g m a e z ( f i ) ) ;
30 i n d u c t o r s ( ind ) . J i z = zeros ( s i z e ( f i ) ) ;
i n d u c t o r s ( i n d ) . C j e z = ( d t * dz ) / ( L * dx * dy ) ;
32 end
i n d u c t o r s ( ind ) . f i e l d i n d i c e s = f i ;
34 end
4.2.4.3 Initialization of Inductor Updating Coefficients The updating coefficients for modeling in-
ductors are initialized in the subroutine initialize inductor updating coefficients, which is shown
in Listing 4.9, based on the updating equation (4.24). Comparing (4.24) with (1.28) one can ob-
serve that the form of the updating equation modeling an inductor is the same as the form of the
general updating equation. Therefore, there is no need to recalculate the coefficients that have
been initialized as general updating coefficients. However, a coefficient term Ce zj has not been
defined in the implementation of the general updating equations. Therefore, the coefficient term
Ce zj associated with the inductor is defined as inductors(i).Cezj in Listing 4.9. Furthermore,
the Ji z term is also associated with the inductor, and it is also defined as inductors(i).Jiz and is
initialized with zeros.
As discussed in Section 4.1.6, during the FDTD time-marching iteration, at every time step
n+ 12 n− 12
the new value of Ji z (i, j, k) is to be calculated by (4.23) using E zn (i, j, k) and Ji z (i, j, k) before
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
n+ 12 n− 12 tz n
Ji z (i, j, k) = Ji z (i, j, k) + E (i, j, k)
Lxy z
n− 12
= Ji z (i, j, k) + C j e z (i, j, k) × E zn (i, j, k),
where
tz
C j e z (i, j, k) = .
Lxy
Therefore, C j e z is an additional coefficient that can be initialized before the time-marching loop.
Hence, the parameter inductors(i).Cjez is constructed as shown in Listing 4.9.
4.2.4.6 Initialization of Diode Updating Coefficients The algorithm for modeling diodes is signifi-
cantly different compared with other lumped element components, and it requires the initializa-
tion of a different set of parameters. The updating coefficients for modeling diodes are initial-
ized in initialize diode updating coefficients, and implementation of this subroutine is shown in
Listing 4.12.
As mentioned in Section 4.2.3, only one electric field component is associated with a diode;
therefore, it needs a special updating based on the equations in Section 4.1.8. For example, for a
diode oriented in the positive z direction and defined between the nodes (is , j s , ks ) and (ie, j e, ke),
only the field component E z (is , j s , ks ) is updated as illustrated in Fig. 4.9.
As discussed in Section 4.1.8, the new value of the electric field component associated with a
diode is obtained by the solution of the equation
Ae Bx + x + C = 0, (4.42)
where
n
x = E zn+1 (i, j, k), A = −Ce zd (i, j, k)e B×Ez (i, j,k) , B = (q z/2kT),
n+ 1 n+ 1
C = Ce ze (i, j, k) × E zn (i, j, k) + Ce zhy (i, j, k) × Hy 2 (i, j, k) − Hy 2 (i − 1, j, k)
n+ 1 n+ 1
+ Ce zhx (i, j, k) × Hx 2 (i, j, k) − Hx 2 (i, j − 1, k) + Ce zd (i, j, k).
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
sw i t ch ( r e s i s t o r s ( i n d ) . d i r e c t i o n ( 1 ) )
14 case ’ x ’
f i = c r e a t e l i n e a r i n d e x l i s t ( e p s r x , i s : i e −1 , j s : j e , k s : ke ) ;
16 a t e r m = ( d t * dx ) / ( R * dy * dz ) ;
Cexe ( f i ) = . . .
18 ( 2 * e p s 0 * e p s r x ( f i )− d t * s i g m a e x ( f i )− a t e r m ) . . .
. / ( 2 * e p s 0 * e p s r x ( f i )+ d t * s i g m a e x ( f i )+ a t e r m ) ;
20 C e x h z ( f i )= ( 2 * d t / dy ) . . .
. / ( 2 * e p s r x ( f i ) * e p s 0+d t * s i g m a e x ( f i )+ a t e r m ) ;
22 C e x h y ( f i )= −(2 * d t / dz ) . . .
. / ( 2 * e p s r x ( f i ) * e p s 0 + d t * s i g m a e x ( f i )+ a t e r m ) ;
24 case ’ y ’
f i = c r e a t e l i n e a r i n d e x l i s t ( e p s r y , i s : i e , j s : j e −1 , k s : ke ) ;
26 a t e r m = ( d t * dy ) / ( R * dz * dx ) ;
Ceye ( f i ) = . . .
28 ( 2 * e p s 0 * e p s r y ( f i )− d t * s i g m a e y ( f i )− a t e r m ) . . .
. / ( 2 * e p s 0 * e p s r y ( f i )+ d t * s i g m a e y ( f i )+ a t e r m ) ;
30 C e y h x ( f i )= ( 2 * d t / dz ) . . .
. / ( 2 * e p s r y ( f i ) * e p s 0+d t * s i g m a e y ( f i )+ a t e r m ) ;
32 C e y h z ( f i )= −(2 * d t / dx ) . . .
. / ( 2 * e p s r y ( f i ) * e p s 0 + d t * s i g m a e y ( f i )+ a t e r m ) ;
34 case ’ z ’
f i = c r e a t e l i n e a r i n d e x l i s t ( e p s r z , i s : i e , j s : j e , k s : ke − 1 ) ;
36 a t e r m = ( d t * dz ) / ( R * dx * dy ) ;
Ceze ( f i ) = . . .
38 ( 2 * e p s 0 * e p s r z ( f i )− d t * s i g m a e z ( f i )− a t e r m ) . . .
. / ( 2 * e p s 0 * e p s r z ( f i )+ d t * s i g m a e z ( f i )+ a t e r m ) ;
40 C e z h y ( f i )= ( 2 * d t / dx ) . . .
. / ( 2 * e p s r z ( f i ) * e p s 0+d t * s i g m a e z ( f i )+ a t e r m ) ;
42 C e z h x ( f i )= −(2 * d t / dy ) . . .
. / ( 2 * e p s r z ( f i ) * e p s 0+d t * s i g m a e z ( f i )+ a t e r m ) ;
44 end
r e s i s t o r s ( ind ) . f i e l d i n d i c e s = f i ;
46 end
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
sw i t ch ( c a p a c i t o r s ( i n d ) . d i r e c t i o n ( 1 ) )
14 case ’ x ’
f i = c r e a t e l i n e a r i n d e x l i s t ( e p s r x , i s : i e −1 , j s : j e , k s : ke ) ;
16 a t e r m = ( 2 * C * dx ) / ( dy * dz ) ;
Cexe ( f i ) = . . .
18 ( 2 * e p s 0 * e p s r x ( f i )− d t * s i g m a e x ( f i )+ a t e r m ) . . .
. / ( 2 * e p s 0 * e p s r x ( f i )+ d t * s i g m a e x ( f i )+ a t e r m ) ;
20 C e x h z ( f i )= ( 2 * d t / dy ) . . .
. / ( 2 * e p s r x ( f i ) * e p s 0+d t * s i g m a e x ( f i )+ a t e r m ) ;
22 C e x h y ( f i )= −(2 * d t / dz ) . . .
. / ( 2 * e p s r x ( f i ) * e p s 0 + d t * s i g m a e x ( f i )+ a t e r m ) ;
24 case ’ y ’
f i = c r e a t e l i n e a r i n d e x l i s t ( e p s r y , i s : i e , j s : j e −1 , k s : ke ) ;
26 a t e r m = ( 2 * C * dy ) / ( dz * dx ) ;
Ceye ( f i ) = . . .
28 ( 2 * e p s 0 * e p s r y ( f i )− d t * s i g m a e y ( f i )+ a t e r m ) . . .
. / ( 2 * e p s 0 * e p s r y ( f i )+ d t * s i g m a e y ( f i )+ a t e r m ) ;
30 C e y h x ( f i )= ( 2 * d t / dz ) . . .
. / ( 2 * e p s r y ( f i ) * e p s 0+d t * s i g m a e y ( f i )+ a t e r m ) ;
32 C e y h z ( f i )= −(2 * d t / dx ) . . .
. / ( 2 * e p s r y ( f i ) * e p s 0 + d t * s i g m a e y ( f i )+ a t e r m ) ;
34 case ’ z ’
f i = c r e a t e l i n e a r i n d e x l i s t ( e p s r z , i s : i e , j s : j e , k s : ke − 1 ) ;
36 a t e r m = ( 2 * C * dz ) / ( dx * dy ) ;
Ceze ( f i ) = . . .
38 ( 2 * e p s 0 * e p s r z ( f i )− d t * s i g m a e z ( f i )+ a t e r m ) . . .
. / ( 2 * e p s 0 * e p s r z ( f i )+ d t * s i g m a e z ( f i )+ a t e r m ) ;
40 C e z h y ( f i )= ( 2 * d t / dx ) . . .
. / ( 2 * e p s r z ( f i ) * e p s 0+d t * s i g m a e z ( f i )+ a t e r m ) ;
42 C e z h x ( f i )= −(2 * d t / dy ) . . .
. / ( 2 * e p s r z ( f i ) * e p s 0+d t * s i g m a e z ( f i )+ a t e r m ) ;
44 end
c a p a c i t o r s ( ind ) . f i e l d i n d i c e s = f i ;
46 end
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
q = 1 . 6 0 2 * 1 e −19; % c h a r g e o f an e l e c t r o n
4 k = 1 . 3 8 0 6 6 e −23; % Boltzman c o n s t a n t , j o u l e / k e l v i n
T = 273+27; % K e l v i n ; room t e m p e r a t u r e
6 I 0 = 1e −14; % saturation current
16 i f strcmp ( d i o d e s ( ind ) . d i r e c t i o n ( 2 ) , ’ n ’ )
s g n = −1;
18 else
sgn = 1;
20 end
sw i t ch ( d i o d e s ( i n d ) . d i r e c t i o n ( 1 ) )
22 case ’ x ’
f i = c r e a t e l i n e a r i n d e x l i s t ( eps r x , is , js , ks ) ;
24 d i o d e s ( i n d ) . B = s g n * q * dx / ( 2 * k * T ) ;
d i o d e s ( ind ) . Cexd = . . .
26 −s g n * ( 2 * d t * I 0 / ( dy * dz ) ) . . .
. / ( 2 * e p s r x ( f i ) * eps 0 + dt * sigma e x ( fi ));
28 d i o d e s ( i n d ) . Exn = 0 ;
case ’ y ’
30 f i = c r e a t e l i n e a r i n d e x l i s t ( eps r y , is , js , ks ) ;
d i o d e s ( i n d ) . B = s g n * q * dy / ( 2 * k * T ) ;
32 d i o d e s ( i n d ) . Ceyd = . . .
−s g n * ( 2 * d t * I 0 / ( dz * dx ) ) . . .
34 . / ( 2 * e p s r y ( f i ) * eps 0 + dt * sigma e y ( fi ));
d i o d e s ( i n d ) . Eyn = 0 ;
36 case ’ z ’
f i = c r e a t e l i n e a r i n d e x l i s t ( eps r z , is , js , ks ) ;
38 d i o d e s ( i n d ) . B = s g n * q * dz / ( 2 * k * T ) ;
d i o d e s ( ind ) . Cezd = . . .
40 −s g n * ( 2 * d t * I 0 / ( dx * dy ) ) . . .
. / ( 2 * e p s r z ( f i ) * eps 0 + dt * sigma e z ( fi ));
42 d i o d e s ( i n d ) . Ezn = 0 ;
end
44 diodes ( ind ) . f i e l d i n d i c e s = f i ;
end
Here the E zn+1 (i, j, k) is the electric field component that is sought. The term B is a constant
that can be constructed before the time-marching loop starts and stored as parameter diodes(i).B.
However, the parameters A and C are expressions that have to be recalculated at every time step of
the time-marching iteration using the previous values of electric and magnetic field components.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Comparing the first three terms on the right-hand side of the equation expressing C in (4.34)
with the updating equation for general media (1.28), one can see that their forms are the same and
that the coefficients Ce ze , Ce zhy , and Ce zhx are different only by a minus sign. These coefficients
were initialized as Ceze, Cezhy, and Cezhx in the subroutine initialize updating coefficients,
and there is no need to redefine them. We only need to keep in mind that the components of these
parameters with the indices (is , j s , ks )—Ceze(is,js,ks), Cezhy(is,js,ks), and Cezhz(is,js,ks)—
are the negatives of the coefficients that are used to recalculate C while updating E zn+1 (is , j s , ks )
as associated with a diode.
However, the fourth term in the expression of C includes a coefficient, Ce zd (i, j, k), which has
not been defined before. Therefore, a parameter, diodes(i).Cezd, is defined to store the value of
Ce zd (is , j s , ks ) in Listing 4.12.
An additional parameter that is defined and initialized with zero in Listing 4.12 is diodes(i).Ezn.
This parameter stores E zn (is , j s , ks ), which is the value of electric field component at the previ-
ous time step. This parameter is used to recalculate the coefficient C at every time step, and it
should be available when recalculating C. Therefore, at every time step the value of E zn (is , j s , ks )
is stored in the parameter diodes(i).Ezn to have it available at the next time step for the
calculation of C.
4.2.5.1 Calculation of Sampled Voltages The voltages and currents that will be sampled are repre-
sented similar to lumped element components by prism-like volumes and their directions. The
voltages across and the currents flowing through these volumes will be calculated using the electric
field components across and the magnetic field components around these volumes, respectively,
during the time-marching loop.
For instance, consider the volume defined between the nodes (is , j s , ks ) and (ie, j e, ke). This
volume is placed between two parallel PEC plates. An average value of voltage can be calculated
between the PEC plates across the volume. Here we employ the integral form of (4.2), which can
be given as
V=− E · dl. (4.43)
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Figure 4.11 A volume between PEC plates where a z-directed sampled voltage is required.
This integration is expressed as a summation in the discrete space. For the configuration in
Fig. 4.11, the voltage between the upper and lower PEC plates can be expressed in discrete
form as
ke−1
V = −d z × E z (is , j s , k). (4.44)
k=ks
However, it can be seen in Fig. 4.11 that there are multiple paths for performing the discrete
summation and that the voltages calculated through these paths should be very close to each other.
Therefore, an average of these voltage values can be calculated by
−d z
ie
j e ke−1
V= × E z (i, j, k). (4.45)
(ie − is + 1) × ( j e − j s + 1) i=is j = j s k=ks
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
ie
j e ke−1
V = Csvf × E z (i, j, k), (4.46)
i=is j = j s k=ks
where
−d z
Csvf = . (4.47)
(ie − is + 1) × ( j e − j s + 1)
The coefficient Csvf is a scaling factor multiplied by the sum of the field components E z (is : ie, j s :
j e, ks : ke − 1) to obtain the average voltage.
The aforementioned equations still hold for the cases where is is equal to ie or j s is equal to
j e. In those cases the voltage is sampled along a line segment or across a surface.
4.2.5.2 Calculation of Sampled Currents To calculate the current flowing through a surface we can
employ Ampere’s law in integral form, which is given by
Ifree = H · dl, (4.48)
where Ifree is the total free current. We need to describe the integral in (4.48) as a summation
of magnetic field components in the discrete space. For instance, consider the case shown in
Fig. 4.12. The figure shows magnetic field components enclosing a surface. The positions of the
fields are given with respect to the Yee cell, and indices of the fields are given with respect to
the nodes (is , j s , ks ) and (ie, j e, ke). These fields can be used to calculate the enclosed total free
Figure 4.12 A surface enclosed by magnetic field components and z-directed current flowing through it.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
current by
ie
je
Iz (ke − 1) = d x × Hx (i, j s − 1, ke − 1) + d y × Hy (ie, j, ke − 1)
i=is j= js
ie
je
−dx × Hx (i, j e, ke − 1) − d y × Hy (is − 1, j, ke − 1). (4.49)
i=is j= js
Here we indexed Iz by (ke − 1) since the magnetic field components with the index (ke − 1) in the
z direction are used to calculate Iz .
As discussed before, we can determine the position of the current sampling by a volume
identified by the node indices (is , j s , ks ) and (ie, j e, ke). Then, a surface intersecting with the
cross-section of this volume and enclosing it can be used to determine the magnetic field com-
ponents that are used to calculate the current as illustrated in Fig. 4.12. It is possible that the
volume identified by the nodes (is , j s , ks ) and (ie, j e, ke) reduces to a surface or a line segment
or even to a point in the case where ie = is , j e = j s , and ke = ks . The expression in (4.49) still
can be used to calculate the current in those cases. However, one should notice that the surface
represented by the magnetic field components indexed by (ke − 1) is not coinciding with the
nodes; it instead crosses the centers of the cells. Therefore, if sampling of both the voltage and
the current is required at the same position, one should sample one of these quantities over mult-
iple positions and should take the average to obtain both the voltage and current effectively at the
same position.
Furthermore, another point that should be kept in mind is that the voltages and currents are
sampled at different time instants and a half time step apart from each other, since the voltages
are calculated from electric field components and currents are calculated from magnetic field
components, which are offset in time due to the leap-frog Yee algorithm. This time difference
can also be compensated for as pointed out in [11].
11 % mode o f o p e r a t i o n
run simulation = true ;
13 show material mesh = true ;
show problem space = true ;
15
% d e f i n e sampled e l e c t r i c f i e l d s
17 % component : v e c t o r component ’ x ’ , ’ y ’ , ’ z ’ , o r m a g n i t u d e ’m’
% d i s p l a y p l o t = true , in order to plot f i e l d during simulation
19 s a m p l e d e l e c t r i c f i e l d s ( 1 ) . x = 30 * dx ;
s a m p l e d e l e c t r i c f i e l d s ( 1 ) . y = 30 * dy ;
21 s a m p l e d e l e c t r i c f i e l d s ( 1 ) . z = 10 * dz ;
s a m p l e d e l e c t r i c f i e l d s ( 1 ) . component = ’ x ’ ;
23 sampled electric fields ( 1 ) . display plot = true ;
25 % d e f i n e sampled m a g n e t i c f i e l d s
% component : v e c t o r component ’ x ’ , ’ y ’ , ’ z ’ , o r m a g n i t u d e ’m’
27 % d i s p l a y p l o t = true , in order to plot f i e l d during simulation
s a m p l e d m a g n e t i c f i e l d s ( 1 ) . x = 30 * dx ;
29 s a m p l e d m a g n e t i c f i e l d s ( 1 ) . y = 30 * dy ;
s a m p l e d m a g n e t i c f i e l d s ( 1 ) . z = 10 * dz ;
31 s a m p l e d m a g n e t i c f i e l d s ( 1 ) . component = ’m ’ ;
sampled magnetic fields ( 1 ) . display plot = true ;
33
51 s a m p l e d c u r r e n t s ( 1 ) . d i r e c t i o n = ’ xp ’ ;
sampled currents ( 1 ) . display plot = true ;
53
% d i s p l a y problem s p a c e p a r a m e t e r s
55 problem space display . labels = true ;
problem space display . a x i s a t o r i g i n = false ;
57 problem space display . axis outside domain = true ;
problem space display . grid xn = false ;
59 problem space display . grid xp = true ;
problem space display . grid yn = false ;
61 problem space display . grid yp = true ;
problem space display . grid zn = true ;
63 problem space display . grid zp = false ;
problem space display . outer boundaries = true ;
65 problem space display . cpml boundaries = true ;
67 % define animation
% f i e l d t y p e s h a l l be ’ e ’ o r ’ h ’
69 % p l a n e c u t s h a l l be ’ xy ’ , yz , o r z x
% component s h a l l be ’ x ’ , ’ y ’ , ’ z ’ , o r ’m;
71 animation ( 1 ) . f i e l d t y p e = ’ e ’ ;
a n i m a t i o n ( 1 ) . component = ’m ’ ;
73 animation ( 1 ) . p l a n e c u t ( 1 ) . t y pe = ’ xy ’ ;
animation ( 1 ) . plane cut ( 1 ) . p o s i t i o n = 0;
75 animation ( 1 ) . p l a n e c u t ( 2 ) . t y pe = ’ yz ’ ;
animation ( 1 ) . plane cut ( 2 ) . p o s i t i o n = 0;
77 animation ( 1 ) . p l a n e c u t ( 3 ) . t y pe = ’ zx ’ ;
animation ( 1 ) . plane cut ( 3 ) . p o s i t i o n = 0;
79 animation ( 1 ) . enable = true ;
animation ( 1 ) . d i s p l a y g r i d = f a l s e ;
81 animation ( 1 ) . d i s p l a y o b j e c t s = true ;
Usually it is a good practice to examine the positioning of the objects in the three-dimensional
problem space before running the simulation. Furthermore, examining the distribution of the
material parameters on the FDTD grid will also reveal if the simulation is set up correctly.
In these cases it is better to run the simulation up to a point where the three-dimensional
view of the problem space and the material mesh can be displayed. Therefore, a parameter
named run simulation is defined. If this parameter is true, then the program proceeds with run-
ning the simulation; otherwise, it stops after calling the subroutines display problem space and
display material mesh as shown in Listing 3.1. The display problem space is a subroutine that
displays the three-dimensional view of the problem space, and it is controlled by a logical
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
parameter named show problem space. A set of parameters that can be used to set the view
of the problem space is listed at the end of Listing 4.13. Similarly, display material mesh is a sub-
routine that launches a utility program with a graphical user interface, display material mesh gui,
and it is controlled by a parameter named show material mesh. For instance, the material grid
in Fig. 3.13 is obtained using display material mesh gui.
During the FDTD time-marching loop the electric and magnetic fields are calculated all over
the problem space at their respective positions on the Yee grid. Since all of the field components
are available, any of them can be captured, plotted, or stored. For instance, some field components
on some plane cuts can be captured and plotted on figures so as to demonstrate the real-time pro-
gression of fields on these plane cuts. Or some fields can be captured and stored for postprocessing.
Here we limit our implementation to field components sampled at nodes of the FDTD grid. To
define a node, we need its position in the Cartesian coordinates. Therefore, the parameters x, y,
and z are defined in the structures sampled electric fields(i) and sampled magnetic fields(i).
Since the fields are vectors, their x, y, and z components or magnitudes can be sampled. Hence,
the parameter component, which can take one of the values ‘x’, ‘y’, ‘z’, or ‘m’, is defined with
sampled electric fields(i) and sampled magnetic fields(i). If the component takes the value
‘m’ then the magnitude of the field is calculated using
Em = E x2 + E y2 + E z2 , Hm = Hx2 + Hy2 + Hz2 .
One additional parameter is display plot, which takes one of the values true or false and
determines whether this field component will be plotted while the simulation is running or not.
Meanwhile, the volumes representing the sampled voltages and currents are identified by
the parameters min x, min y, min z, max x, max y, and max z. The directions of the sampled
voltages and currents are defined by the parameter direction, which can take one of the values
‘xp’, ‘yp’, ‘zp’, ‘xn’, ‘yn’, or ‘zn’.
As discussed already, since all of the field components are available at every time step of the
simulation, they can be captured on desired plane cuts and plotted; thus, a propagation of fields
on these plane cuts can be simulated. The definition of animation as an output is done using a
parameter animation. The parameter animation is an array so each element in the array generates
a figure that displays the fields. An element animation(i) has the following subfields that are used
to define the properties of the animation. The subfield field type can take a value either ‘e’ or ‘h’,
determining whether the electric field or magnetic field will be animated, respectively. Then the
subfield component is used to define which component of the field to display, and it takes one of
the values ‘x’, ‘y’, ‘z’, or ‘m’. Then several plane cuts can be defined to be displayed on a figure using
the subfield plane cut(j). The parameter plane cut(j).type can take one of the values ‘xy’, ‘yz’,
or ‘zx’, describing which principal plane the plane cut is parallel to. Then the parameter plane -
cut(j).position determines the position of the plane cut. For instance, if type is ‘yz’, and position
is 5, then the plane cut is the plane at x = 5. Finally, three other subfields of animation(i) are the
logical parameters enable, display grid, and display objects. The animation can be disabled by
simply setting enable ‘false’, the FDTD grid can be displayed during the simulation by setting
display grid ‘true’, and the objects in the problem space can be displayed by a wire grid by setting
display objects ‘true’.
4.2.6.1 Initialization of Output Parameters The initialization of output parameters is imple-
mented in the subroutine initialize output parameters, as shown in Listing 4.14. Here the
parameter sampled electric fields represents the sampled electric field components, and
sampled magnetic fields represents the sampled magnetic field components. Similarly, the
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
parameters sampled voltages and sampled currents represent sampled voltages and currents,
respectively. As indicated before, the electric and magnetic field components are sampled at spec-
ified positions, which coincide with respective nodes in the Yee grid. The indices of the sampling
nodes are determined in Listing 4.14 and are stored in the parameters is, js, and ks. Furthermore,
a one-dimensional array with size number of time steps is constructed as sampled value and
initialized with zeros. This parameter is used to store the new computed values of the sampled
Listing 4.14 initialize output parameters.m
1 disp ( ’ i n i t i a l i z i n g the output parameters ’ ) ;
% i n i t i a l i z e sampled e l e c t r i c f i e l d t e r m s
9 f o r i n d =1: n u m b e r o f s a m p l e d e l e c t r i c f i e l d s
i s = round ( ( s a m p l e d e l e c t r i c f i e l d s ( i n d ) . x ...
11 − f d t d d o m a i n . m i n x ) / dx ) + 1 ;
j s = round ( ( s a m p l e d e l e c t r i c f i e l d s ( i n d ) . y ...
13 − f d t d d o m a i n . m i n y ) / dy ) + 1 ;
k s = round ( ( s a m p l e d e l e c t r i c f i e l d s ( i n d ) . z ...
15 − f d t d d o m a i n . m i n z ) / dz ) + 1 ;
s a m p l e d e l e c t r i c f i e l d s ( ind ) . i s = i s ;
17 s a m p l e d e l e c t r i c f i e l d s ( ind ) . j s = j s ;
s a m p l e d e l e c t r i c f i e l d s ( ind ) . ks = ks ;
19 s a m p l e d e l e c t r i c f i e l d s ( ind ) . sampled value = ...
zeros (1 , number of time steps ) ;
21 s a m p l e d e l e c t r i c f i e l d s ( ind ) . time = . . .
( [ 1 : number of time steps ] ) * dt ;
23 end
25 % i n i t i a l i z e sampled m a g n e t i c f i e l d t e r m s
f o r i n d =1: n u m b e r o f s a m p l e d m a g n e t i c f i e l d s
27 i s = round ( ( s a m p l e d m a g n e t i c f i e l d s ( i n d ) . x ...
− f d t d d o m a i n . m i n x ) / dx ) + 1 ;
29 j s = round ( ( s a m p l e d m a g n e t i c f i e l d s ( i n d ) . y ...
− f d t d d o m a i n . m i n y ) / dy ) + 1 ;
31 k s = round ( ( s a m p l e d m a g n e t i c f i e l d s ( i n d ) . z ...
− f d t d d o m a i n . m i n z ) / dz ) + 1 ;
33 s a m p l e d m a g n e t i c f i e l d s ( ind ) . i s = i s ;
s a m p l e d m a g n e t i c f i e l d s ( ind ) . j s = j s ;
35 s a m p l e d m a g n e t i c f i e l d s ( ind ) . ks = ks ;
s a m p l e d m a g n e t i c f i e l d s ( ind ) . sampled value = ...
37 zeros (1 , number of time steps ) ;
s a m p l e d m a g n e t i c f i e l d s ( ind ) . time = . . .
39 ( [ 1 : number of time steps ] −0.5)* dt ;
end
41
% i n i t i a l i z e sampled v o l t a g e t e r m s
43 f o r i n d =1: n u m b e r o f s a m p l e d v o l t a g e s
i s = round ( ( s a m p l e d v o l t a g e s ( i n d ) . m i n x − f d t d d o m a i n . m i n x ) / dx ) + 1 ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
59 sw i t ch ( s a m p l e d v o l t a g e s ( i n d ) . d i r e c t i o n ( 1 ) )
case ’ x ’
61 f i = c r e a t e l i n e a r i n d e x l i s t ( Ex , i s : i e −1 , j s : j e , k s : ke ) ;
s a m p l e d v o l t a g e s ( i n d ) . C s v f = −dx / ( ( j e − j s + 1 ) * ( ke−k s + 1 ) ) ;
63 case ’ y ’
f i = c r e a t e l i n e a r i n d e x l i s t ( Ey , i s : i e , j s : j e −1 , k s : ke ) ;
65 s a m p l e d v o l t a g e s ( i n d ) . C s v f = −dy / ( ( ke−k s + 1 ) * ( i e − i s + 1 ) ) ;
case ’ z ’
67 f i = c r e a t e l i n e a r i n d e x l i s t ( Ez , i s : i e , j s : j e , k s : ke − 1 ) ;
s a m p l e d v o l t a g e s ( i n d ) . C s v f = −dz / ( ( i e − i s + 1 ) * ( j e − j s + 1 ) ) ;
69 end
i f strcmp ( s a m p l e d v o l t a g e s ( ind ) . d i r e c t i o n ( 2 ) , ’ n ’ )
71 sampled voltages ( ind ) . C s v f = . . .
−1 * s a m p l e d v o l t a g e s ( i n d ) . C s v f ;
73 end
sampled voltages ( ind ) . f i e l d i n d i c e s = f i ;
75 s a m p l e d v o l t a g e s ( ind ) . time = ( [ 1 : n u m b e r o f t i m e s t e p s ] ) * dt ;
end
77
% i n i t i a l i z e sampled c u r r e n t t e r m s
79 f o r i n d =1: n u m b e r o f s a m p l e d c u r r e n t s
i s = round ( ( s a m p l e d c u r r e n t s ( i n d ) . m i n x − f d t d d o m a i n . m i n x ) / dx ) + 1 ;
81 j s = round ( ( s a m p l e d c u r r e n t s ( i n d ) . m i n y − f d t d d o m a i n . m i n y ) / dy ) + 1 ;
k s = round ( ( s a m p l e d c u r r e n t s ( i n d ) . m i n z − f d t d d o m a i n . m i n z ) / dz ) + 1 ;
83 i e = round ( ( s a m p l e d c u r r e n t s ( i n d ) . max x − f d t d d o m a i n . m i n x ) / dx ) + 1 ;
j e = round ( ( s a m p l e d c u r r e n t s ( i n d ) . max y − f d t d d o m a i n . m i n y ) / dy ) + 1 ;
85 ke = round ( ( s a m p l e d c u r r e n t s ( i n d ) . max z − f d t d d o m a i n . m i n z ) / dz ) + 1 ;
sampled currents ( ind ) . i s = i s ;
87 sampled currents ( ind ) . j s = j s ;
sampled currents ( ind ) . ks = ks ;
89 sampled currents ( ind ) . i e = i e ;
sampled currents ( ind ) . j e = j e ;
91 s a m p l e d c u r r e n t s ( i n d ) . ke = ke ;
sampled currents ( ind ) . sampled value = . . .
93 zeros (1 , number of time steps ) ;
s a m p l e d c u r r e n t s ( ind ) . time = ( [ 1 : n u m b e r o f t i m e s t e p s ] −0.5)* dt ;
95 end
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
component while the FDTD iterations proceed. Another one-dimensional array with size num-
ber of time steps is time, which is used to store the time instants of the respective captured
values. One should notice that there is a half time step duration (d t/2) shift between the electric
field and magnetic field time arrays.
The indices of the nodes indicating the positions of the sampled voltages are calculated and
assigned to the parameters is, js, ks, ie, je, and ke. The indices of the fields that are used to
calculate sampled voltages are determined and assigned to the parameter field indices. Then
coefficient Csvf , which is a scaling factor as described in Section 4.2.5, is calculated using (4.47)
and is assigned to the parameter Csvf.
4.2.6.2 Initialization of Figures for Runtime Display So far we have defined four types of outputs for
an FDTD simulation: namely, sampled electric and magnetic fields, voltages, and currents. While
the FDTD simulation is running, the progress of these sampled parameters can be displayed
on MATLAB figures. In the subroutine define output parameters, while defining the sampled
components, a parameter display plot is associated to each defined component indicating whether
the real-time progress of this component displayed. If there are any components defined for
runtime display, figures displaying these components can be opened and their properties can
be set before the FDTD time-marching loop starts. This figure initialization process can be
performed in the subroutine initialize display parameters, which is given in Listing 4.15. Here
figures are launched for every sampled component that is displayed, and their axis labels are set.
Furthermore, the number of the figure associated with each sampled component is stored in the
parameter figure number.
Listing 4.15 initialize display parameters.m
1 disp ( ’ i n i t i a l i z i n g d i s p l a y parameters ’ ) ;
3 % open f i g u r e s f o r sampled e l e c t r i c f i e l d s
f o r i n d =1: n u m b e r o f s a m p l e d e l e c t r i c f i e l d s
5 i f s a m p l e d e l e c t r i c f i e l d s ( i n d ) . d i s p l a y p l o t == t r u e
s a m p l e d e l e c t r i c f i e l d s ( ind ) . figure number = f i g u r e ;
7 s a m p l e d e l e c t r i c f i e l d s ( i n d ) . p l o t h a n d l e = p l o t ( 0 , 0 , ’ b− ’ ) ;
x l a b e l ( ’ time ( ns ) ’ , ’ f o n t s i z e ’ , 1 2 ) ;
9 y l a b e l ( ’ ( v o l t / meter ) ’ , ’ f o n t s i z e ’ , 1 2 ) ;
t i t l e ( [ ’ sampled e l e c t r i c f i e l d [ ’ . . .
11 num2str ( i n d ) ’ ] ’ ] , ’ f o n t s i z e ’ , 1 2 ) ;
g r i d on ;
13 hold on ;
end
15 end
17 % open f i g u r e s f o r sampled m a g n e t i c f i e l d s
f o r i n d =1: n u m b e r o f s a m p l e d m a g n e t i c f i e l d s
19 i f s a m p l e d m a g n e t i c f i e l d s ( i n d ) . d i s p l a y p l o t == t r u e
s a m p l e d m a g n e t i c f i e l d s ( ind ) . figure number = f i g u r e ;
21 s a m p l e d m a g n e t i c f i e l d s ( i n d ) . p l o t h a n d l e = p l o t ( 0 , 0 , ’ b− ’ ) ;
x l a b e l ( ’ time ( ns ) ’ , ’ f o n t s i z e ’ , 1 2 ) ;
23 y l a b e l ( ’ ( ampere / meter ) ’ , ’ f o n t s i z e ’ , 1 2 ) ;
t i t l e ( [ ’ sampled m a g n e t i c f i e l d [ ’ num2str ( i n d ) ’ ] ’ ] , . . .
25 ’ fontsize ’ ,12);
g r i d on ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
27 hold on ;
end
29 end
31 % i n i t i a l i z e f i g u r e s f o r sampled v o l t a g e s
f o r i n d =1: n u m b e r o f s a m p l e d v o l t a g e s
33 i f s a m p l e d v o l t a g e s ( i n d ) . d i s p l a y p l o t == t r u e
sampled voltages ( ind ) . figure number = f i g u r e ;
35 s a m p l e d v o l t a g e s ( i n d ) . p l o t h a n d l e = p l o t ( 0 , 0 , ’ b− ’ ) ;
x l a b e l ( ’ time ( ns ) ’ , ’ f o n t s i z e ’ , 1 2 ) ;
37 ylabel ( ’ ( volt ) ’ , ’ fontsize ’ ,12);
t i t l e ( [ ’ sampled v o l t a g e [ ’ num2str ( i n d ) ’ ] ’ ] , . . .
39 ’ fontsize ’ ,12);
g r i d on ;
41 hold on ;
end
43 end
45 % i n i t i a l i z e f i g u r e s f o r sampled c u r r e n t s
f o r i n d =1: n u m b e r o f s a m p l e d c u r r e n t s
47 i f s a m p l e d c u r r e n t s ( i n d ) . d i s p l a y p l o t == t r u e
sampled currents ( ind ) . figure number = f i g u r e ;
49 s a m p l e d c u r r e n t s ( i n d ) . p l o t h a n d l e = p l o t ( 0 , 0 , ’ b− ’ ) ;
x l a b e l ( ’ time ( ns ) ’ , ’ f o n t s i z e ’ , 1 2 ) ;
51 y l a b e l ( ’ ( ampere ) ’ , ’ f o n t s i z e ’ , 1 2 ) ;
t i t l e ( [ ’ sampled c u r r e n t [ ’ num2str ( i n d ) ’ ] ’ ] , . . .
53 ’ fontsize ’ ,12);
g r i d on ;
55 hold on ;
end
57 end
59 % i n i t i a l i z e f i e l d animation parameters
initialize animation parameters ;
Finally a subroutine initialize animation parameters is called, which performs the initializa-
tion of parameters for field animation on the plane cuts defined in define output parameters.
Furthermore, figures and display parameters for other types of sampled outputs can be initial-
ized in this routine.
Therefore, so far we have constructed the necessary components for starting an FDTD sim-
ulation for a problem space assuming PEC boundaries and including objects of isotropic and
linear materials and lumped element components. Now we are ready to implement the subroutine
run fdtd time marching loop, which includes the steps of the leap-frog time-marching algorithm
of the FDTD method. The implementation of run fdtd time marching loop is given in Listing
4.16. We discuss the functions and provide the implementation of subroutines of these steps in
this section.
Listing 4.16 starts with the definition and initialization of a parameter current time, which
is used to include the current value of time instant during the FDTD loop. Then the MATLAB
function cputime is used to capture the time on the computer system. This is first called to capture
the start time of the FDTD loop and is stored in start time. The function cputime is called one
more time to capture the time on the system after the FDTD loop is completed. The captured
value is copied to end time. Hence, the difference between the start and end times is used to
calculate the total simulation time spent for the time-marching iterations.
4.2.7.1 Updating Magnetic Fields The time-marching iterations are performed number of time -
steps times. At every iteration first the magnetic field components are updated in the subroutine
update magnetic fields, as given in Listing 4.17. Here the new values of the magnetic field com-
ponents are calculated all over the problem space based on the general updating equations (1.29)–
(1.31), excluding the impressed magnetic current terms since there are no impressed magnetic
currents defined.
s t a r t t i m e = cputime ;
6 current time = 0;
22 e n d t i m e = cputime ;
t o t a l t i m e i n m i n u t e s = ( end time − s t a r t t i m e ) / 6 0 ;
24 disp ( [ ’ T o t a l s i m u l a t i o n time i s ’ . . .
num2str ( t o t a l t i m e i n m i n u t e s ) ’ m i n u t e s . ’ ] ) ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
4.2.7.2 Updating Electric Fields Then the next important step in an FDTD iteration is the update
of electric fields, which is performed in the subroutine update electric fields and is shown in
Listing 4.18. The electric field components are updated using the general updating equations
given in (1.26)–(1.28), except for the impressed electric current terms. While discussing the
lumped element components, it has been shown that impressed current terms are needed for
modeling inductors. Since only a small number of electric field components need to be updated
for modeling the inductors; these components are recalculated by addition of impressed current
related terms in the subroutine update inductors.
One should notice that in Listing 4.18, the electric field components that are tangential to the
boundaries are excluded in the updating. The reason is the specific arrangement of field positions
6 E x ( 1 : nx , 2 : ny , 2 : nz ) = C e x e ( 1 : nx , 2 : ny , 2 : nz ) . * E x ( 1 : nx , 2 : ny , 2 : nz ) . . .
+ C e x h z ( 1 : nx , 2 : ny , 2 : nz ) . * . . .
8 ( Hz ( 1 : nx , 2 : ny , 2 : nz )−Hz ( 1 : nx , 1 : ny −1 ,2: nz ) ) . . .
+ C e x h y ( 1 : nx , 2 : ny , 2 : nz ) . * . . .
10 ( Hy ( 1 : nx , 2 : ny , 2 : nz )−Hy ( 1 : nx , 2 : ny , 1 : nz − 1 ) ) ;
12 E y ( 2 : nx , 1 : ny , 2 : nz )= C e y e ( 2 : nx , 1 : ny , 2 : nz ) . * E y ( 2 : nx , 1 : ny , 2 : nz ) . . .
+ C e y h x ( 2 : nx , 1 : ny , 2 : nz ) . * ...
14 ( Hx ( 2 : nx , 1 : ny , 2 : nz )−Hx ( 2 : nx , 1 : ny , 1 : nz − 1 ) ) . . .
+ C e y h z ( 2 : nx , 1 : ny , 2 : nz ) . * ...
16 ( Hz ( 2 : nx , 1 : ny , 2 : nz )−Hz ( 1 : nx −1 ,1: ny , 2 : nz ) ) ;
18 E z ( 2 : nx , 2 : ny , 1 : nz )= C e z e ( 2 : nx , 2 : ny , 1 : nz ) . * E z ( 2 : nx , 2 : ny , 1 : nz ) . . .
+ C e z h y ( 2 : nx , 2 : ny , 1 : nz ) . * ...
20 ( Hy ( 2 : nx , 2 : ny , 1 : nz )−Hy ( 1 : nx −1 ,2: ny , 1 : nz ) ) . . .
+ C e z h x ( 2 : nx , 2 : ny , 1 : nz ) . * . . .
22 ( Hx ( 2 : nx , 2 : ny , 1 : nz )−Hx ( 2 : nx , 1 : ny −1 ,1: nz ) ) ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
on the Yee cell. While updating an electric field component, the magnetic field components
encircling it are required. However, for an electric field component resting tangential to the
boundary of the problem space, at least one of the required magnetic field components would be
out of the problem space and thus would be undefined. Therefore, the electric field components
tangential to the boundaries cannot be updated using the general updating equations. However,
if these components are not updated, they maintain their initial values, which are zeros, thus
naturally simulating the PEC boundaries. Therefore, there is no need for any additional effort to
enforce PEC boundaries. However, some other types of boundaries may require special updates
for these electric field components.
The updating coefficient values that model the lumped element components were assigned to
the respective positions in the updating coefficient arrays; therefore, the updating of the electric
field in update electric fields completes the modeling of capacitors and resistors. The modeling of
other lumped elements requires addition of some other terms to the electric fields at their respective
positions. The following sections elaborate on updates for these other lumped elements.
4.2.7.3 Updating Electric Fields Associated with Voltage Sources The updating equations modeling
the voltage sources are derived and represented by (4.10). This equation includes an additional
voltage source specific term,
n+ 12
Ce zs (i, j, k) × Vs (i, j, k), (4.50)
which was omitted in the implementation of update electric fields in Listing 4.18. This term
can be added to the electric field components that are associated with the voltage sources. The
indices of the electric field components requiring an additional update are stored in the parameter
voltage sources(i).field indices. The coefficient terms are constructed as Cexs, Ceys, and Cezs,
based on the direction of the voltage source. The value of the voltage at the current time step can
be retrieved from the waveform array voltage sources(i).waveform. The additional update of
electric field components due to voltage sources is performed in update voltage sources as shown
in Listing 4.19.
4 for ind = 1: n u m b e r o f v o l t a g e s o u r c e s
f i = v o l t a g e s o u r c e s ( ind ) . f i e l d i n d i c e s ;
6 sw i t ch ( v o l t a g e s o u r c e s ( i n d ) . d i r e c t i o n ( 1 ) )
case ’ x ’
8 Ex ( f i ) = Ex ( f i ) + v o l t a g e s o u r c e s ( ind ) . Cexs . . .
* v o l t a g e s o u r c e s ( ind ) . v o l t a g e p e r e field ( time step ) ;
10 case ’ y ’
Ey ( f i ) = Ey ( f i ) + v o l t a g e s o u r c e s ( ind ) . Ceys . . .
12 * v o l t a g e s o u r c e s ( ind ) . v o l t a g e p e r e field ( time step ) ;
case ’ z ’
14 Ez ( f i ) = Ez ( f i ) + v o l t a g e s o u r c e s ( ind ) . Cezs . . .
* v o l t a g e s o u r c e s ( ind ) . v o l t a g e p e r e field ( time step ) ;
16 end
end
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
4.2.7.4 Updating Electric Fields Associated with Current Sources Updating of the field components
associated with the current sources is similar to that for the voltage sources. The updating equations
modeling the current sources are derived and given by (4.15). This equation includes an additional
current source specific term,
n+ 12
Ce zs (i, j, k) × Is (i, j, k). (4.51)
The additional update of electric field components due to current sources is performed in
update current sources as shown in Listing 4.20.
4.2.7.5 Updating Electric Fields Associated with Inductors The updating equations modeling the
inductors are derived as in equation (4.24), which includes an additional impressed electric current
source term
n+ 12
Ce zj (i, j, k) × Ji z (i, j, k). (4.52)
The coefficients in the additional terms have been constructed in Listing 4.9 as Cexj, Ceyj, and
n+ 1
Cezj. However, the impressed current term Ji z 2 1should be recalculated at every time step using
n−
the previous value of the impressed current, Ji z 2 , and the associated electric field component,
E z , based on equation (4.23), before adding 1the terms in equation (4.52) to E zn+1 . However,
n
n+
since update electric
1
fields overwrites E zn , Ji z 2 must be calculated before update electric fields.
n+
Therefore, Ji z 2 can be recalculated after updating the electric fields due to inductors for use in
the following time step. The algorithm for updating electric field components and calculating
the impressed currents can be followed in Listing 4.21, which shows the implementation of
update inductors.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
4.2.7.6 Updating Electric Fields Associated with Diodes Update of electric field components for
modeling diodes is more complicated compared to other types of lumped elements. As discussed
in Section 4.1.8, the new value of the electric field component associated with a diode is obtained
by the solution of the equation
Ae Bx + x + C = 0, (4.53)
where
n
x = E zn+1 (i, j, k), A = −Ce zd (i, j, k)e B×Ez (i, j,k) , B = (q z/2kT),
n+ 1 n+ 1
C = Ce ze (i, j, k) × E zn (i, j, k) + Ce zhy (i, j, k) × Hy 2 (i, j, k) − Hy 2 (i − 1, j, k)
n+ 1 n+ 1
+ Ce zhx (i, j, k) × Hx 2 (i, j, k) − Hx 2 (i, j − 1, k) + Ce zd (i, j, k). (4.54)
At this point, to calculate C we need the previous time step value of the electric field compo-
nent, E zn (i, j, k). Since this component is overwritten in update electric fields, we copy it to the
parameter diodes(ind).Ezn before executing update electric fields. Therefore, at every time step
after the value of the electric field component associated with a diode is obtained, it is copied to
diodes(ind).Ezn for use in the following time step. Similarly, the new value of A can be calculated
using E zn (i, j, k).
Once the parameters A and C are recalculated, the new value of electric field component E zn+1
can be calculated by solving (4.53). As discussed in Section 4.8, this equation can easily be solved
numerically by using the Newton-Raphson method. The updating procedure of electric field
components for modeling diodes is implemented in the subroutine update diodes, which is shown
in Listing 4.22. Comparing the given implementation with the previous discussion helps in under-
standing this complicated updating process. Finally, a function with name solve diode equation is
implemented for solving (4.53) based on the the Newton-Raphson method, and its implementation
is given in Listing 4.23.
6 t o l e r a n c e = 1e −25;
max iter = 50;
8 i t e r = 0;
f = A * exp ( B * x ) + x + C ;
10 w h i l e ( ( i t e r < m a x i t e r ) && ( abs ( f ) > t o l e r a n c e ) )
f p = A * B * exp ( B * x ) + 1 ;
12 x = x − f / fp ;
f = A * exp ( B * x ) + x + C ;
14 i t e r = i t e r + 1;
end
4.2.7.7 Capturing the Sampled Magnetic Field Components After the magnetic field components are
updated by update magnetic fields, they can be sampled for the current time step. As mentioned
before, although all of the field components in the problem space can be captured, for now we limit
our discussion with sampling the magnetic field values at predefined positions coinciding with the
nodes of the problem space. The indices of the nodes for which the magnetic field will be sampled
are stored in the parameters is, js, and ks. However, examining the field positioning scheme of
the Yee cell reveals that the magnetic field components are not defined at the node positions.
But it is possible to take the average of the four surrounding field components as the field value
of the node. This procedure is illustrated in Listing 4.24, which shows the implementation of
the subroutine capture sampled magnetic fields. For instance, to sample the y component of the
magnetic field at node (is , j s , ks ), an average of the components Hy (is , j s , ks ), Hy (is − 1, j s , ks ),
Hy (is , j s , ks − 1), and Hy (is − 1, j s , ks − 1) can be used as the sampled values as illustrated in
Fig. 4.13(a).
If the magnitude of the field vector is sought, the x, y, and z components of the field vector can
be sampled, and then their vector magnitude can be calculated as shown in Listing 4.24.
4.2.7.8 Capturing the Sampled Currents As discussed before, the currents flowing through a
given surface can be calculated using the magnetic fields components circling around the surface.
Therefore, after the magnetic field components are updated by update magnetic fields, the cur-
rents can be calculated for the current time step. The procedure for capturing the electric current
is implemented in the subroutine capture sampled currents as shown in Listing 4.25.
4.2.7.9 Capturing the Sampled Electric Field Components After the electric field components are
updated by update electric fields, they can be sampled for the current time step. Since there is not
an electric field component defined at the position of the sampling node (is , j s , ks ), an average
of the two field components around the node can be used as the sampled value. For instance,
to sample the y component of the electric field, an average of the components E y (is , j s , ks ) and
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Figure 4.13 The y components of the magnetic and electric fields around the node (i s, j s, ks ).
E y (is , j s − 1, ks ) can be used as the sampled value as illustrated in Fig. 4.13(b). The sampled
electric field components are captured in the subroutine update electric fields, which is shown in
Listing 4.26.
sw i t ch ( s a m p l e d m a g n e t i c f i e l d s ( i n d ) . component )
9 case ’ x ’
s a m p l e d v a l u e = 0 . 2 5 * sum ( sum ( Hx ( i s , j s −1: j s , ks −1: k s ) ) ) ;
11 case ’ y ’
s a m p l e d v a l u e = 0 . 2 5 * sum ( sum ( Hy ( i s −1: i s , j s , ks −1: k s ) ) ) ;
13 case ’ z ’
s a m p l e d v a l u e = 0 . 2 5 * sum ( sum ( Hz ( i s −1: i s , j s −1: j s , k s ) ) ) ;
15 c a s e ’m ’
s v x = 0 . 2 5 * sum ( sum ( Hx ( i s , j s −1: j s , ks −1: k s ) ) ) ;
17 s v y = 0 . 2 5 * sum ( sum ( Hy ( i s −1: i s , j s , ks −1: k s ) ) ) ;
s v z = 0 . 2 5 * sum ( sum ( Hz ( i s −1: i s , j s −1: j s , k s ) ) ) ;
19 sampled value = sqrt ( svx ˆ2 + svy ˆ2 + svz ˆ 2 ) ;
end
21 s a m p l e d m a g n e t i c f i e l d s ( ind ) . sampled value ( time step ) = . . .
sampled value ;
23 end
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
f o r i n d =1: n u m b e r o f s a m p l e d c u r r e n t s
4 i s = sampled currents ( ind ) . i s ;
j s = sampled currents ( ind ) . j s ;
6 ks = sampled currents ( ind ) . ks ;
i e = sampled currents ( ind ) . i e ;
8 j e = sampled currents ( ind ) . j e ;
ke = s a m p l e d c u r r e n t s ( i n d ) . ke ;
10
sw i t ch ( s a m p l e d c u r r e n t s ( i n d ) . d i r e c t i o n ( 1 ) )
12 case ’ x ’
sampled value = . . .
14 + dy * sum ( sum ( sum ( Hy ( i e −1 , j s : j e , ks − 1 ) ) ) ) . . .
+ dz * sum ( sum ( sum ( Hz ( i e −1 , j e , k s : ke ) ) ) ) . . .
16 − dy * sum ( sum ( sum ( Hy ( i e −1 , j s : j e , ke ) ) ) ) . . .
− dz * sum ( sum ( sum ( Hz ( i e −1 , j s −1 , k s : ke ) ) ) ) ;
18 case ’ y ’
sampled value = . . .
20 + dz * sum ( sum ( sum ( Hz ( i s −1 , j e −1 , k s : ke ) ) ) ) . . .
+ dx * sum ( sum ( sum ( Hx ( i s : i e , j e −1 , ke ) ) ) ) . . .
22 − dz * sum ( sum ( sum ( Hz ( i e , j e −1 , k s : ke ) ) ) ) . . .
− dx * sum ( sum ( sum ( Hx ( i s : i e , j e −1 , ks − 1 ) ) ) ) ;
24 case ’ z ’
sampled value = . . .
26 + dx * sum ( sum ( sum ( Hx ( i s : i e , j s −1 , ke − 1 ) ) ) ) . . .
+ dy * sum ( sum ( sum ( Hy ( i e , j s : j e , ke − 1 ) ) ) ) . . .
28 − dx * sum ( sum ( sum ( Hx ( i s : i e , j e , ke − 1 ) ) ) ) . . .
− dy * sum ( sum ( sum ( Hy ( i s −1 , j s : j e , ke − 1 ) ) ) ) ;
30 end
i f strcmp ( s a m p l e d c u r r e n t s ( ind ) . d i r e c t i o n ( 2 ) , ’ n ’ )
32 s a m p l e d v a l u e = −1 * s a m p l e d v a l u e ;
end
34 sampled currents ( ind ) . sampled value ( time step ) = sampled value ;
end
8 sw i t ch ( s a m p l e d e l e c t r i c f i e l d s ( i n d ) . component )
case ’ x ’
10 s a m p l e d v a l u e = 0 . 5 * sum ( E x ( i s −1: i s , j s , k s ) ) ;
case ’ y ’
12 s a m p l e d v a l u e = 0 . 5 * sum ( E y ( i s , j s −1: j s , k s ) ) ;
case ’ z ’
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
14 s a m p l e d v a l u e = 0 . 5 * sum ( E z ( i s , j s , ks −1: k s ) ) ;
c a s e ’m ’
16 s v x = 0 . 5 * sum ( E x ( i s −1: i s , j s , k s ) ) ;
s v y = 0 . 5 * sum ( E y ( i s , j s −1: j s , k s ) ) ;
18 s v z = 0 . 5 * sum ( E z ( i s , j s , ks −1: k s ) ) ;
sampled value = sqrt ( svx ˆ2 + svy ˆ2 + svz ˆ 2 ) ;
20 end
s a m p l e d e l e c t r i c f i e l d s ( ind ) . sampled value ( time step ) = sampled value ;
22 end
4.2.7.10 Capturing the Sampled Voltages The indices of the field components that are required
for calculating the voltage across a volume indicated by the nodes (is , j s , ks ) and (ie, j e, ke) are
determined in the subroutine initialize output parameters and are stored in the paramater field -
indices. Furthermore, another parameter Csvf is defined as a coefficient that would transform
the sum of the electric field components to a voltage value as discussed in Section 4.2.5. Then
a procedure for calculating the sampled voltages is implemented in the subroutine capture -
sampled voltages shown in Listing 4.27.
4.2.7.11 Displaying the Sampled Parameters After all fields are updated and the sampled param-
eters are captured, the sampled parameters defined for runtime display can be plotted using the
subroutine display sampled parameters, which is shown in Listing 4.28.
One should notice that in Listing 4.28 the instructions are executed once every plotting step
time steps. Then for each sampled parameter requiring display, the respective figure is activated
using the respective figure number. Then the sampled parameter is plotted from the first time
step to current time step using MATLAB’s plot function.
Finally, at the end of display sampled parameters another subroutine display animation is
called to display the fields captured on the predefined plane cuts.
3 f o r i n d =1: n u m b e r o f s a m p l e d v o l t a g e s
fi = sampled voltages ( ind ) . f i e l d i n d i c e s ;
5 C s v f = sampled voltages ( ind ) . C s v f ;
sw i t ch ( s a m p l e d v o l t a g e s ( i n d ) . d i r e c t i o n ( 1 ) )
7 case ’ x ’
s a m p l e d v a l u e = C s v f * sum ( E x ( f i ) ) ;
9 case ’ y ’
s a m p l e d v a l u e = C s v f * sum ( E y ( f i ) ) ;
11 case ’ z ’
s a m p l e d v a l u e = C s v f * sum ( E z ( f i ) ) ;
13 end
sampled voltages ( ind ) . sampled value ( time step ) = sampled value ;
15 end
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
i f mod ( t i m e s t e p , p l o t t i n g s t e p ) ˜= 0
4 return ;
end
6
r e m a i n i n g t i m e = ( n u m b e r o f t i m e s t e p s −t i m e s t e p ) . . .
8 * ( cputime−s t a r t t i m e ) / ( 6 0 * t i m e s t e p ) ;
d i s p ( [ num2str ( t i m e s t e p ) ’ o f ’ . . .
10 num2str ( n u m b e r o f t i m e s t e p s ) ’ i s c o m p l e t e d , ’ . . .
num2str ( r e m a i n i n g t i m e ) ’ m i n u t e s r e m a i n i n g ’ ] ) ;
12
% d i s p l a y sampled e l e c t r i c f i e l d s
14 for ind = 1: n u m b e r o f s a m p l e d e l e c t r i c f i e l d s
i f s a m p l e d e l e c t r i c f i e l d s ( i n d ) . d i s p l a y p l o t == t r u e
16 sampled time = . . .
s a m p l e d e l e c t r i c f i e l d s ( i n d ) . t i m e ( 1 : t i m e s t e p ) * 1 e9 ;
18 sampled value = . . .
s a m p l e d e l e c t r i c f i e l d s ( ind ) . sampled value ( 1 : time step ) ;
20 f i g u r e ( s a m p l e d e l e c t r i c f i e l d s ( ind ) . figure number ) ;
delete ( s a m p l e d e l e c t r i c f i e l d s ( ind ) . plot handle ) ;
22 s a m p l e d e l e c t r i c f i e l d s ( ind ) . plot handle = . . .
p l o t ( s a m p l e d t i m e , s a m p l e d v a l u e ( 1 : t i m e s t e p ) , ’ b− ’ , . . .
24 ’ linewidth ’ ,1.5);
drawnow ;
26 end
end
28
% d i s p l a y sampled m a g n e t i c f i e l d s
30 for ind = 1: number of sampled magnetic fields
i f s a m p l e d m a g n e t i c f i e l d s ( i n d ) . d i s p l a y p l o t == t r u e
32 sampled time = . . .
s a m p l e d m a g n e t i c f i e l d s ( i n d ) . t i m e ( 1 : t i m e s t e p ) * 1 e9 ;
34 sampled value = . . .
s a m p l e d m a g n e t i c f i e l d s ( ind ) . sampled value ( 1 : time step ) ;
36 f i g u r e ( s a m p l e d m a g n e t i c f i e l d s ( ind ) . figure number ) ;
delete ( s a m p l e d m a g n e t i c f i e l d s ( ind ) . p l o t handle ) ;
38 s a m p l e d m a g n e t i c f i e l d s ( ind ) . p l o t handle = . . .
p l o t ( s a m p l e d t i m e , s a m p l e d v a l u e ( 1 : t i m e s t e p ) , ’ b− ’ , . . .
40 ’ linewidth ’ ,1.5);
drawnow ;
42 end
end
44
% d i s p l a y sampled v o l t a g e s
46 for ind = 1: number of sampled voltages
i f s a m p l e d v o l t a g e s ( i n d ) . d i s p l a y p l o t == t r u e
48 sampled time = . . .
s a m p l e d v o l t a g e s ( i n d ) . t i m e ( 1 : t i m e s t e p ) * 1 e9 ;
50 sampled value = . . .
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
% d i s p l a y sampled c u r r e n t s
62 for ind = 1: number of sampled currents
i f s a m p l e d c u r r e n t s ( i n d ) . d i s p l a y p l o t == t r u e
64 sampled time = . . .
s a m p l e d c u r r e n t s ( i n d ) . t i m e ( 1 : t i m e s t e p ) * 1 e9 ;
66 sampled value = . . .
sampled currents ( ind ) . sampled value ( 1 : time step ) ;
68 f i g u r e ( sampled currents ( ind ) . figure number ) ;
delete ( sampled currents ( ind ) . plot handle ) ;
70 sampled currents ( ind ) . plot handle = . . .
p l o t ( s a m p l e d t i m e , s a m p l e d v a l u e ( 1 : t i m e s t e p ) , ’ b− ’ , . . .
72 ’ linewidth ’ ,1.5);
drawnow ;
74 end
end
76
78 % d i s p l a y animated f i e l d s
display animation ;
% f i g u r e s f o r sampled e l e c t r i c f i e l d s
4 f o r i n d =1: n u m b e r o f s a m p l e d e l e c t r i c f i e l d s
i f s a m p l e d e l e c t r i c f i e l d s ( i n d ) . d i s p l a y p l o t == f a l s e
6 s a m p l e d e l e c t r i c f i e l d s ( ind ) . figure number = f i g u r e ;
x l a b e l ( ’ time ( ns ) ’ , ’ f o n t s i z e ’ , 1 2 ) ;
8 y l a b e l ( ’ ( v o l t / meter ) ’ , ’ f o n t s i z e ’ , 1 2 ) ;
t i t l e ( [ ’ sampled e l e c t r i c f i e l d [ ’ . . .
10 num2str ( i n d ) ’ ] ’ ] , ’ f o n t s i z e ’ , 1 2 ) ;
g r i d on ; hold on ;
12 else
f i g u r e ( s a m p l e d e l e c t r i c f i e l d s ( ind ) . figure number ) ;
14 delete ( s a m p l e d e l e c t r i c f i e l d s ( ind ) . plot handle ) ;
end
16 sampled time = . . .
s a m p l e d e l e c t r i c f i e l d s ( i n d ) . t i m e ( 1 : t i m e s t e p ) * 1 e9 ;
18 sampled value = . . .
s a m p l e d e l e c t r i c f i e l d s ( ind ) . sampled value ( 1 : time step ) ;
20 p l o t ( s a m p l e d t i m e , s a m p l e d v a l u e ( 1 : t i m e s t e p ) , ’ b− ’ , . . .
’ linewidth ’ ,1.5);
22 drawnow ;
end
The partial implementation of display transient parameters is given in Listing 4.30. Listing
4.30 shows the instructions for plotting only the sampled electric field components. The other
parameters are plotted similarly. One can notice that, if a parameter has not been displayed during
the time-marching loop, a new figure is launched and initialized for it. Then the sampled data are
plotted.
% A f a c t o r t h a t determines d u r a t i o n of a time s t e p
7 % wrt CFL l i m i t
courant factor = 0.9;
9
% A f a c t o r d e t e r m i n i n g t h e a c c u r a c y l i m i t o f FDTD r e s u l t s
11 number of cells per wavelength = 20;
13 % D i m e n s i o n s o f a u n i t c e l l i n x , y , and z d i r e c t i o n s ( m e t e r s )
dx = 1.0 e −3;
15 dy = 1.0 e −3;
dz = 1.0 e −3;
17
% ==<b o u n d a r y c o n d i t i o n s >========
19 % Here we d e f i n e t h e b o u n d a r y c o n d i t i o n s p a r a m e t e r s
% ’ pec ’ : p e r f e c t e l e c t r i c c o n d u c t o r
21 b o u n d a r y . t y p e x p = ’ pec ’ ;
boundary . a i r b u f f e r n u m b e r o f c e l l s x p = 3 ;
52
% PEC : p e r f e c t e l e c t r i c c o n d u c t o r
54 material types ( 2 ) . eps r = 1;
m a t e r i a l t y p e s ( 2 ) . mu r = 1;
56 m a t e r i a l t y p e s ( 2 ) . s i g m a e = 1 e10 ;
m a t e r i a l t y p e s ( 2 ) . sigma m = 0 ;
58 material types ( 2 ) . color = [1 0 0];
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
% d e f i n e a PEC p l a t e
16 b r i c k s ( 2 ) . min x = 0 ;
b r i c k s ( 2 ) . min y = 0 ;
18 b r i c k s ( 2 ) . m i n z = 4e −3;
b r i c k s ( 2 ) . max x = 8e −3;
20 b r i c k s ( 2 ) . max y = 2e −3;
b r i c k s ( 2 ) . max z = 4e −3;
22 bricks ( 2 ) . material type = 2;
15 % voltage sources
% d i r e c t i o n : ’ xp ’ , ’ xn ’ , ’ yp ’ , ’ yn ’ , ’ zp ’ , o r ’ zn ’
17 % r e s i s t a n c e : ohms , m a g i t u d e : volts
v o l t a g e s o u r c e s ( 1 ) . min x = 0 ;
19 v o l t a g e s o u r c e s ( 1 ) . min y = 0 ;
v o l t a g e s o u r c e s ( 1 ) . min z = 0 ;
21 v o l t a g e s o u r c e s ( 1 ) . max x = 1 . 0 e −3;
v o l t a g e s o u r c e s ( 1 ) . max y = 2 . 0 e −3;
23 v o l t a g e s o u r c e s ( 1 ) . max z = 4 . 0 e −3;
v o l t a g e s o u r c e s ( 1 ) . d i r e c t i o n = ’ zp ’ ;
25 v o l t a g e s o u r c e s ( 1 ) . r e s i s t a n c e = 50;
v o l t a g e s o u r c e s ( 1 ) . magnitude = 1 ;
27 v o l t a g e s o u r c e s ( 1 ) . waveform type = ’ s i n u s o i d a l ’ ;
v o l t a g e s o u r c e s ( 1 ) . waveform index = 2;
29
% resistors
31 % direction : ’ x ’ , ’ y ’ , or ’ z ’
% resistance : ohms
33 resistors (1). m i n x = 7 . 0 e −3;
resistors (1). mi n y = 0 ;
35 resistors (1). min z = 0 ;
resistors (1). max x = 8 . 0 e −3;
37 resistors (1). max y = 2 . 0 e −3;
resistors (1). max z = 4 . 0 e −3;
39 resistors (1). direction = ’z ’ ;
resistors (1). r e s i s t a n c e = 50;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
11 % mode o f o p e r a t i o n
run simulation = true ;
13 show material mesh = true ;
show problem space = true ;
15
shows the outputs defined for this simulation. A sampled voltage is defined between the parallel
PEC plates. Furthermore, a sampled current is defined for the upper PEC plate.
Figure 4.15 shows the result of this simulation. Figure 4.15(a) shows a comparison of the source
voltage and the sampled voltage. As can be seen, the sampled voltage is half the source voltage
as expected. Furthermore, the sampled current shown in 4.15(b) confirms that the sum of the
resistances is 100 .
0.5
(volt)
−0.5
voltage source
sampled voltage
−1
0 1 2 3 4 5 6
time (ns)
(a) Source waveform and sampled voltage
0.01
0.008
0.006
0.004
0.002
(ampere)
−0.002
−0.004
−0.006
−0.008
sampled current
−0.01
0 1 2 3 4 5 6
time (ns)
(b) Sampled current
Figure 4.15 Sinusoidal voltage source waveform with 500 MHz frequency and sampled voltage and current.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
10
5
(volt)
−5
voltage source
−10 sampled voltage
0 1 2 3 4 5 6
time (ns)
(b) Source waveform and sampled voltage
Figure 4.16 Sinusoidal voltage source waveform with 500 MHz frequency and sampled voltage.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
15 % d e f i n e a PEC p l a t e
b r i c k s ( 2 ) . min x = 0 ;
17 b r i c k s ( 2 ) . mi n y = 0 ;
b r i c k s ( 2 ) . m i n z = 1e −3;
19 b r i c k s ( 2 ) . max x = 2e −3;
b r i c k s ( 2 ) . max y = 2e −3;
21 b r i c k s ( 2 ) . max z = 1e −3;
bricks ( 2 ) . material type = 2;
15 % voltage sources
% d i r e c t i o n : ’ xp ’ , ’ xn ’ , ’ yp ’ , ’ yn ’ , ’ zp ’ , o r ’ zn ’
17 % r e s i s t a n c e : ohms , m a g i t u d e : volts
v o l t a g e s o u r c e s ( 1 ) . min x = 0 ;
19 v o l t a g e s o u r c e s ( 1 ) . min y = 0 ;
v o l t a g e s o u r c e s ( 1 ) . min z = 0 ;
21 v o l t a g e s o u r c e s ( 1 ) . max x = 0 . 0 e −3;
v o l t a g e s o u r c e s ( 1 ) . max y = 2 . 0 e −3;
23 v o l t a g e s o u r c e s ( 1 ) . max z = 1 . 0 e −3;
v o l t a g e s o u r c e s ( 1 ) . d i r e c t i o n = ’ zp ’ ;
25 v o l t a g e s o u r c e s ( 1 ) . r e s i s t a n c e = 50;
v o l t a g e s o u r c e s ( 1 ) . magnitude = 10;
27 v o l t a g e s o u r c e s ( 1 ) . waveform type = ’ s i n u s o i d a l ’ ;
v o l t a g e s o u r c e s ( 1 ) . waveform index = 2;
29
% diodes
31 % d i r e c t i o n : ’ xp ’ , ’ xn ’ , ’ yp ’ , ’ yn ’ , ’ zp ’ , o r ’ zn ’
d i o d e s ( 1 ) . m i n x = 2 . 0 e −3;
33 d i o d e s ( 1 ) . m i n y = 1 . 0 e −3;
d i o d e s ( 1 ) . m i n z = 0 . 0 e −3;
35 d i o d e s ( 1 ) . max x = 2 . 0 e −3;
d i o d e s ( 1 ) . max y = 1 . 0 e −3;
37 d i o d e s ( 1 ) . max z = 1 . 0 e −3;
d i o d e s ( 1 ) . d i r e c t i o n = ’ zn ’ ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
11 % mode o f o p e r a t i o n
run simulation = true ;
13 show material mesh = true ;
show problem space = true ;
15
Figure 4.16(b) shows the result of this simulation, where the source voltage and the sampled
voltage are compared. As can be seen, the sampled voltage demonstrates the response of a diode;
when the source voltage is larger than 0.7 V, the sampled voltage on the diode is maintained as
0.7 V.
15 % d e f i n e a PEC p l a t e
b r i c k s ( 2 ) . min x = 0 ;
17 b r i c k s ( 2 ) . mi n y = 0 ;
b r i c k s ( 2 ) . m i n z = 1e −3;
19 b r i c k s ( 2 ) . max x = 1e −3;
b r i c k s ( 2 ) . max y = 1e −3;
21 b r i c k s ( 2 ) . max z = 1e −3;
bricks ( 2 ) . material type = 2;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Exercises 139
0.8
0.6
(volt)
0.4
0.2
sampled voltage
analytical solution
0
voltage source
0 1 2 3 4 5
time (ns)
(a) A voltage source terminated by (b) Sampled voltage and analytical solution
a capacitor
Figure 4.17 Unit step voltage source waveform and sampled voltage.
In Listing 4.38, two parallel PEC plates are defined 1 mm apart. A voltage source with 50
internal resistances is places at one end and a capacitor with 10 p F capacitance is placed at the
other end between these two plates as shown in Listing 4.39. A unit step waveform is assigned to
the voltage source. The unit step function is excited 50 time steps after the start of simulation.
Figure 4.17(b) shows the result of this simulation, where the sampled voltage across the capacitor
is compared with the analytical solution of the equivalent lumped circuit problem. A simple circuit
analysis reveals that the voltage across a capacitor excited by a unit step function can be calculated
from
t−t0
vC (t) = 1 − e − RC , (4.56)
where t0 is time delay, which is represented in this example by 50 time steps, and R is 50 .
4.4 EXERCISES
4.1 A stripline structure that has width/height ratio of 1.44 and an air substrate is forming
a transmission line with 50 characteristic impedance. Construct such a 50 stripline
structure, and keep all boundaries as PEC. The geometry and dimensions of such a stripline
is shown in Fig. 4.18 as a reference. Feed the stripline with a voltage source from one end,
and let the other end touch the problem space boundary. Capture the voltage on the stripline
around the center of the stripline. Show that if the voltage source is excited by a unit step
waveform with 1 volt magnitude, the sampled voltage will be a pulse with 0.5 volts.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
15 % voltage sources
% d i r e c t i o n : ’ xp ’ , ’ xn ’ , ’ yp ’ , ’ yn ’ , ’ zp ’ , o r ’ zn ’
17 % r e s i s t a n c e : ohms , m a g i t u d e : volts
v o l t a g e s o u r c e s ( 1 ) . min x = 0 ;
19 v o l t a g e s o u r c e s ( 1 ) . min y = 0 ;
v o l t a g e s o u r c e s ( 1 ) . min z = 0 ;
21 v o l t a g e s o u r c e s ( 1 ) . max x = 0 . 0 e −3;
v o l t a g e s o u r c e s ( 1 ) . max y = 1 . 0 e −3;
23 v o l t a g e s o u r c e s ( 1 ) . max z = 1 . 0 e −3;
v o l t a g e s o u r c e s ( 1 ) . d i r e c t i o n = ’ zp ’ ;
25 v o l t a g e s o u r c e s ( 1 ) . r e s i s t a n c e = 50;
v o l t a g e s o u r c e s ( 1 ) . magnitude = 1 ;
27 v o l t a g e s o u r c e s ( 1 ) . waveform type = ’ u n i t s t e p ’ ;
v o l t a g e s o u r c e s ( 1 ) . waveform index = 1;
29
% capacitors
31 % d i r e c t i o n : ’ x ’ , ’ y ’ , or ’ z ’
% capacitance : farads
33 c a p a c i t o r s ( 1 ) . m i n x = 1 . 0 e −3;
c a p a c i t o r s ( 1 ) . min y = 0 . 0 ;
35 c a p a c i t o r s ( 1 ) . min z = 0 . 0 ;
c a p a c i t o r s ( 1 ) . max x = 1 . 0 e −3;
37 c a p a c i t o r s ( 1 ) . max y = 1 . 0 e −3;
c a p a c i t o r s ( 1 ) . max z = 1 . 0 e −3;
39 capacitors ( 1 ) . direction = ’z ’ ;
c a p a c i t o r s ( 1 ) . c a p a c i t a n c e = 10 e −12;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Exercises 141
4.2 Consider the stripline in Exercise 4.1. Place a resistor with 50 between the end of stripline
and the problem space boundary as shown in Fig. 4.19. Show that with the same excitation,
the sampled voltage is going to be 0.5 volts unit step function.
4.3 Construct a problem space with the cell size as 1 mm on a side, boundaries as ‘pec’, and air
gap between the objects and boundaries as 5 cells on all sides. Connect a sinusoidal voltage
source with 5 internal resistance at one end between two parallel PEC plates. At the other
end place a 50 pF capacitor and a diode connected in series between the plates. The diode
is oriented in the positive z direction. The geometry of the circuit is illustrated in Fig. 4.20.
Run the simulation with the voltage source having 2 volts magnitude and 1 GHz frequency.
Capture the voltage across the capacitor. Run the same simulation using a circuit simulator,
and verify your simulation result.
4.4 Construct a problem space with the cell size as 1 mm on a side, boundaries as ‘pec’, and
air gap between the objects and boundaries as 5 cells on all sides. Connect a sinusoidal
voltage source with 10 internal resistance at one end between two parallel PEC plates.
At the other end place an inductor, a capacitor, and a resistor connected in series between
the plates. For these components use the values L = 10 nH, C = 253.3 pF, and R = 10 ,
respectively. At 100 MHz the series RLC circuit is in resonance. Excite the voltage source
with a sinusoidal waveform with 100 MHz frequency, and capture the voltage between
the plates approximately at the middle of the PEC plates. Show that the magnitude of the
captured voltage waveform is half the magnitude of the source waveform when it reaches
steady state. Repeat the same simulation with another frequency, and verify the magnitude
of the observed voltage by calculating the exact expected value.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
5
Source Waveforms
and Transformation from
Time Domain to Frequency Domain
143
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
finite duration of the waveform is going to add other frequency components to the spectrum. The
initial conditions for the sources are zero before the simulation is started in an FDTD simulation,
and the sources are active during the duration of simulation. Therefore, if a sinusoidal signal
(sin(2π t), 0 < t < 4) is used for a source its duration is finite as shown in Fig. 5.1(a).
The Fourier transform of a continuous time function x(t) is X(ω) given by
+∞
X(ω) = x(t)e − j ωt d t, (5.1)
−∞
The Fourier transform of the signal in Fig. 5.1(a) is a complex function, and its magnitude
is plotted in Fig. 5.1(b). The frequency spectrum of the signal in Fig. 5.1(a) covers a range of
frequencies while being maximum at 1 Hz, which is the frequency of the finite sinusoidal function.
If the simulation runs for a longer duration as shown in Fig. 5.2(a), the Fourier transform of the
waveform becomes more pronounced at 1 Hz as shown in Fig. 5.2(b). In Fig. 5.1(b) the ratio of
the highest harmonic to the main signal at 1 Hz is 0.53/2 ≡ −11.53dB, while in Fig. 5.2(b) this
ratio is 0.96/4 ≡ −12.39dB. In this case running the simulation twice as long in time reduced the
effect of the highest harmonic.
0.8
0.6
0.4
0.2
magnitude
−0.2
−0.4
−0.6
−0.8
−1
−2 0 2 4 6 8
time (s)
2.5
1.5
magnitude
0.5
0
−3 −2 −1 0 1 2 3
frequency (Hz)
Figure 5.1 (b) A sinusoidal waveform excited for 4 seconds: X (ω) magnitude.
0.8
0.6
0.4
0.2
magnitude
−0.2
−0.4
−0.6
−0.8
−1
−2 0 2 4 6 8 10
time (s)
4.5
3.5
3
magnitude
2.5
1.5
0.5
0
−3 −2 −1 0 1 2 3
frequency (Hz)
Figure 5.2 (b) A sinusoidal waveform excited for 8 seconds: X (ω) magnitude.
where τ is a parameter that determines the width of the Gaussian pulse both in the time domain
and the frequency domain. The Fourier transform of a Gaussian waveform is also a Gaussian
waveform, which can be expressed as a function of frequency as
√ τ 2 ω2
G(w) = τ π e − 4 . (5.4)
The highest frequency that is available out of an FDTD calculation can be determined by the
accuracy parameter number of cells per wavelength such that
c c
fmax = = , (5.5)
λmin nc s max
where c is the speed of light in free space, s max is the maximum of the cell dimensions (x, y, or
z), and λmin is the wavelength of the highest frequency in free space. Once the highest frequency
in the spectrum of the frequency domain Gaussian waveform is determined, it is possible to find
a τ that constructs the corresponding time-domain Gaussian waveform. Following is a procedure
that determines τ , so that one can construct the Gaussian waveform in the time domain before
the simulation starts with a good estimate of the highest frequency at which the simulation results
will be acceptable.
Consider the Gaussian waveform plotted in Fig. 5.3(a) and the magnitude of its Fourier trans-
form pair plotted in Fig. 5.3(b) using (5.4). The function (5.4) is real, and its phase vanishes; hence,
the phase of the Fourier transform is not plotted here. We consider the maximum valid frequency
of the Gaussian spectrum as the frequency where the magnitude of G(ω) is 10% of its maximum
0.9
0.8
0.7
0.6
magnitude
0.5
0.4
0.3
0.2
0.1
0
−8 −6 −4 −2 0 2 4 6 8
time (s)
Figure 5.3 (a) A Gaussian waveform and its Fourier transform: g (t).
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
max
2.5
2
magnitude
1.5
1
10% of max
0.5
fmax
0
−0.5 0 0.5
frequency (Hz)
Figure 5.3 (b) A Gaussian waveform and its Fourier transform: G (ω) magnitude.
0.9
0.8
0.7
0.6
magnitude
0.5
0.4
0.3
0.2
t
0
0.1
0
−2 0 2 4 6 8 10 12 14
time (s)
where t0 is the amount of time shift. We can find t0 as the time instant in (5.3) where g(t = 0) =
e −20 , which is a negligible value and is good for more than 16 digits of numerical accuracy. Solving
(5.8) with g(0) = e −20 we can find
√
t0 = 20τ ∼= 4.5τ. (5.9)
Using the time shift t0 , we obtain a Gaussian waveform as illustrated in Fig. 5.4, which can be
used as a source waveform in FDTD simulations to obtain acceptable results for frequencies up
to fmax .
The normalized derivative of a Gaussian waveform and its Fourier transform are illustrated in
Figs. 5.5(a) and 5.5(b), respectively. One can notice that the function in the frequency domain
vanishes at zero frequency. The form of the function suggests that there is a minimum frequency,
fmin , and a maximum frequency, fmax , that determine the bounds of the valid frequency spectrum
for an FDTD simulation considering 10% of the maximum as the limit. Having determined the
maximum usable frequency from the number of cells per wavelength and maximum cell size using
(5.5), one can find the parameter τ that sets G(ω) to 10% of its maximum value at fmax and
can use τ in (5.10) to construct a time-domain waveform for the FDTD simulation. However,
this procedure requires solution of a nonlinear equation and is not convenient. The equations
readily available for a Gaussian waveform can be used instead for convenience. For instance, τ
can be calculated using (5.7). Similar to the Gaussian waveform, the derivative of a Gaussian
waveform is also centered at time instant zero as it appears in (5.10) and as shown in Fig. 5.5(a).
Therefore, it also needs a time shift to have practically zero value at time instant zero; hence, it
can be written as
√
2e (t−t0 )2
g(t) = − (t − t0 )e − τ 2 . (5.12)
τ
The time shift value t0 can be obtained as well using the readily available equation (5.9).
0.8
0.6
0.4
0.2
magnitude
−0.2
−0.4
−0.6
−0.8
−1
−8 −6 −4 −2 0 2 4 6 8
time (s)
Figure 5.5 (a) Normalized derivative of a Gaussian waveform and its Fourier transform: g (t).
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
2.5
2
magnitude
1.5
1
10% of max 10% of max
0.5
f min f max
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8
frequency (Hz)
Figure 5.5 (b) Normalized derivative of a Gaussian waveform and its Fourier transform: G (ω) magnitude.
Then τ can be used in (5.13) to construct the intended waveform. However, we still need to apply
a time shift to the waveform such that initial value of the excitation is zero. We can use (5.9) to
find the required time shift value, t0 . Then the final equation for the cosine-modulated Gaussian
waveform takes the form
(t−t0 )2
g(t) = cos(ωc (t − t0 )) × e − τ2 . (5.16)
0.8
0.6
0.4
0.2
magnitude
−0.2
−0.4
−0.6
−0.8
−1
−8 −6 −4 −2 0 2 4 6 8
time (s)
Figure 5.6 (a) Cosine modulated Gaussian waveform and its Fourier transform: g (t).
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
0.9
0.8
0.7
0.6
magnitude
0.5
0.4
0.3
0.2
0.1 ∆f
0
−4 −3 −2 −1 0 1 2 3 4
frequency (Hz) fc
Figure 5.6 (b) Cosine modulated Gaussian waveform and its Fourier transform: G (ω) magnitude.
the same structure waveforms. For instance, in this listing two sinusoidal waveforms and two
Gaussian waveforms are defined. The Gaussian and the derivative of Gaussian waveforms have
the parameter number of cells per wavelength, which is the accuracy parameter nc described
in the previous section used to determine the maximum frequency of the spectrum of the Gaussian
waveform. If the number of cells per wavelength is assigned zero, then the number of cells -
per wavelength that is defined in the subroutine define problem space parameters will be used
as the default value.
The cosine-modulated Gaussian waveform has the parameter bandwidth, which specifies the
width of the frequency band f . One more parameter is modulation frequency, which is the
center frequency of the band, fc .
Once the waveform types are defined, the desired waveform type can be assigned to the sources
as illustrated in Listing 5.1. For instance, for the voltage source voltage sources(1) the parameter
waveform type is assigned the value ‘gaussian’, and the parameter waveform index is assigned
the value 2, indicating that the waveform waveforms.gaussian(2) is the waveform of the voltage
source.
The initialization of the waveforms is performed in the subroutine initialize waveforms, which
is called in initialize sources and lumped elements before the initialization of lumped sources as
discussed in Section 4.2.3. The implementation of initialize waveforms is extended to include
the Gaussian, derivative of Gaussian, and cosine-modulated Gaussian waveforms based on the
discussions in Section 5 as shown in Listing 5.2. After the waveforms are initialized, the constructed
waveforms are copied to appropriate subfields in the source structures in initialize sources and -
lumped elements.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
voltage sources = [ ] ;
4 current sources = [ ] ;
diodes = [ ] ;
6 resistors = [];
inductors = [ ] ;
8 capacitors = [ ] ;
10 % d e f i n e s o u r c e waveform t y p e s and p a r a m e t e r s
w a v e f o r m s . s i n u s o i d a l ( 1 ) . f r e q u e n c y = 1 e9 ;
12 w a v e f o r m s . s i n u s o i d a l ( 2 ) . f r e q u e n c y = 5 e8 ;
waveforms . u n i t s t e p ( 1 ) . s t a r t t i m e s t e p = 50;
14 waveforms . g a u s s i a n ( 1 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 0 ;
waveforms . g a u s s i a n ( 2 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 15;
16 waveforms . d e r i v a t i v e g a u s s i a n ( 1 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 20;
w a v e f o r m s . c o s i n e m o d u l a t e d g a u s s i a n ( 1 ) . b a n d w i d t h = 1 e9 ;
18 w a v e f o r m s . c o s i n e m o d u l a t e d g a u s s i a n ( 1 ) . m o d u l a t i o n f r e q u e n c y = 2 e9 ;
20 % voltage sources
% d i r e c t i o n : ’ xp ’ , ’ xn ’ , ’ yp ’ , ’ yn ’ , ’ zp ’ , o r ’ zn ’
22 % r e s i s t a n c e : ohms , m a g i t u d e : volts
v o l t a g e s o u r c e s ( 1 ) . min x = 0 ;
24 v o l t a g e s o u r c e s ( 1 ) . min y = 0 ;
v o l t a g e s o u r c e s ( 1 ) . min z = 0 ;
26 v o l t a g e s o u r c e s ( 1 ) . max x = 1 . 0 e −3;
v o l t a g e s o u r c e s ( 1 ) . max y = 2 . 0 e −3;
28 v o l t a g e s o u r c e s ( 1 ) . max z = 4 . 0 e −3;
v o l t a g e s o u r c e s ( 1 ) . d i r e c t i o n = ’ zp ’ ;
30 v o l t a g e s o u r c e s ( 1 ) . r e s i s t a n c e = 50;
v o l t a g e s o u r c e s ( 1 ) . magnitude = 1 ;
32 v o l t a g e s o u r c e s ( 1 ) . waveform type = ’ gaussian ’ ;
v o l t a g e s o u r c e s ( 1 ) . waveform index = 2;
In the previous sections, we discussed construction of different types of source waveforms for an
FDTD simulation. These waveforms are functions of time, and any primary output obtained from
an FDTD simulation is in the time domain. The input–output relationship is available in the time
domain after an FDTD simulation is completed. The input and output time functions can be
transformed to the frequency domain by the use of the Fourier transform to obtain the response
of the system in the case of time-harmonic excitations. The Fourier transform is an integration
applied to a continuous time function. In the FDTD method the values are sampled at discrete
time instants; therefore, the continuous time integration can be approximated by a discrete time
summation. The Fourier transform of a continuous time function x(t) is given as X(ω) using (5.1).
In FDTD the time function is sampled at a period t; therefore, the values x(nt) are known.
Then the Fourier transform (5.1) can be expressed for discrete samples x(nt) as
n=N
X(ω) = t
n=1 steps x(nt)e − j ωnt , (5.17)
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
3 % i n i t i a l i z e s i n u s o i d a l waveforms
i f i s f i e l d ( waveforms , ’ s i n u s o i d a l ’ )
5 f o r i n d =1: s i z e ( w a v e f o r m s . s i n u s o i d a l , 2 )
w a v e f o r m s . s i n u s o i d a l ( i n d ) . waveform = . . .
7 s i n ( 2 * pi * waveforms . s i n u s o i d a l ( ind ) . f r e q u e n c y * time ) ;
waveforms . s i n u s o i d a l ( ind ) . t 0 = 0 ;
9 end
end
11
% i n i t i a l i z e u n i t s t e p waveforms
13 i f i s f i e l d ( waveforms , ’ u n i t s t e p ’ )
f o r i n d =1: s i z e ( w a v e f o r m s . u n i t s t e p , 2 )
15 s t a r t i n d e x = waveforms . u n i t s t e p ( ind ) . s t a r t t i m e s t e p ;
w a v e f o r m s . u n i t s t e p ( i n d ) . waveform ( 1 : n u m b e r o f t i m e s t e p s ) = 1 ;
17 w a v e f o r m s . u n i t s t e p ( i n d ) . waveform ( 1 : s t a r t i n d e x −1) = 0 ;
waveforms . u n i t s t e p ( ind ) . t 0 = 0 ;
19 end
end
21
% i n i t i a l i z e G a u s s i a n waveforms
23 i f i s f i e l d ( waveforms , ’ g a u s s i a n ’ )
f o r i n d =1: s i z e ( w a v e f o r m s . g a u s s i a n , 2 )
25 i f w a v e f o r m s . g a u s s i a n ( i n d ) . n u m b e r o f c e l l s p e r w a v e l e n g t h == 0
nc = n u m b e r o f c e l l s p e r w a v e l e n g t h ;
27 else
nc = w a v e f o r m s . g a u s s i a n ( i n d ) . n u m b e r o f c e l l s p e r w a v e l e n g t h ;
29 end
w a v e f o r m s . g a u s s i a n ( i n d ) . maximum frequency = . . .
31 c / ( nc * max ( [ dx , dy , dz ] ) ) ;
t a u = ( nc * max ( [ dx , dy , dz ] ) ) / ( 2 * c ) ;
33 waveforms . g a u s s i a n ( ind ) . tau = tau ;
t 0 = 4 . 5 * waveforms . g a u s s i a n ( ind ) . tau ;
35 waveforms . g a u s s i a n ( ind ) . t 0 = t 0 ;
w a v e f o r m s . g a u s s i a n ( i n d ) . waveform = exp ( − ( ( t i m e − t 0 ) / t a u ) . ˆ 2 ) ;
37 end
end
39
% i n i t i a l i z e d e r i v a t i v e of G a u s s i a n waveforms
41 i f i s f i e l d ( waveforms , ’ d e r i v a t i v e g a u s s i a n ’ )
f o r i n d =1: s i z e ( w a v e f o r m s . d e r i v a t i v e g a u s s i a n , 2 )
43 wfrm = w a v e f o r m s . d e r i v a t i v e g a u s s i a n ( i n d ) ;
i f wfrm . n u m b e r o f c e l l s p e r w a v e l e n g t h == 0
45 nc = n u m b e r o f c e l l s p e r w a v e l e n g t h ;
else
47 nc = . . .
waveforms . d e r i v a t i v e g a u s s i a n ( ind ) . n u m b e r o f c e l l s p e r w a v e l e n g t h ;
49 end
w a v e f o r m s . d e r i v a t i v e g a u s s i a n ( i n d ) . maximum frequency = . . .
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
51 c / ( nc * max ( [ dx , dy , dz ] ) ) ;
t a u = ( nc * max ( [ dx , dy , dz ] ) ) / ( 2 * c ) ;
53 waveforms . d e r i v a t i v e g a u s s i a n ( ind ) . tau = tau ;
t 0 = 4 . 5 * waveforms . d e r i v a t i v e g a u s s i a n ( ind ) . tau ;
55 waveforms . d e r i v a t i v e g a u s s i a n ( ind ) . t 0 = t 0 ;
w a v e f o r m s . d e r i v a t i v e g a u s s i a n ( i n d ) . waveform = . . .
57 −( s q r t ( 2 * exp ( 1 ) ) / t a u ) * ( t i m e − t 0 ) . * exp ( − ( ( t i m e − t 0 ) / t a u ) . ˆ 2 ) ;
end
59 end
61 % i n i t i a l i z e c o s i n e modulated G a u s s i a n w a v e f o r m s
i f i s f i e l d ( waveforms , ’ c o s i n e m o d u l a t e d g a u s s i a n ’ )
63 f o r i n d =1: s i z e ( w a v e f o r m s . c o s i n e m o d u l a t e d g a u s s i a n , 2 )
frequency = . . .
65 waveforms . c o s i n e m o d u l a t e d g a u s s i a n ( ind ) . m o d u l a t i o n f r e q u e n c y ;
tau = 0 . 9 6 6 / waveforms . c o s i n e m o d u l a t e d g a u s s i a n ( ind ) . bandwidth ;
67 waveforms . c o s i n e m o d u l a t e d g a u s s i a n ( ind ) . tau = tau ;
t 0 = 4 . 5 * waveforms . c o s i n e m o d u l a t e d g a u s s i a n ( ind ) . tau ;
69 waveforms . c o s i n e m o d u l a t e d g a u s s i a n ( ind ) . t 0 = t 0 ;
w a v e f o r m s . c o s i n e m o d u l a t e d g a u s s i a n ( i n d ) . waveform = . . .
71 c o s ( 2 * p i * f r e q u e n c y * ( t i m e − t 0 ) ) . * exp ( − ( ( t i m e − t 0 ) / t a u ) . ˆ 2 ) ;
end
73 end
where Nsteps is the number of time steps. It is easy to implement a function based on (5.17)
that calculates the Fourier transform of the discrete samples x(nt) for a list of frequencies.
Implementation of such a function, time to frequency domain, is shown in Listing 5.3. This
function accepts a parameter x, which is an array of sampled time-domain values of a function.
The parameter frequency array includes list of frequencies for which the transform is to be
performed. The output parameter of the function X is an array including the transform at the
respective frequencies.
Another input parameter that needs consideration is time shift. As discussed in previous chap-
ters, the electric field-related values and magnetic field-related values are sampled at different time
instants during the FDTD time-marching scheme. There is a half time step duration in between,
and the function time to frequency domain accepts a value time shift to account for this time
shift in the Fourier transform. For electric field-related values (e.g., sampled voltages), time -
shift can take the value 0, whereas for the magnetic field-related values (e.g., sampled currents),
time shift can take the value -dt/2.
The function implementation given in Listing 5.3 is intended for an easy understanding of the
time-to-frequency-domain transform action, and is not necessarily the best or optimum algorithm
for this purpose. More efficient discrete Fourier transform implementations, such as fast Fourier
transforms (FFTs), can be used as well.
Similarly, the inverse Fourier transform can also be implemented. Consider a band-limited
frequency domain function X(ω) sampled at uniformly distributed discrete frequency points with
sampling period ω, where the sampling frequencies include zero and positive frequencies. Then
the inverse Fourier transform (5.2) can be expressed as
ω
x(t) = X(0) +
m=1
m=M−1
X(mω)e j ωt + X∗ (mω)e − j ωt , (5.18)
2π
where X∗ is the complex conjugate of X, X(0) is the value of X at zero frequency, and M is the
number of sampled frequency points. We have assumed that X includes the samples at zero and
positive frequencies. It is evident from (5.2) that the integration includes the negative frequencies
as well. However, for a causal time function, the Fourier transform at a negative frequency is the
complex conjugate of its positive-frequency counterpart. So, if the Fourier transform is known
for the positive frequencies, the transform at the negative frequencies can be obtained by the
conjugate. Therefore, (5.18) includes summation at the negative frequencies as well. Since the
zero frequency appears once, it is added to the discrete summation separately. Then a function
named as frequency to time domain is constructed based on (5.18) as shown in Listing 5.4.
So far we have discussed some source waveform types that can be used to excite an FDTD problem
space. We considered the relationship between the time- and frequency-domain representations
of the waveforms and provided equations that can be used to construct a temporal waveform
having specific frequency spectrum characteristics. Then we provided functions that perform
time-to-frequency-domain transformation, which can be used to obtain simulation results in the
frequency domain after an FDTD simulation is completed. In this section we provide examples
that utilize source waveforms and transformation functions.
Listing 5.6 initialize output parameters.m
8 % i n t i a l i z e f r e q u e n c y domain p a r a m e t e r s
frequency domain . f r e q u e n c i e s = [ frequency domain . s t a r t : ...
10 f r e q u e n c y d o m a i n . s t e p : f r e q u e n c y d o m a i n . end ] ;
frequency domain . number of frequencies = . . .
12 s i z e ( frequency domain . frequencies , 2 ) ;
5 % sampled e l e c t r i c f i e l d s i n f r e q u e n c y domain
f o r i n d =1: n u m b e r o f s a m p l e d e l e c t r i c f i e l d s
7 x = s a m p l e d e l e c t r i c f i e l d s ( ind ) . sampled value ;
t i m e s h i f t = 0;
9 [ X ] = t i m e t o f r e q u e n c y d o m a i n ( x , dt , f r e q u e n c y a r r a y , t i m e s h i f t ) ;
s a m p l e d e l e c t r i c f i e l d s ( ind ) . frequency domain value = X ;
11 s a m p l e d e l e c t r i c f i e l d s ( ind ) . f r e q u e n c i e s = f r e q u e n c y a r r a y ;
end
31
% sampled c u r r e n t s i n f r e q u e n c y domain
33 f o r i n d =1: n u m b e r o f s a m p l e d c u r r e n t s
x = sampled currents ( ind ) . sampled value ;
35 t i m e s h i f t = −d t / 2 ;
[ X ] = t i m e t o f r e q u e n c y d o m a i n ( x , dt , f r e q u e n c y a r r a y , t i m e s h i f t ) ;
37 sampled currents ( ind ) . frequency domain value = X ;
sampled currents ( ind ) . f r e q u e n c i e s = f r e q u e n c y a r r a y ;
39 end
41 % v o l t a g e s o u r c e s i n f r e q u e n c y domain
f o r i n d =1: n u m b e r o f v o l t a g e s o u r c e s
43 x = v o l t a g e s o u r c e s ( i n d ) . waveform ;
t i m e s h i f t = 0;
45 [ X ] = t i m e t o f r e q u e n c y d o m a i n ( x , dt , f r e q u e n c y a r r a y , t i m e s h i f t ) ;
v o l t a g e s o u r c e s ( ind ) . frequency domain value = X ;
47 v o l t a g e s o u r c e s ( ind ) . f r e q u e n c i e s = f r e q u e n c y a r r a y ;
end
17 % P e r f o r m t i m e t o f r e q u e n c y domain t r a n s f o r m
f r e q u e n c y a r r a y = [ 0 : 1 0 0 0 ] * 2 e6 ;
19 dt = t i m e a r r a y (2) − t i m e a r r a y ( 1 ) ;
G = t i m e t o f r e q u e n c y d o m a i n ( g , dt , f r e q u e n c y a r r a y , 0 ) ;
21
figure ( 2 ) ;
23 subplot ( 2 , 1 , 1 ) ;
p l o t ( f r e q u e n c y a r r a y * 1 e −9 , abs ( G ) , ’ b− ’ , ’ l i n e w i d t h ’ , 1 . 5 ) ;
25 t i t l e ( ’ G ( \ omega ) = F ( g ( t ) ) ’ , ’ f o n t s i z e ’ , 1 2 ) ;
x l a b e l ( ’ f r e q u e n c y ( GHz ) ’ , ’ f o n t s i z e ’ , 1 2 ) ;
27 y l a b e l ( ’ magnitude ’ , ’ f o n t s i z e ’ , 1 2 ) ;
s e t ( gca , ’ f o n t s i z e ’ , 1 2 ) ;
29 g r i d on ;
subplot ( 2 , 1 , 2 ) ;
31 p l o t ( f r e q u e n c y a r r a y * 1 e −9 , a n g l e ( G ) * 1 8 0 / pi , ’ r− ’ , ’ l i n e w i d t h ’ , 1 . 5 ) ;
x l a b e l ( ’ f r e q u e n c y ( GHz ) ’ , ’ f o n t s i z e ’ , 1 2 ) ;
33 y l a b e l ( ’ phase ( d e g r e e s ) ’ , ’ f o n t s i z e ’ , 1 2 ) ;
s e t ( gca , ’ f o n t s i z e ’ , 1 2 ) ;
35 g r i d on ;
drawnow ;
37
% P e r f o r m f r e q u e n c y t o t i m e domain t r a n s f o r m
39 df = f r e q u e n c y a r r a y (2) − f r e q u e n c y a r r a y ( 1 ) ;
g2 = f r e q u e n c y t o t i m e d o m a i n ( G , df , t i m e a r r a y ) ;
41
figure ( 3 ) ;
43 p l o t ( t i m e a r r a y * 1 e9 , abs ( g2 ) , ’ b− ’ , ’ l i n e w i d t h ’ , 1 . 5 ) ;
t i t l e ( ’ g ( t )= F ˆ{ −1}( G ( \ omega ) ) ’ , ’ f o n t s i z e ’ , 1 4 ) ;
45 x l a b e l ( ’ time ( ns ) ’ , ’ f o n t s i z e ’ , 1 2 ) ;
y l a b e l ( ’ magnitude ’ , ’ f o n t s i z e ’ , 1 2 ) ;
47 s e t ( gca , ’ f o n t s i z e ’ , 1 2 ) ;
g r i d on ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
First, a Gaussian waveform, g(t), for which the frequency spectrum is 1 GHz wide, is constructed
and is time shifted as shown in Fig. 5.7(a). The Fourier transform of g(t) is obtained as G(ω), as
plotted in Fig. 5.7(b), using time to frequency domain. One should notice that the value of G(ω)
is 10% of the maximum at 1 GHz. Furthermore, the phase vanishes for the Fourier transform of a
time-domain Gaussian waveform having its center at time instant zero. However, the phase shown
in Fig. 5.7(b) is nonzero. This is due to the time shift introduced to the Gaussian waveform in the
time domain. Finally, the time-domain Gaussian waveform is reconstructed from G(ω) using the
function frequency to time domain and is plotted in Fig. 5.7(c).
0.9
0.8
0.7
0.6
magnitude
2
0.5 g(t)=e−((t−t0)/τ)
0.4
0.3
0.2
0.1
0
0 2 4 6 8 10
time (ns)
Figure 5.7 (a) A Gaussian waveform and its Fourier transform: g (t).
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
−9
x 10 G(ω) = F(g(t))
1
magnitude
0.5
0
0 0.5 1 1.5 2
frequency (GHz)
200
phase (degrees)
100
−100
−200
0 0.5 1 1.5 2
frequency (GHz)
Figure 5.7 (b) A Gaussian waveform and its Fourier transform: G (ω).
0.9
0.8
0.7
0.6
magnitude
0.3
0.2
0.1
0
0 2 4 6 8 10
time (ns)
Figure 5.7 (c) A Gaussian waveform and its Fourier transform: g (t) recovered from G (ω).
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Rs=50Ω C=10pF
Vo
Vs L=10nH
3 bricks = [ ] ;
spheres = [ ] ;
5
% d e f i n e a PEC p l a t e
7 b r i c k s ( 1 ) . min x = 0 ;
b r i c k s ( 1 ) . min y = 0 ;
9 b r i c k s ( 1 ) . min z = 0 ;
b r i c k s ( 1 ) . max x = 1e −3;
11 b r i c k s ( 1 ) . max y = 1e −3;
b r i c k s ( 1 ) . max z = 0 ;
13 bricks ( 1 ) . material type = 2;
15 % d e f i n e a PEC p l a t e
b r i c k s ( 2 ) . min x = 0 ;
17 b r i c k s ( 2 ) . mi n y = 0 ;
b r i c k s ( 2 ) . m i n z = 2e −3;
19 b r i c k s ( 2 ) . max x = 1e −3;
b r i c k s ( 2 ) . max y = 1e −3;
21 b r i c k s ( 2 ) . max z = 2e −3;
bricks ( 2 ) . material type = 2;
3 voltage sources = [ ] ;
current sources = [ ] ;
5 diodes = [ ] ;
resistors = [];
7 inductors = [ ] ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
capacitors = [ ] ;
9
% d e f i n e s o u r c e waveform t y p e s and p a r a m e t e r s
11 w a v e f o r m s . s i n u s o i d a l ( 1 ) . f r e q u e n c y = 1 e9 ;
w a v e f o r m s . s i n u s o i d a l ( 2 ) . f r e q u e n c y = 5 e8 ;
13 waveforms . u n i t s t e p ( 1 ) . s t a r t t i m e s t e p = 50;
waveforms . g a u s s i a n ( 1 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 0 ;
15 waveforms . g a u s s i a n ( 2 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 15;
waveforms . d e r i v a t i v e g a u s s i a n ( 1 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 20;
17 w a v e f o r m s . c o s i n e m o d u l a t e d g a u s s i a n ( 1 ) . b a n d w i d t h = 4 e9 ;
w a v e f o r m s . c o s i n e m o d u l a t e d g a u s s i a n ( 1 ) . m o d u l a t i o n f r e q u e n c y = 2 e9 ;
19
% voltage sources
21 % d i r e c t i o n : ’ xp ’ , ’ xn ’ , ’ yp ’ , ’ yn ’ , ’ zp ’ , o r ’ zn ’
% r e s i s t a n c e : ohms , m a g i t u d e : volts
23 v o l t a g e s o u r c e s ( 1 ) . min x = 0 ;
v o l t a g e s o u r c e s ( 1 ) . min y = 0 ;
25 v o l t a g e s o u r c e s ( 1 ) . min z = 0 ;
v o l t a g e s o u r c e s ( 1 ) . max x = 0 ;
27 v o l t a g e s o u r c e s ( 1 ) . max y = 1 . 0 e −3;
v o l t a g e s o u r c e s ( 1 ) . max z = 2 . 0 e −3;
29 v o l t a g e s o u r c e s ( 1 ) . d i r e c t i o n = ’ zp ’ ;
v o l t a g e s o u r c e s ( 1 ) . r e s i s t a n c e = 50;
31 v o l t a g e s o u r c e s ( 1 ) . magnitude = 1 ;
v o l t a g e s o u r c e s ( 1 ) . waveform type = ’ cosine modulated gaussian ’ ;
33 v o l t a g e s o u r c e s ( 1 ) . waveform index = 1;
35 % inductors
% direction : ’ x ’ , ’ y ’ , or ’ z ’
37 % inductance : henrys
inductors ( 1 ) . m i n x = 1 . 0 e −3;
39 inductors ( 1 ) . min y = 0 . 0 ;
inductors ( 1 ) . min z = 0 . 0 ;
41 inductors ( 1 ) . max x = 1 . 0 e −3;
inductors ( 1 ) . max y = 1 . 0 e −3;
43 inductors ( 1 ) . max z = 1 . 0 e −3;
inductors ( 1 ) . direction = ’z ’ ;
45 inductors ( 1 ) . i n d u c t a n c e = 10 e −9;
47 % capacitors
% d i r e c t i o n : ’ x ’ , ’ y ’ , or ’ z ’
49 % capacitance : farads
c a p a c i t o r s ( 1 ) . m i n x = 1 . 0 e −3;
51 c a p a c i t o r s ( 1 ) . min y = 0 . 0 ;
c a p a c i t o r s ( 1 ) . m i n z = 1 . 0 e −3;
53 c a p a c i t o r s ( 1 ) . max x = 1 . 0 e −3;
c a p a c i t o r s ( 1 ) . max y = 1 . 0 e −3;
55 c a p a c i t o r s ( 1 ) . max z = 2 . 0 e −3;
capacitors ( 1 ) . direction = ’ z ’ ;
57 c a p a c i t o r s ( 1 ) . c a p a c i t a n c e = 10 e −12;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
11 % mode o f o p e r a t i o n
run simulation = true ;
13 show material mesh = true ;
show problem space = true ;
15
% f r e q u e n c y domain p a r a m e t e r s
17 f r e q u e n c y d o m a i n . s t a r t = 2 e7 ;
f r e q u e n c y d o m a i n . end = 4 e9 ;
19 f r e q u e n c y d o m a i n . s t e p = 2 e7 ;
Figure 5.9 shows the time-domain results of this simulation; Vo is compared with the source
waveform, Vs . The frequency-domain counterparts of these waveforms are calculated using
time to frequency domain and are plotted in Fig. 5.10. We can find the transfer function of this
circuit by normalizing the output voltage Vo to Vs . Furthermore, we can perform a circuit analysis
to find the transfer function of the equivalent circuit in Fig. 5.8(b), which yields
Vo (ω) s 2 LC + 1
T(ω) = = 2 , (5.19)
Vs (ω) s LC + s RC + 1
where s = j ω. The transfer function obtained from the FDTD simulation and the exact equation
(5.19) are compared as shown in Fig. 5.11. These two results agree with each other very well at low
frequencies; however, there is a deviation at high frequencies. One of the reasons for the difference
is that the two circuits in Figs. 5.8(a) and 5.8(b) are not exactly the same. For instance, the parallel
plates introduce a capacitance, and the overall circuit is a loop and introduces an inductance in
Fig. 5.8(a). However, these additional effects are not accounted for in the lumped circuit in Fig.
5.8(b). Therefore, an electromagnetic simulation including lumped element components should
account for the additional effects due to the physical structure of the circuit to obtain more accurate
data at higher frequencies.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
1
voltage source
0.8 sampled voltage
0.6
0.4
(volt)
0.2
−0.2
−0.4
−0.6
0 0.5 1 1.5 2 2.5 3 3.5
time (ns)
5.5 EXERCISES
5.1 Consider the stripline structure that you constructed in Exercise 4.2. Define a Gaussian
source waveform, assign it to the voltage source and run the FDTD simulation. By the time
the simulation is completed, the sampled voltage and current will be captured, transformed
to frequency domain, and stored in the frequency domain value field of the parameters
sampled voltages(i) and sampled currents(i). Input impedance of this stripline can be
−10
x 10
4
magnitude
0
0 1 2 3 4
frequency (GHz)
phase (degrees)
200
−200
0 1 2 3 4
frequency (GHz)
Figure 5.10 (a) Frequency-domain response of source waveform V s and output voltage V o : Fourier transform
of V s .
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Exercises 167
−10
x 10
1.5
magnitude 1
0.5
0
0 0.5 1 1.5 2 2.5 3 3.5 4
frequency (GHz)
200
phase (degrees)
100
−100
−200
0 0.5 1 1.5 2 2.5 3 3.5 4
frequency (GHz)
Figure 5.10 (b) Frequency-domain response of source waveform V s and output voltage V o : Fourier transform
of V o .
1.4
|Vo/Vs| simulated
1.2 |Vo/Vs| exact
1
magnitude
0.8
0.6
0.4
0.2
0
0 0.5 1 1.5 2 2.5 3 3.5 4
frequency (GHz)
calculated using these sampled voltage and current arrays in the frequency domain. Since
the stripline characteristic impedance is expected to be 50 and the stripline is terminated
by a 50 resistor, the input impedance shall be 50 as well. Calculate and plot the input
impedance for a wide frequency band, and verify that the input impedance is close to 50 .
5.2 Consider the simulation you performed in Exercise 5.1. When you examine the sampled
transient voltage you will observe a Gaussian waveform generated by the voltage source
followed by some reflections due to the imperfect termination of the 50 resistor. If
your stripline structure is long enough and the Gaussian waveform is narrow enough, the
Gaussian waveform and reflections should not overlap. Determine from the transient voltage
a number of time steps that would be used to run the FDTD simulations such that the
simulation would end before the reflections are captured and only the Gaussian waveform
would be observed as the sampled transient voltage. This way you would be simulating an
infinitely long stripline structure. Therefore, when you calculate the input impedance, you
would actually be calculating the characteristic impedance of the stripline. Rerun the FDTD
simulation with the time step you have determined as discussed, calculate and plot the input
impedance for a wide frequency band, and verify that the characteristic impedance of the
stripline is 50 .
5.3 Consider the circuit in Exercise 4.4. Set the waveform of the voltage source as the Gaussian
waveform, and define a sampled current to capture the current flowing through the circuit.
Rerun the FDTD simulation, calculate and plot the input impedance for a wide frequency
band, and verify that the circuit resonates at 100 MHz. Note that you may need to run the
simulation for a large number of time steps since it will take a long time for the low-frequency
components in the Gaussian waveform to decay.
5.4 Consider Exercise 5.3. Now set the waveform of the voltage-source derivative of the Gaussian
waveform. Rerun the FDTD simulation, calculate and plot the input impedance for a wide
frequency band, and verify that the circuit resonates at 100 MHz. Note that with the
derivative of the Gaussian waveform you should be able to obtain the results with a much
smaller number of time steps compared with the amount of steps used in Exercise 5.3 since
the derivative of the Gaussian waveform does not include zero frequency and since very
low-frequency components are negligible.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
6
Scattering Parameters
S-parameters are based on the power waves concept. The incident and reflected power waves a i
and b i associated with port i are defined as
Vi + Zi × Ii Vi − Zi∗ × Ii
ai = √ , bi = √ , (6.1)
2 |Re{Zi }| 2 |Re{Zi }|
where Vi , and Ii are the voltage and the current flowing into the i th port of a junction and Zi
is the impedance looking out from the i th port as illustrated in Fig. 6.1 [13]. In general, Zi is
complex; however, in most of the microwaves applications it is real and equal to 50 . Then the
S-parameters matrix can be expressed as
⎡ ⎤ ⎡ ⎤ ⎡ ⎤
b1 S11 S12 · · · S1N a1
⎢ b 2 ⎥ ⎢ S21 S22 · · · S2N ⎥ ⎢ a2 ⎥
⎢ ⎥ ⎢ ⎥ ⎢ ⎥
⎢ .. ⎥ = ⎢ .. .. .. . ⎥ × ⎢ . ⎥. (6.2)
⎣ . ⎦ ⎣ . . . .. ⎦ ⎣ .. ⎦
bN SN1 SN2 · · · SNN aN
By definition, the subscripts mn indicate output port number, m, and input port number, n, of
the scattering parameter Smn . If only the port n is excited while all other ports are terminated by
matched loads, the output power wave at port m, b m , and the input power wave at port n, a n , can
be used to calculate Smn using
bm
Smn = . (6.3)
an
This technique can be applied to FDTD simulation results to obtain S-parameters for an input port
n. A multiport circuit can be constructed in an FDTD problem space where all ports are terminated
by matching loads and only the reference port n is excited by a source. Then sampled voltages
and currents can be captured at all ports during the FDTD time-marching loop. S-parameters
169
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
I1 I2
a1 + + a2
N-port circuit V2 b
b1 _V1 _ 2
Z1 Z2
IN
+VN _ ZN
bN
aN
are frequency-domain outputs of a network. After the FDTD iterations are completed, the sampled
voltages and currents can be transformed to the frequency domain using the algorithms described
in Chapter 5. Then the frequency-domain sampled voltages and currents can be used in (6.1) to
obtain incident and reflected power waves, a i and b i , from which the S-parameters can be obtained
for the reference port using (6.3). One should keep in mind that in an FDTD simulation only one
of the ports can be excited. Therefore, to obtain a complete set of S-parameters for all of the port
excitations in the circuit, more than one FDTD run may be required depending on the type and
symmetry conditions of the problem.
The S-parameters are complex quantities, as they are obtained using (6.3). Generally S-
parameters are plotted by their magnitudes in decibels such that |Smn |d B = 20 log10 (|Smn |) and
by their phases.
Figure 6.2 (a) A microstrip low-pass filter terminated by a voltage source and a resistor on two ends: three-
dimensional view.
We associate a sampled voltage and sampled current pair to a port, and thus we have two
ports. In Listing 6.2 a new parameter ports is defined and initialized as an empty array. At the
end of the listing the sampled voltages and currents are associated to ports through their indices.
For instance, the subfield sampled voltage index of ports(2) is assigned the value 2, implying
that sampled voltages(2) is the sampled voltage associated to the second port. The subfield
impedance is assigned the impedance of the respective port, which is supposed to be equal to
the microstrip-line characteristic impedance and the resistance of the voltage source and resistor
Figure 6.2 (b) A microstrip low-pass filter terminated by a voltage source and a resistor on two ends: dimensions.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
3 bricks = [ ] ;
spheres = [ ] ;
5
% define a substrate
7 b r i c k s ( 1 ) . min x = 0 ;
b r i c k s ( 1 ) . mi n y = 0 ;
9 b r i c k s ( 1 ) . min z = 0 ;
b r i c k s ( 1 ) . max x = 50 * dx ;
11 b r i c k s ( 1 ) . max y = 46 * dy ;
b r i c k s ( 1 ) . max z = 3 * dz ;
13 bricks ( 1 ) . material type = 4;
15 % d e f i n e a PEC p l a t e
b r i c k s ( 2 ) . m i n x = 14 * dx ;
17 b r i c k s ( 2 ) . mi n y = 0 ;
b r i c k s ( 2 ) . m i n z = 3 * dz ;
19 b r i c k s ( 2 ) . max x = 20 * dx ;
b r i c k s ( 2 ) . max y = 20 * dy ;
21 b r i c k s ( 2 ) . max z = 3 * dz ;
bricks ( 2 ) . material type = 2;
23
% d e f i n e a PEC p l a t e
25 b r i c k s ( 3 ) . m i n x = 30 * dx ;
b r i c k s ( 3 ) . mi n y = 26 * dy ;
27 b r i c k s ( 3 ) . m i n z = 3 * dz ;
b r i c k s ( 3 ) . max x = 36 * dx ;
29 b r i c k s ( 3 ) . max y = 46 * dy ;
b r i c k s ( 3 ) . max z = 3 * dz ;
31 bricks ( 3 ) . material type = 2;
33 % d e f i n e a PEC p l a t e
b r i c k s ( 4 ) . min x = 0 ;
35 b r i c k s ( 4 ) . mi n y = 20 * dy ;
b r i c k s ( 4 ) . m i n z = 3 * dz ;
37 b r i c k s ( 4 ) . max x = 50 * dx ;
b r i c k s ( 4 ) . max y = 26 * dy ;
39 b r i c k s ( 4 ) . max z = 3 * dz ;
bricks ( 4 ) . material type = 2;
41
% d e f i n e a PEC p l a t e a s ground
43 b r i c k s ( 5 ) . min x = 0 ;
b r i c k s ( 5 ) . mi n y = 0 ;
45 b r i c k s ( 5 ) . min z = 0 ;
b r i c k s ( 5 ) . max x = 50 * dx ;
47 b r i c k s ( 5 ) . max y = 46 * dy ;
b r i c k s ( 5 ) . max z = 0 ;
49 bricks ( 5 ) . material type = 2;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
% mode o f o p e r a t i o n
13 run simulation = true ;
show material mesh = true ;
15 show problem space = true ;
17 % f r e q u e n c y domain p a r a m e t e r s
f r e q u e n c y d o m a i n . s t a r t = 20 e6 ;
19 f r e q u e n c y d o m a i n . end = 20 e9 ;
f r e q u e n c y d o m a i n . s t e p = 20 e6 ;
21
% define ports
61 ports ( 1 ) . sampled voltage index = 1;
ports ( 1 ) . sampled current index = 1;
63 ports ( 1 ) . impedance = 5 0 ;
ports ( 1 ) . is source port = true ;
65
terminating the microstrip line. One additional subfield of ports is is source port, which indicates
whether the port is the source port or not. In this two ports example the first port is the excitation
port due to the voltage source; therefore, ports(1).is source port is assigned the value true
whereas for the second port ports(2).is source port is false.
One should notice that the direction of the second sampled current sampled currents(2).-
direction is toward the negative x direction as xn. The reference currents are defined as flow-
ing into the circuit for the purpose of calculating the network parameters, as can be seen in
Fig. 6.1.
Furthermore, one should notice that we can compute only the set of S-parameters (S11 and S21 )
for which the first port is the excitation port. The other set of S-parameters (S12 and S22 ) can be
obtained from (S11 and S21 ) due to the symmetry in the structure. If the structure is not symmetric,
we should assign the voltage source to the second port location and repeat the simulation. Another
approach for obtaining all S-parameters is that, instead of defining a single source, sources can
be defined at every port separately, each having internal impedance equal to the port impedance.
Then the FDTD simulations can be repeated in a loop a number of times equals the number
of ports, where each time one of the ports is set as the excitation port. Each time, the sources
associated with the excitation port are activated while other sources are deactivated. The inactive
sources will not generate power and serve only as passive terminations. Each time, the S-parameter
set for the excitation port as the input can be calculated and stored.
Listing 6.2 illustrates how we can define the ports. The only initialization required for the
ports is the determination of the number of ports in initialize output parameters as illustrated in
Listing 6.3. After the FDTD time-marching loop is completed, the S-parameters are calculated in
calculate frequency domain outputs after frequency-domain transformation of sampled voltages
and currents as shown in Listing 6.4. First, the incident and reflected power waves are calculated
for every port using (6.1). Then the S-parameters are calculated for the active port using (6.3).
The calculated S-parameters are plotted as the last step in display frequency domain outputs, as
shown in Listing 6.5.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
% c a l c u l a t e t h e S−p a r a m e t e r s
73 f o r i n d =1: n u m b e r o f p o r t s
i f p o r t s ( i n d ) . i s s o u r c e p o r t == t r u e
75 f o r o i n d =1: n u m b e r o f p o r t s
p o r t s ( ind ) . S ( oind ) . v a l u e s = p o r t s ( oind ) . b . / p o r t s ( ind ) . a ;
77 end
end
79 end
subplot ( 2 , 1 , 2 ) ;
133 p l o t ( f r e q u e n c i e s , S p h a s e , ’ r− ’ , ’ l i n e w i d t h ’ , 1 . 5 ) ;
x l a b e l ( ’ f r e q u e n c y ( GHz ) ’ , ’ f o n t s i z e ’ , 1 2 ) ;
135 y l a b e l ( ’ phase ( d e g r e e s ) ’ , ’ f o n t s i z e ’ , 1 2 ) ;
g r i d on ;
137 drawnow ;
end
139 end
end
The sample circuit in Fig. 6.1 is run for 20,000 time steps, and the S-parameters of the circuit are
obtained at the reference planes 10 cells away from the terminations where the ports are defined.
Although the reference planes for the S-parameters are defined away from the terminations, it is
possible to define the planes at the terminations. It is sufficient to place the sampled voltages and
currents on the terminations.
Figure 6.3(a) shows the calculated S11 up to 20 GHz, and Fig. 6.3(b) shows the calculated S21 .
It can be seen that the circuit acts as a low-pass filter where the pass band is up to 5.5 GHz.
Comparing the results in Figs. 6.3 with the ones published in [14] it is evident that there are
differences between the sets of results: some spikes appear in Figs. 6.3. This is because of the
PEC boundaries, which make the FDTD simulation space into a cavity that resonates at certain
frequencies. Figure 6.4 shows the sampled voltage captured at the second port of this microstrip
filter. One can notice that, although the simulation is performed in 20,000 time steps, which
10
S11
−10
magnitude (dB)
−20
−30
−40
−50
0 5 10 15 20
frequency (GHz)
10
S21
−10
magnitude (dB)
−20
−30
−40
−50
0 5 10 15 20
frequency (GHz)
0.25
sampled voltage at port 2
0.2
0.15
0.1
(volt)
0.05
−0.05
−0.1
0 2 4 6 8 10 12
time (ns)
Figure 6.4 Sampled voltage at the second port of the microstrip low-pass filter.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
0.25
sampled voltage at port 2
0.2
0.15
0.1
(volt)
0.05
−0.05
−0.1
0 2 4 6 8 10 12
time (ns)
Figure 6.5 Sampled voltage at the second port of the microstrip low-pass filter with σ e = 0.2.
is a large number of time steps for this problem, the transient response still did not damp out.
This behavior exposes itself as spikes (numerical errors) in the S-parameter plots at different
frequencies as shown in Figs. 6.3. If the filter has slight loss, the attenuation will improve the
numerical errors, as the time-domain response will be diminishing (as shown in Fig. 6.5) for the
filter lossy dielectric substrate. Therefore, the truncation at a diminishing time-domain waveform
will not cause significant errors even though the cavity modes of the PEC closed box still exist.
This is clearly shown in Figs. 6.6(a) and 6.6(b). If the simulation had been performed such that
boundaries simulate open space, the simulation time would take less and the S-parameters results
would be clear of these spikes. Chapters 7 and 8 discuss algorithms that simulate open boundaries
for FDTD simulations.
10
S11
−10
magnitude (dB)
−20
−30
−40
−50
0 5 10 15 20
frequency (GHz)
Figure 6.6 (a) S-parameters of the microstrip low-pass filter with σ e = 0.2: S 11 .
10
S21
−10
magnitude (dB)
−20
−30
−40
−50
0 5 10 15 20
frequency (GHz)
Figure 6.6 (b) S-parameters of the microstrip low-pass filter with σ e = 0.2: S 21 .
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
RL=100 Ω Absorber
Sampled voltage 2
Sampled current 2
z
y
x
Absorbers
Voltage source
Sampled voltage 1
Sampled current 1 4 mm 10 mm 4 mm
10 mm
1 mm 0.4 mm
1.8 mm
Figure 6.7 The geometry and dimensions of a microstrip quarter-wave transformer matching a 100 line to
50 line.
index of the material type of the absorber is 5. The relative permittivity and permeabilty of this
absorber is 1, the electric conductivity is 1, and the magnetic conductivity is 142,130, which is the
square of the intrinsic impedance of free space. The air gap between the objects and boundaries is
zero on all sides. The bottom boundary serves as the ground of the microstrip circuit, while the
other five sides are surrounded by the absorber material. The definition of the relevant problem
space parameters and geometry are shown in Listing 6.6. The definition of the voltage source and
the resistor are shown in Listing 6.7. In the previous example, the sampled voltages and sampled
currents are defined on the microstrip lines away from the voltage source and the terminating
resistor. In this example the sampled voltages and sampled currents are defined on the voltage
source and the terminating resistor. Then the sampled voltages and currents are assigned to ports.
The definition of the output parameters is shown in Listing 6.8.
The FDTD simulation is run for 5,000 time steps, and the S-parameters of the simulation are
plotted in Fig. 6.8. The plotted S11 indicates that a good match has been obtained at 4 GHz.
Furthermore, the results are free of spikes, indicating that the absorbers used in the simulation
suppressed the cavity resonances. However, one should keep in mind that although the use of
absorbers improves the FDTD simulation results, it may introduce some other undesired errors
to the simulation results. In the following chapters, more advanced absorbing boundaries are
discussed that minimize these errors.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
magnitude (dB)
S11
−20
−40
0 1 2 3 4 5 6 7 8
frequency (GHz)
0
magnitude (dB)
S21
−0.5
−1
−1.5
0 1 2 3 4 5 6 7 8
frequency (GHz)
bricks = [ ] ;
4 spheres = [ ] ;
42 % d e f i n e a b s o r b e r f o r zp s i d e
b r i c k s ( 5 ) . m i n x = −1e −3;
44 b r i c k s ( 5 ) . mi n y = −2e −3;
b r i c k s ( 5 ) . m i n z = 3e −3;
46 b r i c k s ( 5 ) . max x = 11 e −3;
b r i c k s ( 5 ) . max y = 20 e −3;
48 b r i c k s ( 5 ) . max z = 4e −3;
bricks ( 5 ) . material type = 5;
50
% d e f i n e a b s o r b e r f o r xn s i d e
52 b r i c k s ( 6 ) . m i n x = −1e −3;
b r i c k s ( 6 ) . mi n y = −2e −3;
54 b r i c k s ( 6 ) . min z = 0 ;
b r i c k s ( 6 ) . max x = 0 ;
56 b r i c k s ( 6 ) . max y = 20 e −3;
b r i c k s ( 6 ) . max z = 4e −3;
58 bricks ( 6 ) . material type = 5;
60 % d e f i n e a b s o r b e r f o r xp s i d e
b r i c k s ( 7 ) . m i n x = 10 e −3;
62 b r i c k s ( 7 ) . mi n y = −2e −3;
b r i c k s ( 7 ) . min z = 0 ;
64 b r i c k s ( 7 ) . max x = 11 e −3;
b r i c k s ( 7 ) . max y = 20 e −3;
66 b r i c k s ( 7 ) . max z = 4e −3;
bricks ( 7 ) . material type = 5;
68
% d e f i n e a b s o r b e r f o r yn s i d e
70 b r i c k s ( 8 ) . m i n x = −1e −3;
b r i c k s ( 8 ) . mi n y = −2e −3;
72 b r i c k s ( 8 ) . min z = 0 ;
b r i c k s ( 8 ) . max x = 11 e −3;
74 b r i c k s ( 8 ) . max y = −1e −3;
b r i c k s ( 8 ) . max z = 4e −3;
76 bricks ( 8 ) . material type = 5;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
78 % d e f i n e a b s o r b e r f o r yp s i d e
b r i c k s ( 9 ) . m i n x = −1e −3;
80 b r i c k s ( 9 ) . mi n y = 19 e −3;
b r i c k s ( 9 ) . min z = 0 ;
82 b r i c k s ( 9 ) . max x = 11 e −3;
b r i c k s ( 9 ) . max y = 20 e −3;
84 b r i c k s ( 9 ) . max z = 4e −3;
bricks ( 9 ) . material type = 5;
31 % d e f i n e sampled v o l t a g e s
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
61 % define ports
ports ( 1 ) . sampled voltage index = 1;
63 ports ( 1 ) . sampled current index = 1;
ports ( 1 ) . impedance = 5 0 ;
65 ports ( 1 ) . is source port = true ;
6.4 EXERCISES
6.1 Consider the low-pass filter circuit in the example described in Section 6.2. Use the same
type of absorber as shown in the example in Section 6.3.1 to terminate the boundaries of the
low-pass filter circuit. Use absorbers with 5 cells thickness, and leave at least 5 cells air gap
between the circuit and the absorbers in the xn, xp, yn, and y p directions. Leave at least 10
cells air gap between the circuit and the absorbers in the zp direction. In the zn direction
the PEC boundary will serve as the ground plane of the circuit. The FDTD problem space
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Exercises 185
Figure 6.9 The problem space for the low-pass filter with absorbers on the x n, x p, yn, yp, and zp sides.
is illustrated in Fig. 6.9 as a reference. Rerun the simulation for 3,000 time steps, and verify
that the spikes in Fig. 6.3 due to cavity resonances are suppressed.
6.2 Consider the quarter-wave transformer circuit shown in Example 6.3.1. Redefine the voltage
source and the resistor such that voltage source will feed the 100 line and will have
100 internal resistance, while the resistor will terminate the 50 line and will have 50
resistance. Set Port 2 as the active port, and run the simulation. Obtain the figures plotting
S12 and S22 , and verify that they are similar to the S21 and S11 in Fig. 6.8, respectively.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
7
Perfectly Matched Layer Absorbing
Boundary
Because computational storage space is finite, the finite-difference time-domain (FDTD) prob-
lem space size is finite and needs to be truncated by special boundary conditions. In the previous
chapters we discussed some examples for which the problem space is terminated by perfect electric
conductor (PEC) boundaries. However, many applications, such as scattering and radiation prob-
lems, require the boundaries simulated as open space. The types of special boundary conditions
that simulate electromagnetic waves propagating continuously beyond the computational space
are called absorbing boundary conditions (ABCs). However, the imperfect truncation of the problem
space will create numerical reflections, which will corrupt the computational results in the problem
space after certain amounts of simulation time. So far, several various types of ABCs have been
developed. However, the perfectly matched layer (PML) introduced by Berenger [15,16] has been
proven to be one of the most robust ABCs [17,18,19,20] in comparison with other techniques
adopted in the past. PML is a finite-thickness special medium surrounding the computational
space based on fictitious constitutive parameters to create a wave-impedance matching condition,
which is independent of the angles and frequencies of the wave incident on this boundary. The
theory and implementation of the PML boundary condition are illustrated in this chapter.
187
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
E Ey
φ0 k̂
Ex Hz
Figure 7.1 The field decomposition of a T E z polarized plane wave.
∂ Ex ∂ Hz
ε0 + σ e Ex = , (7.2a)
∂t ∂y
∂ Ey ∂ Hz
ε0 + σ e Ey = − , (7.2b)
∂t ∂x
∂ Hz ∂ Ex ∂ Ey
µ0 + σ m Hz = − . (7.2c)
∂t ∂y ∂x
In a T E z PML medium, Hz can be broken into two artificial components associated with the x
and y directions as
where Hz = Hzx + Hzy . Therefore, a modified set of Maxwell’s equations for a T E z polarized
PML medium can be expressed as
∂ Ex ∂(Hzx + Hzy )
ε0 + σ pe y E x = , (7.4a)
∂t ∂y
∂ Ey ∂(Hzx + Hzy )
ε0 + σ pe x E y = − , (7.4b)
∂t ∂x
∂ Hzx ∂ Ey
µ0 + σ pmx Hzx = − , (7.4c)
∂t ∂x
∂ Hzy ∂ Ex
µ0 + σ pmy Hzy = , (7.4d)
∂t ∂y
where σ pe x , σ pe y , σ pmx , and σ pmy are the introduced fictitious conductivities. With the given
conductivities the PML medium described by (7.4) is an anisotropic medium. When σ pmx =
σ pmy = σ m , merging (7.4c) and (7.4d) yields (7.2c). Field components E y and Hzx together can
represent a wave propagating in the x direction, and field components of E x and Hzy represent a
wave propagating in the y direction. Substituting the field equations for the x and y propagating
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
waves in (7.1a), (7.1b), (7.3a), and (7.3b) into the modified Maxwell’s equations given, one can
obtain
σ pe y
ε0 E0 sin φ0 − j E0 sin φ0 = β(Hzx0 + Hzy0 ), (7.5a)
ω
σ pe x
ε0 E0 cos φ0 − j E0 cos φ0 = α(Hzx0 + Hzy0 ), (7.5b)
ω
σ pmx
µ0 Hzx0 − j Hzx0 = α E0 cos φ0 , (7.5c)
ω
σ pmy
µ0 Hzy0 − j Hzy0 = β E0 sin φ0 . (7.5d)
ω
Using equations (7.5c) and (7.5d) to eliminate magnetic field terms from equations (7.5a) and
(7.5b) yields
σ pe y α cos φ0 β sin φ0
ε0 µ0 1− j sin φ0 = β + , (7.6a)
ε0 ω 1 − j σ pmx /µ0 ω 1 − j σ pmy /µ0 ω
σ pe x α cos φ0 β sin φ0
ε0 µ0 1 − j cos φ0 = α + . (7.6b)
ε0 ω 1 − j σ pmx /µ0 ω 1 − j σ pmy /µ0 ω
The unknown constants α and β can be obtained from (7.6a) and (7.6b) as
√
µ0 ε0 σ pe x
α= 1− j cos φ0 , (7.7a)
G ωε0
√
µ0 ε0 σ pe y
β= 1− j sin φ0 , (7.7b)
G ωε0
where
G= wx cos2 φ0 + w y sin2 φ0 , (7.8)
and
1 − j σ pe x /ωε0 1 − j σ pe y /ωε0
wx = , wy = , (7.9)
1 − j σ pmx /ωµ0 1 − j σ pmy /ωµ0
where the first exponential represents the phase of a plane wave and the second and third expo-
nentials govern the decrease in the magnitude of the wave along the x axis and y axis, respectively.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Once α and β are determined by (7.7), the split magnetic field can be determined from (7.5c) and
(7.5d) as
ε0 wx cos2 φ0
Hzx0 = E0 , (7.11a)
µ0 G
ε0 w y sin2 φ0
Hzy0 = E0 . (7.11b)
µ0 G
It is important to note that if the conductivity parameters are chosen such that
σ pe x σ pmx σ pe y σ pmy
= and = , (7.14)
ε0 µ0 ε0 µ0
then the term G becomes equal to unity as wx and w y becomes equal to unity. Therefore, the
wave impedance of this PML medium becomes the same as that of the interior free space. In
other words, when the constitutive conditions of (7.14) are satisfied, a T E z polarized wave can
propagate from free space into the PML medium without reflection for all frequencies, and all
incident angles as can be concluded from (7.8). One should notice that, when the electric and
magnetic losses are assigned to be zero, the field updating equation (7.4) for the PML region
becomes that of a vacuum region.
φ2
φ1
y
x
Figure 7.2 The plane wave transition at the interface between two PML media.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
for an arbitrary incident wave between two lossy media can be expressed as
Z2 cos φ2 − Z1 cos φ1
rp = , (7.15)
Z2 cos φ2 + Z1 cos φ1
where Z1 and Z2 are the intrinsic impedances of respective mediums. Applying (7.13), the reflection
coefficient r p becomes
G1 cos φ2 − G2 cos φ1
rp = . (7.16)
G1 cos φ2 + G2 cos φ1
The Snell-Descartes law at the interface normal to x of two lossy media can be described as
σ y1 sin φ1 σ y2 sin φ2
1−i = 1−i . (7.17)
ε0 ω G1 ε0 ω G2
When the two media have the same conductivities σ pe y1 = σ pe y2 = σ pe y and σ pmy1 = σ pmy2 = σ pmy ,
(7.17) becomes
sin φ1 sin φ2
= . (7.18)
G1 G2
Moreover, when (σ pe x1 , σ pmx1 ), (σ pe x2 , σ pmx2 ), and (σ pe y , σ pmy ) satisfy the matching condition in
equation (7.14), G1 = G2 = 1. Then (7.18) reduces to φ1 = φ2 , and equation (7.16) reduces to
r p = 0. Therefore, theoretically when two PML media satisfy (7.14) and lie at an interface normal
to the x axis with the same (σ pe y , σ pmy ), a wave can transmit through this interface with no
reflections, at any angle of incidence and any frequency. When (σ pe x1 , σ pmx1 , σ pe y1 , σ pmy1 ) are
assigned to be (0, 0, 0, 0), the PML medium 1 becomes a vacuum. Therefore, when (σ pe x2 , σ pmx2 )
satisfies (7.14), the reflection coefficient at this interface is also null, which agrees with the previous
vacuum–PML analysis. However, if the two media have the same (σ pe y , σ pmy ) but do not satisfy
(7.14), then the reflection coefficient becomes
Substituting (7.18) into equation (7.19), the reflection coefficient of two unmatched PML media
becomes
√ √
wx1 − wx2
rp = √ √ . (7.20)
wx1 + wx2
Equation (7.20) shows that the reflection coefficient for two unmatched PML media is highly
dependent on frequency, regardless of the incident angle. When the two PML media follow the
reflectionless condition in (7.14), wx1 = wx2 = 1, the reflection coefficient becomes null.
The analysis can be applied to two PML media lying at the interface normal to the y axis as
well. The Snell-Descartes law related to this interface is
σx1 sin φ1 σx2 sin φ2
1−i = 1−i . (7.21)
ε0 ω G1 ε0 ω G2
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
If the two media have the same conductivities such that σ pe x1 = σ pe x2 = σ pe x and σ pmx1 = σ pmx2 =
σ pmx , (7.21) reduces to (7.18). Similarly, if (σ pe y1 , σ pmy1 ), (σ pe y2 , σ pmy2 ), and (σ pe x , σ pmx ) satisfy the
matching condition in (7.14), then G1 = G2 = 1. Equation (7.21) then reduces to φ1 = φ2 , and
the reflection coefficient at this interface is r p = 0. To match the vacuum–PML interface normal
to the y axis, the reflectionless condition can be achieved when (σ pe y2 , σ pmy2 ) of the PML medium
satisfies (7.14).
Based on the previous discussion, if a two-dimensional FDTD problem space is attached with an
adequate thickness of PML media as shown in Fig. 7.3, the outgoing waves will be absorbed without
any undesired numerical reflections. The PML regions must be assigned appropriate conductivity
values satisfying the matching condition (7.14); the positive and negative x boundaries of the PML
regions have nonzero σ pe x , and σ pmx , whereas the positive and negative y boundaries of the PML
regions have nonzero σ pe y , and σ pmy values. The coexistence of nonzero values of σ pe x , σ pmx , σ pe y ,
and σ pmy is required at the four corner PML overlapping regions. Using a similar analysis, the
conditions of (7.14) can be applied to a T Mz polarized wave to travel from free space to PML
and from PML to PML without reflection [21]. Using the same impedance matching condition
in (7.14), the modified Maxwell’s equations for two-dimensional T Mz PML updating equations
are obtained as
∂ E zx ∂ Hy
ε0 + σ pe x E zx = , (7.22a)
∂t ∂x
∂ E zy ∂ Hx
ε0 + σ pe y E zy = − , (7.22b)
∂t ∂y
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
∂ Hx ∂(E zx + E zy )
µ0 + σ pmy Hx = − , (7.22c)
∂t ∂y
∂ Hy ∂(E zx + E zy )
µ0 + σ pmx Hy = . (7.22d)
∂t ∂x
The finite difference approximation schemes can be applied to the modified Maxwell’s equations
(7.4) and (7.22) to obtain the field-updating equations for the PML regions in the two-dimensional
FDTD problem space.
For a three-dimensional problem space, each field component of the electric and magnetic fields
is broken into two field components similar to the two-dimensional case. Therefore, the modified
Maxwell’s equations have 12 field components instead of the original six components. These
modified split electric field equations presented in [16] are
∂ E xy ∂(Hzx + Hzy )
ε0 + σ pe y E xy = , (7.23a)
∂t ∂y
∂ E xz ∂(Hy x + Hy z )
ε0 + σ pe z E xz = − , (7.23b)
∂t ∂z
∂ Eyx ∂(Hzx + Hzy )
ε0 + σ pe x E y x = − , (7.23c)
∂t ∂x
∂ Eyz ∂(Hxy + Hxz )
ε0 + σ pe z E y z = , (7.23d)
∂t ∂z
∂ E zx ∂(Hy x + Hy z )
ε0 + σ pe x E zx = , (7.23e)
∂t ∂x
∂ E zy ∂(Hxy + Hxz )
ε0 + σ pe y E zy = − , (7.23f)
∂t ∂y
∂ Hzy ∂(E xy + E xz )
µ0 + σ pmy Hzy = , (7.24e)
∂t ∂y
∂ Hzx ∂(E y x + E y z )
µ0 + σ pmx Hzx = − . (7.24f)
∂t ∂x
σ pe x σ pmx σ pe y σ pe y σ pe z σ pmz
= , = , and = . (7.25)
ε0 µ0 ε0 µ0 ε0 µ0
If a three-dimensional FDTD problem space is attached with adequate thickness of PML media
as shown in Fig. 7.4, the outgoing waves will be absorbed without any undesired numerical
(a) Nonzero σ pex and σ pmx (b) Nonzero σ pey and σ pmy
Figure 7.4 Nonzero regions of PML conductivities for a three-dimensional FDTD simulation domain.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
reflections. The PML regions must be assigned appropriate conductivity values satisfying the
matching condition (7.25); the positive and negative x boundaries of PML regions have nonzero
σ pe x and σ pmx , the positive and negative y boundaries of PML regions have nonzero σ pe y and σ pmy ,
and the positive and negative z boundaries of PML regions have nonzero σ pe z and σ pmz values as
illustrated in Fig. 7.4. The coexistence of nonzero values of σ pe x , σ pmx , σ pe y , σ pmy , σ pe z , and σ pmz
is required at the PML overlapping regions.
Finally, applying the finite difference schemes to the modified Maxwell’s equations (7.23) and
(7.24), one can obtain the FDTD field updating equations for the three-dimensional PML regions.
As discussed in the previous sections, PML regions can be formed as the boundaries of an FDTD
problem space where specific conductivities are assigned such that the outgoing waves penetrate
without reflection and attenuate while traveling in the PML medium. The PML medium is
governed by the modified Maxwell’s equations (7.4), (7.22), (7.23), and (7.24), which can be used
to obtain the updating equations for the field components in the PML regions. Furthermore, the
outer boundaries of the PML regions are terminated by PEC walls. When a finite-thickness PML
medium backed by a PEC wall is adopted, an incident plane wave may not be totally attenuated
within the PML region, and small reflections to the interior domain from the PEC back wall may
occur. For a finite-width PML medium where the conductivity distribution is uniform, there is
an apparent reflection coefficient, which is expressed as
σ cos φ0
−2 δ
R(φ0 ) = e ε0 c
, (7.26)
where σ is the conductivity of the medium. Here the exponential term is the attenuation factor
of the field magnitudes of the plane waves as shown in equation (7.10), and δ is the thickness of
the PML medium. The factor 2 in the exponent is due to the travel distance, which is twice the
distance between the vacuum–PML interface and the PEC backing. If φ0 is 0, equation (7.26) is
the reflection coefficient for a finite-thickness PML medium at normal incidence. If φ0 is π/2, the
incident plane wave is grazing to the PML medium and is attenuated by the perpendicular PML
medium. From (7.26), the effectiveness of a finite-width PML is dependent on the losses within
the PML medium. In addition, (7.26) can be used not only to predict the ideal performance of a
finite-width PML medium but also to compute the appropriate loss distribution based on the loss
profiles described in the following paragraphs.
As presented in [15], significant reflections were observed when constant uniform losses are
assigned throughout the PML media, which is a result of the discrete approximation of fields and
material parameters at the domain–PML interfaces and sharp variation of conductivity profiles.
This mismatch problem can be tempered using a spatially gradually increasing conductivity distri-
bution, which is zero at the domain–PML interface and tends to be a maximum conductivity σmax
at the end of the PML region. In [18] two major types of mathematical functions are proposed as
the conductivity distributions or loss profiles: power and geometrically increasing functions. The
power-increasing function is defined as
ρ n pml
σ (ρ) = σmax , (7.27a)
δ
n pml + 1 ε0 c ln(R(0))
σmax = − , (7.27b)
2s N
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
where ρ is the distance from the computational domain–PML interface to the position of the field
component, and δ is the thickness of the PML cells. The parameter N is the number of PML cells,
s is the cell size used for a PML cell, and R(0) is the reflection coefficient of the finite-width
PML medium at normal incidence. The distribution function is linear for n pml = 1 and parabolic
for n pml = 2. To determine the conductivity profile using (7.27a) the parameters R(0) and n pml
must be predefined. These parameters are used to determine σmax using (7.27b), which is then
used in the calculation of σ (ρ). Usually n pml takes a value such as 2, 3, or 4 and R(0) takes a very
small value such as 10−8 for a satisfactory PML performance.
The geometrically increasing distribution for σ (ρ) is given by
ρ
σ (ρ) = σ0 g s , (7.28a)
ε0 c ln(g)
σ0 = − ln(R(0)), (7.28b)
2s g N − 1
where the parameter g is a real number used for a geometrically increasing function.
where
n+ 1 n+ 1
E yn+1 (i, j ) = Ce ye (i, j ) × E yn (i, j ) + Ce yhz (i, j ) × Hz 2 (i, j ) − Hz 2 (i − 1, j ) , (7.30)
where
n+ 1 n− 1
Hzx 2 (i, j ) = C hzxh (i, j ) × Hzx 2 (i, j ) + C hzxe y (i, j ) × E yn (i + 1, j ) − E yn (i, j ) , (7.31)
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
where
2µ0 − tσ pmx (i, j )
C hzxh (i, j ) = ,
2µ0 + tσ pmx (i, j )
2t
C hzxe y (i, j ) = − .
2µ0 + tσ pmx (i, j ) x
n+ 1 n− 1
Hzy 2 (i, j ) = C hzyh (i, j ) × Hzy 2 (i, j ) + C hzye x (i, j ) × E xn (i, j + 1) − E xn (i, j ) , (7.32)
where
2µ0 − tσ pmy (i, j )
C hzyh (i, j ) = ,
2µ0 + tσ pmy (i, j )
2t
C hzye x (i, j ) = .
2µ0 + tσ pmy (i, j ) y
One should recall that Hz (i, j ) = Hzx (i, j ) + Hzy (i, j ). As illustrated in Fig. 7.3 certain PML
conductivities are defined at certain regions. Therefore, each of the equations (7.29)–(7.32) is
applied in a two-dimensional problem space where its respective PML conductivity is defined.
Figure 7.5 shows the PML regions where the conductivity parameters are nonzero and the
respective field components that need to be updated at each region. Figure 7.5(a) shows the
regions where σ pe x is defined. These regions are denoted as xn and xp. One can notice from (7.4b)
and (7.30) that σ pe x appears in the equation where E y is updated. Therefore, the components of E y
lying in the xn and xp regions are updated at every time step using (7.30). The other components
of E y that are located in the intermediate region can be updated using the regular non-PML
updating equation (1.34). Similarly, σ pe y is nonzero in the regions that are denoted as yn and y p
in Fig. 7.5(b). The components of E x lying in the yn and y p regions are updated at every time
step using (7.29), and the components located in the intermediate region are updated using the
regular non-PML updating equation (1.33).
Since the magnetic field Hz is the sum of two split fields Hzx and Hzy in the PML regions, its
update is more complicated. The PML regions and non-PML regions are shown in Figs. 7.5(c) and
7.5(d), where the PML regions are denoted as xn, xp, yn, and y p. The magnetic field components
of Hz lying in the non-PML region can be updated using the regular updating equation (1.35).
However, the components of Hz in the PML regions are not directly calculated; the components
of Hzx and Hzy are calculated in the PML regions using the appropriate updating equations, and
then they are summed up to yield Hz in the PML region. The conductivity σ pmx is nonzero in
the xn and xp regions as shown in Fig. 7.5(c). The components of Hzx are calculated in the same
regions using (7.31). However, components of Hzx need to be calculated in the yn and y p regions
as well. Since σ pmx is zero in these regions setting σ pmx zero in (7.31) will yield the required
updating equation for Hzx in the yn and y p regions as
n+ 1 n− 1
Hzx 2 (i, j ) = C hzxh (i, j ) × Hzx 2 (i, j ) + C hzxe y (i, j ) × E yn (i + 1, j ) − E yn (i, j ) , (7.33)
where
t
C hzxh (i, j ) = 1, C hzxe y (i, j ) = − .
µ0 x
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Similarly, the conductivity σ pmy is nonzero in the yn and y p regions as shown in Fig. 7.5(d). The
components of Hzy are calculated in these regions using (7.32). The components of Hzy need to
be calculated in the xn and xp regions as well. Since σ pmy is zero in these regions, setting σ pmy to
zero in (7.32) will yield the required updating equation for Hzy in the xn and xp regions as
n+ 1 n− 1
Hzy 2 (i, j ) = C hzyh (i, j ) × Hzy 2 (i, j ) + C hzye x (i, j ) × E xn (i, j + 1) − E xn (i, j ) , (7.34)
where
t
C hzyh (i, j ) = 1, C hzye x (i, j ) = .
µ0 y
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
After all the components of Hzx and Hzy are updated in the PML regions, they are added to
calculate Hz .
where
2ε0 − tσ pe x (i, j )
Ce zxe (i, j ) = ,
2ε0 + tσ pe x (i, j )
2t
Ce zxhy (i, j ) = .
2ε0 + tσ pe x (i, j ) x
n+ 1 n+ 1
n+1
E zy (i, j ) = Ce zye (i, j ) × E zn (i, j ) + Ce zyhx (i, j ) × Hx 2 (i, j ) − Hx 2 (i, j − 1) , (7.36)
where
2ε0 (i, j ) − tσ pe y (i, j )
Ce zye (i, j ) = ,
2ε0 (i, j ) + tσ pe y (i, j )
2t
Ce zyhx (i, j ) = − .
2ε0 + tσ pe y (i, j ) y
n+ 12 n− 12
Hx (i, j ) = C hxh (i, j ) × Hx (i, j ) + C hxe z (i, j ) × E zn (i, j + 1) − E zn (i, j ) , (7.37)
where
2µ0 − tσ pmy (i, j )
C hxh (i, j ) = ,
2µ0 + tσ pmy (i, j )
2t
C hxe z (i, j ) = − .
2µ0 + tσ pmy (i, j ) y
n+ 12 n− 12
Hy (i, j ) = C hyh (i, j ) × Hy (i, j ) + C hye z (i, j ) × E zn (i + 1, j ) − E zn (i, j ) , (7.38)
where
2µ0 − tσ pmx (i, j )
C hyh (i, j ) = ,
2µ0 + tσ pmx (i, j )
2t
C hye z (i, j ) = .
2µ0 + tσ pmx (i, j ) x
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
One should recall that E z (i, j ) = E zx (i, j ) + E zy (i, j ). Consider the nonzero PML conductivity
regions given in Fig. 7.6. Figure 7.6(a) shows that σ pmx is defined in the regions denoted as xn
and xp. Therefore, components of Hy lying in these regions are updated at every time step using
the PML updating equation (7.38). The components of Hy lying in the intermediate region are
updated using the regular updating equation (1.38). The conductivity σ pmy is nonzero in the yn
and y p regions shown in Fig. 7.6(b); therefore, the components of Hx lying in the yn and y p
regions are updated using the PML updating equation (7.37). The components of Hx lying in the
intermediate region are updated using the regular updating equation (1.37).
The components of E z are the sum of two split fields E zx and E zy in all of the PML regions xn,
xp, yn, and y p as illustrated in Figs. 7.6(c) and 7.6(d). The components of E z in the intermediate
non-PML region are updated using the regular updating equation (1.36). The conductivity σ pe x
is nonzero in the xn and xp regions as shown in Fig. 7.6(c); therefore, components of E zx in these
regions are updated using (7.35). Furthermore, the components of E zx in the yn and y p regions
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
need to be calculated as well. Since σ pe x is zero in these regions, setting σ pe x to zero in (7.35) yields
the updating equation for E zx in the yn and y p regions as
n+ 1 n+ 1
n+1
E zx (i, j ) = Ce zxe (i, j ) × E zx
n
(i, j ) + Ce zxhy (i, j ) × Hy 2 (i, j ) − Hy 2 (i − 1, j ) , (7.39)
where
t
Ce zxe (i, j ) = 1, Ce zxhy (i, j ) = .
ε0 x
Similarly, σ pe y is nonzero in the yn and y p regions as shown in Fig. 7.6(d); therefore, components
of E zy in these regions are updated using (7.36). Furthermore, the components of E zy in the xn
and xp regions need to be calculated as well. Since σ pe y is zero in these regions, setting σ pe y to
zero in (7.36) yields the updating equation for E zy in the xn and xp regions as
n+ 1 n+ 1
n+1
E zy (i, j ) = Ce zye (i, j ) × E zn (i, j ) + Ce zyhx (i, j ) × Hx 2 (i, j ) − Hx 2 (i, j − 1) , (7.40)
where
t
Ce zye (i, j ) = 1, Ce zyhx (i, j ) = − .
ε0 y
After all the components of E zx and E zy are updated in the PML regions, they are added to
calculate E z .
7.4.3.1 Definition of the Two-Dimensional FDTD Problem The types of boundaries surrounding
the problem space are defined in the subroutine define problem space parameters 2d, a partial
code of which is shown in Listing 7.2. Here if a boundary on one side is defined as PEC, the variable
boundary.type takes the value ‘pec’, whereas for PML it takes the value ‘pml’. The parameter
air buffer number of cells determines the distance in number of cells between the objects in the
problem space and the boundaries, whether PEC or PML. The parameter pml number of cells
determines the thickness of the PML regions in number of cells. In this implementation the power
increasing function (7.27a) is used for the PML conductivity distributions along the thickness of
the PML regions. Two additional parameters are required for the PML, the theoretical reflection
coefficient (R(0)) and the order of PML (n pml ), as discussed in Section 7.3. These two parameters
are defined as boundary.pml R 0 and boundary.pml order, respectively.
In the subroutine define geometry 2d two-dimensional geometrical objects such as circles and
rectangles can be defined by their coordinates, sizes, and material types.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
4 % d e f i n e t h e problem
define problem space parameters 2d ;
6 define geometry 2d ;
define sources 2d ;
8 define output parameters 2d ;
10 % i n i t i a l i z e t h e problem s p a c e and p a r a m e t e r s
initialize fdtd material grid 2d ;
12 initialize fdtd parameters and arrays 2d ;
initialize sources 2d ;
14 initialize updating coefficients 2d ;
initialize boundary conditions 2d ;
16 initialize output parameters 2d ;
initialize display parameters 2d ;
18
% draw t h e o b j e c t s i n t h e problem s p a c e
20 draw objects 2d ;
22 % FDTD t i m e m a r c h i n g l o o p
run fdtd time marching loop 2d ;
24
The sources exciting the two-dimensional problem space are defined in the subroutine define -
sources 2d. Unlike the three-dimensional case, in this implementation the impressed current
sources are defined as sources explicitly as shown in Listing 7.3.
Outputs of the program are defined in the subroutine define output parameters 2d. In this
implementation the output parameters are sampled electric fields and sampled magnetic -
fields captured at certain positions.
7.4.3.2 Initialization of the Two-Dimensional FDTD Problem The steps of the initialization process
are shown in Listing 7.1. This process starts with the subroutine initialize fdtd material grid -
2d. In this subroutine the first task is the calculation of the dimensions of the two-dimensional
problem space and the number of cells nx and ny in the x and y dimensions, respectively. If some
of the boundaries are defined as PML, the PML regions are also included in the problem space.
Therefore, nx and ny include the PML number of cells as well. Then the material component
arrays of the two-dimensional problem space are constructed using the material averaging schemes
that were discussed in Section 3.2. Next, while creating the material grid, the PML regions are
assigned free-space parameters. At this point the PML regions are treated as if they are free-space
regions; however, later PML conductivity parameters are assigned to these regions, and special
updating equations are used to update fields in these regions. Furthermore, new parameters are
defined and assigned appropriate values as n pml xn, n pml xp, n pml yn, and n pml yp to hold
the numbers of cells for the thickness of the PML regions. Four logical parameters, is pml xn,
is pml xp, is pml yn, and is pml yp, are defined to indicate whether the respective side of the
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
22 b o u n d a r y . t y p e x n = ’ pml ’ ;
boundary . a i r b u f f e r n u m b e r o f c e l l s x n = 10;
24 boundary . p m l n u m b e r o f c e l l s x n = 5 ;
26 b o u n d a r y . t y p e x p = ’ pml ’ ;
boundary . a i r b u f f e r n u m b e r o f c e l l s x p = 10;
28 boundary . p m l n u m b e r o f c e l l s x p = 5 ;
30 b o u n d a r y . t y p e y n = ’ pml ’ ;
boundary . a i r b u f f e r n u m b e r o f c e l l s y n = 10;
32 boundary . p m l n u m b e r o f c e l l s y n = 5 ;
34 b o u n d a r y . t y p e y p = ’ pml ’ ;
boundary . a i r b u f f e r n u m b e r o f c e l l s y p = 10;
36 boundary . p m l n u m b e r o f c e l l s y p = 5 ;
computational boundary is PML or not. Since these parameters are used frequently, shorthand
notations are more appropriate to use. Figure 7.7 illustrates a problem space composed of two
circles, two rectangles, an impressed current source at the center, and 5 cells thick PML boundaries.
The air gap between the objects and the PML is 10 cells.
impressed J = [ ] ;
4 impressed M = [ ] ;
6 % d e f i n e s o u r c e waveform t y p e s and p a r a m e t e r s
waveforms . g a u s s i a n ( 1 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 0 ;
8 waveforms . g a u s s i a n ( 2 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 15;
% % magnetic c u r r e n t s o u r c e s
22 % % d i r e c t i o n : ’ xp ’ , ’ xn ’ , ’ yp ’ , ’ yn ’ , ’ zp ’ , o r ’ zn ’
% i m p r e s s e d M ( 1 ) . m i n x = −0.1 e −3;
24 % i m p r e s s e d M ( 1 ) . m i n y = −0.1 e −3;
% i m p r e s s e d M ( 1 ) . max x = 0 . 1 e −3;
26 % i m p r e s s e d M ( 1 ) . max y = 0 . 1 e −3;
% i m p r e s s e d M ( 1 ) . d i r e c t i o n = ’ zp ’ ;
28 % impressed M ( 1 ) . magnitude = 1 ;
% impressed M ( 1 ) . waveform type = ’ gaussian ’ ;
30 % impressed M ( 1 ) . waveform index = 1;
The subroutine initialize fdtd parameters and arrays 2d includes the definition of some pa-
rameters such as ε0 , µ0 , c , and t that are required for the FDTD calculation and definition and
initialization of field arrays Ex, Ey, Ez, Hx, Hy, and Hz. The field arrays are defined for all the
problem space including the PML regions.
In the subroutine initialize sources 2d the indices indicating the positions of the impressed
electric and magnetic currents are determined and stored as the subfields of the respective param-
eters impressed J and impressed M. Since the impressed currents are used as explicit sources,
their source waveforms are also computed. A two-dimensional problem can have two modes of
operation as T E and T M. The mode of operation is determined by the sources. For instance, an
impressed electric current Ji z excites Ez fields in the problem space, thus giving rise to a T Mz
operation. Similarly, impressed magnetic currents Mi x and Mi y also give rise to T Mz operation.
The impressed currents Mi z , Ji x , and Ji y give rise to T E z operation. Therefore, the mode of
operation is determined by the impressed currents as shown in Listing 7.4, which includes the
partial code of initialize sources 2d. Here a logical parameter is TEz is defined to indicate that
the mode of operation is T E z , whereas another logical parameter is TMz is defined to indicate
that the mode of operation is T Mz .
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
The regular updating coefficients of the two-dimensional FDTD method are calculated in
the subroutine initialize updating coefficients 2d based on the updating equations (1.33)–(1.38),
including the impressed current coefficients as well.
Some coefficients and field arrays need to be defined and initialized for the application of
the PML boundary conditions. The PML initialization process is performed in the subrou-
tine initialize boundary conditions 2d, which is shown in Listing 7.5. The indices of the nodes
3 % d e t e r m i n e t h e b o u n d a r i e s o f t h e non−pml r e g i o n
p i s = n p m l x n +1;
5 p i e = nx−n p m l x p +1;
p j s = n p m l y n +1;
7 p j e = ny−n p m l y p +1;
16 i f is pml xn
s i g m a p e x x n = z e r o s ( n pml xn , ny ) ;
18 s i g m a p m x x n = z e r o s ( n pml xn , ny ) ;
20 sigma max = −( p m l o r d e r + 1 ) * e p s 0 * c * l o g ( R 0 ) / ( 2 * dx * n p m l x n ) ;
rho e = ( [ n pml xn : −1:1] − 0 . 7 5 ) / n pml xn ;
22 rho m = ( [ n p m l x n : − 1 : 1 ] − 0 . 2 5 ) / n p m l x n ;
f o r ind = 1: n pml xn
24 s i g m a p e x x n ( ind , : ) = sigma max * r h o e ( i n d ) ˆ p m l o r d e r ;
s i g m a p m x x n ( ind , : ) = . . .
26 ( mu 0 / e p s 0 ) * sigma max * rho m ( i n d ) ˆ p m l o r d e r ;
end
28
% C o e f f i e c i e n t s updating Ey
30 C e y e x n = ( 2 * e p s 0 − d t * s i g m a p e x x n ) . / ( 2 * e p s 0+d t * s i g m a p e x x n ) ;
C e y h z x n= −(2 * d t / dx ) . / ( 2 * e p s 0 + d t * s i g m a p e x x n ) ;
32
% C o e f f i e c i e n t s u p d a t i n g Hzx
34 C h z x h x n = ( 2 * mu 0 − d t * s i g m a p m x x n ) . / ( 2 * mu 0+d t * s i g m a p m x x n ) ;
C h z x e y x n = −(2 * d t / dx ) . / ( 2 * mu 0 + d t * s i g m a p m x x n ) ;
36
% C o e f f i e c i e n t s u p d a t i n g Hzy
38 Chzyh xn = 1;
C h z y e x x n = d t / ( dy * mu 0 ) ;
40 end
i f is pml yp
95 s i g m a p e y y p = z e r o s ( nx , n p m l y p ) ;
s i g m a p m y y p = z e r o s ( nx , n p m l y p ) ;
97
sigma max = −( p m l o r d e r + 1 ) * e p s 0 * c * l o g ( R 0 ) / ( 2 * dy * n p m l y p ) ;
99 rho e = ( [ 1 : n pml yp ] − 0 . 7 5 ) / n pml yp ;
rho m = ( [ 1 : n p m l y p ] − 0 . 2 5 ) / n p m l y p ;
101 f o r ind = 1: n pml yp
s i g m a p e y y p ( : , i n d ) = sigma max * r h o e ( i n d ) ˆ p m l o r d e r ;
103 sigma pmy yp ( : , ind ) = . . .
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
107 % C o e f f i e c i e n t s updating Ex
C e x e y p = ( 2 * e p s 0 − d t * s i g m a p e y y p ) . / ( 2 * e p s 0+d t * s i g m a p e y y p ) ;
109 C e x h z y p = ( 2 * d t / dy ) . / ( 2 * e p s 0 + d t * s i g m a p e y y p ) ;
111 % C o e f f i e c i e n t s u p d a t i n g Hzx
Chzxh yp = 1;
113 C h z x e y y p = −d t / ( dx * mu 0 ) ;
115 % C o e f f i e c i e n t s u p d a t i n g Hzy
C h z y h y p = ( 2 * mu 0 − d t * s i g m a p m y y p ) . / ( 2 * mu 0+d t * s i g m a p m y y p ) ;
117 C h z y e x y p = ( 2 * d t / dy ) . / ( 2 * mu 0 + d t * s i g m a p m y y p ) ;
end
determining the non-PML rectangular region as illustrated in Fig. 7.7 are calculated as ( pis , p j s )
and ( pie, p j e). Then two separate subroutines dedicated to the initialization of the T E z and T Mz
cases are called based on the mode of operation.
The coefficients and fields required for the T E z PML boundaries are initialized in the sub-
routine initialize pml boundary conditions 2d TEz, and partial code for this case is shown in
Listing 7.6. Figure 7.8 shows the field distribution for the T E z case. The field components in
the shaded region are updated by the PML updating equations. The field components on the
outer boundary are not updated and are kept at zero value during the FDTD iterations since
they are simulating the PEC boundaries. The magnetic field components Hzx and Hzy are defined
in the four PML regions shown in Fig. 7.5; therefore, the corresponding field arrays Hzx xn,
Hzx xp, Hzx yn, Hzx yp, Hzy xn, Hzy xp, Hzy yn, and Hzy yp are initialized in Listing 7.6.
Then for each region the corresponding conductivity parameters and PML updating coefficients
are calculated. Listing 7.6 shows the initialization for the xn and y p regions.
One should take care while calculating the conductivity arrays. The conductivities σ pe x and
σ pe y are associated with the electric fields E x and E y , respectively, whereas σ pmx and σ pmy are
associated with the magnetic field Hz . Therefore, the conductivity components are located in
different positions. As mentioned before, the conductivity σ (ρ) is zero at the PML interior-
domain interface, and it increases to a maximum value σmax at the end of the PML region.
In this implementation the imaginary PML regions are shifted inward by a quarter cell size as
shown in Fig. 7.8. If the thickness of the PML region is N cells, this shift ensures that N electric
field components and N magnetic field components are updated across the PML thickness. For
instance, consider the cross-section of a two-dimensional problem space shown in Fig. 7.9, which
illustrates the field components updated in the xn and xp regions. The distance of the electric field
components E y from the interior boundary of the PML is denoted as ρe whereas for the magnetic
field components Hz it is denoted as ρm . The distances ρe and ρm are used in (7.27a) to calculate
the values of σ pe x and σ pmx , respectively. These values are stored in arrays sigma pex xn and
sigma pmx xn for the xn region as shown in Listing 7.6 and in sigma pex xp and sigma pmx xp
for the xp region. Calculation of σ pe y and σ pmy follows the same logic. Then these parameters are
used to calculate the respective PML updating coefficients in (7.29)–(7.32).
The initialization of the auxiliary split fields and the PML updating coefficients for the two-
dimensional T Mz case is performed in the subroutine initialize pml boundary conditions 2d -
Tmz, a partial code of which is given for the xp and yn regions in Listing 7.7. The initialization of
the T Mz case follows the same logic as the T E z case. The field positioning and PML regions are
shown in Fig. 7.10, while the positions of the field components updated by the PML equations
and conductivity positions are shown in Fig. 7.11 as a reference.
7.4.3.3 Running the Two-Dimensional FDTD Simulation: The Time-Marching Loop After the ini-
tialization process is completed, the subroutine run fdtd time marching loop 2d including the
time-marching loop of FDTD procedure is called. The implementation of the FDTD updating
loop is shown in Listing 7.8.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
42 i f is pml xp
s i g m a p e x x p = z e r o s ( n pml xp , nym1 ) ;
44 s i g m a p m x x p = z e r o s ( n pml xp , nym1 ) ;
46 sigma max = −( p m l o r d e r + 1 ) * e p s 0 * c * l o g ( R 0 ) / ( 2 * dx * n p m l x p ) ;
rho e = ( [ 1 : n pml xp ] − 0 . 7 5 ) / n pml xp ;
48 rho m = ( [ 1 : n p m l x p ] − 0 . 2 5 ) / n p m l x p ;
for ind = 1: n pml xp
50 s i g m a p e x x p ( ind , : ) = sigma max * r h o e ( i n d ) ˆ p m l o r d e r ;
s i g m a p m x x p ( ind , : ) = . . .
52 ( mu 0 / e p s 0 ) * sigma max * rho m ( i n d ) ˆ p m l o r d e r ;
end
54
% C o e f f i e c i e n t s u p d a t i n g Hy
56 C h y h x p = ( 2 * mu 0 − d t * s i g m a p m x x p ) . / ( 2 * mu 0 + d t * s i g m a p m x x p ) ;
C h y e z x p = ( 2 * d t / dx ) . / ( 2 * mu 0 + d t * s i g m a p m x x p ) ;
58
% C o e f f i e c i e n t s updating Ezx
60 C e z x e x p = ( 2 * e p s 0 − d t * s i g m a p e x x p ) . / ( 2 * e p s 0+d t * s i g m a p e x x p ) ;
C e z x h y x p = ( 2 * d t / dx ) . / ( 2 * e p s 0 + d t * s i g m a p e x x p ) ;
62
% C o e f f i e c i e n t s updating Ezy
64 Cezye xp = 1;
C e z y h x x p = −d t / ( dy * e p s 0 ) ;
66 end
68 i f is pml yn
s i g m a p e y y n = z e r o s ( nxm1 , n p m l y n ) ;
70 s i g m a p m y y n = z e r o s ( nxm1 , n p m l y n ) ;
72 sigma max = −( p m l o r d e r + 1 ) * e p s 0 * c * l o g ( R 0 ) / ( 2 * dy * n p m l y n ) ;
rho e = ( [ n pml yn : −1:1] − 0 . 7 5 ) / n pml yn ;
74 rho m = ( [ n p m l y n : − 1 : 1 ] − 0 . 2 5 ) / n p m l y n ;
f o r ind = 1: n pml yp
76 s i g m a p e y y n ( : , i n d ) = sigma max * r h o e ( i n d ) ˆ p m l o r d e r ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
% C o e f f i e c i e n t s u p d a t i n g Hx
82 C h x h y n = ( 2 * mu 0 − d t * s i g m a p m y y n ) . / ( 2 * mu 0+d t * s i g m a p m y y n ) ;
C h x e z y n= −(2 * d t / dy ) . / ( 2 * mu 0 + d t * s i g m a p m y y n ) ;
84
% C o e f f i e c i e n t s updating Ezx
86 Cezxe yn = 1;
C e z x h y y n = d t / ( dx * e p s 0 ) ;
88
% C o e f f i e c i e n t s updating Ezy
90 C e z y e y n = ( 2 * e p s 0 − d t * s i g m a p e y y n ) . / ( 2 * e p s 0+d t * s i g m a p e y y n ) ;
C e z y h x y n = −(2 * d t / dy ) . / ( 2 * e p s 0 + d t * s i g m a p e y y n ) ;
92 end
During the time-marching loop the first step at every iteration is the update of magnetic
field components using the regular updating equations in update magnetic fields 2d as shown in
Listing 7.9. In the T E z case the Hz field components in the intermediate regions of Figs. 7.5(c) and
7.5(d) are updated based on (1.35). In the T Mz case the Hx field components in the intermediate
region of Fig. 7.6(b) and Hy field components in the intermediate region of Fig. 7.6(a) are updated
based on (1.37) and (1.38), respectively.
Then in update impressed M the impressed current terms appearing in (1.35), (1.37), and
(1.38) are added to their respective field terms Hz , Hx , and Hy .
The subroutine update magnetic fields for PML 2d is used to update the magnetic field com-
ponents needing special PML updates. As can be followed in Listing 7.11 the T E z and T Mz cases
are treated in separate subroutines.
The T Mz case is implemented in Listing 7.12, where Hx is updated in the yn and y p regions
of Fig. 7.6(b) using (7.37). Hy is updated in the xn and xp regions of Fig. 7.6(a) using (7.38).
s t a r t t i m e = cputime ;
6 current time = 0;
20 e n d t i m e = cputime ;
t o t a l t i m e i n m i n u t e s = ( end time − s t a r t t i m e ) / 6 0 ;
22 disp ( [ ’ T o t a l s i m u l a t i o n time i s ’ . . .
num2str ( t o t a l t i m e i n m i n u t e s ) ’ m i n u t e s . ’ ] ) ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
5 % TEz
if is TEz
7 Hz ( p i s : p i e −1 , p j s : p j e −1) = . . .
Chzh ( p i s : p i e −1 , p j s : p j e − 1 ) . * Hz ( p i s : p i e −1 , p j s : p j e −1) . . .
9 + C h z e x ( p i s : p i e −1 , p j s : p j e −1) . . .
. * ( E x ( p i s : p i e −1 , p j s +1: p j e )− E x ( p i s : p i e −1 , p j s : p j e − 1 ) ) ...
11 + C h z e y ( p i s : p i e −1 , p j s : p j e −1) . . .
. * ( E y ( p i s +1: p i e , p j s : p j e −1)− E y ( p i s : p i e −1 , p j s : p j e − 1 ) ) ;
13 end
15 % TMz
i f is TMz
17 Hx ( : , p j s : p j e −1) = Chxh ( : , p j s : p j e −1) . * Hx ( : , p j s : p j e −1) . . .
+ C h x e z ( : , p j s : p j e −1) . * ( E z ( : , p j s +1: p j e )− E z ( : , p j s : p j e − 1 ) ) ;
19
Hy ( p i s : p i e − 1 , : ) = Chyh ( p i s : p i e − 1 , : ) . * Hy ( p i s : p i e − 1 , : ) . . .
21 + C h y e z ( p i s : p i e − 1 , : ) . * ( E z ( p i s +1: p i e , : ) − E z ( p i s : p i e − 1 , : ) ) ;
end
The T E z case is implemented in Listing 7.13. Hzx is updated in the xn and xp regions of
Fig. 7.5(c) using (7.31). Hzx is updated in the yn and y p regions of Fig. 7.5(c) using (7.33).
Hzy is updated in the yn and y p regions of Fig. 7.5(d) using (7.32). Hzy is updated in xn
and xp regions of Fig. 7.5(d) using (7.34). After all these updates are completed, the com-
ponents of Hzx and Hzy , located at the same positions, are added to obtain Hz at the same
positions.
The update of the electric field components using the regular updating equations is per-
formed in update electric fields 2d as shown in Listing 7.14. In the T Mz case the E z field com-
ponents in the intermediate regions of Figs. 7.6(c) and 7.6(d) are updated based on (1.36). In
the T E z case the E x field components in the intermediate region of Fig. 7.5(b) and E y field
components in the intermediate region of Fig. 7.5(a) are updated based on (1.33) and (1.34),
respectively.
8 i f is pml xp
Hy ( p i e : nx , 2 : ny ) = C h y h x p . * Hy ( p i e : nx , 2 : ny ) . . .
10 + C h y e z x p . * ( E z ( p i e +1: nxp1 , 2 : ny )− E z ( p i e : nx , 2 : ny ) ) ;
end
12
i f is pml yn
14 Hx ( 2 : nx , 1 : p j s −1) = C h x h y n . * Hx ( 2 : nx , 1 : p j s −1) . . .
+ C h x e z y n . * ( E z ( 2 : nx , 2 : p j s )− E z ( 2 : nx , 1 : p j s − 1 ) ) ;
16 end
18 i f is pml yp
Hx ( 2 : nx , p j e : ny ) = C h x h y p . * Hx ( 2 : nx , p j e : ny ) . . .
20 + C h x e z y p . * ( E z ( 2 : nx , p j e +1: nyp1 )− E z ( 2 : nx , p j e : ny ) ) ;
end
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Then in update impressed J the impressed current terms appearing in (1.36), (1.33), and (1.34)
are added to their respective field terms E z , E x , and E y .
The subroutine update electric fields for PML 2d is used to update the electric field compo-
nents needing special PML updates. As can be followed in Listing 7.15 the T E z and T Mz cases
are treated in separate subroutines.
The T E z case is implemented in Listing 7.16, where E x is updated in the yn and y p regions of
Fig. 7.5(b) using (7.29). E y is updated in the xn and xp regions of Fig. 7.5(a) using (7.30).
The T Mz case is implemented in Listing 7.17, where E zx is updated in the xn and xp re-
gions of Fig. 7.6(c) using (7.35). E zx is updated in the yn and y p regions of Fig. 7.6(c) using
(7.39). E zy is updated in the yn and y p regions of Fig. 7.6(d) using (7.36). E zy is updated in
the xn and xp regions of Fig. 7.6(d) using (7.40). After all these updates are completed, the
components of E zx and E zy , located at the same positions, are added to obtain E z at the same
positions.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
3 if is TEz
E x ( : , p j s +1: p j e −1) = C e x e ( : , p j s +1: p j e − 1 ) . * E x ( : , p j s +1: p j e −1) . . .
5 + C e x h z ( : , p j s +1: p j e − 1 ) . * . . .
( Hz ( : , p j s +1: p j e −1)−Hz ( : , p j s : p j e − 2 ) ) ;
7
13 i f is TMz
E z ( p i s +1: p i e −1 , p j s +1: p j e −1) = . . .
15 C e z e ( p i s +1: p i e −1 , p j s +1: p j e − 1 ) . * E z ( p i s +1: p i e −1 , p j s +1: p j e −1) . . .
+ C e z h y ( p i s +1: p i e −1 , p j s +1: p j e −1) . . .
17 . * ( Hy ( p i s +1: p i e −1 , p j s +1: p j e −1)−Hy ( p i s : p i e −2 , p j s +1: p j e − 1 ) ) . . .
+ C e z h x ( p i s +1: p i e −1 , p j s +1: p j e −1) . . .
19 . * ( Hx ( p i s +1: p i e −1 , p j s +1: p j e −1)−Hx ( p i s +1: p i e −1 , p j s : p j e − 2 ) ) ;
end
i f is pml xp
9 E y ( p i e : nx , : ) = C e y e x p . * E y ( p i e : nx , : ) . . .
+ C e y h z x p . * ( Hz ( p i e : nx , : ) − Hz ( p i e −1: nx − 1 , : ) ) ;
11 end
13 i f is pml yn
Ex ( : , 2 : p j s ) = Cexe yn . * Ex ( : , 2 : p j s ) . . .
15 + C e x h z y n . * ( Hz ( : , 2 : p j s )−Hz ( : , 1 : p j s − 1 ) ) ;
end
17
i f is pml yp
19 E x ( : , p j e : ny ) = C e x e y p . * E x ( : , p j e : ny ) . . .
+ C e x h z y p . * ( Hz ( : , p j e : ny )−Hz ( : , p j e −1: ny − 1 ) ) ;
21 end
28 E z ( 2 : p i s , p j e : ny ) = E z x x n ( : , p j e −1:nym1 ) + E z y y p ( 1 : p i s − 1 , : ) ;
E z ( p i e : nx , p j e : ny ) = E z x x p ( : , p j e −1:nym1 ) + E z y y p ( p i e −1:nxm1 , : ) ;
30 E z ( p i e : nx , 2 : p j s ) = E z x x p ( : , 1 : p j s −1) + E z y y n ( p i e −1:nxm1 , : ) ;
E z ( p i s +1: p i e −1 ,2: p j s ) = E z x y n + E z y y n ( p i s : p i e − 2 , : ) ;
32 E z ( p i s +1: p i e −1 , p j e : ny ) = E z x y p + E z y y p ( p i s : p i e − 2 , : ) ;
E z ( 2 : p i s , p j s +1: p j e −1) = E z x x n ( : , p j s : p j e −2) + E z y x n ;
34 E z ( p i e : nx , p j s +1: p j e −1) = E z x x p ( : , p j s : p j e −2) + E z y x p ;
To determine how well the PML boundaries simulate the open boundaries, a reference case
is constructed as shown in Fig. 7.13(a). The cell size, the source, and the output of this problem
space is the same as the previous one, but in this case the problem space size is 600 × 600 cells, and
it is terminated by PEC boundaries on four sides. Any fields excited by the source will propagate,
will hit the PEC boundaries, and will propagate back to the center. Since the problem size is large,
it will take some time until the reflected fields arrive at the sampling point. Therefore, the fields
captured at the sampling point before any reflected fields arrive is the same as the fields that would
be observed if the boundaries are open space. In the given example no reflection is observed in
the 1,800 time steps of simulation. Therefore, this case can be considered as a reference case for
an open space during the 1,800 time steps. The captured sampled magnetic field is shown in Fig.
7.13(b) as a function of time.
No difference can be seen by looking at the responses of the PML case and the reference case.
The difference between the two cases is a measure for the amount of reflection from the PML
and can be determined numerically. The difference denoted as errort is the error as a function of
H1
y
x
M1
Figure 7.12 (a) A two-dimensional TEz FDTD problem terminated by PML boundaries and its simulation results:
an empty two-dimensional problem space.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
−7
x 10
1
0.5
(ampere/meter)
−0.5
−1
−1.5
0 0.5 1 1.5 2 2.5 3 3.5 4
time (ns)
Figure 7.12 (b) A two-dimensional TEz FDTD problem terminated by PML boundaries and its simulation results:
sampled H z in time.
pml re f
|Hz − Hz |
errort = 20 × log10 re f
, (7.41)
max(|Hz |)
pml re f
where Hz is the sampled magnetic field in the PML problem case and Hz is the sampled
magnetic field in the reference case. The error as a function of time is plotted in Fig. 7.14(a). The
error in frequency domain as well is obtained as error f from the difference between the Fourier
transforms of the sampled magnetic fields from the PML and reference cases by
pml re f
|F(Hz ) − F(Hz )|
error f = 20 × log10 re f
, (7.42)
F(|Hz |)
where the operator F( ) denotes the Fourier transform. The error in frequency-domain error f
is plotted in Fig. 7.14(b). The errors obtained in this example can further be reduced by us-
ing a larger number of cells of PML thickness, a better choice of R(0), and a higher order
of PML n pml . One can see in Fig. 7.14(b) that the performance of the PML degrades at low
frequencies.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
impressed J = [ ] ;
4 impressed M = [ ] ;
6 % d e f i n e s o u r c e waveform t y p e s and p a r a m e t e r s
waveforms . g a u s s i a n ( 1 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 0 ;
8 waveforms . g a u s s i a n ( 2 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 25;
10 % magnetic c u r r e n t s o u r c e s
% d i r e c t i o n : ’ xp ’ , ’ xn ’ , ’ yp ’ , ’ yn ’ , ’ zp ’ , o r ’ zn ’
12 i m p r e s s e d M ( 1 ) . m i n x = −1e −3;
i m p r e s s e d M ( 1 ) . m i n y = −1e −3;
14 i m p r e s s e d M ( 1 ) . max x = 1e −3;
i m p r e s s e d M ( 1 ) . max y = 1e −3;
16 i m p r e s s e d M ( 1 ) . d i r e c t i o n = ’ zp ’ ;
impressed M ( 1 ) . magnitude = 1 ;
18 impressed M ( 1 ) . waveform type = ’ gaussian ’ ;
impressed M ( 1 ) . waveform index = 2;
11 % f r e q u e n c y domain p a r a m e t e r s
f r e q u e n c y d o m a i n . s t a r t = 20 e6 ;
13 f r e q u e n c y d o m a i n . end = 20 e9 ;
f r e q u e n c y d o m a i n . s t e p = 20 e6 ;
15
M1
ny=600
nx=600
Figure 7.13 (a) A two-dimensional TEz FDTD problem used as open boundary reference and its simulation results:
an empty two-dimensional problem space.
−7
x 10
1
0.5
(ampere/meter)
−0.5
−1
−1.5
0 0.5 1 1.5 2 2.5 3 3.5 4
time (ns)
Figure 7.13 (b) A two-dimensional TEz FDTD problem used as open boundary reference and its simulation results:
sampled H z in time.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
−20
−40
−60
errort (dB)
−80
−100
−120
−140
−160
−180
−200
0 0.5 1 1.5 2 2.5 3 3.5 4
time (ns)
(a) Error in time
0
−10
−20
−30
errorf (dB)
−40
−50
−60
−70
−80
0 5 10 15 20
frequency (GHz)
(b) Error in frequency domain
Figure 7.15 A two-dimensional problem space including a cylinder and a line source.
electric field distribution in a problem space including a cylinder of circular cross-section with
radius 0.2 m, and dielectric constant 4, due to a current line source placed 0.2 m away from
the cylinder and excited at 1 GHz frequency. Figure 7.15 illustrates the geometry of the two-
dimensional problem space. The problem space is composed of square cells with 5 mm on a side
and is terminated by PML boundaries with 8 cells thickness. The air gap between the cylinder
and the boundaries is 30 cells in the xn, yn, and y p directions and 80 cells in the xp direction.
The definition of the geometry is shown in Listing 7.20. The line source is an impressed current
density with a sinusoidal waveform as shown in Listing 7.21.
In this example we define two new output types: (1) transient electric field distributions repre-
sented with a parameter named sampled transient E planes; and (2) electric field distributions
calculated at certain frequencies represented with a parameter named sampled frequency E -
planes. The definition of these parameters is shown in Listing 7.22, and the initialization of these
parameters are performed in the subroutine initialize output parameters 2d is shown in 7.23.
The electric fields at node positions are captured and displayed as an animation while
the simulation is running in the subroutine display sampled parameters 2d as shown in
Listing 7.24.
27 % f r e q u e n c y domain
s a m p l e d f r e q u e n c y E p l a n e s ( 1 ) . component = ’ z ’ ;
29 s a m p l e d f r e q u e n c y E p l a n e s ( 1 ) . f r e q u e n c y = 1 e9 ;
% i n i t i a l i z e sampled t i m e h a r m o n i c e l e c t r i c f i e l d
42 f o r i n d =1: n u m b e r o f s a m p l e d f r e q u e n c y E p l a n e s
s a m p l e d f r e q u e n c y E p l a n e s ( i n d ) . s a m p l e d f i e l d = z e r o s ( nxp1 , nyp1 ) ;
44 end
x c o o r = l i n s p a c e ( f d t d d o m a i n . min x , f d t d d o m a i n . max x , nxp1 ) ;
46 y c o o r = l i n s p a c e ( f d t d d o m a i n . min y , f d t d d o m a i n . max y , nyp1 ) ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
0.05
sampled electric field
0.04
0.03
0.02
(volt/meter)
0.01
−0.01
−0.02
−0.03
−0.04
−0.05
0 10 20 30 40 50 60 70 80 90
time (ns)
Figure 7.16 Sampled electric field at a point between the cylinder and the line source.
Figure 7.19 Magnitude of electric field distribution calculated by FDTD using DFT at 1 GHz.
Exercises 229
Figure 7.20 Magnitude of electric field distribution calculated by FDTD using DFT at 2 GHz.
The FDTD simulation is run, and electric field distributions are calculated for 1 GHz and 2
GHz and are plotted in Figs. 7.19 and 7.20, respectively. One can notice that the result obtained
at 1 GHz using the on-the-fly DFT technique is the same as the ones shown in Section 7.5.2.
7.6 EXERCISES
7.1 The performance of the two-dimensional PML for the T E z case is evaluated in Section
7.5.1. Follow the same procedure, and evaluate the performance of the two-dimensional
PML case for the T Mz case. You can use the same parameters as the given example. Notice
that you need to use an electric current source to excite the T Mz mode, and you can sample
E z at a point close to the PML boundaries.
7.2 In Sections 7.5.2 and 7.5.3 new code sections are added to the two-dimensional FDTD
program to add the functionality of displaying the electric field distributions. Follow the
same procedure, and add new code sections to the program such that the program will
display magnetic field distributions as animations while the simulation is running and it will
display the magnitude of the magnetic field distribution as the response of time-harmonic
excitations at a number of frequencies.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
8
The Convolutional Perfectly
Matched Layer
In the previous chapter we discussed the perfectly matched layers (PMLs) as a boundary to
terminate the finite-difference time-domain (FDTD) lattices to simulate open boundary problems.
However, the PML is shown to be ineffective for absorbing evanescent waves. As a result, the PML
must be placed sufficiently far from an obstacle such that the evanescent waves have sufficiently
decayed [23]. However, this increases the number of cells in an FDTD computational domain
and, hence, the computational memory and time requirements. Another problem reported for
PML is that it suffers from late-time reflections when terminating highly elongated lattices or
when simulating fields with very long time signatures [23]. This is partly due to the weakly causal
nature of the PML [24].
A strictly causal form of the PML, which is referred to as the complex frequency-shifted PML
(CFS-PML) was developed in [25]. It has been shown that the CFS-PML is highly effective at
absorbing evanescent waves and signals with a long time signature. Therefore, using the CFS-
PML, the boundaries can be placed closer to the objects in the problem space and a time and
memory saving can be achieved, thus avoiding the aforementioned weaknesses of the PML.
An efficient implementation of the CFS-PML, known as the convolutional PML (CPML), is
introduced in [23]. The theoretical analyses of the CPML and other forms of PML can be found
in [26]. In this chapter we introduce the formulation of the CPML based on [23] and provide a
MATLAB implementation of the concept.
In Chapter 7 we provided the PML equations for terminating a problem space surrounded by free
space. However, in general a PML can be constructed to terminate a problem space surrounded by
an arbitrary media. Furthermore, it can even simulate infinite length structures; these structures
penetrate into the PML, and the PML absorbs the waves traveling on them.
1 ∂ Hz 1 ∂ Hy
j ωεx E x + σxe E x = − , (8.1a)
Se y ∂ y Se z ∂z
231
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
1 ∂ Hx 1 ∂ Hz
j ωε y E y + σ ye E y = − , (8.1b)
Se z ∂z Se x ∂ x
1 ∂ Hy 1 ∂ Hx
j ωεz E z + σze E z = − , (8.1c)
Se x ∂ x Se y ∂ y
where Se x , Se y , and Se z are the stretched coordinate metrics, and σxe , σ ye , and σze are the electric
conductivities of the terminating media. One can notice that (8.1) is in the frequency domain with
e j ωt time-harmonic convention.
Equations (8.1) reduce to Berenger’s PML in the case where
σpex σpey σpez
Se x = 1 + , Se y = 1 + , and Se z = 1 + . (8.2)
j ωε0 j ωε0 j ωε0
1 ∂ Ez 1 ∂ Ey
j ωµx Hx + σxm Hx = − + , (8.3a)
Smy ∂ y Smz ∂z
1 ∂ Ex 1 ∂ Ez
j ωµ y Hy + σ ym Hy = − + , (8.3b)
Smz ∂z Smx ∂ x
1 ∂ Ey 1 ∂ Ex
j ωµz Hz + σzm Hz = − + . (8.3c)
Smx ∂ x Smy ∂ y
where the parameters κei , κmi , αei , and αmi are the new parameters taking the values
∂ Ex ∂ Hz ∂ Hy
εx + σxe E x = S¯e y ∗ − S¯e z ∗ , (8.8)
∂t ∂y ∂z
where S¯e y is a function of time that is the inverse Laplace transform of Se−1 ¯
y , and Se z is the inverse
−1
Laplace transform of Se z . One should notice that the product operations in the frequency-domain
equations (8.1) and (8.3) are expressed as convolution operations in the time domain.
The terms S¯ei and Smi ¯ are then given in open form as
δ(t) σ pei − σ pei
+
α pei
t δ(t)
S¯ei (t) = − e ε0 κei ε0
u(t) = + ξei (t), (8.9a)
κei ε0 κei2 κei
σ
¯ (t) = δ(t) − pmi e − δ(t)
σpmi αpmi
+ t
Smi µ0 κmi µ0
u(t) = + ξmi (t), (8.9b)
κmi µ0 κmi
2 κmi
where δ(t) is the unit impulse function and u(t) is the unit step function. Inserting (8.9) in (8.8)
leads to
∂ Ex 1 ∂ Hz 1 ∂ Hy ∂ Hz ∂ Hy
εx + σxe E x = − + ξe y (t) ∗ − ξe z (t) ∗ . (8.10)
∂t κe y ∂ y κe z ∂z ∂y ∂z
At this point the central difference approximation of the derivatives can be used to express (8.10)
in discrete time and space and then to obtain the field updating equation for E xn+1 . However,
(8.10) includes two convolution terms, and these terms also need to be expressed in discrete time
and space before proceeding with the construction of the updating equations.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
τ =t
m=n−1
∂ Hz (t − τ ) n−m+ 12 n−m+ 12
ξe y (τ ) dτ Z0e y (m) Hz (i, j, k) − Hz (i, j − 1, k) , (8.12)
τ =0 ∂y
m=0
where
τ =(m+1)t
1
Z0e y (m) = ξe y (τ )d τ
y τ =mt
τ =(m+1)t σ
σpey − ε pei
α pei
κ + ε τ
=− e 0 ei 0 dτ
yε0 κe2y τ =mt
σ
− κpei +α pei mt
= ae y e ei ε0
, (8.13)
and
σpey
σpey − +α t
ae y = e κe y pey ε0 − 1 . (8.14)
y σpey κe y + αe y κe2y
Having derived the expression for Z0e y (m) we can express the discrete convolution term in (8.12)
n+ 1
with a new parameter ψexy 2 (i, j, k), such that
m=n−1
n+ 1 n−m+ 12 n−m+ 12
ψexy 2 (i, j, k) = Z0e y (m) Hz (i, j, k) − Hz (i, j − 1, k) . (8.15)
m=0
Here the subscript exy indicates that this term is updating E x and is associated with the deriva-
tive of the magnetic field term with respect to y. Then equation (8.10) can be written in
discrete form as
m=n−1
ψ(n) = Ae mT B(n − m), (8.17)
m=0
A = ae y
σpey t
T=− + αe y
κe y ε0
n−m+ 12 n−m+ 12
B = Hz (i, j, k) − Hz (i, j − 1, k).
We can write the same equation in open form for one previous time step value ψ(n − 1) as
Comparing the right-hand side of (8.18) with (8.19), one can realize that the right-hand side of
(8.18), except the first term, is nothing but a multiplication of e T by ψ(n − 1). Therefore, (8.18)
can be rewritten as
In this form only the previous time step value ψ(n − 1) is required to calculate the new value of
ψ(n). Hence, the need for the storage of all previous values is eliminated. Since the new value of
ψ(n) is calculated recursively in (8.20), this technique is known as recursive convolution.
After applying this technique to simplify (8.15) we obtain
n+ 1 n− 1 n+ 1 n+ 1
ψexy 2 (i, j, k) = b e y ψexy 2 (i, j, k) + a e y Hz 2 (i, j, k) − Hz 2 (i, j − 1, k) , (8.21)
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
where
σpey
ae y = bey − 1 , (8.22)
y σpey κe y + αe y κe y
2
σ
− κe y +αpey t
pey
bey = e ε
0 . (8.23)
Then the updating equation for the CPML region takes the form
Start
Yes No
Stop Last iteration?
Figure 8.1 The FDTD flowchart including the steps of CPML algorithm.
n+ 1
Notice that the negative sign in front of the ψexz 2 (i, j, k) term in (8.16) is embedded in the
coefficient Ce xhy (i, j, k) as can be followed from (1.26). Here two new coefficients can be
defined such that
These modifications are applied to the coefficients only at the positions overlapping with the
respective CPML regions and further reduce (8.27) to
With the given form of updating equation and coefficients, E xn+1 (i, j, k) is updated using the first
n+ 1 n+ 1
three terms on the right side in the entire domain as usual. Then ψexy 2 (i, j, k) and ψexz 2 (i, j, k)
n+ 1
are calculated (e.g., using (8.21) for ψexy 2 (i, j, k)), and the last two terms of (8.29) are added to
E xn+1 (i, j, k) at their respective CPML regions. It should be mentioned that the same procedure
applies for updating the other electric and magnetic field components as well by using their
respective updating equations and CPML parameters.
(a) σpex , σ pmx , αex , αmx , κex , and κmx (b) σpey , σ pmy , αey , αmy , κey , and κmy
(c) σpez , σ pmz , αez , αmz , κez , and κmz (d) Overlapping CPML regions
npml + 1
σopt = √ . (8.30)
150π εr i
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Here npml is the order of the polynomial scaling, and εr is the relative permittivity of the background
material. Then the CPML conductivity σ pei can be calculated by
ρ npml
σ pei (ρ) = σmax , (8.31)
δ
where ρ is the distance from the computational domain–PML interface to the position of the field
component and δ is the thickness of the CPML layer. Similarly, σpmi can be calculated by
µ0 ρ npml
σpmi (ρ) = σmax , (8.32)
ε0 δ
This scaling of the CPML parameter profile is chosen as before specifically to reduce the
reflection error of evanescent modes; α must be nonzero at the front boundary interface. However,
for the CFS-PML to absorb purely propagating modes at low frequency, α should actually decrease
to zero away from the boundary interface [23].
The choice of the parameters σfactor , κmax , αmax , αmin , and npml and the thickness of the CPML
layer in terms of number of cells determine the performance of the CPML. In [23] parametric
studies have been performed to evaluate the effects of these parameters. Usually σfactor can be taken
in the range 0.7–1.5, κmax in the range 5–11, αmax in the range 0–0.05, thickness of CPML as 8
cells, and npml as 2, 3, or 4.
25 b o u n d a r y . t y p e x n = ’ cpml ’ ;
boundary . a i r b u f f e r n u m b e r o f c e l l s x n = 4 ;
27 boundary . c p m l n u m b e r o f c e l l s x n = 5 ;
29 b o u n d a r y . t y p e x p = ’ cpml ’ ;
boundary . a i r b u f f e r n u m b e r o f c e l l s x p = 4 ;
31 boundary . c p m l n u m b e r o f c e l l s x p = 5 ;
33 b o u n d a r y . t y p e y n = ’ cpml ’ ;
boundary . a i r b u f f e r n u m b e r o f c e l l s y n = 0 ;
35 b o u n d a r y . c p m l n u m b e r o f c e l l s y n = −5;
37 b o u n d a r y . t y p e y p = ’ cpml ’ ;
boundary . a i r b u f f e r n u m b e r o f c e l l s y p = 0 ;
39 b o u n d a r y . c p m l n u m b e r o f c e l l s y p = −5;
41 b o u n d a r y . t y p e z n = ’ pec ’ ;
boundary . a i r b u f f e r n u m b e r o f c e l l s z n = 0 ;
43 boundary . c p m l n u m b e r o f c e l l s z n = 5 ;
45 b o u n d a r y . t y p e z p = ’ pec ’ ;
boundary . a i r b u f f e r n u m b e r o f c e l l s z p = 6 ;
47 boundary . c p m l n u m b e r o f c e l l s z p = 5 ;
Another parameter required for a boundary defined as CPML is the thickness of the CPML
layer in terms of number of cells. A new parameter cpml number of cells is defined as a subfield
of the parameter boundary, and the thicknesses of the CPML regions are assigned to this new pa-
rameter. One can notice that the thickness of CPML is 5 cells in the xn and xp regions and −5 cells
in the yn and y p regions. As discussed before, objects in an FDTD problem space can be defined
as penetrating into CPML; thus, these objects resemble structures extending to infinity. As a con-
vention, if cpml number of cells is defined as a negative number, it is assumed that the CPML
layers are extending to inside of the domain rather than extending outside from the end of the air
buffer region. For instance, if air buffer number of cells is zero, and the cpml number of cells
is a negative number at the yn region, then the objects on the yn side will be penetrating to the
CPML region. Figure 8.3 illustrates a problem space including a 20 × 20 × 4 cells brick and
having its boundaries defined as shown in Listing 8.1. The solid thick line shows the boundaries
of the problem space. The dash-dot thick line shows the inner boundaries of the CPML regions.
The brick penetrates into the CPML in yn and y p regions. The zn and zp boundaries are PEC.
The other parameters described in Section 8.3 are defined in define problem space parameters
as well. The order of the polynomial distribution npml is defined as boundary.cpml order as
shown in Listing 8.1. The σfactor is defined as boundary.cpml sigma factor, κmax is defined as
boundary.cpml kappa max, αmax is defined as boundary.cpml alpha max, and similarly, αmin is
defined as boundary.cpml alpha min.
position of the outer boundary needs to be updated accordingly. The necessary modifications are
implemented in calculate domain size, and the modified section of the code is given in Listing 8.2.
It can be noticed in the code that, for the sides where the boundary type is CPML, the problem
space boundary is extended outward by the thickness of the CPML.
Listing 8.2 calculate domain size
% D e t e r m i n e t h e problem s p a c e b o u n d a r i e s including air buffers
36 fdtd domain . min x = fdtd domain . min x . . .
− dx * b o u n d a r y . a i r b u f f e r n u m b e r o f cells xn ;
38 fdtd domain . min y = fdtd domain . min y . . .
− dy * b o u n d a r y . a i r b u f f e r n u m b e r o f cells yn ;
40 fdtd domain . min z = fdtd domain . min z . . .
− dz * b o u n d a r y . a i r b u f f e r n u m b e r o f cells zn ;
42 f d t d d o m a i n . max x = f d t d d o m a i n . max x . . .
+ dx * b o u n d a r y . a i r b u f f e r n u m b e r o f cells xp ;
44 f d t d d o m a i n . max y = f d t d d o m a i n . max y . . .
+ dy * b o u n d a r y . a i r b u f f e r n u m b e r o f cells yp ;
46 f d t d d o m a i n . max z = f d t d d o m a i n . max z . . .
+ dz * b o u n d a r y . a i r b u f f e r n u m b e r o f cells zp ;
48
% D e t e r m i n e t h e problem s p a c e b o u n d a r i e s i n c l u d i n g cpml l a y e r s
50 i f s t r c m p ( b o u n d a r y . t y p e x n , ’ cpml ’ ) && . . .
( b o u n d a r y . c p m l n u m b e r o f c e l l s x n >0)
52 fdtd domain . min x = fdtd domain . min x . . .
− dx * b o u n d a r y . c p m l n u m b e r o f c e l l s x n ;
54 end
i f s t r c m p ( b o u n d a r y . t y p e x p , ’ cpml ’ ) && . . .
56 ( b o u n d a r y . c p m l n u m b e r o f c e l l s x p >0)
f d t d d o m a i n . max x = f d t d d o m a i n . max x . . .
58 + dx * b o u n d a r y . c p m l n u m b e r o f c e l l s x p ;
end
60 i f s t r c m p ( b o u n d a r y . t y p e y n , ’ cpml ’ ) && . . .
( b o u n d a r y . c p m l n u m b e r o f c e l l s y n >0)
62 fdtd domain . min y = fdtd domain . min y . . .
− dy * b o u n d a r y . c p m l n u m b e r o f c e l l s y n ;
64 end
i f s t r c m p ( b o u n d a r y . t y p e y p , ’ cpml ’ ) && . . .
66 ( b o u n d a r y . c p m l n u m b e r o f c e l l s y p >0)
f d t d d o m a i n . max y = f d t d d o m a i n . max y . . .
68 + dy * b o u n d a r y . c p m l n u m b e r o f c e l l s y p ;
end
70 i f s t r c m p ( b o u n d a r y . t y p e z n , ’ cpml ’ ) && . . .
( b o u n d a r y . c p m l n u m b e r o f c e l l s z n >0)
72 fdtd domain . min z = fdtd domain . min z . . .
− dz * b o u n d a r y . c p m l n u m b e r o f c e l l s z n ;
74 end
i f s t r c m p ( b o u n d a r y . t y p e z p , ’ cpml ’ ) && . . .
76 ( b o u n d a r y . c p m l n u m b e r o f c e l l s z p >0)
f d t d d o m a i n . max z = f d t d d o m a i n . max z . . .
78 + dz * b o u n d a r y . c p m l n u m b e r o f c e l l s z p ;
end
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
The initialization process of the CPML continues in initialize boundary conditions, which
is a subroutine called in the main program fdtd solve as shown in Listing 3.1. So far we have
not implemented any code in initialize boundary conditions, since the only type of boundary
we have considered is PEC; which does not require any special treatment; the tangential electric
field components on the outer faces of the problem space are not updated, and their values
are left zero during the time-marching loop which naturally simulates the PEC boundaries.
However, the CPML requires special treatment, and the initialization of the CPML is coded
in initialize boundary conditions accordingly as shown in Listing 8.3. In this subroutine several
frequently used parameters are defined for convenience. For instance, the parameter is cpml xn
is a logical parameter that indicates whether the xn boundary is CPML, and n cpml xn stores
the thickness of the CPML for the xn region. Similar parameters are defined for other sides as
well. Then another subroutine, initialize CPML ABC, is called to continue the CPML specific
initialization process.
Listing 8.4 shows the contents of initialize CPML ABC for the xn and xp regions. The
code listing for the other sides follows the same procedure. Let’s consider the xp region, for
example. In the code, distribution of the CPML parameters σpex , σ pmx , κe x , κmx , αe x , and αmx along
the CPML thickness are calculated as one-dimensional arrays first, with the respective names
% I n i t i a l i z e cpml f o r xn r e g i o n
10 if is cpml xn
12 % d e f i n e one−d i m e n s i o n a l t e m p o r a r y cpml p a r a m e t e r a r r a y s
sigma max = s i g m a r a t i o * ( p o r d e r + 1 ) / ( 1 5 0 * p i * dx ) ;
14 n c e l l s = n cpml xn ;
rho e = ( [ n c e l l s : −1:1] −0.75)/ n c e l l s ;
16 rho m = ( [ n c e l l s : − 1 : 1 ] − 0 . 2 5 ) / n c e l l s ;
s i g m a p e x x n = sigma max * r h o e . ˆ p o r d e r ;
18 s i g m a p m x x n = sigma max * rho m . ˆ p o r d e r ;
s i g m a p m x x n = ( mu 0 / e p s 0 ) * s i g m a p m x x n ;
20 k a p p a e x x n = 1 + ( kappa max − 1 ) * r h o e . ˆ p o r d e r ;
k a p p a m x x n = 1 + ( kappa max − 1 ) * rho m . ˆ p o r d e r ;
22 a l p h a e x x n = a l p h a m i n + ( a l p h a m a x − a l p h a m i n ) * (1 − r h o e ) ;
a l p h a m x x n = a l p h a m i n + ( a l p h a m a x − a l p h a m i n ) * (1 − rho m ) ;
24 a l p h a m x x n = ( mu 0 / e p s 0 ) * a l p h a m x x n ;
26 % d e f i n e one−d i m e n s i o n a l cpml p a r a m e t e r a r r a y s
c p m l b e x x n = exp ( ( − d t / e p s 0 ) . . .
28 * ( ( s i g m a p e x x n . / k a p p a e x x n )+ a l p h a e x x n ) ) ;
c p m l a e x x n = ( 1 / dx ) * ( c p m l b e x x n − 1 . 0 ) . * s i g m a p e x x n . . .
30 . / ( k a p p a e x x n . * ( s i g m a p e x x n +k a p p a e x x n . * a l p h a e x x n ) ) ;
c p m l b m x x n = exp ( ( − d t / mu 0 ) . . .
32 * ( ( s i g m a p m x x n . / k a p p a m x xn )+ a l p h a m x x n ) ) ;
c p m l a m x x n = ( 1 / dx ) * ( cpml b mx xn − 1 . 0 ) . * s i g m a p m x x n . . .
34 . / ( k a p p a m x xn . * ( s i g m a p m x x n+k a p p a m x xn . * a l p h a m x x n ) ) ;
36 % C r e a t e and i n i t i a l i z e 2D cpml c o n v o l u t i o n p a r a m e t e r s
Psi eyx xn = z e r o s ( n c e l l s , ny , nzp1 ) ;
38 Psi ezx xn = z e r o s ( n c e l l s , nyp1 , nz ) ;
Psi hyx xn = z e r o s ( n c e l l s , nyp1 , nz ) ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
40 P s i h z x x n = z e r o s ( n c e l l s , ny , nzp1 ) ;
% A d j u s t FDTD c o e f f i c i e n t s i n t h e CPML r e g i o n
50 % N o t i c e t h a t E y ( 1 , : , : ) and E z ( 1 , : , : ) a r e n o t u p d a t e d by cmpl
for i = 1: n c e l l s
52 Ceyhz ( i + 1 , : , : ) = Ceyhz ( i + 1 , : , : ) / kappa ex xn ( i ) ;
Cezhy ( i + 1 , : , : ) = Cezhy ( i + 1 , : , : ) / kappa ex xn ( i ) ;
54 C h y e z ( i , : , : ) = C h y e z ( i , : , : ) / k a p p a m x xn ( i ) ;
C h z e y ( i , : , : ) = C h z e y ( i , : , : ) / k a p p a m x xn ( i ) ;
56 end
58 % D e l e t e t e m p o r a r y a r r a y s . T h e s e a r r a y s w i l l n o t be u s e d any more .
c l e a r sigma pex xn sigma pmx xn ;
60 c l e a r k a p p a e x x n k a p p a m x xn ;
clear alpha ex xn alpha mx xn ;
62 end
64 % I n i t i a l i z e cpml f o r xp r e g i o n
if is cpml xp
66
% d e f i n e one−d i m e n s i o n a l t e m p o r a r y cpml p a r a m e t e r a r r a y s
68 sigma max = s i g m a r a t i o * ( p o r d e r + 1 ) / ( 1 5 0 * p i * dx ) ;
n c e l l s = n cpml xp ;
70 rho e = ( [ 1 : n c e l l s ] −0.75)/ n c e l l s ;
rho m = ( [ 1 : n c e l l s ] − 0 . 2 5 ) / n c e l l s ;
72 s i g m a p e x x p = sigma max * r h o e . ˆ p o r d e r ;
s i g m a p m x x p = sigma max * rho m . ˆ p o r d e r ;
74 s i g m a p m x x p = ( mu 0 / e p s 0 ) * s i g m a p m x x p ;
k a p p a e x x p = 1 + ( kappa max − 1 ) * r h o e . ˆ p o r d e r ;
76 k a p p a m x x p = 1 + ( kappa max − 1 ) * rho m . ˆ p o r d e r ;
a l p h a e x x p = a l p h a m i n + ( a l p h a m a x − a l p h a m i n ) * (1 − r h o e ) ;
78 a l p h a m x x p = a l p h a m i n + ( a l p h a m a x − a l p h a m i n ) * (1 − rho m ) ;
a l p h a m x x p = ( mu 0 / e p s 0 ) * a l p h a m x x p ;
80
% d e f i n e one−d i m e n s i o n a l cpml p a r a m e t e r a r r a y s
82 c p m l b e x x p = exp ( ( − d t / e p s 0 ) . . .
* ( ( s i g m a p e x x p . / k a p p a e x x p )+ a l p h a e x x p ) ) ;
84 c p m l a e x x p = ( 1 / dx ) * ( c p m l b e x x p − 1 . 0 ) . * s i g m a p e x x p . . .
. / ( k a p p a e x x p . * ( s i g m a p e x x p +k a p p a e x x p . * a l p h a e x x p ) ) ;
86 c p m l b m x x p = exp ( ( − d t / mu 0 ) . . .
* ( ( s i g m a p m x x p . / k a p p a m x x p )+ a l p h a m x x p ) ) ;
88 c p m l a m x x p = ( 1 / dx ) * ( c p m l b m x xp − 1 . 0 ) . * s i g m a p m x x p . . .
. / ( k a p p a m x x p . * ( s i g m a p m x x p+k a p p a m x x p . * a l p h a m x x p ) ) ;
90
% C r e a t e and i n i t i a l i z e 2D cpml c o n v o l u t i o n p a r a m e t e r s
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
% D e l e t e t e m p o r a r y a r r a y s . T h e s e a r r a y s w i l l n o t be u s e d any more .
114 c l e a r sigma pex xp sigma pmx xp ;
c l e a r kappa ex xp kappa mx xp ;
116 clear alpha ex xp alpha mx xp ;
end
sigma pex xp, sigma pmx xp, kappa ex xp, kappa mx xp, alpha ex xp, and alpha mx xp, us-
ing the equations given in Section 8.3. The parameters σpex , κe x , and αe x are used to update the E y
and E z field components, and the distances of these field components from the interior interface
of the CPML are used in equations (8.31), (8.33), and (8.35) as ρe . The positions of the field
components and the respective distances of the field components from the CPML interface are
illustrated in Fig. 8.4. One can see that CPML interface is assumed to be offset from the first
CPML cell by a quarter cell size. This is to ensure that the same number of electric and magnetic
field components are updated by the CPML algorithm. Similarly, Fig. 8.5 illustrates the magnetic
field components of Hy and Hz being updated using the CPML in the xp region. The distances
of these field components from the CPML interface are denoted as ρh and are used in equations
(8.32), (8.34), and (8.36) to calculate σ pmx , κmx , and αmx .
Then Listing 8.4 continues with calculation of a e x , b e x , a mx , and b mx as cpml a ex xp,
cpml b ex xp, cpml a mx xp, and cpml b mx xp using the equations in Appendix B. Then the
CPML auxiliary parameters ψe y x , ψe zx , ψhy x , and ψhzx are defined as two dimensional arrays with
the names Psi eyx xp, Psi ezx xp, Psi hyx xp, and Psi hzx xp and are initialized with zero value.
The coefficients Cψe y x , Cψe zx , Cψhy x , and Cψhzx are calculated and stored as two-dimensional ar-
rays with the respective names CPsi eyx xp, CPsi ezx xp, CPsi hyx xp, and CPsi hzx xp. Then
the FDTD updating coefficients Ceyhz, Cezhy, Chyez, and Chzey are scaled with the respective
κ values in the xp region. Finally, the parameters that will not be used anymore during the FDTD
calculations are cleared from MATLAB’s workspace.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
ρe(2)
ρe(1)
Ey and Ez components
updated by CPML
Figure 8.4 Positions of the electric field components updated by CPML in the x p region.
ρh(2)
ρh(1)
Hy and Hz components
updated by CPML
Figure 8.5 Positions of the magnetic field components updated by CPML in the x p region.
s t a r t t i m e = cputime ;
6 current time = 0;
24 e n d t i m e = cputime ;
t o t a l t i m e i n m i n u t e s = ( end time − s t a r t t i m e ) / 6 0 ;
26 disp ( [ ’ T o t a l s i m u l a t i o n time i s ’ . . .
num2str ( t o t a l t i m e i n m i n u t e s ) ’ m i n u t e s . ’ ] ) ;
The implementation of update magnetic field CPML ABC is given in Listing 8.6. The mag-
netic field components are updated for the current time step using the regular updating equations
in update magnetic fields, and then in update magnetic field CPML ABC, first the auxil-
iary ψ parameters are calculated using the current values of the electric field components.
These terms are then added to the appropriate magnetic field components in their respective
CPML regions.
Similarly, the implementation of update electric field CPML ABC is given in Listing 8.7.
The electric field components are updated for the current time step using the regular updating
equations in update electric fields, and then in update electric field CPML ABC, first the aux-
iliary ψ parameters are calculated using the current values of the magnetic field components.
These terms are then added to the appropriate electric field components in their respective
CPML regions.
One can notice in the code listings that the arrays representing ψe and ψh are two-dimensional,
whereas the arrays representing a ei , a mi , b ei , and b mi are one-dimensional. Therefore, ψe and
ψh are updated in a “for” loop using the one-dimensional arrays; if they were defined as two-
dimensional arrays, the “for” loop would be avoided, which would speed up the calculation with
the trade-off of increased memory. In the two-dimensional array case, the coefficients repre-
senting Cψe and Cψm can be distributed over a ei , a mi , b ei , and b mi in the initialization process
initialize CPML ABC, which further reduces the amount of calculations during the CPML
updates.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
15 if is cpml xp
n s t = nx − n c p m l x p ;
17 for i = 1: n cpml xp
P s i h y x x p ( i , : , : ) = cpml b mx xp ( i ) * P s i h y x x p ( i , : , : ) . . .
19 + cpml a mx xp ( i ) * ( Ez ( i+n s t +1 ,: ,:) − Ez ( i+n st , : , : ) ) ;
P s i h z x x p ( i , : , : ) = cpml b mx xp ( i ) * P s i h z x x p ( i , : , : ) . . .
21 + cpml a mx xp ( i ) * ( Ey ( i + n s t +1 ,: ,:) − Ey ( i+n s t , : , : ) ) ;
end
23
So far we have discussed the CPML algorithm and have demonstrated its implementation in the
MATLAB program. In this section we provide examples in which the boundaries are realized by
the CPML.
if is cpml xp
16 n s t = nx − n c p m l x p ;
for i = 1: n cpml xp
18 Psi eyx xp ( i , : , : ) = cpml b ex xp ( i ) * Psi eyx xp ( i ,: ,:) ...
+ c p m l a e x x p ( i ) * ( Hz ( i + n s t , : , : ) − Hz ( i+n st − 1 ,: ,:));
20 Psi ezx xp ( i , : , : ) = cpml b ex xp ( i ) * Psi ezx xp ( i ,: ,:) ...
+ c p m l a e x x p ( i ) * ( Hy ( i + n s t , : , : ) − Hy ( i+n st − 1 ,: ,:));
22 end
E y ( n s t +1: nx , : , : ) = E y ( n s t +1: nx , : , : ) . . .
24 + CPsi eyx xp .* Psi eyx xp ;
E z ( n s t +1: nx , : , : ) = E z ( n s t +1: nx , : , : ) . . .
26 + CPsi ezx xp .* Psi ezx xp ;
end
25 b o u n d a r y . t y p e x n = ’ cpml ’ ;
boundary . a i r b u f f e r n u m b e r o f c e l l s x n = 5 ;
27 boundary . c p m l n u m b e r o f c e l l s x n = 8 ;
29 b o u n d a r y . t y p e x p = ’ cpml ’ ;
boundary . a i r b u f f e r n u m b e r o f c e l l s x p = 5 ;
31 boundary . c p m l n u m b e r o f c e l l s x p = 8 ;
33 b o u n d a r y . t y p e y n = ’ cpml ’ ;
boundary . a i r b u f f e r n u m b e r o f c e l l s y n = 5 ;
35 boundary . c p m l n u m b e r o f c e l l s y n = 8 ;
37 b o u n d a r y . t y p e y p = ’ cpml ’ ;
boundary . a i r b u f f e r n u m b e r o f c e l l s y p = 5 ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
39 boundary . c p m l n u m b e r o f c e l l s y p = 8 ;
41 b o u n d a r y . t y p e z n = ’ cpml ’ ;
boundary . a i r b u f f e r n u m b e r o f c e l l s z n = 5 ;
43 boundary . c p m l n u m b e r o f c e l l s z n = 8 ;
45 b o u n d a r y . t y p e z p = ’ cpml ’ ;
boundary . a i r b u f f e r n u m b e r o f c e l l s z p = 5 ;
47 boundary . c p m l n u m b e r o f c e l l s z p = 8 ;
1.2
sampled voltage at port 1
sampled voltage at port 2
1
source voltage
0.8
0.6
(V)
0.4
0.2
−0.2
0 0.5 1 1.5 2
time (ns)
Figure 8.6 Source voltage and sampled voltages observed at the ports of the low-pass filter.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
−3
x 10
12
sampled current at port 1
10 sampled current at port 2
4
(A)
−2
−4
−6
0 0.5 1 1.5 2
time (ns)
Figure 8.7 Sampled currents observed at the ports of the low-pass filter.
0
magnitude (dB)
−20
−40
−60
0 5 10 15 20
frequency (GHz)
200
phase (degrees)
−200
0 5 10 15 20
frequency (GHz)
magnitude (dB)
−20
−40
0 5 10 15 20
frequency (GHz)
200
phase (degrees)
−200
0 5 10 15 20
frequency (GHz)
y = 0.406 mm, and z = 0.265 mm. In this circuit the wide lines are 10 cells wide and the nar-
row lines are 6 cells wide. The center-to-center distances between the strips in the square coupler
section are 24 cells. The dielectric substrate has 2.2 dielectric constant and 3 cells thickness. The
definition of the geometry of the problem is shown in Listing 8.9.
The boundaries of the problem space are the same as those in Listing 8.8: that is, an 8 cells
thick CPML, which terminates a 5 cells thick air gap surrounding the circuit.
Figure 8.10 An FDTD problem space including a microstrip branch line coupler.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
bricks = [ ] ;
4 spheres = [ ] ;
6 % define a substrate
b r i c k s ( 1 ) . m i n x = −20* dx ;
8 b r i c k s ( 1 ) . m i n y = −25* dy ;
b r i c k s ( 1 ) . min z = 0 ;
10 b r i c k s ( 1 ) . max x = 20 * dx ;
b r i c k s ( 1 ) . max y = 25 * dy ;
12 b r i c k s ( 1 ) . max z = 3 * dz ;
bricks ( 1 ) . material type = 4;
14
% d e f i n e a PEC p l a t e
16 b r i c k s ( 2 ) . m i n x = −12* dx ;
b r i c k s ( 2 ) . m i n y = −15* dy ;
18 b r i c k s ( 2 ) . m i n z = 3 * dz ;
b r i c k s ( 2 ) . max x = 12 * dx ;
20 b r i c k s ( 2 ) . max y = −9* dy ;
b r i c k s ( 2 ) . max z = 3 * dz ;
22 bricks ( 2 ) . material type = 2;
24 % d e f i n e a PEC p l a t e
b r i c k s ( 3 ) . m i n x = −12* dx ;
26 b r i c k s ( 3 ) . mi n y = 9 * dy ;
b r i c k s ( 3 ) . m i n z = 3 * dz ;
28 b r i c k s ( 3 ) . max x = 12 * dx ;
b r i c k s ( 3 ) . max y = 15 * dy ;
30 b r i c k s ( 3 ) . max z = 3 * dz ;
bricks ( 3 ) . material type = 2;
32
% d e f i n e a PEC p l a t e
34 b r i c k s ( 4 ) . m i n x = −17* dx ;
b r i c k s ( 4 ) . m i n y = −12* dy ;
36 b r i c k s ( 4 ) . m i n z = 3 * dz ;
b r i c k s ( 4 ) . max x = −7* dx ;
38 b r i c k s ( 4 ) . max y = 12 * dy ;
b r i c k s ( 4 ) . max z = 3 * dz ;
40 bricks ( 4 ) . material type = 2;
42 % d e f i n e a PEC p l a t e
b r i c k s ( 5 ) . m i n x = 7 * dx ;
44 b r i c k s ( 5 ) . mi n y = −12* dy ;
b r i c k s ( 5 ) . m i n z = 3 * dz ;
46 b r i c k s ( 5 ) . max x = 17 * dx ;
b r i c k s ( 5 ) . max y = 12 * dy ;
48 b r i c k s ( 5 ) . max z = 3 * dz ;
bricks ( 5 ) . material type = 2;
50
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
% d e f i n e a PEC p l a t e
52 b r i c k s ( 6 ) . m i n x = −15* dx ;
b r i c k s ( 6 ) . mi n y = −25* dy ;
54 b r i c k s ( 6 ) . m i n z = 3 * dz ;
b r i c k s ( 6 ) . max x = −9* dx ;
56 b r i c k s ( 6 ) . max y = −12* dy ;
b r i c k s ( 6 ) . max z = 3 * dz ;
58 bricks ( 6 ) . material type = 2;
60 % d e f i n e a PEC p l a t e
b r i c k s ( 7 ) . m i n x = 9 * dx ;
62 b r i c k s ( 7 ) . mi n y = −25* dy ;
b r i c k s ( 7 ) . m i n z = 3 * dz ;
64 b r i c k s ( 7 ) . max x = 15 * dx ;
b r i c k s ( 7 ) . max y = −12* dy ;
66 b r i c k s ( 7 ) . max z = 3 * dz ;
bricks ( 7 ) . material type = 2;
68
% d e f i n e a PEC p l a t e
70 b r i c k s ( 8 ) . m i n x = −15* dx ;
b r i c k s ( 8 ) . mi n y = 12 * dy ;
72 b r i c k s ( 8 ) . m i n z = 3 * dz ;
b r i c k s ( 8 ) . max x = −9* dx ;
74 b r i c k s ( 8 ) . max y = 25 * dy ;
b r i c k s ( 8 ) . max z = 3 * dz ;
76 bricks ( 8 ) . material type = 2;
78 % d e f i n e a PEC p l a t e
b r i c k s ( 9 ) . m i n x = 9 * dx ;
80 b r i c k s ( 9 ) . mi n y = 12 * dy ;
b r i c k s ( 9 ) . m i n z = 3 * dz ;
82 b r i c k s ( 9 ) . max x = 15 * dx ;
b r i c k s ( 9 ) . max y = 25 * dy ;
84 b r i c k s ( 9 ) . max z = 3 * dz ;
bricks ( 9 ) . material type = 2;
86
% d e f i n e a PEC p l a t e a s ground
88 b r i c k s ( 1 0 ) . m i n x = −20* dx ;
b r i c k s ( 1 0 ) . mi n y = −25* dy ;
90 b r i c k s ( 1 0 ) . min z = 0 ;
b r i c k s ( 1 0 ) . max x = 20 * dx ;
92 b r i c k s ( 1 0 ) . max y = 25 * dy ;
b r i c k s ( 1 0 ) . max z = 0 ;
94 bricks ( 1 0 ) . material type = 2;
The voltage source with a 50 internal resistance is placed at the input of the circuit indicated
as port 1 as shown in Fig. 8.10. The outputs of the circuit are terminated by 50 resistors. The
definition of the voltage source and resistors is shown in Listing 8.10.
Four sampled voltages and four sampled currents are defined as the outputs of the circuit as
shown in Listing 8.11. One should notice that the sampled voltages and currents are defined
directly on the voltage source and the termination resistors. Therefore, the reference planes for
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
3 voltage sources = [ ] ;
current sources = [ ] ;
5 diodes = [ ] ;
resistors = [];
7 inductors = [ ] ;
capacitors = [ ] ;
9
% d e f i n e s o u r c e waveform t y p e s and p a r a m e t e r s
11 waveforms . g a u s s i a n ( 1 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 0 ;
waveforms . g a u s s i a n ( 2 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 15;
13
% voltage sources
15 % d i r e c t i o n : ’ xp ’ , ’ xn ’ , ’ yp ’ , ’ yn ’ , ’ zp ’ , o r ’ zn ’
% r e s i s t a n c e : ohms , m a g i t u d e : volts
17 v o l t a g e s o u r c e s ( 1 ) . m i n x = −15* dx ;
v o l t a g e s o u r c e s ( 1 ) . m i n y = −25* dy ;
19 v o l t a g e s o u r c e s ( 1 ) . min z = 0 ;
v o l t a g e s o u r c e s ( 1 ) . max x = −9* dx ;
21 v o l t a g e s o u r c e s ( 1 ) . max y = −25* dy ;
v o l t a g e s o u r c e s ( 1 ) . max z = 3 * dz ;
23 v o l t a g e s o u r c e s ( 1 ) . d i r e c t i o n = ’ zp ’ ;
v o l t a g e s o u r c e s ( 1 ) . r e s i s t a n c e = 50;
25 v o l t a g e s o u r c e s ( 1 ) . magnitude = 1 ;
v o l t a g e s o u r c e s ( 1 ) . waveform type = ’ gaussian ’ ;
27 v o l t a g e s o u r c e s ( 1 ) . waveform index = 1;
29 % resistors
% direction : ’ x ’ , ’ y ’ , or ’ z ’
31 % resistance : ohms
resistors (1). m i n x = 9 * dx ;
33 resistors (1). mi n y = −25* dy ;
resistors (1). min z = 0 ;
35 resistors (1). max x = 15 * dx ;
resistors (1). max y = −25* dy ;
37 resistors (1). max z = 3 * dz ;
resistors (1). direction = ’z ’ ;
39 resistors (1). r e s i s t a n c e = 50;
41 % resistors
% direction : ’ x ’ , ’ y ’ , or ’ z ’
43 % resistance : ohms
resistors (2). m i n x = 9 * dx ;
45 resistors (2). mi n y = 25 * dy ;
resistors (2). min z = 0 ;
47 resistors (2). max x = 15 * dx ;
resistors (2). max y = 25 * dy ;
49 resistors (2). max z = 3 * dz ;
resistors (2). direction = ’z ’ ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
51 r e s i s t o r s ( 2 ) . r e s i s t a n c e = 50;
53 % resistors
% direction : ’ x ’ , ’ y ’ , or ’ z ’
55 % resistance : ohms
resistors (3). m i n x = −15* dx ;
57 resistors (3). mi n y = 25 * dy ;
resistors (3). min z = 0 ;
59 resistors (3). max x = −9* dx ;
resistors (3). max y = 25 * dy ;
61 resistors (3). max z = 3 * dz ;
resistors (3). direction = ’z ’ ;
63 resistors (3). r e s i s t a n c e = 50;
12 % mode o f o p e r a t i o n
run simulation = true ;
14 show material mesh = true ;
show problem space = true ;
16
% f r e q u e n c y domain p a r a m e t e r s
18 f r e q u e n c y d o m a i n . s t a r t = 20 e6 ;
f r e q u e n c y d o m a i n . end = 10 e9 ;
20 f r e q u e n c y d o m a i n . s t e p = 20 e6 ;
88 s a m p l e d c u r r e n t s ( 3 ) . max z = 2 * dz ;
s a m p l e d c u r r e n t s ( 3 ) . d i r e c t i o n = ’ zp ’ ;
90 sampled currents ( 3 ) . display plot = false ;
% define animation
124 % f i e l d t y p e s h a l l be ’ e ’ o r ’ h ’
% p l a n e c u t s h a l l be ’ xy ’ , yz , o r z x
126 % component s h a l l be ’ x ’ , ’ y ’ , ’ z ’ , o r ’m;
animation ( 1 ) . f i e l d t y p e = ’ e ’ ;
128 a n i m a t i o n ( 1 ) . component = ’m ’ ;
animation ( 1 ) . p l a n e c u t ( 1 ) . t y pe = ’ xy ’ ;
130 a n i m a t i o n ( 1 ) . p l a n e c u t ( 1 ) . p o s i t i o n = 2 * dz ;
animation ( 1 ) . enable = true ;
132 animation ( 1 ) . d i s p l a y g r i d = f a l s e ;
animation ( 1 ) . d i s p l a y o b j e c t s = true ;
134
% d i s p l a y problem s p a c e p a r a m e t e r s
136 problem space display . labels = false ;
problem space display . a x i s a t o r i g i n = false ;
138 problem space display . axis outside domain = false ;
problem space display . grid xn = false ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
the S-parameter calculations are at the positions of the source and resistor terminations. Then
four 50 ports are defined by associating sampled voltage–current pairs with them. Then port 1
is set to be the excitation port for this FDTD simulation.
After the definition of the problem is completed, the FDTD simulation is performed for 4,000
time steps, and the S-parameters of this circuit are calculated. Figure 8.11 shows the results of
this calculation, where S11 , S21 , S31 , and S41 are plotted. There is a good agreement between the
plotted results and those published in [14].
−5
−10
magnitude (dB)
−15
S11
−20
S21
S31
−25
S41
−30
−35
−40
0 2 4 6 8 10
frequency (GHz)
microstrip circuit is constructed in the FDTD method as illustrated in Fig. 8.12. The microstrip
line is fed with a voltage source. There is a 5 cells air gap on the yn and zp sides of the substrate.
On the zn side of the substrate the boundary is PEC, which serves as the ground plane for the
microstrip line. The other sides of the geometry are terminated by CPML. One should notice
that the substrate and microstrip line penetrate into the CPML regions on the y p, xn, and xp
sides, thus simulating structures extending to infinity in these directions. The definition of the
problem space including the cell sizes and boundaries is shown in Listing 8.12. The definition of
the geometry is given in Listing 8.13. The microstrip line is fed with voltage source as defined in
Listing 8.14. A sampled voltage and a sampled current are defined 10 cells away from the source,
and they are tied to form a port as shown in Listing 8.15.
6 % A f a c t o r t h a t determines d u r a t i o n of a time s t e p
% wrt CFL l i m i t
8 courant factor = 0.9;
10 % A f a c t o r d e t e r m i n i n g t h e a c c u r a c y l i m i t o f FDTD r e s u l t s
number of cells per wavelength = 20;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
12
% D i m e n s i o n s o f a u n i t c e l l i n x , y , and z d i r e c t i o n s ( m e t e r s )
14 dx = 2 . 0 3 0 e −4;
dy = 2 . 0 3 0 e −4;
16 dz = 1 . 3 2 5 e −4;
18 % ==<b o u n d a r y c o n d i t i o n s >========
% Here we d e f i n e t h e b o u n d a r y c o n d i t i o n s p a r a m e t e r s
20 % ’ pec ’ : p e r f e c t e l e c t r i c c o n d u c t o r
% ’ cpml ’ : c o n l v o l u t i o n a l PML
22 % i f c p m l n u m b e r o f c e l l s i s l e s s than zero
% CPML e x t e n d s i n s i d e o f t h e domain r a t h e r t h a n o u t w a r d s
24
b o u n d a r y . t y p e x n = ’ cpml ’ ;
26 boundary . a i r b u f f e r n u m b e r o f c e l l s x n = 0 ;
b o u n d a r y . c p m l n u m b e r o f c e l l s x n = −8;
28
b o u n d a r y . t y p e x p = ’ cpml ’ ;
30 boundary . a i r b u f f e r n u m b e r o f c e l l s x p = 0 ;
b o u n d a r y . c p m l n u m b e r o f c e l l s x p = −8;
32
b o u n d a r y . t y p e y n = ’ cpml ’ ;
34 boundary . a i r b u f f e r n u m b e r o f c e l l s y n = 8 ;
boundary . c p m l n u m b e r o f c e l l s y n = 8 ;
36
b o u n d a r y . t y p e y p = ’ cpml ’ ;
38 boundary . a i r b u f f e r n u m b e r o f c e l l s y p = 0 ;
b o u n d a r y . c p m l n u m b e r o f c e l l s y p = −8;
40
b o u n d a r y . t y p e z n = ’ pec ’ ;
42 boundary . a i r b u f f e r n u m b e r o f c e l l s z n = 0 ;
boundary . c p m l n u m b e r o f c e l l s z n = 8 ;
44
b o u n d a r y . t y p e z p = ’ cpml ’ ;
46 boundary . a i r b u f f e r n u m b e r o f c e l l s z p = 10;
boundary . c p m l n u m b e r o f c e l l s z p = 8 ;
48
An FDTD simulation of the microstrip line is performed for 1,000 timesteps. Figure 8.13 shows
the source voltage and sampled voltage captured at the port position, whereas Fig. 8.14 shows the
sampled current. The sampled voltages and currents are transformed to the frequency domain, and
the return loss of the circuit is calculated as S11 using these frequency-domain voltage and current
values. The S11 of the circuit is plotted in Fig. 8.15 and indicates that there is better than −35d B
matching of the line to 50 . Furthermore, these frequency-domain values are used to calculate
the input impedance of the microstrip line. Since there is no visible reflection observed from the
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
bricks = [ ] ;
4 spheres = [ ] ;
6 % define a substrate
b r i c k s ( 1 ) . min x = 0 ;
8 b r i c k s ( 1 ) . mi n y = 0 ;
b r i c k s ( 1 ) . min z = 0 ;
10 b r i c k s ( 1 ) . max x = 60 * dx ;
b r i c k s ( 1 ) . max y = 60 * dy ;
12 b r i c k s ( 1 ) . max z = 6 * dz ;
bricks ( 1 ) . material type = 4;
14
% d e f i n e a PEC p l a t e
16 b r i c k s ( 2 ) . m i n x = 24 * dx ;
b r i c k s ( 2 ) . mi n y = 0 ;
18 b r i c k s ( 2 ) . m i n z = 6 * dz ;
b r i c k s ( 2 ) . max x = 36 * dx ;
20 b r i c k s ( 2 ) . max y = 60 * dy ;
b r i c k s ( 2 ) . max z = 6 . 0 2 * dz ;
22 bricks ( 2 ) . material type = 2;
voltage sources = [ ] ;
4 current sources = [ ] ;
diodes = [ ] ;
6 resistors = [];
inductors = [ ] ;
8 capacitors = [ ] ;
10 % d e f i n e s o u r c e waveform t y p e s and p a r a m e t e r s
waveforms . g a u s s i a n ( 1 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 0 ;
12 waveforms . g a u s s i a n ( 2 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 15;
14 % voltage sources
% d i r e c t i o n : ’ xp ’ , ’ xn ’ , ’ yp ’ , ’ yn ’ , ’ zp ’ , o r ’ zn ’
16 % r e s i s t a n c e : ohms , m a g i t u d e : volts
v o l t a g e s o u r c e s ( 1 ) . m i n x = 24 * dx ;
18 v o l t a g e s o u r c e s ( 1 ) . min y = 0 ;
v o l t a g e s o u r c e s ( 1 ) . min z = 0 ;
20 v o l t a g e s o u r c e s ( 1 ) . max x = 36 * dx ;
v o l t a g e s o u r c e s ( 1 ) . max y = 0 ;
22 v o l t a g e s o u r c e s ( 1 ) . max z = 6 * dz ;
v o l t a g e s o u r c e s ( 1 ) . d i r e c t i o n = ’ zp ’ ;
24 v o l t a g e s o u r c e s ( 1 ) . r e s i s t a n c e = 50;
v o l t a g e s o u r c e s ( 1 ) . magnitude = 1 ;
26 v o l t a g e s o u r c e s ( 1 ) . waveform type = ’ gaussian ’ ;
v o l t a g e s o u r c e s ( 1 ) . waveform index = 1;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
% mode o f o p e r a t i o n
13 run simulation = true ;
show material mesh = true ;
15 show problem space = true ;
17 % f r e q u e n c y domain p a r a m e t e r s
f r e q u e n c y d o m a i n . s t a r t = 20 e6 ;
19 f r e q u e n c y d o m a i n . end = 10 e9 ;
f r e q u e n c y d o m a i n . s t e p = 20 e6 ;
21
% define ports
43 ports ( 1 ) . sampled voltage index = 1;
ports ( 1 ) . sampled current index = 1;
45 ports ( 1 ) . impedance = 5 0 ;
ports ( 1 ) . is source port = true ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
1.2
sampled voltage
source voltage
1
0.8
0.6
(volt)
0.4
0.2
−0.2
0 0.05 0.1 0.15 0.2 0.25 0.3
time (ns)
Figure 8.13 Source voltage and sampled voltage of the microstrip line.
−3
x 10
10
sampled current
6
(ampere)
−2
0 0.05 0.1 0.15 0.2 0.25 0.3
time (ns)
Exercises 267
−30
magnitude (dB)
−40
−50
0 2 4 6 8 10
frequency (GHz)
−50
phase (degrees)
−100
−150
−200
0 2 4 6 8 10
frequency (GHz)
CPML terminated end of the microstrip line, the input impedance of the line is equivalent to the
characteristic impedance of the line. The characteristic impedance is plotted in Fig. 8.16, which
again indicates a good matching to 50 .
8.6 EXERCISES
8.1 Consider the quarter-wave transformer circuit in Section 6.3.1. Remove the absorbers from
the circuit, and use 8 cells thick CPML boundaries instead. Leave 5 cells air gap between
the substrate and the CPML on the xn, xp, yn, and y p sides. Leave 10 cells air gap on
the zp side. The geometry of the problem is illustrated in Fig. 8.17 as a reference. Run the
simulation, obtain the S-parameters of the circuit, and compare the results with those shown
in Section 6.3.1.
8.2 Consider the quarter-wave transformer circuit in Exercise 8.1. Redefine the CPML absorb-
ing boundary condition (ABC) such that the substrate penetrates into the CPML on the xn
and xp sides. The geometry of the problem is illustrated in Fig. 8.18. Run the simulation,
obtain the S-parameters of the circuit, and compare the results with those you obtained for
Exercise 8.1.
8.3 Consider the microstrip line circuit in Section 8.5.3. In this example the performance of
the CPML is not examined numerically. We need a reference case to examine the CPML
performance. Extend the length of the circuit twice on the y p side, and change the boundary
type on that side to PEC such that the microstrip line is touching the PEC boundary.
The geometry of the problem is illustrated in Fig. 8.19. Run the simulation a number of
time steps such that the reflected pulse from the PEC termination will not be observed at
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
60
50
real{Z0}
40
imaginary{Z0}
30
(Ω)
20
10
−10
0 2 4 6 8 10
frequency (GHz)
the sampled voltage. This simulation result serves as the reference case since it does not
include any reflected signals as if the microstrip line is infinitely long. Compare the sampled
voltage that you obtained from the circuit in Section 8.5.3 with the reference case. The
difference between the sampled voltage magnitudes is the reflection. Find the maximum
value of the reflection.
Figure 8.17 The problem space for the quarter-wave transformer with CPML boundaries on the x n, x p, yn, yp,
and zp sides.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Exercises 269
Figure 8.18 The problem space for the quarter-wave transformer with the substrate penetrating into the CPML
boundaries on the x n and x p sides.
8.4 In Exercise 8.3 you constructed a reference case for examining the CPML performance.
Change the thickness of the CPML to 5 cells on the y p side in the microstrip line circuit
in Section 8.5.3. Run the simulation, and then calculate the reflected voltage as described
in Exercise 8.3. Examine whether the reflection increases or decreases. Then repeat the
same exercise by increasing the CPML thickness to 10 cells. Examine whether the reflection
increases or decreases.
8.5 The CPML parameters σfactor , κmax , αmax , αmin , and npml used in the example in Section 8.5.3
are not necessarily the optimum parameters for the CPML performance. Change the values
of some of these parameters, and examine whether the reflections from the 8 cell thick
CPML boundary increases or decreases. For instance, try σfactor = 1.5, κmax = 11, αmin = 0,
αmax = 0.02, and npml = 3.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
9
Near-Field to Far-Field
Transformation
2π R
kR 1 ⇒ 1, (9.1)
λ
where R is the distance from radiator to the observation point, k is the wavenumber in free space,
and λ is the wavelength. For an electrically large antenna such as a parabolic reflector, the aperture
size D is often used to determine the far-field condition [28]:
2D2
r> , (9.2)
λ
where r is the distance from the center of the antenna aperture to the observation point. In the
far-field region, the electromagnetic field at an observation point (r, θ, φ) can be expressed as
− j kr
θ, φ) = e
E(r, F (θ, φ), (9.3a)
4πr
H = r̂ × E , (9.3b)
η0
where η0 is the wave impedance of free space, and F (θ, φ) is a term determining the angular
variations of the far-field pattern of the electric field. Thus, the radiation pattern of the antenna
is only a function of the angular position (θ, φ) and is independent of the distance r.
In general, the near-field to far-field transformation technique is implemented in a two-step
procedure. First, an imaginary surface is selected to enclose the antenna, as shown in Fig. 9.1.
The currents J and M on the surface are determined by the computed E and H fields inside
271
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
J
M
Equivalence principle
Figure 9.1 Near-field to far-field transformation technique: equivalent currents on an imaginary surface.
the computational domain. According to the equivalence theorem, the radiation field from the
currents is equivalent to the radiation field from the antenna. Next, the vector potentials A and
F are used to compute the radiation fields from the equivalent currents J and M. The far-field
conditions are used in the derivations to obtain the appropriate analytical formulas.
Compared with the direct FDTD simulation that requires a mesh extending many wavelengths
from the object, a much smaller FDTD mesh is needed to evaluate the equivalent currents J and
Thus, it is much more computationally efficient to use this near-field to far-field transformation
M.
technique.
According to different computation objectives, the transformation technique can be applied
in both the time and frequency domains, as shown in Fig. 9.2. When transient or broadband
frequency-domain results are required at a limited number of observation angles, the left path in
Fig. 9.2 is adopted. For these situations, the time-domain transformation is used and the transient
far-zone fields at each angle of interest are stored while updating the field components [29,30].
In contrast, when the far fields at all observation angles are required for a limited number
of frequencies, the right path in Fig. 9.2 is adopted. For each frequency of interest a running
discrete Fourier transform (DFT) of the tangential fields (surface currents) on a closed surface is
updated at each time step. The complex frequency-domain currents obtained from the DFT are
then used to compute the far-zone fields at all observation angles through the frequency-domain
transformation.
This chapter is organized as follows. First, the surface equivalence theorem is discussed, and
the equivalent currents J and M are obtained from the near-field FDTD data. Then the im-
portant radiation formulas are presented to calculate the far fields from the equivalent currents.
The implementation procedure is illustrated with full details. Finally, two antenna examples are
provided to demonstrate the validity of the near-to far-field technique.
J
M DFT
Currents (J,M) in
Currents (J,M) in Frequency Domain at
Time Domain a specific frequency
Transformation of Transformation of
(J,M) (E,H) (J,M) (E,H)
DFT
Figure 9.2 Two paths of the near-field to far-field transformation technique are implemented to achieve different
computation objectives.
Within a specific region, the fields generated by the fictitious currents represent the original
fields.
Figure 9.3 illustrates a typical implementation of the surface equivalent theorem. Assume that
fields generated by an arbitrary source are ( E, H).
An imaginary surface S is selected to enclose
all the sources and scattering objects, as shown in Fig. 9.3(a). Outside the surface S is only free
space. An equivalent problem is set up in Fig. 9.3(b), where the fields outside the surface S remain
the same but inside the surface S are set to zero. It is obvious that this setup is feasible because
the fields satisfy Maxwell’s equations both inside and outside the surface S. To comply with the
E, H
E, H
S n̂
S
J s = nˆ × H
E = 0,
scatterers H = 0.
and sources Ms = −nˆ × Eˆ
(a) original problem (b) Equivalent problem for region
outside S
It is worthwhile to emphasize that Figs. 9.3(a) and 9.3(b) have the same fields outside the surface
S but different fields inside the surface S.
If the field values on the surface S in the original problem Fig. 9.3(a) can be accurately obtained
by some means, the surface currents in Fig. 9.3(b) can be determined from (9.4). Then the fields
at any arbitrary far observation point in Fig. 9.3(b) can be readily calculated from the vector
potential approach. Based on the uniqueness theorem, the computed fields are the only solution
of the problem in Fig. 9.3(b). According to the relations between Figs. 9.3(a) and 9.3(b), the
computed fields outside the surface S are also the solution for the original problem.
The implementation of the surface equivalence theorem simplifies the far-field calculation. In
the original Fig. 9.3(a) problem, materials with different permittivities and permeabilities may
exist inside the surface S. Thus, a complex Green’s function needs to be derived to calculate
the radiating field. In the problem in Fig. 9.3(b), the fields inside the surface are zero, and the
permittivity and permeability can be set the same as the outside free space. Hence, the simple free
space Green’s function is used to compute the radiating field.
(ui,uj,uk)
z
y
(li,lj,lk)
x
Note that the E and H fields used in (9.6) are computed from the FDTD simulation. For a time-
domain far-field calculation, the time-domain data are used directly. For a frequency-domain
far-field calculation, a DFT needs to be carried out to obtain the desired frequency components
of the fields.
z
x y
facexn ⇒ J y , J z , M y , M z
face yn ⇒ J x , J z , M x , M z face yp ⇒ J x , J z , M x , M z
face zn ⇒ J x , J y , M x , M y
facexp ⇒ J y , J z , M y , M z
Similar methodology is used to obtain the surface currents on the other five surfaces. On the
bottom surface,
To obtain complete source currents for the far-field calculation, equations (9.6)–(9.11) must be
calculated at every FDTD cell on the equivalent closed surface. It is preferable that the magnetic
and electric currents should be located at the same position, namely, the center of each Yee’s cell
surface that touches the equivalent surface S. Because of the spatial offset between the components
of the E and H field locations on Yee’s cell, averaging of the field components may be performed
to obtain the value of the current components at the center location. The obtained surface currents
are then used to compute the far-field pattern in the next section.
Imaginary Imaginary
closed surface closed surface
Image
Ground plane
Figure 9.6 An imaginary closed surface on an infinite PEC ground plane using the image theory.
Ns te ps
Jy (u, v, w; f1 ) = Hx (u, v, w; f1 ) = Hx (u, v, w; n)e − j 2π f1 nt t. (9.12)
n=1
Here, (u, v, w) is the index for the space location, and n is the time step index. Ns te ps is the maximum
number of the time steps used in the time-domain simulation. Similar formulas can be applied
in calculating other surface currents in equations (9.6)–(9.11). Therefore, the frequency-domain
patterns are calculated after all the time steps of the FDTD computation is finished. For a cubic
imaginary box with N × N cells on each surface, the total required storage size for the surface
currents is 4 × 6 × N2 . Note that the frequency-domain data in (9.12) have complex values.
If radiation patterns at multiple frequencies are required, a pulse excitation is used in the
FDTD simulation. For each frequency of interest, the DFT in (9.12) is performed with the
corresponding frequency value. One round of FDTD simulation is capable to provide surface
currents and radiation patterns at multiple frequencies.
Observation
point
Equivalent surface
( x′, y′, z′) R ( x, y , z )
r
r′
y ψ
x
z
Figure 9.7 The equivalent surface current source and far field.
where
=
N JS e − j kr cos(ψ) dS ,
(9.14a)
S
=
L S e − j kr cos(ψ) dS .
M (9.14b)
S
As illustrated in Fig. 9.7, the vector r = r r̂ denotes the position of the observation point (x, y, z),
whereas the vector r = r r̂ denotes the position of source point (x , y , z ) on the surface S. The
vector R = R R̂ is between the source point and the observation point, and the angle ψ represents
the angle between r and r . In the far-field calculation, the distance R is approximated by
r − r cos(ψ) for the phase term
R = r + (r ) − 2rr cos(ψ) =
2 2 (9.15)
r for the amplitude term
The computation of the components of E and H in the far fields can then be obtained using the
vector potentials, which are expressed as
Er = 0, (9.16a)
j ke − j kr
Eθ = − Lφ + η0 Nθ , (9.16b)
4πr
j ke − j kr
Eφ = + Lθ − η0 Nφ , (9.16c)
4πr
Hr = 0, (9.16d)
− j kr
j ke Lθ
Hθ = + Nφ − , (9.16e)
4πr η0
j ke − j kr Lφ
Hφ = − Nθ + . (9.16f)
4πr η0
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
When the closed surface S is chosen as in Fig. 9.4, the equivalent surface currents are computed
based on equations (9.6)–(9.11), and the DFT in (9.12) is performed to obtain frequency-domain
components; the auxiliary functions N and L are calculated as
Nθ = Jx cos(θ )cos(φ) + Jy cos(θ )sin(φ) − Jz sin(θ ) e − j kr cos(ψ) dS , (9.17a)
S
Nφ = −Jx sin(φ) + Jy cos(φ) e − j kr cos(ψ) dS , (9.17b)
S
Lθ = Mx cos(θ )cos(φ) + My cos(θ )sin(φ) − Mz sin(θ ) e − j kr cos(ψ) dS , (9.17c)
S
Lφ = −Mx sin(φ) + My cos(φ) e − j kr cos(ψ) dS . (9.17d)
S
Substituting (9.17) into (9.16), the far-field pattern can be obtained at any observation point
(r, θ, φ).
θ̂ − j φ̂ θ̂ + j φ̂ Ê R Ê L
θ̂ = + =√ +√ , (9.18a)
2 2 2 2
θ̂ + j φ̂ θ̂ − j φ̂ Ê L Ê R
φ̂ = − = √ − √ , (9.18b)
2j 2j j 2 j 2
where Ê R and Ê L are unit vectors for the right-hand circularly polarized (RHCP) field and
left-hand circularly polarized (LHCP) field. Substituting (9.18) into (9.16), we obtain
Ê Ê Ê Ê
E = θ̂ Eθ + φ̂ Eφ = √ + √
R L L R
Eθ + √ − √ Eφ
2 2 j 2 j 2
Eθ Eφ Eθ Eφ
= Ê R √ − √ + Ê L √ + √ = Ê R E R + Ê L E L ,
2 j 2 2 j 2
Eθ Eφ
ER = √ − √ , (9.19)
2 j 2
Eθ Eφ
EL = √ + √ . (9.20)
2 j 2
The magnitudes of the RHCP component (E R ) and the LHCP component (E L ) are then obtained.
The axial ratio is defined to describe the polarization purity of the propagating waves and is
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
|E R | + |E L |
AR = − . (9.21)
|E R | − |E L |
For an LP wave, AR goes to infinity. For an RHCP wave AR = −1 and for an LHCP wave
AR = 1. For a general elliptically polarized wave, 1 ≤ |AR| ≤ ∞. Other expressions for direct
computation of the AR from the far-field components Eθ and Eφ are given in [33]
⎛ ⎞
12 ! 12
⎜
1
2
Eφ2 + Eθ2 + Eθ4 + Eφ4 + 2Eθ2 Eφ2 cos (2δ) ⎟
AR = 20 log10 ⎜
⎝
⎟, (9.22)
12 ! 12 ⎠
1
2
Eφ2 + Eθ2 + Eθ4 + Eφ4 − 2Eθ2 Eφ2 cos (2δ)
and in [34]
|Eφ |2 sin2 (τ ) + |Eθ |2 cos2 (τ ) + |Eφ ||Eθ | cos(δ)sin(2τ )
AR = 20 log10 , (9.23)
|Eφ |2 sin2 (τ ) + |Eθ |2 cos2 (τ ) − |Eφ ||Eθ | cos(δ)sin(2τ )
where
−1 2|Eφ ||Eθ | cos(δ)
2τ = tan ,
|Eθ |2 − |Eφ |2
The delivered power to an antenna is determined by the product of the voltage and current
provided from the voltage source and can be expressed as
1 & '
Pdel = Re Vs (ω)Is∗ (ω) , (9.25)
2
where Vs (ω) and Is (ω) represent the Fourier transformed values of the source voltage and current.
The antenna’s radiation efficiency ηa is then defined as [35]
Prad
ηa = . (9.26)
Pdel
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
13 % mode o f o p e r a t i o n
run simulation = true ;
15 show material mesh = true ;
show problem space = true ;
17
% f a r f i e l d c a l c u l a t i o n parameters
19 f a r f i e l d . f r e q u e n c i e s ( 1 ) = 3 e9 ;
f a r f i e l d . f r e q u e n c i e s ( 2 ) = 5 e9 ;
21 f a r f i e l d . f r e q u e n c i e s ( 3 ) = 6 e9 ;
f a r f i e l d . f r e q u e n c i e s ( 4 ) = 9 e9 ;
23 f a r f i e l d . number of cells from outer boundary = 10;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
% d e f i n e t h e problem
5 define problem space parameters ;
define geometry ;
7 define sources and lumped elements ;
define output parameters ;
9
% i n i t i a l i z e t h e problem s p a c e and p a r a m e t e r s
11 initialize fdtd material grid ;
display problem space ;
13 display material mesh ;
if run simulation
15 initialize fdtd parameters and arrays ;
initialize sources and lumped elements ;
17 initialize updating coefficients ;
initialize boundary conditions ;
19 initialize output parameters ;
initialize farfield arrays ;
21 initialize display parameters ;
23 % FDTD t i m e m a r c h i n g l o o p
run fdtd time marching loop ;
25
used to determine the nodes (li, l j, lk) and (ui, u j, uk) indicating the boundaries of the imaginary
surface in Fig. 9.4.
4 i f n u m b e r o f f a r f i e l d f r e q u e n c i e s == 0
return ;
6 end
nc farbuffer = f a r f i e l d . number of cells from outer boundary ;
8 l i = nc farbuffer + 1;
l j = nc farbuffer + 1;
10 lk = nc farbuffer + 1;
u i = nx − n c f a r b u f f e r +1;
12 u j = ny − n c f a r b u f f e r +1;
uk = nz − n c f a r b u f f e r +1;
14
f a r f i e l d w = 2* p i * f a r f i e l d . f r e q u e n c i e s ;
16
5 s t a r t t i m e = cputime ;
current time = 0;
7
25 e n d t i m e = cputime ;
t o t a l t i m e i n m i n u t e s = ( end time − s t a r t t i m e ) / 6 0 ;
27 disp ( [ ’ T o t a l s i m u l a t i o n time i s ’ . . .
num2str ( t o t a l t i m e i n m i n u t e s ) ’ m i n u t e s . ’ ] ) ;
+ Hx ( l i : u i −1 , uj −1 , l k : uk −1) + Hx ( l i +1: u i , uj −1 , l k : uk − 1 ) ) ;
22
26 t j y z p ( 1 , : , : , 1 ) = 0 . 2 5 * ( Hx ( l i : u i −1 , l j : uj −1 , uk )+ Hx ( l i +1: u i , l j : uj −1 , uk ) ...
+ Hx ( l i : u i −1 , l j : uj −1 , uk −1) + Hx ( l i +1: u i , l j : uj −1 , uk − 1 ) ) ;
28
56 t j x z n ( 1 , : , : , 1 ) = 0 . 2 5 * ( Hy ( l i : u i −1 , l j : uj −1 , l k )+ Hy ( l i : u i −1 , l j +1: uj , l k ) ...
+ Hy ( l i : u i −1 , l j : uj −1 , l k −1) + Hy ( l i : u i −1 , l j +1: uj , l k − 1 ) ) ;
58
% fourier transform
60 f o r mi =1: n u m b e r o f f a r f i e l d f r e q u e n c i e s
e x p h = d t * exp (− j * f a r f i e l d w ( mi ) * ( time step −0.5)* dt ) ;
62 c j x y p ( mi , : , : , : ) = c j x y p ( mi , : , : , : ) + exp h * t j x y p ( 1 , : , : ,:);
c j x z p ( mi , : , : , : ) = c j x z p ( mi , : , : , : ) + exp h * t j x z p ( 1 , : , : ,:);
64 c j y x p ( mi , : , : , : ) = c j y x p ( mi , : , : , : ) + exp h * t j y x p ( 1 , : , : ,:);
c j y z p ( mi , : , : , : ) = c j y z p ( mi , : , : , : ) + exp h * t j y z p ( 1 , : , : ,:);
66 c j z x p ( mi , : , : , : ) = c j z x p ( mi , : , : , : ) + exp h * t j z x p ( 1 , : , : ,:);
c j z y p ( mi , : , : , : ) = c j z y p ( mi , : , : , : ) + exp h * t j z y p ( 1 , : , : ,:);
68
c j z x n ( mi , : , : , : ) = c j z x n ( mi , : , : , : ) + e x p h * t j z x n ( 1 , : , : , : ) ;
74 c j z y n ( mi , : , : , : ) = c j z y n ( mi , : , : , : ) + e x p h * t j z y n ( 1 , : , : , : ) ;
76 e x p e = d t * exp (− j * f a r f i e l d w ( mi ) * t i m e s t e p * d t ) ;
Similarly, every fictitious electric current component is calculated at the centers of the faces
of the cells by averaging four magnetic field components. For example, Fig. 9.9 illustrates the
magnetic field components Hx around the yn face of the imaginary NF–FF surface. The Hx
components are located at the centers of the faces of cells, which are not coinciding with the
NF–FF surface. To obtain equivalent Hx values at the centers of the cell faces, the average of four
Hx components are calculated for each cell. Thus, the fictitious electric current components Jz
generated by the averaged Hx components using (9.10a) are located at the centers of the cell faces.
Figure 9.8 E x field components on the yn face of the NF–FF imaginary surface and the magnetic currents
generated by them.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Figure 9.9 H x field components around the yn face of the NF–FF imaginary surface and the electric currents
generated by them.
After the fictitious electric and magnetic currents are sampled on the NF–FF surface at the
current time step, they are used to update the on-the-fly DFTs for the far-field frequencies defined
in the subroutine define output parameters. For instance, one iteration of (9.12) is performed at
each time step for calculating Jy in frequency domain. Therefore, when the FDTD time-marching
loop is completed, the DFT of Jy is completed together.
i f n u m b e r o f f a r f i e l d f r e q u e n c i e s == 0
8 return ;
end
10
j = sqrt ( −1);
14 number of angles = 360;
16 % p a r a m e t e r s u s e d by p o l a r p l o t t i n g f u n c t i o n s
s t e p s i z e = 10; % i n c r e m e n t between t h e r i n g s i n t h e p o l a r g r i d
18 Nrings = 4; % number o f r i n g s i n t h e p o l a r g r i d
l i n e s t y l e 1 = ’ b− ’ ; % l i n e s t y l e f o r t h e t a component
20 l i n e s t y l e 2 = ’ r−− ’ ; % l i n e s t y l e f o r p h i component
s c a l e t y p e = ’ dB ’ ; % l i n e a r o r dB
22 p l o t t y p e = ’D ’ ; % the c a l c u l a t e d data i s d i r e c t i v i t y
24 % xy plane
% ===============================================
26 f a r f i e l d t h e t a = zeros ( number of angles , 1 ) ;
farfield phi = zeros ( number of angles , 1 ) ;
28 f a r f i e l d t h e t a = f a r f i e l d t h e t a + pi / 2 ;
f a r f i e l d p h i = ( pi / 1 8 0 ) * [ − 1 8 0 : 1 : 1 7 9 ] . ’ ;
30 c o n s t t h e t a = 90; % used f o r p l o t
32 % calculate farfields
calculate farfields per plane ;
34
% p l o t t i n g the f a r f i e l d data
36 f o r mi =1: n u m b e r o f f a r f i e l d f r e q u e n c i e s
f = figure ;
38 p a t 1 = f a r f i e l d d a t a T h e t a ( mi , : ) . ’ ;
p a t 2 = f a r f i e l d d a t a P h i ( mi , : ) . ’ ;
40
% i f s c a l e t y p e i s db u s e t h e s e , o t h e r w i s e comment t h e s e two l i n e s
42 p a t 1 = 10 * l o g 1 0 ( p a t 1 ) ;
p a t 2 = 10 * l o g 1 0 ( p a t 2 ) ;
44
m a x v a l = max ( max ( [ p a t 1 p a t 2 ] ) ) ;
46 max val = s t e p s i z e * c e i l ( max val / s t e p s i z e ) ;
48 l e g e n d s t r 1 = [ p l o t t y p e ’ {\ t h e t a } , f = ’ . . .
num2str ( f a r f i e l d . f r e q u e n c i e s ( mi ) * 1 e −9) ’ GHz ’ ] ;
50 l e g e n d s t r 2 = [ p l o t t y p e ’ {\ p h i } , f = ’ . . .
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
p o l a r p l o t c o n s t a n t t h e t a ( f a r f i e l d p h i , pat1 , pat2 , m a x v a l , . . .
54 s t e p s i z e , Nrings , l i n e s t y l e 1 , l i n e s t y l e 2 , const theta , ...
legend str1 , legend str2 , scale type ) ;
56 end
58 % xz plane
% ===============================================
60 f a r f i e l d t h e t a = zeros ( number of angles , 1 ) ;
farfield phi = zeros ( number of angles , 1 ) ;
62 f a r f i e l d t h e t a = ( pi / 1 8 0 ) * [ − 1 8 0 : 1 : 1 7 9 ] . ’ ;
c o n s t p h i = 0 ; % used f o r p l o t
64
% calculate farfields
66 calculate farfields per plane ;
68 % p l o t t i n g the f a r f i e l d data
f o r mi =1: n u m b e r o f f a r f i e l d f r e q u e n c i e s
70 f = figure ;
p a t 1 = f a r f i e l d d a t a T h e t a ( mi , : ) . ’ ;
72 p a t 2 = f a r f i e l d d a t a P h i ( mi , : ) . ’ ;
74 % i f s c a l e t y p e i s db u s e t h e s e , o t h e r w i s e comment t h e s e two l i n e s
p a t 1 = 10 * l o g 1 0 ( p a t 1 ) ;
76 p a t 2 = 10 * l o g 1 0 ( p a t 2 ) ;
78 m a x v a l = max ( max ( [ p a t 1 p a t 2 ] ) ) ;
max val = s t e p s i z e * c e i l ( max val / s t e p s i z e ) ;
80
legend str1 = . . .
82 [ p l o t t y p e ’ {\ t h e t a } , f = ’ . . .
num2str ( f a r f i e l d . f r e q u e n c i e s ( mi ) * 1 e −9) ’ GHz ’ ] ;
84 legend str2 = . . .
[ p l o t t y p e ’ {\ p h i } , f = ’ . . .
86 num2str ( f a r f i e l d . f r e q u e n c i e s ( mi ) * 1 e −9) ’ GHz ’ ] ;
88 p o l a r p l o t c o n s t a n t p h i ( f a r f i e l d t h e t a , pat1 , pat2 , m a x v a l , . . .
s t e p s i z e , Nrings , l i n e s t y l e 1 , l i n e s t y l e 2 , const phi , . . .
90 legend str1 , legend str2 , scale type ) ;
end
92
% yz plane
94 % ===============================================
f a r f i e l d t h e t a = zeros ( number of angles , 1 ) ;
96 farfield phi = zeros ( number of angles , 1 ) ;
f a r f i e l d p h i = f a r f i e l d p h i + pi / 2 ;
98 f a r f i e l d t h e t a = ( pi / 1 8 0 ) * [ − 1 8 0 : 1 : 1 7 9 ] . ’ ;
c o n s t p h i = 90; % used f o r p l o t
100
% calculate farfields
102 calculate farfields per plane ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
legend str1 = . . .
118 [ p l o t t y p e ’ {\ t h e t a } , f = ’ . . .
num2str ( f a r f i e l d . f r e q u e n c i e s ( mi ) * 1 e −9) ’ GHz ’ ] ;
120 legend str2 = . . .
[ p l o t t y p e ’ {\ p h i } , f = ’ . . .
122 num2str ( f a r f i e l d . f r e q u e n c i e s ( mi ) * 1 e −9) ’ GHz ’ ] ;
function calculate farfields per plane is called to calculate far-field directivity data at the given
angles. These data are plotted using another function polar plot constant theta. For the xy plane
θ is a constant value of π/2 radians. For the xz and y z planes φ takes constant values of 0 and
π/2 radians, respectively, hence another function, which is called for plotting patterns in the xz
and y z planes is polar plot constant phi. The implementations of polar plot constant theta and
polar plot constant phi are given in Appendix C.
The near-field to far-field calculations are performed mainly in the function calculate farfields -
per plane, implementation of which is given in Listing 9.9.
One of the initial tasks in calculate farfields per plane is the calculation of total radiated power.
A subroutine named calculate radiated power is called to perform this task. The total radiated
power is stored in the parameter radiated power, as can be seen in Listing 9.8. Calculation of
radiated power is based on the discrete summation representation of (9.24).
Before calculating any far-field data, the auxiliary fields Nθ , Nφ , Lθ , and Lφ need to be calculated
based on (9.17). In (9.17) the parameters θ and φ are angles indicating the position vector of the
observation point r as illustrated in Fig. 9.7. The parameters Jx , Jy , Jz , Mx , My , and Mz are the
fictitious currents, which have already been calculated at the center points of the faces of the cells
coinciding with the NF–FF surface for the given far-field frequencies. The parameter k is the
wavenumber expressed by
√
k = 2π f µ0 ε0 , (9.27)
where f is the far-field frequency under consideration. Yet another term in (9.17) is r cos(ψ),
which needs to be further defined explicitly. As shown in Fig. 9.7, r is the position vector
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
f o r mi =1: n u m b e r o f f a r f i e l d f r e q u e n c i e s
5 powr = 0 ;
powr = dx * dy * sum ( sum ( sum ( cmyzp ( mi , : , : , : ) . * ...
7 c o n j ( c j x z p ( mi , : , : , : ) ) − cmxzp ( mi , : , : , : ) ...
. * c o n j ( c j y z p ( mi , : , : , : ) ) ) ) ) ;
9 powr = powr − dx * dy * sum ( sum ( sum ( cmyzn ( mi , : ,: ,:) ...
. * c o n j ( c j x z n ( mi , : , : , : ) ) − cmxzn ( mi , : , : ,:) ...
11 . * c o n j ( c j y z n ( mi , : , : , : ) ) ) ) ) ;
powr = powr + dx * dz * sum ( sum ( sum ( cmxyp ( mi , : ,: ,:) ...
13 . * c o n j ( c j z y p ( mi , : , : , : ) ) − cmzyp ( mi , : , : ,:) ...
. * c o n j ( c j x y p ( mi , : , : , : ) ) ) ) ) ;
15 powr = powr − dx * dz * sum ( sum ( sum ( cmxyn ( mi , : ,: ,:) ...
. * c o n j ( c j z y n ( mi , : , : , : ) ) − cmzyn ( mi , : , : ,:) ...
17 . * c o n j ( c j x y n ( mi , : , : , : ) ) ) ) ) ;
powr = powr + dy * dz * sum ( sum ( sum ( cmzxp ( mi , : ,: ,:) ...
19 . * c o n j ( c j y x p ( mi , : , : , : ) ) − cmyxp ( mi , : , : ,:) ...
. * c o n j ( c j z x p ( mi , : , : , : ) ) ) ) ) ;
21 powr = powr − dy * dz * sum ( sum ( sum ( cmzxn ( mi , : ,: ,:) ...
. * c o n j ( c j y x n ( mi , : , : , : ) ) − cmyxn ( mi , : , : ,:) ...
23 . * c o n j ( c j z x n ( mi , : , : , : ) ) ) ) ) ;
r a d i a t e d p o w e r ( mi ) = 0 . 5 * r e a l ( powr ) ;
25 end
dx s i n t h c o s p h i = dx * s i n ( f a r f i e l d t h e t a ) . * c o s ( f a r f i e l d p h i ) ;
31 dy s i n t h s i n p h i = dy * s i n ( f a r f i e l d t h e t a ) . * s i n ( f a r f i e l d p h i ) ;
dz c o s t h = dz * c o s ( f a r f i e l d t h e t a ) ;
33 dy d z c o s t h s i n p h i = dy * dz * c o s ( f a r f i e l d t h e t a ) . * s i n ( f a r f i e l d phi );
dy d z s i n t h = dy * dz * s i n ( f a r f i e l d t h e t a ) ;
35 dy d z c o s p h i = dy * dz * c o s ( f a r f i e l d p h i ) ;
dx d z c o s t h c o s p h i = dx * dz * c o s ( f a r f i e l d t h e t a ) . * c o s ( f a r f i e l d phi );
37 dx d z s i n t h = dx * dz * s i n ( f a r f i e l d t h e t a ) ;
dx d z s i n p h i = dx * dz * s i n ( f a r f i e l d p h i ) ;
39 dx d y c o s t h c o s p h i = dx * dy * c o s ( f a r f i e l d t h e t a ) . * c o s ( f a r f i e l d phi );
dx d y c o s t h s i n p h i = dx * dy * c o s ( f a r f i e l d t h e t a ) . * s i n ( f a r f i e l d phi );
41 dx d y s i n p h i = dx * dy * s i n ( f a r f i e l d p h i ) ;
dx d y c o s p h i = dx * dy * c o s ( f a r f i e l d p h i ) ;
43 ci = 0 . 5 * ( u i+ l i ) ;
cj = 0 . 5 * ( u j+ l j ) ;
45 ck = 0 . 5 * ( uk+ l k ) ;
47 % calculate directivity
f o r mi =1: n u m b e r o f f a r f i e l d f r e q u e n c i e s
49 disp ( [ ’ C a l c u l a t i n g d i r e c t i v i t y for ’ , . . .
num2str ( f a r f i e l d . f r e q u e n c i e s ( mi ) ) ’ Hz ’ ] ) ;
51 k = 2 * p i * f a r f i e l d . f r e q u e n c i e s ( mi ) * ( mu 0 * e p s 0 ) ˆ 0 . 5 ;
59 f o r n j = l j : uj −1
f o r nk = l k : uk−1
61 % f o r +ax d i r e c t i o n
+ ( cmyxp ( mi , 1 , nj − l j +1 , nk−l k + 1 ) . * d y d z c o s p h i ) . * e x p j k r p r ;
77
% f o r −ax d i r e c t i o n
79 rpr = ( l i − ci )* dx sinth cosphi . . .
+ ( nj −c j + 0 . 5 ) * d y s i n t h s i n p h i . . .
81 + ( nk−c k + 0 . 5 ) * d z c o s t h ;
e x p j k r p r = exp (− j * k * r p r ) ;
83 Ntheta = Ntheta . . .
+ ( c j y x n ( mi , 1 , nj − l j +1 , nk−l k + 1 ) . * d y d z c o s t h s i n p h i . . .
85 − c j z x n ( mi , 1 , nj − l j +1 , nk−l k + 1 ) . * d y d z s i n t h ) . * e x p j k r p r ;
Ltheta = Ltheta . . .
87 + ( cmyxn ( mi , 1 , nj − l j +1 , nk−l k + 1 ) . * d y d z c o s t h s i n p h i . . .
− cmzxn ( mi , 1 , nj − l j +1 , nk−l k + 1 ) . * d y d z s i n t h ) . * e x p j k r p r ;
89 Nphi = Nphi . . .
+ ( c j y x n ( mi , 1 , nj − l j +1 , nk−l k + 1 ) . * d y d z c o s p h i ) . * e x p j k r p r ;
91 Lphi = Lphi . . .
+ ( cmyxn ( mi , 1 , nj − l j +1 , nk−l k + 1 ) . * d y d z c o s p h i ) . * e x p j k r p r ;
93 end
end
95 f o r n i = l i : u i −1
f o r nk = l k : uk−1
97 % f o r +ay d i r e c t i o n
Ntheta = Ntheta . . .
105 + ( c j x y p ( mi , ni − l i + 1 , 1 , nk−l k + 1 ) . * d x d z c o s t h c o s p h i . . .
− c j z y p ( mi , ni − l i + 1 , 1 , nk−l k + 1 ) . * d x d z s i n t h ) . * e x p j k r p r ;
107 Ltheta = Ltheta . . .
+ ( cmxyp ( mi , ni − l i + 1 , 1 , nk−l k + 1 ) . * d x d z c o s t h c o s p h i . . .
109 − cmzyp ( mi , ni − l i + 1 , 1 , nk−l k + 1 ) . * d x d z s i n t h ) . * e x p j k r p r ;
Nphi = Nphi . . .
111 + (− c j x y p ( mi , ni − l i + 1 , 1 , nk−l k + 1 ) . * d x d z s i n p h i ) . * e x p j k r p r ;
Lphi = Lphi . . .
113 + (− cmxyp ( mi , ni − l i + 1 , 1 , nk−l k + 1 ) . * d x d z s i n p h i ) . * e x p j k r p r ;
115 % f o r −ay d i r e c t i o n
rpr = ( ni − c i + 0 . 5 ) * dx sinth cosphi ...
117 + ( l j −c j ) * d y s i n t h s i n p h i . . .
+ ( nk−c k + 0 . 5 ) * d z c o s t h ;
119 e x p j k r p r = exp (− j * k * r p r ) ;
+ (− c j x y n ( mi , ni − l i + 1 , 1 , nk−l k + 1 ) . * d x d z s i n p h i ) . * e x p j k r p r ;
129 Lphi = Lphi . . .
+ (− cmxyn ( mi , ni − l i + 1 , 1 , nk−l k + 1 ) . * d x d z s i n p h i ) . * e x p j k r p r ;
131 end
end
133
f o r n i = l i : u i −1
135 f o r n j = l j : uj −1
% f o r +a z d i r e c t i o n
137
r p r = ( ni −c i + 0 . 5 ) * d x s i n t h c o s p h i . . .
139 + ( nj − c j + 0 . 5 ) * d y s i n t h s i n p h i ...
+ ( uk−c k ) * d z c o s t h ;
141 e x p j k r p r = exp (− j * k * r p r ) ;
% f o r −a z d i r e c t i o n
159
r p r = ( ni −c i + 0 . 5 ) * d x s i n t h c o s p h i . . .
161 + ( nj − c j + 0 . 5 ) * d y s i n t h s i n p h i ...
+ ( l k −c k ) * d z c o s t h ;
163 e x p j k r p r = exp ( − j * k * r p r ) ;
end
181 % calculate directivity
f a r f i e l d d a t a T h e t a ( mi , : ) = ( k ˆ 2 . / ( 8 * p i * e t a 0 * r a d i a t e d p o w e r ( mi ) ) ) ...
183 . * ( abs ( L p h i+ e t a 0 * N t h e t a ) . ˆ 2 ) ;
f a r f i e l d d a t a P h i ( mi , : ) =( k ˆ 2 . / ( 8 * p i * e t a 0 * r a d i a t e d p o w e r ( mi ) ) ) ...
185 . * ( abs ( L t h e t a −e t a 0 * Nphi ) . ˆ 2 ) ;
end
indicating the observation point while r is the position vector indicating the source point. The
term r cos(ψ) is actually obtained from r · r̂ where r̂ is a unit vector in the direction of r. The
unit vector r̂ can be expressed in Cartesian coordinates as
As mentioned already the vector r is the position vector indicating the source point and is
expressed in terms of source positions. The sources are located at the centers of the faces, and the
source position vectors can be expressed as follows. A position vector for a source point located
on the zn face of the NF–FF surface can be expressed as
as can be observed in Fig. 9.10. Here (c i, c j, c k) is the center node of the problem space, which is
assumed to be the origin for the far-field calculations. The parameters mi and mj are the indices
of the nodes of the faces, which include the sources under consideration. Then the term r cos(ψ)
in (9.17) can be expressed explicitly using (9.28) and (9.29) as
The equations in (9.17) are integrations of continuous current distributions over the imaginary
surface. However, we have obtained the currents at discrete points. Therefore, these integrations
can be represented by discrete summations. For instance, for the zn and zp faces (9.17) can be
rewritten as
j −1
u
ui−1
Nθ = xy Jx cos(θ ) cos(φ) + Jy cos(θ )sin(φ) e − j kr cos(ψ) , (9.32a)
mi=li mj =l j
j −1
u
ui−1
Nφ = xy −Jx sin(φ) + Jy cos(φ) e − j kr cos(ψ) , (9.32b)
mi=li mj =l j
j −1
u
ui−1
Lθ = xy Mx cos(θ ) cos(φ) + My cos(θ )sin(φ) e − j kr cos(ψ) , (9.32c)
mi=li mj =l j
j −1
u
ui−1
Lφ = xy −Mx sin(φ) + My cos(φ) e − j kr cos(ψ) . (9.32d)
mi=li mj =l j
Referring to Fig. 9.11 one can obtain r cos(ψ) for the xn and xp faces, respectively, as
where mj and mk are the indices of the nodes of the faces that include the sources. Then the
summations in 9.32 are expressed in terms of these indices mj and mk as
u j −1 uk−1
Nθ = yz Jy cos(θ )sin(φ) − Jz sin(θ ) e − j kr cos(ψ) , (9.35a)
mj =l j mk=lk
u j −1 uk−1
Nφ = yz Jy cos(φ) e − j kr cos(ψ) , (9.35b)
mj =l j mk=lk
u j −1 uk−1
Lθ = yz My cos(θ )sin(φ) − Mz sin(θ ) e − j kr cos(ψ) , (9.35c)
mj =l j mk=lk
u j −1 uk−1
Lφ = yz My cos(φ) e − j kr cos(ψ) . (9.35d)
mj =l j mk=lk
Similarly, referring to Fig. 9.12 r cos(ψ) can be obtained for the yn and y p faces,
respectively, as
Then the summations in (9.32) are expressed in terms of these indices mi and mk as
uk−1
ui−1
Nθ = xz (Jx cos(θ ) cos(φ) − Jz sin(θ )) e − j kr cos(ψ)
, (9.38a)
mi=li mk=lk
uk−1
ui−1
Nφ = xz (−Jx sin(φ)) e − j kr cos(ψ)
, (9.38b)
mi=li mk=lk
uk−1
ui−1
Lθ = xz (Mx cos(θ ) cos(φ) − Mz sin(θ )) e − j kr cos(ψ)
, (9.38c)
mi=li mk=lk
uk−1
ui−1
Lφ = xz (−Mx sin(φ)) e − j kr cos(ψ)
. (9.38d)
mi=li mk=lk
k2
Dθ = |Lφ + η0 Nθ |2 , (9.39a)
8π η0 Prad
k2
Dφ = |Lθ − η0 Nφ |2 . (9.39b)
8π η0 Prad
40
24
ε r = 2.2
12
.4
16.4
5.
2
7.6
x
y
16
ground
z
13.6 voltage source
the definition of the NF–FF transformation is part of the define outputs parameters routine. In
this example the far-field frequencies are 2.4 GHz and 5.8 GHz. One additional parameter for the
NF–FF transform is the number of cells from outer boundary. The value of this parameter is
13, which means that the imaginary NF–FF surface is 13 cells away from the outer boundaries,
thus 5 cells away from the CPML interface and residing in the air gap region.
6 % A f a c t o r t h a t determines d u r a t i o n of a time s t e p
% wrt CFL l i m i t
8 courant factor = 0.9;
10 % A f a c t o r d e t e r m i n i n g t h e a c c u r a c y l i m i t o f FDTD r e s u l t s
number of cells per wavelength = 20;
12
% D i m e n s i o n s o f a u n i t c e l l i n x , y , and z d i r e c t i o n s ( m e t e r s )
14 dx = 0 . 2 6 2 e −3;
dy = 0 . 4 e −3;
16 dz = 0 . 4 e −3;
18 % ==<b o u n d a r y c o n d i t i o n s >========
% Here we d e f i n e t h e b o u n d a r y c o n d i t i o n s p a r a m e t e r s
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
20 % ’ pec ’ : p e r f e c t e l e c t r i c c o n d u c t o r
% ’ cpml ’ : c o n l v o l u t i o n a l PML
22 % i f c p m l n u m b e r o f c e l l s i s l e s s than zero
% CPML e x t e n d s i n s i d e o f t h e domain r a t h e r t h a n o u t w a r d s
24
b o u n d a r y . t y p e x n = ’ cpml ’ ;
26 boundary . a i r b u f f e r n u m b e r o f c e l l s x n = 10;
boundary . c p m l n u m b e r o f c e l l s x n = 8 ;
28
b o u n d a r y . t y p e x p = ’ cpml ’ ;
30 boundary . a i r b u f f e r n u m b e r o f c e l l s x p = 10;
boundary . c p m l n u m b e r o f c e l l s x p = 8 ;
32
b o u n d a r y . t y p e y n = ’ cpml ’ ;
34 boundary . a i r b u f f e r n u m b e r o f c e l l s y n = 10;
boundary . c p m l n u m b e r o f c e l l s y n = 8 ;
36
b o u n d a r y . t y p e y p = ’ cpml ’ ;
38 boundary . a i r b u f f e r n u m b e r o f c e l l s y p = 10;
boundary . c p m l n u m b e r o f c e l l s y p = 8 ;
40
b o u n d a r y . t y p e z n = ’ cpml ’ ;
42 boundary . a i r b u f f e r n u m b e r o f c e l l s z n = 10;
boundary . c p m l n u m b e r o f c e l l s z n = 8 ;
44
b o u n d a r y . t y p e z p = ’ cpml ’ ;
46 boundary . a i r b u f f e r n u m b e r o f c e l l s z p = 10;
boundary . c p m l n u m b e r o f c e l l s z p = 8 ;
48
% PEC : p e r f e c t e l e c t r i c c o n d u c t o r
70 material types ( 2 ) . eps r = 1;
m a t e r i a l t y p e s ( 2 ) . mu r = 1;
72 m a t e r i a l t y p e s ( 2 ) . s i g m a e = 1 e10 ;
m a t e r i a l t y p e s ( 2 ) . sigma m = 0 ;
74 material types ( 2 ) . color = [1 0 0];
83 % substrate
material types (4). eps r = 2.2;
85 material types (4). mu r = 1;
material types (4). sigma e = 0;
87 material types (4). sigma m = 0 ;
material types (4). color = [0 0 1];
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
bricks = [ ] ;
4 spheres = [ ] ;
6 % define substrate
b r i c k s ( 1 ) . m i n x = −0.787 e −3;
8 b r i c k s ( 1 ) . mi n y = 0 ;
b r i c k s ( 1 ) . min z = 0 ;
10 b r i c k s ( 1 ) . max x = 0 ;
b r i c k s ( 1 ) . max y = 40 e −3;
12 b r i c k s ( 1 ) . max z = 40 e −3;
bricks ( 1 ) . material type = 4;
14
b r i c k s ( 6 ) . max y = 16 e −3;
52 b r i c k s ( 6 ) . max z = 3 2 . 4 e −3;
bricks ( 6 ) . material type = 2;
54
The FDTD simulation of the inverted-F antenna is performed with 7,000 time steps, and S11
of the input port is calculated. The calculated return loss is plotted in Figure 9.14 and shows a
good agreement with the published measurement data in [36].
Furthermore, the directivity patterns are calculated in the xy, xz, and y z plane cuts at 2.4 GHz
and 5.8 GHz. These patterns are plotted in Figs. 9.15, 9.16, and 9.17, respectively. The simulated
FDTD radiation patterns show very good agreement with the published measurement data [36].
3 voltage sources = [ ] ;
current sources = [ ] ;
5 diodes = [ ] ;
resistors = [];
7 inductors = [ ] ;
capacitors = [ ] ;
9
% d e f i n e s o u r c e waveform t y p e s and p a r a m e t e r s
11 waveforms . g a u s s i a n ( 1 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 0 ;
waveforms . g a u s s i a n ( 2 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 15;
13
% voltage sources
15 % d i r e c t i o n : ’ xp ’ , ’ xn ’ , ’ yp ’ , ’ yn ’ , ’ zp ’ , o r ’ zn ’
% r e s i s t a n c e : ohms , m a g i t u d e : volts
17 v o l t a g e s o u r c e s ( 1 ) . m i n x = −0.787 e −3;
v o l t a g e s o u r c e s ( 1 ) . min y = 0 ;
19 v o l t a g e s o u r c e s ( 1 ) . m i n z = 24 e −3;
v o l t a g e s o u r c e s ( 1 ) . max x = 0 ;
21 v o l t a g e s o u r c e s ( 1 ) . max y = 0 ;
v o l t a g e s o u r c e s ( 1 ) . max z = 2 6 . 4 e −3;
23 v o l t a g e s o u r c e s ( 1 ) . d i r e c t i o n = ’ xp ’ ;
v o l t a g e s o u r c e s ( 1 ) . r e s i s t a n c e = 50;
25 v o l t a g e s o u r c e s ( 1 ) . magnitude = 1 ;
v o l t a g e s o u r c e s ( 1 ) . waveform type = ’ gaussian ’ ;
27 v o l t a g e s o u r c e s ( 1 ) . waveform index = 1;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
13 % mode o f o p e r a t i o n
run simulation = true ;
15 show material mesh = true ;
show problem space = true ;
17
% f a r f i e l d c a l c u l a t i o n parameters
19 f a r f i e l d . f r e q u e n c i e s ( 1 ) = 2 . 4 e9 ;
f a r f i e l d . f r e q u e n c i e s ( 2 ) = 5 . 8 e9 ;
21 f a r f i e l d . number of cells from outer boundary = 13;
23 % f r e q u e n c y domain p a r a m e t e r s
f r e q u e n c y d o m a i n . s t a r t = 20 e6 ;
25 f r e q u e n c y d o m a i n . end = 10 e9 ;
f r e q u e n c y d o m a i n . s t e p = 20 e6 ;
27
% define ports
49 ports ( 1 ) . sampled voltage index = 1;
ports ( 1 ) . sampled current index = 1;
51 ports ( 1 ) . impedance = 5 0 ;
ports ( 1 ) . is source port = true ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
10
S11
5
magnitude (dB) 0
−5
−10
−15
−20
−25
−30
0 2 4 6 8 10
frequency (GHz)
↑y ↑y
9010 9010
120 60 120 60
0 θ = 90o 0 θ = 90o
xy plane xy plane
150 −10 30 150 −10 30
−20 −20
↑φ ↑φ
x x
180 0 → 180 0 →
↑z ↑z
θ 0 10 θ θ 0 10 θ
← → ← →
30 30 30 30
0 φ = 0o 0 φ = 0o
xz plane xz plane
60 −10 60 60 −10 60
−20 −20
x x
90 90 → 90 90 →
↑z ↑z
θ 0 10 θ θ 0 10 θ
← → ← →
30 30 30 30
0 φ = 90o 0 φ = 90o
yz plane yz plane
60 −10 60 60 −10 60
−20 −20
y y
90 90 → 90 90 →
z
y x
ε r =9.8
Strip width 1 mm.
25.4
26.1
.3
14
10
ground
PEC boundary
Voltage source PML interface
3 bricks = [ ] ;
spheres = [ ] ;
5
% define d i e l e c t r i c
7 b r i c k s ( 1 ) . min x = 0 ;
b r i c k s ( 1 ) . mi n y = 0 ;
9 b r i c k s ( 1 ) . min z = 0 ;
b r i c k s ( 1 ) . max x = 1 4 . 3 e −3;
11 b r i c k s ( 1 ) . max y = 2 5 . 4 e −3;
b r i c k s ( 1 ) . max z = 2 6 . 1 e −3;
13 bricks ( 1 ) . material type = 4;
voltage sources = [ ] ;
4 current sources = [ ] ;
diodes = [ ] ;
6 resistors = [];
inductors = [ ] ;
8 capacitors = [ ] ;
10 % d e f i n e s o u r c e waveform t y p e s and p a r a m e t e r s
waveforms . g a u s s i a n ( 1 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 0 ;
12 waveforms . g a u s s i a n ( 2 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 15;
14 % voltage sources
% d i r e c t i o n : ’ xp ’ , ’ xn ’ , ’ yp ’ , ’ yn ’ , ’ zp ’ , o r ’ zn ’
16 % r e s i s t a n c e : ohms , m a g i t u d e : volts
v o l t a g e s o u r c e s ( 1 ) . min x = 0 ;
18 v o l t a g e s o u r c e s ( 1 ) . m i n y = 1 2 . 2 e −3;
v o l t a g e s o u r c e s ( 1 ) . min z = 0 ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
13 % mode o f o p e r a t i o n
run simulation = true ;
15 show material mesh = true ;
show problem space = true ;
17
% f a r f i e l d c a l c u l a t i o n parameters
19 f a r f i e l d . f r e q u e n c i e s ( 1 ) = 3 . 5 e9 ;
f a r f i e l d . f r e q u e n c i e s ( 2 ) = 4 . 3 e9 ;
21 f a r f i e l d . number of cells from outer boundary = 13;
23 % f r e q u e n c y domain p a r a m e t e r s
f r e q u e n c y d o m a i n . s t a r t = 2 e9 ;
25 f r e q u e n c y d o m a i n . end = 6 e9 ;
f r e q u e n c y d o m a i n . s t e p = 20 e6 ;
27
% define ports
49 ports ( 1 ) . sampled voltage index = 1;
ports ( 1 ) . sampled current index = 1;
51 ports ( 1 ) . impedance = 5 0 ;
ports ( 1 ) . is source port = true ;
The FDTD simulation of the DRA is performed with 10,000 time steps, and S11 of the input
port is calculated. The calculated return loss is plotted in Fig. 9.19, and it shows good agreement
with the published simulation and measurement data in [37].
Furthermore, the directivity patterns are calculated in the xy, xz, and y z plane cuts at 3.5 GHz
and 4.3 GHz. These patterns are plotted in Figs. 9.20, 9.21, and 9.22, respectively. The simulated
FDTD radiation patterns show good agreement with the published data as well [37].
9.5 EXERCISES
9.1 In this exercise we construct and study the characteristics of a half-wave dipole antenna.
Create a problem space composed of a cubic Yee cell with 0.5 mm size on a side. Set
the boundaries as CPML, and leave 10 cells air gap between the antenna and the CPML
boundaries on all sides. Place a brick of square cross-section with 1 mm width and 14.5 mm
10
S11
0
magnitude (dB)
−10
−20
−30
−40
2 2.5 3 3.5 4 4.5 5 5.5 6
frequency (GHz)
Exercises 311
↑y ↑y
9010 9010
120 60 120 60
0 θ = 90o 0 θ = 90o
xy plane xy plane
150 −10 30 150 −10 30
−20 −20
↑φ ↑φ
x x
180 0 → 180 0 →
↑z ↑z
θ 0 10 θ 0
← → θ 10 θ
← →
30 30 30 30
0 φ = 0o 0 φ = 0o
xz plane xz plane
60 −10 60 60 −10 60
−20 −20
x x
90 90 → 90 90 →
120 12 0 120 12 0
↑z ↑z
θ 010 θ
← → θ 010 θ
← →
30 30 30 30
0 φ = 90o 0 φ = 90o
yz plane yz plane
60 −10 60 60 −10 60
−20 −20
y y
90 90 → 90 90 →
120 12 0 120 1 20
height 0.5 mm above the origin. Place another brick with the same dimensions 0.5 mm below
the origin. Thus, the dipole will be oriented in the z direction with 1 mm gap between its
poles. Place a voltage source with 50 internal impedance between the poles. Then define
a sampled voltage and a sampled current across and around the voltage source and associate
them to a port. The geometry of the problem is illustrated in Fig. 9.23. Run the simulation,
and calculate the input impedance of the antenna using the frequency-domain simulation
results. Identify the resonance frequency of the antenna from the input impedance results.
Then rerun the simulation to calculate the radiation pattern at the resonance frequency.
9.2 Consider the dipole antenna that you constructed in Exercise 9.1. Examine the input
impedance that you calculated, and record the real part of the input impedance at resonance
frequency. Then change the resistance of the voltage source and the port to the resistance
you recorded. Rerun the simulation, and obtain the scattering parameter (S-parameter) and
radiation pattern results. Examine whether the S-parameters and the radiation patterns have
changed.
9.3 In this exercise we try to construct a microstrip rectangular square patch antenna. Define
a problem space with grid size x = 2 mm, y = 2 mm, and z = 0.95 mm. Place a
rectangular brick in the problem space as the substrate of the antenna with dimensions
60 mm × 40 mm × 1.9 mm and 2.2 dielectric constant. Place a PEC plate as the ground of
the antenna on the bottom side of the substrate covering the entire surface area. Then place
a PEC patch on the top surface of the substrate with 56 mm width and 20 mm length in the
x and y directions, respectively. Make sure that the top patch is centered on the top surface
of the substrate. The feeding point to the top patch will be at the center of one of the long
edges of the patch. Place a voltage source with 50 internal resistance between the ground
plane and the feeding point, define a sampled voltage and a sampled current on the voltage
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Exercises 313
source, and associate them to a port. The geometry of the problem is illustrated in Fig. 9.24.
Run the simulation, and obtain the return loss (S11 ) of the antenna. Verify that the antenna
operates around 4.35 GHz. Then rerun the simulation to obtain the radiation patterns at
the operation frequency.
9.4 Consider the microstrip rectangular square patch antenna you constructed in Exercise 9.3.
In this configuration the patch feeding is placed right at the center of the edge of the antenna.
In this example the antenna will be fed through a microstrip line. Place a microstrip line
with 6 mm width between the antenna feeding point and the edge of the substrate. This
microstrip line with 6 mm width will simulate a characteristic impedance of 50 . Notice
that you will need to place the microstrip line off center by 1 mm to have it conforming
to the FDTD grid. Move the voltage source, the sampled voltage, and the sampled current
to the edge of the substrate where the microstrip line is extended. The geometry of the
problem is illustrated in Fig. 9.25. Run the simulation, and obtain the return loss and the
radiation pattern at the corresponding operating frequency. Does the existence of a feeding
line change the radiation pattern?
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
10
Thin-Wire Modeling
So far we have assumed that all of the objects in the finite-difference time-domain (FDTD)
problem space conform to the FDTD grid. Some subcell modeling techniques are developed to
model geometries that do not conform to the grid or have dimensions smaller than cell dimensions.
One of the most common such geometries is a thin wire that has a radius less than a cell size.
In this chapter we discuss one of the subcell modeling techniques that is proposed to model thin
wires in FDTD simulations.
There are various techniques proposed for modeling thin wires. However, we discuss the one
proposed in [38], which is based on Faraday’s law contour-path formulation. This model is easy
to understand and to implement in the FDTD program.
∂H
−µ · d s = E · d l (10.1)
S ∂t L
can be applied on the enclosed surface shown in Fig. 10.1 to establish the relation between
Hy (i, j, k) and the electric field components located on the boundaries of the enclosed surface.
Before utilizing (10.1) it should be noted that the variation of the fields around the thin wire is
assumed to be a function of 1/r, where r represents the distance to the field position from the
thin-wire axis [38]. In more explicit form Hy can be expressed as
Hy0
Hy (r) = , (10.2)
r
315
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Figure 10.1 A thin wire with its axis coinciding with E z (i, j, k) and field components surrounding H y (i, j, k).
E x0
E x (r) = , (10.3)
r
where Hy0 and E x0 are constants. In Fig. 10.1 one can observe that the field components Hy (i, j, k),
E x (i, j, k), and E x (i, j, k + 1) are located at r = x/2. For instance,
x 2Hy0
Hy = = Hy (i, j, k). (10.4)
2 x
Then
Hy (i, j, k)x
Hy0 = , (10.5)
2
hence,
Hy (i, j, k)x
Hy (r) = . (10.6)
2r
Similarly,
E x (i, j, k)x
E x (r)| j,k = , (10.7)
2r
and
E x (i, j, k + 1)x
E x (r)| j,k+1 = . (10.8)
2r
Notice that the electric field should vanish inside the wire; therefore, the integration limits
are from a to x. Due to the same reasoning, E z (i, j, k) is zero as well. Then evaluation of
(10.12) yields
−µzx x ∂ Hy (i, j, k)
ln = −zE z (i + 1, j, k)
2 a ∂t
x x x x
+ ln E x (i, j, k + 1) − ln E x (i, j, k). (10.12)
a 2 a 2
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
After applying the central difference approximation to the time derivative of magnetic field com-
ponent and re-arranging the terms, one can obtain the new value of Hy (i, j, k) in terms of other
components as
2t
Hyn+1/2 (i, j, k) = Hyn−1/2 (i, j, k) + E zn (i + 1, j, k)
µx ln x
a
t n
− E x (i, j, k + 1) − E xn (i, j, k) . (10.13)
µz
Equation (10.13) can be written in the same form as the general updating equation for Hy (1.30),
such that
n+ 12 n− 12
Hy (i, j, k) = C hyh (i, j, k) × Hy (i, j, k)
+ C hye z (i, j, k) × E zn (i + 1, j, k) − E zn (i, j, k)
+ C hye x (i, j, k) × E xn (i, j, k + 1) − E xn (i, j, k) , (10.14)
where
2t
C hyh (i, j, k) = 1, C hye z (i, j, k) = ,
µ y (i, j, k)x ln x
a
t
C hye x (i, j, k) = − .
µ y (i, j, k)z
Then one only need to modify the updating coefficients before the FDTD time-marching loop
n+ 1
according to (10.14) to have Hy 2 (i, j, k) updated due to a thin wire between nodes (i, j, k) and
(i, j, k + 1). Furthermore, we have enforced E z (i, j, k) to be zero. This can be accomplished sim-
ilarly by setting the updating coefficients for E zn (i, j, k) in (1.28) as zero. That means Ce ze (i, j, k),
Ce zhy (i, j, k), and Ce zhy (i, j, k) should be assigned zeros before the FDTD time-marching proce-
dure begins.
As mentioned before, there are four magnetic field components circulating around E zn (i, j, k) as
illustrated in Fig. 10.2; therefore, all these magnetic field components need to be updated based on
thin-wire modeling. The updating equation for Hy (i, j, k) is given in (10.13). Similarly, updating
equations can be obtained for the other three components as
n+ 12 n− 12
Hy (i − 1, j, k) = C hyh (i − 1, j, k) × Hy (i − 1, j, k)
+ C hye z (i − 1, j, k) × E zn (i, j, k) − E zn (i − 1, j, k)
+ C hye x (i − 1, j, k) × E xn (i − 1, j, k + 1) − E xn (i − 1, j, k) , (10.15)
where
2t
C hyh (i − 1, j, k) = 1, C hye z (i − 1, j, k) = ,
µ y (i − 1, j, k)x ln x
a
t
C hye x (i − 1, j, k) = − .
µ y (i − 1, j, k)z
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
n+ 12 n− 12
Hx (i, j, k) = C hxh (i, j, k) × Hx (i, j, k)
+ C hxe y (i, j, k) × E yn (i, j, k + 1) − E yn (i, j, k)
+ C hxe z (i, j, k) × E zn (i, j + 1, k) − E zn (i, j, k) , (10.16)
where
t
C hxh (i, j, k) = 1, C hxe y (i, j, k) = ,
µx (i, j, k)z
2t
C hxe z (i, j, k) = − .
y
µx (i, j, k)y ln a
and
n+ 12 n− 12
Hx (i, j − 1, k) = C hxh (i, j − 1, k) × Hx (i, j − 1, k)
+ C hxe y (i, j − 1, k) × E yn (i, j − 1, k + 1) − E yn (i, j − 1, k)
+ C hxe z (i, j − 1, k) × E zn (i, j, k) − E zn (i, j − 1, k) , (10.17)
where
t
C hxh (i, j − 1, k) = 1, C hxe y (i, j − 1, k) = ,
µx (i, j − 1, k)z
2t
C hxe z (i, j − 1, k) = − .
y
µx (i, j − 1, k)y ln a
3 bricks = [ ] ;
spheres = [ ] ;
5 thin wires = [ ] ;
After the definition process, the initialization process is performed. Since the thin wire is a
new type of geometry that would determine the size of the problem space, necessary codes must
be implemented in the subroutine calculate domain size. The code for this task is shown in
Listing 10.2.
The next step in the thin-wire implementation is the initialization of the thin-wire parame-
ters through the updating coefficients. A new subroutine named initialize thin wire updating -
coefficients is implemented for initialization of the thin-wire updating coefficients. This subrou-
tine is named initialize updating coefficients and is called after the initialization subroutines
for the updating coefficients of other types of objects are called. The implementation of initial-
ize thin wire updating coefficients is shown in Listing 10.3. In this subroutine, the electric and
magnetic field coefficients associated with thin wires are updated based on the equations derived
in Section 10.1.
Listing 10.3 initialize thin wire updating coefficients
disp ( ’ i n i t i a l i z i n g thin wire updating c o e f f i c i e n t s ’ ) ;
2
dtm = d t / mu 0 ;
4
14 sw i t ch ( t h i n w i r e s ( i n d ) . d i r e c t i o n ( 1 ) )
case ’ x ’
16 C e x e ( i s : i e −1 , j s , k s ) = 0 ;
C e x h y ( i s : i e −1 , j s , k s ) = 0 ;
18 C e x h z ( i s : i e −1 , j s , k s ) = 0 ;
Chyh ( i s : i e −1 , j s , ks −1: k s ) = 1 ;
20 C h y e z ( i s : i e −1 , j s , ks −1: k s ) = dtm . . .
. / ( m u r y ( i s : i e −1 , j s , ks −1: k s ) * dx ) ;
22 C h y e x ( i s : i e −1 , j s , ks −1: k s ) = −2 * dtm . . .
. / ( m u r y ( i s : i e −1 , j s , ks −1: k s ) * dz * l o g ( dz / r o ) ) ;
24 Chzh ( i s : i e −1 , j s −1: j s , k s ) = 1 ;
C h z e x ( i s : i e −1 , j s −1: j s , k s ) = 2 * dtm . . .
26 . / ( m u r z ( i s : i e −1 , j s −1: j s , k s ) * dy * l o g ( dy / r o ) ) ;
C h z e y ( i s : i e −1 , j s −1: j s , k s ) = −dtm . . .
28 . / ( m u r z ( i s : i e −1 , j s −1: j s , k s ) * dx ) ;
case ’ y ’
30 C e y e ( i s , j s : j e −1 , k s ) = 0 ;
C e y h x ( i s , j s : j e −1 , k s ) = 0 ;
32 C e y h z ( i s , j s : j e −1 , k s ) = 0 ;
Chzh ( i s −1: i s , j s : j e −1 , k s ) = 1 ;
34 C h z e x ( i s −1: i s , j s : j e −1 , k s ) = dtm . . .
. / ( m u r z ( i s −1: i s , j s : j e −1 , k s ) * dy ) ;
36 C h z e y ( i s −1: i s , j s : j e −1 , k s ) = −2 * dtm . . .
. / ( m u r z ( i s −1: i s , j s : j e −1 , k s ) * dx * l o g ( dx / r o ) ) ;
38 Chxh ( i s , j s : j e −1 , ks −1: k s ) = 1 ;
C h x e y ( i s , j s : j e −1 , ks −1: k s ) = 2 * dtm . . .
40 . / ( m u r x ( i s , j s : j e −1 , ks −1: k s ) * dz * l o g ( dz / r o ) ) ;
C h x e z ( i s , j s : j e −1 , ks −1: k s ) = −dtm . . .
42 . / ( m u r x ( i s , j s : j e −1 , ks −1: k s ) * dy ) ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
case ’ z ’
44 Ceze ( i s , j s , k s : ke −1) = 0 ;
Cezhx ( i s , j s , k s : ke −1) = 0 ;
46 Cezhy ( i s , j s , k s : ke −1) = 0 ;
Chxh ( i s , j s −1: j s , k s : ke −1) = 1 ;
48 Chxey ( i s , j s −1: j s , k s : ke −1) = dtm . . .
./ ( m u r x ( i s , j s −1: j s , k s : ke −1) * dz ) ;
50 Chxez ( i s , j s −1: j s , k s : ke −1) = −2 * dtm . . .
./ ( m u r x ( i s , j s −1: j s , k s : ke −1) * dy * l o g ( dy / r o ) ) ;
52 Chyh ( i s −1: i s , j s , k s : ke −1) = 1 ;
Chyez ( i s −1: i s , j s , k s : ke −1) = 2 * dtm . . .
54 ./ ( m u r y ( i s −1: i s , j s , k s : ke −1) * dx * l o g ( dx / r o ) ) ;
Chyex ( i s −1: i s , j s , k s : ke −1) = −dtm . . .
56 ./ ( m u r y ( i s −1: i s , j s , k s : ke −1) * dz ) ;
end
58 end
As the updating coefficients associated with the thin wires are updated appropriately, the
implementation of the thin-wire formulation is completed. The thin-wire implementation only
requires an extra preprocessing step. Then during the FDTD time-marching loop the updating
coefficients will manipulate the fields for modeling the thin-wire behavior.
bricks = [ ] ;
4 spheres = [ ] ;
thin wires = [ ] ;
6
3 voltage sources = [ ] ;
current sources = [ ] ;
5 diodes = [ ] ;
resistors = [];
7 inductors = [ ] ;
capacitors = [ ] ;
9
% d e f i n e s o u r c e waveform t y p e s and p a r a m e t e r s
11 waveforms . g a u s s i a n ( 1 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 0 ;
waveforms . g a u s s i a n ( 2 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 15;
13
% voltage sources
15 % d i r e c t i o n : ’ xp ’ , ’ xn ’ , ’ yp ’ , ’ yn ’ , ’ zp ’ , o r ’ zn ’
% r e s i s t a n c e : ohms , m a g i t u d e : volts
17 v o l t a g e s o u r c e s ( 1 ) . min x = 0 ;
v o l t a g e s o u r c e s ( 1 ) . min y = 0 ;
19 v o l t a g e s o u r c e s ( 1 ) . m i n z = −0.25 e −3;
v o l t a g e s o u r c e s ( 1 ) . max x = 0 ;
21 v o l t a g e s o u r c e s ( 1 ) . max y = 0 ;
v o l t a g e s o u r c e s ( 1 ) . max z = 0 . 2 5 e −3;
23 v o l t a g e s o u r c e s ( 1 ) . d i r e c t i o n = ’ zp ’ ;
v o l t a g e s o u r c e s ( 1 ) . r e s i s t a n c e = 50;
25 v o l t a g e s o u r c e s ( 1 ) . magnitude = 1 ;
v o l t a g e s o u r c e s ( 1 ) . waveform type = ’ gaussian ’ ;
27 v o l t a g e s o u r c e s ( 1 ) . waveform index = 1;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
13 % mode o f o p e r a t i o n
run simulation = true ;
15 show material mesh = true ;
show problem space = true ;
17
% f a r f i e l d c a l c u l a t i o n parameters
19 f a r f i e l d . f r e q u e n c i e s ( 1 ) = 7 . 0 e9 ;
f a r f i e l d . number of cells from outer boundary = 13;
21
% f r e q u e n c y domain p a r a m e t e r s
23 f r e q u e n c y d o m a i n . s t a r t = 20 e6 ;
f r e q u e n c y d o m a i n . end = 20 e9 ;
25 f r e q u e n c y d o m a i n . s t e p = 20 e6 ;
47 % define ports
ports ( 1 ) . sampled voltage index = 1;
49 ports ( 1 ) . sampled current index = 1;
ports ( 1 ) . impedance = 5 0 ;
51 ports ( 1 ) . is source port = true ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
CPML boundaries
outer boundaries
voltage source
z
y x
10
magnitude (dB)
−10 FDTD
WIPL−D
−20
0 5 10 15 20
frequency (GHz)
50
phase (degrees)
−50
−100
0 5 10 15 20
frequency (GHz)
2000
FDTD real[Z ]
in
FDTD imaginary[Zin]
1500
WIPL−D real[Z ]
in
WIPL−D imaginary[Zin]
1000
input impedance (Ω)
500
−500
−1000
0 2 4 6 8 10 12 14 16 18 20
frequency (GHz)
↑y
9010
120 60
0 θ = 90o
xy plane
150 −10 30
−20
↑φ
x
180 0 →
210 330
240 300
dB 270 D , f=7 GHz
θ
D , f=7 GHz
φ
Exercises 327
↑z
θ
←
0 10 θ
→
30 30
0 φ = 0o
xz plane
60 −10 60
−20
x
90 90 →
120 120
150 15 0
dB 180 D , f=7 GHz
θ
D , f=7 GHz
φ
10.4 EXERCISES
10.1 Construct a problem space composed of cells with size 1 mm on a side. Define a dipole
antenna using thin wires similar to the dipole antenna discussed in Section 10.3.1. Set
the length of each wire to 10 mm, and leave a 1 mm gap between the wires. Place a
voltage source, a sampled voltage, and a sampled current in the gap between the wires,
and associate them to a port. Set the radius of the wire as 0.1 mm, run the simulation, and
obtain the return loss of the antenna. Then increase the radius of the wire by 0.2 mm,
repeat the simulation, and observe the change in the return loss. Rerun the simulations
with incremented increase of wire radius by 0.2 mm until the increased wire radius causes
instability in the simulation. Can you determine the maximum wire radius for accurate
results in this configuration?
10.2 In this example we construct an antenna array composed of two thin-wire dipole anten-
nas. Consider the dipole antenna that you constructed in Exercise 10.1. Run the dipole
simulation using the 0.1 mm wire radius, and record the operation frequency. Rerun the
simulation, and obtain the radiation pattern at the frequency of operation. Then define
another thin-wire dipole antenna with the same dimensions as the current one, and place it
2 mm above the current one, such that the center to center distance between antennas will
be 23 mm. Place a voltage source at the feeding gap of the second antenna that has the
same properties of the voltage source of the first antenna. Do not define any ports, and if
there are already defined ports, remove them. The geometry of the problem is illustrated
in Fig. 10.9. Run the simulation, and calculate the radiation patterns at the frequency of
operation. Examine the directivity patterns of the single- and two-dipole configurations.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
↑z
θ
←
0 10 θ
→
30 30
0 φ = 90o
yz plane
60 −10 60
−20
y
90 90 →
1 20 120
1 50 15 0
dB 180 D , f=7 GHz
θ
D , f=7 GHz
φ
Exercises 329
10.3 Consider the dipole antenna array that you constructed in Exercise 10.2. Invert the polarity
of one of the voltage sources. For instance, if the direction of the voltage source is ‘zp’, set
the direction as ‘zn’. This will let the antennas be excited by 180◦ phase difference. Run
the simulation, and obtain the radiation pattern at the frequency of operation.
10.4 In this exercise we construct a square loop inductor. Construct a problem space composed
of cells with size 1 mm on a side. Place three thin wires, each of which is 10 mm long, such
that they will form the three sides of a square loop. Then place two thin wires, each of
which is 4 mm long, on the fourth side, leaving a 2 mm gap in between at the center of the
fourth side. Place a voltage source, a sampled voltage, and a sampled current in this gap. Set
the radius of the wires as 0.1 mm. The geometry of the problem is illustrated in Fig. 10.10.
Run the simulation, and calculate the input impedance. At low frequencies the imaginary
part of the input impedance is positive and linear, which implies that the inductance is
constant at low frequencies. Calculate the inductance of the loop. The inductance of such
a square loop can be calculated as 30.7 nH using the formula in [40].
10.5 Consider the square loop that you constructed in Exercise 10.4. Now reduce the cell size
to 0.5 mm on a side, and reduce the length of the source gap to 1 mm. Run the simulation,
and then calculate the inductance of the loop. Examine if the calculated inductance got
closer to the expected value.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
11
Scattered Field Formulation
∇×H inc = ε0 ∂ Einc , (11.1a)
∂t
∂Hinc
∇ × Einc = −µ0 . (11.1b)
∂t
The most common type of incident field is the plane wave. The expressions for the field compo-
nents generated by plane waves are discussed in a subsequent section.
When the incident field illuminates the objects in an FDTD problem space, scattered fields are
generated and thus need to be calculated. The scattered field formulation is one of the simplest
techniques that can be used for calculating scattered fields.
The fields in a problem space are referred to in general as total fields. The total fields satisfy
Maxwell’s curl equations for a general medium, such that
∇×H tot = ε ∂ Etot + σ e Etot , (11.2a)
∂t
∂H tot
∇ × Etot = −µ − σmH tot . (11.2b)
∂t
331
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Then the scattered fields are defined as the difference between the total fields and incident fields.
Therefore, one can write
where Escat and Hscat are the scattered electric and magnetic fields. In light of (11.3), equation
(11.2) can be rewritten in terms of incident and scattered field terms as
inc = ε
scat + ∇ × H ∂ Escat ∂ Einc
∇×H +ε + σ e Escat + σ e Einc , (11.4a)
∂t ∂t
∂H scat ∂H inc
∇ × Escat + ∇ × Einc = −µ −µ − σmH scat − σ m H inc . (11.4b)
∂t ∂t
The curls of the incident fields in (11.4) can be replaced by the time-derivative terms from (11.1),
which yields
∂ Escat
scat + (ε0 − ε) ∂ Einc − σ e Einc ,
ε + σ e Escat = ∇ × H (11.6a)
∂t ∂t
∂ Hscat
µ + σmH scat = −∇ × Escat + (µ0 − µ) ∂ Hinc − σ m H inc . (11.6b)
∂t ∂t
At this point the derivatives in (11.6) can be represented by central finite difference approximations,
and updating equations can be obtained for the scattered field formulation.
After applying the central finite difference approximation, equation (11.6a) can be expressed for
the x component as
n+1
Escat,x (i, j, k) − Escat,x
n
(i, j, k) n+1
Escat,x (i, j, k) + Escat,x
n
(i, j, k)
εx (i, j, k) + σxe (i, j, k)
t 2
n+ 1 n+ 1 n+ 1 n+ 1
Hscat,z2 (i, j, k) − Hscat,z2 (i, j − 1, k) Hscat,y2 (i, j, k) − Hscat,y2 (i, j, k − 1)
= −
y z
n+1
Einc,x (i, j, k) − Einc,x
n
(i, j, k)
+ (ε0 − εx (i, j, k))
t
n+1
Einc,x (i, j, k) + Einc,x
n
(i, j, k)
− σxe (i, j, k) , (11.7)
2
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Equation (11.7) can be arranged such that the new value of the scattered electric field component
n+1
Escat,x (i, j, k) is calculated using other terms as
n+1
Escat,x (i, j, k) = Cexe (i, j, k) × Escat,x
n
(i, j, k)
n+ 1 n+ 1
!
+ Cexhz (i, j, k) × Hscat,z2 (i, j, k) − Hscat,z2 (i, j − 1, k)
n+ 1 n+ 1
!
+ Cexhy (i, j, k) × Hscat,y2 (i, j, k) − Hscat,y2 (i, j, k − 1)
where
2εx (i, j, k) − σxe (i, j, k)t
Cexe (i, j, k) = ,
2εx (i, j, k) + σxe (i, j, k)t
2t
Cexhz (i, j, k) = ,
y 2εx (i, j, k) + σxe (i, j, k)t
2t
Cexhy (i, j, k) = − ,
z 2εx (i, j, k) + σxe (i, j, k)t
2 (ε0 − εx (i, j, k)) − σxe (i, j, k)t
Cexeic (i, j, k) = ,
2εx (i, j, k) + σxe (i, j, k)t
2 (ε0 − εx (i, j, k)) + σxe (i, j, k)t
Cexeip (i, j, k) = − .
2εx (i, j, k) + σxe (i, j, k)t
In this equation the ic term in the subscript of the coefficient Cexeic indicates that this coefficient
is multiplied with the current value of the incident field component, whereas the ip term in the
subscript of the coefficient Cexeip indicates that this coefficient is multiplied with the previous value
of the incident field component.
n+1
Similarly the updating equation can be written for Escat,y (i, j, k) as
n+1
Escat,y (i, j, k) = Ceye (i, j, k) × Escat,y
n
(i, j, k)
n+ 1 n+ 1
!
+ Ceyhx (i, j, k) × Hscat,x2 (i, j, k) − Hscat,x2 (i, j, k − 1)
n+ 1 n+ 1
!
+ Ceyhz (i, j, k) × Hscat,z2 (i, j, k) − Hscat,z2 (i − 1, j, k)
where
2ε y (i, j, k) − σ ye (i, j, k)t
Ceye (i, j, k) = ,
2ε y (i, j, k) + σ ye (i, j, k)t
2t
Ceyhx (i, j, k) = ,
z 2ε y (i, j, k) + σ ye (i, j, k)t
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
2t
Ceyhz (i, j, k) = − ,
x 2ε y (i, j, k) + σ ye (i, j, k)t
2 ε0 − ε y (i, j, k) − σ ye (i, j, k)t
Ceyeic (i, j, k) = ,
2ε y (i, j, k) + σ ye (i, j, k)t
2 ε0 − ε y (i, j, k) + σ ye (i, j, k)t
Ceyeip (i, j, k) = − .
2ε y (i, j, k) + σ ye (i, j, k)t
n+1
The updating equation can be written for Escat,z (i, j, k) as
n+1
Escat,z (i, j, k) = Ceze (i, j, k) × Escat,z
n
(i, j, k)
n+ 12 n+ 12
+ Cezhy (i, j, k) × Hscat,y (i, j, k) − Hscat,y (i, j, k − 1)
n+ 1 n+ 1
+ Cezhx (i, j, k) × Hscat,x2 (i, j, k) − Hscat,x2 (i − 1, j, k)
where
Following a similar procedure, the updating equations for the magnetic field components can
n+ 1
be obtained as follows. The updating equation for Hscat,x2 (i, j, k) is
n+ 1 n− 1
Hscat,x2 (i, j, k) = Chxh (i, j, k) × Hscat,x2 (i, j, k)
n
+ Chxez (i, j, k) × Escat,z (i, j + 1, k) − Escat,z
n
(i, j, k)
n
+ Chxey (i, j, k) × Escat,y (i, j, k + 1) − Escat,y
n
(i, j, k)
n+ 1 n− 1
+ Chxhic (i, j, k) × Hinc,x2 (i, j, k) + Chxhip (i, j, k) × Hinc,x2 (i, j, k), (11.11)
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
where
n+ 1
The updating equation for Hscat,y2 (i, j, k) is
n+ 1 n− 1
Hscat,y2 (i, j, k) = Chyh (i, j, k) × Hscat,y2 (i, j, k)
n
+ Chyex (i, j, k) × Escat,x (i, j + 1, k) − Escat,x
n
(i, j, k)
n
+ Chyez (i, j, k) × Escat,z (i, j, k + 1) − Escat,z
n
(i, j, k)
n+ 1 n− 1
+ Chyhic (i, j, k) × Hinc,y2 (i, j, k) + Chyhip (i, j, k) × Hinc,y2 (i, j, k), (11.12)
where
n+ 1
Finally, the updating equation for Hscat,z2 (i, j, k) is
n+ 1 n− 1
Hscat,z2 (i, j, k) = Chzh (i, j, k) × Hscat,z2 (i, j, k)
n
+ Chzey (i, j, k) × Escat,y (i, j + 1, k) − Escat,y
n
(i, j, k)
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
where
Equations (11.8)–(11.13) are the updating equations with corresponding definitions for asso-
ciated coefficients for the scattered field formulation. Comparing these equations with the set
of general updating equations (1.26)–(1.31) one can realize that the forms of the equations and
expressions of the coefficients are the same except that (11.8)–(11.13) include additional incident
field terms.
The aforementioned scattered field updating equations are derived to calculate scattered electric
fields in a problem space in response to an incident field. The incident field in general can be
any far-zone source that can be expressed by analytical expressions. In this context incident plane
waves are the most commonly used type of incident field. This section discusses the incident plane
wave field expressions.
Figure 11.1 illustrates an incident plane wave traveling in the direction denoted by a unit
vector
k. The incident electric field in general may have a θ component and a φ component when
expressed in a spherical coordinate system denoting its polarization. The incident electric field
can be expressed for a given point denoted by a position vector r as
1
Einc = Eθ f
θ + Eφ φ t− k · r , (11.14)
c
where f is a function determining the waveform of the incident electric field. This equation can
be rewritten by allowing a time delay t0 and spatial shift l 0 as
1
Einc = Eθ f
θ + Eφ φ (t − t0 ) − (k · r − l 0 ) . (11.15)
c
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
z k̂
r Eφ
θinc Eθ
φinc y
r =
xx +
y y +
zz,
k =
x sin θinc cos φinc +
y sin θinc sin φinc +
z cos θinc , (11.16)
where θinc and φinc are the angles indicating the direction of propagation of the incident plane
wave as shown in Fig. 11.1. The components of the incident electric field Eθ and Eφ can also
be expressed in Cartesian coordinates. Therefore, after using (11.16) in (11.15) and applying the
spherical to Cartesian coordinates transformation, one can obtain the components of the incident
electric field for any point (x, y, z) in space as
Einc,x = Eθ cos θinc cos φinc − Eφ sin φinc fw f , (11.17a)
Einc,y = Eθ cos θinc sin φinc + Eφ cos φinc fw f , (11.17b)
Einc,z = (−Eθ sin θinc ) fw f , (11.17c)
where fw f is given by
1
fw f = f (t − t0 ) − (x sin θinc cos φinc + y sin θinc sin φinc + z cos θinc − l 0 ) . (11.18)
c
Once the expressions for the incident electric field components are obtained, the expressions for
magnetic field components can be obtained using
inc = 1
H k × Einc ,
η0
where η0 is the intrinsic impedance of free space, and the × denotes the cross-product operator.
Then the magnetic field components are
−1
Hinc,x = Eφ cos θinc cos φinc + Eθ sin φinc fw f , (11.19a)
η0
−1
Hinc,y = Eφ cos θinc sin φinc − Eθ cos φinc fw f , (11.19b)
η0
1
Hinc,z = Eφ sin θinc fw f . (11.19c)
η0
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Leading edge of
the waveform
l0 = kˆ ⋅ r0 ⎛
f ⎜ ( t − t0 ) −
k̂ ⋅ r − l0 ⎞
⎟
⎝ c ⎠
FDTD
k̂ problem
space
z
⎛ k̂ ⋅ r ⎞
f ⎜ ( t − t0 ) − ⎟
⎝ c ⎠ r0
⎛ k̂ ⋅ r ⎞
f ⎜t − ⎟ y Waveform’s entry point
⎝ c ⎠ to the problem space
x
Figure 11.2 An incident plane wave delayed in time and shifted in space.
Equations (11.17)–(11.19) express an incident field with a polarization determined by (Eθ θ+
Eφ φ), propagating in a direction determined by the angles θinc and φinc and having a waveform
described by fw f . In general, the waveform can be a function that has the desired bandwidth
characteristics as discussed in Chapter 5. However, there are two additional parameters in (11.18)
we have not discussed yet: t0 and l 0 . These parameters are used to shift the given waveform in
time and space such that when the FDTD iterations start the incident field in the problem space
is zero, and as time proceeds the incident field propagates into the FDTD problem space.
Consider Fig. 11.2, which illustrates a plane wave with a Gaussian waveform propagating in a
direction k toward an FDTD problem space. This waveform is expressed by a function
1
f t − ( k · r) ,
c
where the maximum of the waveform appears on a plane including the origin and normal to k at
t = 0. Clearly the leading edge of this waveform is closer to the FDTD problem space. A time
delay t0 can be applied to this function such that
1
f (t − t0 ) − (
k · r) ,
c
and the leading edge of the waveform coincides with the origin. The value of the waveform
can be calculated as explained in Chapter 5. After applying the time delay, there is a distance
between the leading edge of the waveform and the problem space that needs to be accounted for;
otherwise, it may take considerable time after the simulation is started until the waveform enters
to the problem space. The distance between the waveform and the problem space can be found
as l 0 =
k · r0 , where r0 is the position vector indicating the closest point of the problem space
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
z
A plane wave traveling
away from origin
k̂
θinc
A plane wave traveling E
towards origin Eθ φ
y
Eφ ′
k̂′ φinc
Eθ ′
x
Figure 11.3 Two incident plane waves: one traveling toward the origin and the other traveling away from
the origin.
to the waveform. A problem space has eight corners, and one of these corners will be closest to
the waveform approaching from an arbitrary direction. If r0 indicates the corner points of the
problem space, then the minimum distance for l 0 can be calculated by l 0 = min[
k · r0 ]. After l 0 is
determined, the waveform equation can be modified as
1
f (t − t0 ) − (k · r − l 0 ) ,
c
One of the types of results that can be obtained from the scattered field due to an incident
plane wave is the radar cross-section (RCS) of a scatterer. The near-field to far-field NF-FF
transformation algorithm discussed in Chapter 9 is used for this purpose. In this case the scattered
near fields calculated in a problem space are captured on an imaginary surface enclosing the
scatterer to determine the equivalent fictitious surface currents. These currents are transformed
to the frequency domain while being captured. After the time-marching loop is completed, the
far-field terms Lθ , Lφ , Nθ , and Nφ are calculated following the procedure described in Chapter 9.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
At this point the components of the bistatic RCS can be calculated using
k2
RCSθ = |Lφ + η0 Nθ |2 (11.21a)
8π η0 Pinc
k2
RCSφ = |Lθ − η0 Nφ |2 , (11.21b)
8π η0 Pinc
which is very similar to (9.39). The only difference is that Prad is replaced by Pinc , which is the
power carried by the incident plane wave. The Pinc can be calculated as
1
Pinc = |Einc (ω)|2 , (11.22)
2η0
where Einc (ω) is the discrete Fourier transform (DFT) of the incident electric field waveform at
the frequency for which the RCS calculation is sought.
The scattered field formulation is presented in the previous sections. In this section the imple-
mentation of the scattered field formulation is discussed.
voltage sources = [ ] ;
4 current sources = [ ] ;
diodes = [ ] ;
6 resistors = [];
inductors = [ ] ;
8 capacitors = [ ] ;
incident plane wave = [ ] ;
10
% d e f i n e s o u r c e waveform t y p e s and p a r a m e t e r s
12 waveforms . g a u s s i a n ( 1 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 0 ;
waveforms . g a u s s i a n ( 2 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 15;
14
% Define i n c i d e n t p l a n e wave , a n g l e s a r e i n d e g r e e s
16 incident plane wave . E theta = 1;
incident plane wave . E phi = 0;
18 incident plane wave . theta incident = 0;
incident plane wave . phi incident = 0;
20 incident plane wave . waveform type = ’ gaussian ’ ;
incident plane wave . waveform index = 1;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
first a new empty structure, incident plane wave, is defined. Then the parameters of the incident
plane wave are defined as fields of this structure. Here E theta denotes the maximum amplitude
of the θ component, whereas E phi denotes the maximum amplitude of the φ component of the
electric field waveform. The fields theta incident and phi incident denote the angles indicating
the direction of propagation, θinc and φinc , of the incident plane wave. It should be noted here that
these parameters are based on the convention that the plane wave is propagating in a direction
away from the origin rather than toward the origin. If the parameters are readily available for
the convention wave traveling toward the origin, then the necessary transformation needs to be
performed based on the equations (11.20). Finally, the waveform of the incident plane wave need to
be defined. The definition of the waveform for the incident plane wave follows the same procedure
as the voltage source or the current source waveform. The types of waveforms are defined as a
structure waveforms, and the fields waveform type and waveform index are defined under
incident plane wave, which point to a specific waveform defined under waveforms.
212 i f i n c i d e n t p l a n e w a v e . enabled
% c r e a t e i n c i d e n t f i e l d a r r a y s f o r c u r r e n t time s t e p
214 H x i c = z e r o s ( nxp1 , ny , nz ) ;
H y i c = z e r o s ( nx , nyp1 , nz ) ;
216 H z i c = z e r o s ( nx , ny , nzp1 ) ;
E x i c = z e r o s ( nx , nyp1 , nzp1 ) ;
218 E y i c = z e r o s ( nxp1 , ny , nzp1 ) ;
E z i c = z e r o s ( nxp1 , nyp1 , nz ) ;
220 % c r e a t e i n c i d e n t f i e l d a r r a y s f o r p r e v i o u s time s t e p
H x i p = z e r o s ( nxp1 , ny , nz ) ;
222 H y i p = z e r o s ( nx , nyp1 , nz ) ;
H z i p = z e r o s ( nx , ny , nzp1 ) ;
224 E x i p = z e r o s ( nx , nyp1 , nzp1 ) ;
E y i p = z e r o s ( nxp1 , ny , nzp1 ) ;
226 E z i p = z e r o s ( nxp1 , nyp1 , nz ) ;
228 % c a l c u l a t e t h e a m p l i t u d e f a c t o r s f o r f i e l d components
t h e t a i n c i d e n t = incident plane wave . t h e t a i n c i d e n t * pi /180;
230 p h i i n c i d e n t = incident plane wave . p h i i n c i d e n t * pi /180;
E theta = incident plane wave . E theta ;
232 E phi = incident plane wave . E phi ;
e t a 0 = s q r t ( mu 0 / e p s 0 ) ;
234 E x i 0 = E t h e t a * cos ( t h e t a i n c i d e n t ) * cos ( p h i i n c i d e n t ) . . .
− E phi * sin ( phi incident ) ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
k dot r0 = k v e c x * r0 ( : , 1 ) ...
274 + k v e c y * r0 ( : , 2 ) . . .
+ k v e c z * r0 ( : , 3 ) ;
276
l 0 = min ( k d o t r 0 ) / c ;
278
% c a l c u l a t e k . r f o r e v e r y f i e l d component
280 k d o t r e x = ( ( x p o s ( 1 : nx , 1 : nyp1 , 1 : nzp1 )+ dx / 2 ) * k v e c x ...
+ y p o s ( 1 : nx , 1 : nyp1 , 1 : nzp1 ) * k v e c y . . .
282 + z p o s ( 1 : nx , 1 : nyp1 , 1 : nzp1 ) * k v e c z ) / c ;
292 k d o t r h x = ( x p o s ( 1 : nxp1 , 1 : ny , 1 : nz ) * k v e c x . . .
+ ( y p o s ( 1 : nxp1 , 1 : ny , 1 : nz )+ dy / 2 ) * k v e c y . . .
294 + ( z p o s ( 1 : nxp1 , 1 : ny , 1 : nz )+ dz / 2 ) * k v e c z ) / c ;
312 % s t o r e t h e waveform
w t s t r = incident plane wave . waveform type ;
314 w i s t r = num2str ( i n c i d e n t p l a n e w a v e . w a v e f o r m i n d e x ) ;
e v a l s t r = [ ’ a waveform = waveforms . ’ . . .
316 w t s t r ’ ( ’ w i s t r ’ ) . waveform ; ’ ] ;
eval ( e v a l s t r ) ;
318 i n c i d e n t p l a n e w a v e . waveform = a w a v e f o r m ;
In this code the first step is to determine whether an incident plane wave is defined. If an
incident plane wave is defined, then it indicates that the FDTD simulation is running a scattering
problem and, therefore, the algorithm of the scattered field formulation will be employed. Here
a logical parameter incident plane wave.enabled is assigned a value ’true’ or ’false’ indicating
the mode of the FDTD simulation.
The calculation of the scattered field components using the scattered field updating equation
is the same as the calculation of the total field components using the general updating equation,
except for the additional incident field terms. Therefore, the parameters corresponding to the
field arrays Ex, Ey, Ez, Hx, Hy, and Hz can be assumed as scattered fields if the mode of the
simulation is scattering. Then the field arrays corresponding to incident fields must be defined.
The new field arrays are thus defined as Exi, Eyi, Ezi, Hxi, Hyi, and Hzi and are initialized as
zeros. One should notice that the sizes of these three-dimensional arrays are the same as their
corresponding scattered field arrays.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
In the next step the amplitudes of the electric and magnetic field waveforms are transformed
from the spherical coordinates to Cartesian coordinates based on equations (11.17) and (11.19),
yielding Ex0i, Ey0i, Ez0i, Hx0i, Hy0i, and Hz0i.
The incident field components are computed at different positions in a three-dimensional
space. The coordinates of these field components can be determined with respect to positions
of the nodes of the FDTD grid. Three three-dimensional arrays are constructed, each of which
stores the x, y, and z coordinates of the nodes.
As discussed in Section 11.3 the waveform of the incident field should be shifted in time and
space to ensure that the leading edge of the waveform enters into the problem space after the
simulation has started. These shifts are indicated as t0 and l 0 , respectively. The temporal shift t0 is
determined in the subroutine initialize waveforms, which has been called in initialize sources -
and lumped elements before. Thus, t0 for a specific waveform is readily available. The spatial
shift, however, needs to be calculated. Eight corners determine the boundaries of the problem
space, and an incident plane wave will enter to the problem space from one of these corners. The
coordinates of these corners are stored in an array denoted as r0. The value of l 0 is calculated
by l 0 = min k · r0 , where
k is the propagation vector indicating the direction of propagation.
The components of the vector k are calculated based on (11.16) and are stored in the parameters
k vec x, k vec y, and k vec z. Then these parameters are used together with r0 to calculate l 0
and to store it in the parameter l 0.
Another term that determines the three-dimensional distribution of the waveform is k · r as
shown in (11.18). Here the vector r is the position vector. In the three-dimensional case this dot
product would yield three-dimensional arrays. Since all field components are located at different
positions, this dot product would yield a different three-dimensional array for each component.
Therefore, the dot product is performed separately for each field and is stored in the arrays
k dot r ex, k dot r ey, k dot r ez, k dot r hx, k dot r hy, and k dot r hz. Then the spatial
shift l 0 appearing in (11.18) is embedded in these arrays.
Finally, the waveform of the incident plane wave is acquired from the structure waveforms and
is stored in the structure incident plane wave. This waveform is used only for plotting purposes
after the FDTD calculation is completed. The distribution of the waveform and incident plane
wave has to be recalculated at every time step and stored in the three-dimensional incident field
arrays for use in the scattered field updating equations.
3 i f i n c i d e n t p l a n e w a v e . e n a b l e d == f a l s e
return ;
5 end
7 % C o e f f i e c i e n t s updating Ex
C e x e i c = ( 2 * ( 1 − e p s r x ) * e p s 0 −d t * s i g m a e x ) ...
9 . / ( 2 * e p s r x * e p s 0+d t * s i g m a e x ) ;
C e x e i p = −(2 * (1 − e p s r x ) * e p s 0+d t * s i g m a e x ) ...
11 . / ( 2 * e p s r x * e p s 0+d t * s i g m a e x ) ;
13 % C o e f f i e c i e n t s updating Ey
C e y e i c = ( 2 * ( 1 − e p s r y ) * e p s 0 −d t * s i g m a e y ) ...
15 . / ( 2 * e p s r y * e p s 0+d t * s i g m a e y ) ;
C e y e i p = −(2 * (1 − e p s r y ) * e p s 0+d t * s i g m a e y ) ...
17 . / ( 2 * e p s r y * e p s 0+d t * s i g m a e y ) ;
19 % C o e f f i e c i e n t s updating Ez
C e z e i c = ( 2 * ( 1 − e p s r z ) * e p s 0 −d t * s i g m a e z ) ...
21 . / ( 2 * e p s r z * e p s 0+d t * s i g m a e z ) ;
C e z e i p = −(2 * (1 − e p s r z ) * e p s 0+d t * s i g m a e z ) ...
23 . / ( 2 * e p s r z * e p s 0+d t * s i g m a e z ) ;
25 % C o e f f i e c i e n t s u p d a t i n g Hx
C h x h i c = ( 2 * ( 1 − m u r x ) * mu 0−d t * s i g m a m x ) . / ( 2 * m u r x * mu 0+d t * s i g m a m x ) ;
27 C h x h i p = −(2 * (1 − m u r x ) * mu 0+d t * s i g m a m x ) . / ( 2 * m u r x * mu 0+d t * s i g m a m x ) ;
29 % C o e f f i e c i e n t s u p d a t i n g Hy
C h y h i c = ( 2 * ( 1 − m u r y ) * mu 0−d t * s i g m a m y ) . / ( 2 * m u r y * mu 0+d t * s i g m a m y ) ;
31 C h y h i p = −(2 * (1 − m u r y ) * mu 0+d t * s i g m a m y ) . / ( 2 * m u r y * mu 0+d t * s i g m a m y ) ;
33 % C o e f f i e c i e n t s u p d a t i n g Hz
C h z h i c =(2 * (1 − m u r z ) * mu 0−d t * s i g m a m z ) . / ( 2 * m u r z * mu 0+d t * s i g m a m z ) ;
35 C h z h i p = −(2 * (1 − m u r z ) * mu 0+d t * s i g m a m z ) . / ( 2 * m u r z * mu 0+d t * s i g m a m z ) ;
field components change. Therefore, the values of the incident field components need to be
recalculated at every time step. A new subroutine named update incident fields is implemented
for this purpose and is provided in Listing 11.4. This subroutine is called in run fdtd time -
marching loop, in the time-marching loop, before calling update magnetic fields and therefore
before updating the magnetic field components. Since the waveform needs to be recalculated
at every time step, this subroutine is composed of several sections, each of which pertains to a
specific type of waveform. For instance, this implementation supports the Gaussian, derivative of
Gaussian, and cosine-modulated Gaussian waveforms. Thus, at every iteration only the section
pertaining to the type of the waveform of the incident plane wave are executed. At every time step
all the six incident electric and magnetic field arrays are recalculated. One should notice that the
electric and magnetic field components are calculated at time instants a half time step off from
each other since the magnetic field components are evaluated at half-integer time steps while the
electric field components are evaluated at integer time steps.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
tm = c u r r e n t t i m e + d t / 2 ;
7 te = current time + dt ;
9 % update i n c i d e n t f i e l d s f o r p r e v i o u s time s t e p
Hxip = Hxic ; Hyip = Hyic ; Hzip = Hzic ;
11 Exip = Exic ; Eyip = Eyic ; Ezip = Ezic ;
% i f waveform i s G a u s s i a n w a v e f o r m s
17 i f strcmp ( i n c i d e n t p l a n e w a v e . waveform type , ’ g a u s s i a n ’ )
t a u = w a v e f o r m s . g a u s s i a n ( wi ) . t a u ;
19 t 0 = w a v e f o r m s . g a u s s i a n ( wi ) . t 0 ;
E x i c = E x i 0 * exp ( − ( ( t e − t 0 − k d o t r e x ) / t a u ) . ˆ 2 ) ;
21 E y i c = E y i 0 * exp ( − ( ( t e − t 0 − k d o t r e y ) / t a u ) . ˆ 2 ) ;
E z i c = E z i 0 * exp ( − ( ( t e − t 0 − k d o t r e z ) / t a u ) . ˆ 2 ) ;
23 H x i c = H x i 0 * exp ( − ( ( tm − t 0 − k d o t r h x ) / t a u ) . ˆ 2 ) ;
H y i c = H y i 0 * exp ( − ( ( tm − t 0 − k d o t r h y ) / t a u ) . ˆ 2 ) ;
25 H z i c = H z i 0 * exp ( − ( ( tm − t 0 − k d o t r h z ) / t a u ) . ˆ 2 ) ;
end
27
% i f waveform i s d e r i v a t i v e o f G a u s s i a n
29 i f strcmp ( i n c i d e n t p l a n e w a v e . waveform type , ’ d e r i v a t i v e g a u s s i a n ’)
t a u = w a v e f o r m s . d e r i v a t i v e g a u s s i a n ( wi ) . t a u ;
31 t 0 = w a v e f o r m s . d e r i v a t i v e g a u s s i a n ( wi ) . t 0 ;
E x i c = E x i 0 * (− s q r t ( 2 * exp ( 1 ) ) / t a u ) * ( t e − t 0 − k d o t r e x ) ...
33 . * exp ( − ( ( t e − t 0 − k d o t r e x ) / t a u ) . ˆ 2 ) ;
E y i c = E y i 0 * (− s q r t ( 2 * exp ( 1 ) ) / t a u ) * ( t e − t 0 − k d o t r e y ) ...
35 . * exp ( − ( ( t e − t 0 − k d o t r e y ) / t a u ) . ˆ 2 ) ;
E z i c = E z i 0 * (− s q r t ( 2 * exp ( 1 ) ) / t a u ) * ( t e − t 0 − k d o t r e z ) ...
37 . * exp ( − ( ( t e − t 0 − k d o t r e z ) / t a u ) . ˆ 2 ) ;
H x i c = H x i 0 * (− s q r t ( 2 * exp ( 1 ) ) / t a u ) * ( tm − t 0 − k d o t r h x ) ...
39 . * exp ( − ( ( tm − t 0 − k d o t r h x ) / t a u ) . ˆ 2 ) ;
H y i c = H y i 0 * (− s q r t ( 2 * exp ( 1 ) ) / t a u ) * ( tm − t 0 − k d o t r h y ) ...
41 . * exp ( − ( ( tm − t 0 − k d o t r h y ) / t a u ) . ˆ 2 ) ;
H z i c = H z i 0 * (− s q r t ( 2 * exp ( 1 ) ) / t a u ) * ( tm − t 0 − k d o t r h z ) ...
43 . * exp ( − ( ( tm − t 0 − k d o t r h z ) / t a u ) . ˆ 2 ) ;
end
45
% i f waveform i s c o s i n e modulated G a u s s i a n
47 i f strcmp ( i n c i d e n t p l a n e w a v e . waveform type , . . .
’ cosine modulated gaussian ’ )
49 f = w a v e f o r m s . c o s i n e m o d u l a t e d g a u s s i a n ( wi ) . m o d u l a t i o n f r e q u e n c y ;
t a u = w a v e f o r m s . c o s i n e m o d u l a t e d g a u s s i a n ( wi ) . t a u ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
51 t 0 = waveforms . c o s i n e m o d u l a t e d g a u s s i a n ( wi ) . t 0 ;
E x i c = E x i 0 * cos ( 2 * pi * f * ( te − t 0 − k dot r ex ) ) . . .
53 . * exp ( − ( ( t e − t 0 − k d o t r e x ) / tau ) . ˆ 2 ) ;
E y i c = E y i 0 * cos ( 2 * pi * f * ( te − t 0 − k dot r ey ) ) . . .
55 . * exp ( − ( ( t e − t 0 − k d o t r e y ) / tau ) . ˆ 2 ) ;
E z i c = E z i 0 * cos ( 2 * pi * f * ( te − t 0 − k dot r ez ) ) . . .
57 . * exp ( − ( ( t e − t 0 − k d o t r e z ) / tau ) . ˆ 2 ) ;
H x i c = H x i 0 * c o s ( 2 * p i * f * ( tm − t 0 − k dot r hx ) ) . . .
59 . * exp ( − ( ( tm − t 0 − k d o t r h x ) / tau ) . ˆ 2 ) ;
H y i c = H y i 0 * c o s ( 2 * p i * f * ( tm − t 0 − k dot r hy ) ) . . .
61 . * exp ( − ( ( tm − t 0 − k d o t r h y ) / tau ) . ˆ 2 ) ;
H z i c = H y i 0 * c o s ( 2 * p i * f * ( tm − t 0 − k dot r hz ) ) . . .
63 . * exp ( − ( ( tm − t 0 − k d o t r h z ) / tau ) . ˆ 2 ) ;
end
After update incident fields is called in run fdtd time marching loop, the subroutine update -
magnetic fields is called in which the magnetic field components are updated for the current
time step. The implementation of update magnetic fields is modified as shown in Listing 11.5
to accommodate the scattered field formulation. Here the general updating equation is kept as
is; however, an additional section is added that will be executed if the mode of the simulation is
scattering. In this additional section the incident field arrays are multiplied by the corresponding
coefficients and are added to the magnetic field components, which in this case are assumed to
be scattered fields. Similarly, the implementation of update electric fields is modified as shown
in Listing 11.6 to accommodate the scattered field formulation for updating the scattered electric
field components.
14 if incident p l a n e w a v e . enabled
Hx = Hx + Chxhic . * Hxic + Chxhip . * Hxip ;
16 Hy = Hy + Chyhic . * Hyic + Chyhip . * Hyip ;
Hz = Hz + Chzhic . * Hzic + Chzhip . * Hzip ;
18 end
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
6 E x ( 1 : nx , 2 : ny , 2 : nz ) = C e x e ( 1 : nx , 2 : ny , 2 : nz ) . * E x ( 1 : nx , 2 : ny , 2 : nz ) . . .
+ C e x h z ( 1 : nx , 2 : ny , 2 : nz ) . * . . .
8 ( Hz ( 1 : nx , 2 : ny , 2 : nz )−Hz ( 1 : nx , 1 : ny −1 ,2: nz ) ) . . .
+ C e x h y ( 1 : nx , 2 : ny , 2 : nz ) . * . . .
10 ( Hy ( 1 : nx , 2 : ny , 2 : nz )−Hy ( 1 : nx , 2 : ny , 1 : nz − 1 ) ) ;
12 E y ( 2 : nx , 1 : ny , 2 : nz )= C e y e ( 2 : nx , 1 : ny , 2 : nz ) . * E y ( 2 : nx , 1 : ny , 2 : nz ) . . .
+ C e y h x ( 2 : nx , 1 : ny , 2 : nz ) . * ...
14 ( Hx ( 2 : nx , 1 : ny , 2 : nz )−Hx ( 2 : nx , 1 : ny , 1 : nz − 1 ) ) . . .
+ C e y h z ( 2 : nx , 1 : ny , 2 : nz ) . * ...
16 ( Hz ( 2 : nx , 1 : ny , 2 : nz )−Hz ( 1 : nx −1 ,1: ny , 2 : nz ) ) ;
18 E z ( 2 : nx , 2 : ny , 1 : nz )= C e z e ( 2 : nx , 2 : ny , 1 : nz ) . * E z ( 2 : nx , 2 : ny , 1 : nz ) . . .
+ C e z h y ( 2 : nx , 2 : ny , 1 : nz ) . * ...
20 ( Hy ( 2 : nx , 2 : ny , 1 : nz )−Hy ( 1 : nx −1 ,2: ny , 1 : nz ) ) . . .
+ C e z h x ( 2 : nx , 2 : ny , 1 : nz ) . * . . .
22 ( Hx ( 2 : nx , 2 : ny , 1 : nz )−Hx ( 2 : nx , 1 : ny −1 ,1: nz ) ) ;
24 if incident p l a n e w a v e . enabled
Ex = Ex + Cexeic .* Exic + Cexeip .* Exip ;
26 Ey = Ey + Ceyeic .* Eyic + Ceyeip .* Eyip ;
Ez = Ez + Cezeic .* Ezic + Cezeip .* Ezip ;
28 end
14 j = sqrt ( −1);
number of angles = 360;
16
% p a r a m e t e r s u s e d by p o l a r p l o t t i n g f u n c t i o n s
18 s t e p s i z e = 10; % i n c r e m e n t between t h e r i n g s i n t h e p o l a r g r i d
Nrings = 4; % number o f r i n g s i n t h e p o l a r g r i d
20 l i n e s t y l e 1 = ’ b− ’ ; % l i n e s t y l e f o r t h e t a component
l i n e s t y l e 2 = ’ r−− ’ ; % l i n e s t y l e f o r p h i component
22 s c a l e t y p e = ’ dB ’ ; % l i n e a r o r dB
24 i f i n c i d e n t p l a n e w a v e . e n a b l e d == f a l s e
p l o t t y p e = ’D ’ ;
26 else
p l o t t y p e = ’ RCS ’ ;
28 end
subroutine calculate incident plane wave power, which is shown in Listing 11.8, is implemented
to calculate the power of the incident plane wave at the desired frequency or frequencies based
on (11.22).
The actual calculation of RCS is performed in the subroutine calculate farfields per plane.
The last part of this subroutine is modified as shown in Listing 11.9. If the mode of the simulation
is scattering then RCS is calculated using (11.21); otherwise, the directivity is calculated.
In the previous sections we discussed scattered field algorithm and demonstrated its implementa-
tion using MATLAB programs. In this section we provide examples of scattering problems.
Einc
permittivity is 3, and relative permeability is 2. The definition of the problem space is shown in
Listing 11.11. The incident plane wave source is defined as shown in Listing 11.12. The waveform
of the plane wave is Gaussian. The output of the FDTD simulation is defined as far field at 1 GHz,
which indicates that the RCS will be calculated. Furthermore, the x component of the scattered
electric field at the origin is defined as the output as shown in Listing 11.13.
bricks = [ ] ;
4 spheres = [ ] ;
thin wires = [ ] ;
6
% define a sphere
8 spheres ( 1 ) . radius = 100 e −3;
spheres ( 1 ) . center x = 0;
10 spheres ( 1 ) . center y = 0;
spheres ( 1 ) . center z = 0;
12 spheres ( 1 ) . material type = 4;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
voltage sources = [ ] ;
4 current sources = [ ] ;
diodes = [ ] ;
6 resistors = [];
inductors = [ ] ;
8 capacitors = [ ] ;
incident plane wave = [ ] ;
10
% d e f i n e s o u r c e waveform t y p e s and p a r a m e t e r s
12 waveforms . g a u s s i a n ( 1 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 0 ;
waveforms . g a u s s i a n ( 2 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 15;
14
% Define i n c i d e n t p l a n e wave , a n g l e s a r e i n d e g r e e s
16 incident plane wave . E theta = 1;
incident plane wave . E phi = 0;
18 incident plane wave . theta incident = 0;
incident plane wave . phi incident = 0;
20 incident plane wave . waveform type = ’ gaussian ’ ;
incident plane wave . waveform index = 1;
% mode o f o p e r a t i o n
14 run simulation = true ;
show material mesh = true ;
16 show problem space = true ;
18 % f a r f i e l d c a l c u l a t i o n parameters
f a r f i e l d . f r e q u e n c i e s ( 1 ) = 1 . 0 e9 ;
20 f a r f i e l d . number of cells from outer boundary = 13;
22 % f r e q u e n c y domain p a r a m e t e r s
f r e q u e n c y d o m a i n . s t a r t = 20 e6 ;
24 f r e q u e n c y d o m a i n . end = 4 e9 ;
f r e q u e n c y d o m a i n . s t e p = 20 e6 ;
26
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
28 % d e f i n e sampled e l e c t r i c f i e l d s
% component : v e c t o r component í x í , í y í , í z í , o r m a g n i t u d e í m í
30 % d i s p l a y plot = true , in order to plot f i e l d during simulation
s a m p l e d e l e c t r i c f i e l d s ( 1 ) . x = 0;
32 s a m p l e d e l e c t r i c f i e l d s ( 1 ) . y = 0;
s a m p l e d e l e c t r i c f i e l d s ( 1 ) . z = 0;
34 s a m p l e d e l e c t r i c f i e l d s ( 1 ) . component = ’ x ’ ;
sampled electric fields (1). display plot = false ;
36
% define animation
38 % f i e l d t y p e s h a l l be ’ e ’ o r ’ h ’
% p l a n e c u t s h a l l be ’ xy ’ , yz , o r z x
40 % component s h a l l be ’ x ’ , ’ y ’ , ’ z ’ , o r ’m;
animation ( 1 ) . f i e l d t y p e = ’ e ’ ;
42 a n i m a t i o n ( 1 ) . component = ’m ’ ;
animation ( 1 ) . p l a n e c u t ( 1 ) . t y pe = ’ zx ’ ;
44 animation ( 1 ) . plane cut ( 1 ) . p o s i t i o n = 0;
animation ( 1 ) . enable = true ;
46 animation ( 1 ) . d i s p l a y g r i d = f a l s e ;
animation ( 1 ) . d i s p l a y o b j e c t s = true ;
The simulation is run for 2,000 time steps, and the sampled electric field at the origin and the
RCS plots are obtained. Figure 11.5 shows the sampled scattered electric field captured at the
origin and shows the waveform of the incident plane wave. Figures 11.6, 11.7, and 11.8 show
the RCS of the dielectric sphere in the xy, xz, and y z planes, respectively.
1.5
Eθ,inc
Eφ,inc
1 Ex,scat
(volt/meter)
0.5
−0.5
−1
0 2 4 6 8 10
time (ns)
Figure 11.5 Scattered electric field captured at the origin and the incident field waveform.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
↑y
90−10
120 60
−20 θ = 90o
xy plane
150 −30 30
−40
↑φ
x
180 0 →
210 330
240 300
dB 270 RCSθ, f=1 GHz
RCS , f=1 GHz
φ
↑z
θ 00 θ
← →
30 30
−10 φ = 0o
xz plane
60 −20 60
−30
x
90 90 →
120 120
150 150
dB 180 RCS , f=1 GHz
θ
↑z
θ 0 0 θ
← →
30 30
−10 φ = 90o
yz plane
60 −20 60
−30
y
90 90 →
120 1 20
1 50 150
dB 180 RCS , f=1 GHz
θ
To verify the accuracy of the calculated RCSs, the results are compared with the analytical
solution presented in [41]. The θ component of the RCS in the xz plane calculated by the FDTD
simulation is compared with the analytical solution in the Cartesian plot in Fig. 11.9, whereas
the φ component of the RCS in the y z plane calculated by the FDTD simulation is compared
with the analytical solution in the Cartesian plot in Fig. 11.10. Both comparisons show very good
agreement.
Listing 11.13 shows that an animation is also defined as an output. The scattered electric field is
thus captured on the xz plane displayed during the simulation. Figure 11.11 shows the snapshots
of the animation captured at time steps 120, 140, 160, and 180.
0
exact
FDTD
−5
−10
σθθ [dB]
−15
−20
−25
−30
0 20 40 60 80 100 120 140 160 180
o o
θ , [φ =0]
Figure 11.9 Calculated RCS θ at 1 GHz in the x z plane compared with the analytical solution.
0
exact
FDTD
−5
−10
σφθ [dB]
−15
−20
−25
−30
0 20 40 60 80 100 120 140 160 180
o o
θ , [φ =90]
Figure 11.10 Calculated RCS φ at 1 GHz in the yz plane compared with the analytical solution.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Figure 11.11 Scattered field due to a sphere captured on the x z plane cut.
propagates in a direction expressed by angles θ = 45◦ and φ = 30◦ . The waveform of the plane
wave is Gaussian. The far-field output is defined at 1 GHz as shown in Listing 11.16. Finally, a
sampled electric field is defined at the origin to observe whether the fields in the problem space
are sufficiently decayed.
After the FDTD time-marching loop is completed, the far-field patterns are obtained as shown
in Figs. 11.13, 11.14, and 11.15; for the RCS at 1 GHz in the xy, xz, and y z planes, respectively.
The same problem is simulated at 1 GHz using the MoM solver. Figure 11.16 shows the compared
RCSθ in the xz plane, whereas Figure 11.17 shows the compared RCSφ . The results show a good
agreement.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Figure 11.12 An FDTD problem space including a cube, and the surface mesh of the cube used by the MoM
solver.
3 bricks = [ ] ;
spheres = [ ] ;
5 thin wires = [ ] ;
7 % define d i e l e c t r i c
b r i c k s ( 1 ) . m i n x = −80e −3;
9 b r i c k s ( 1 ) . mi n y = −80e −3;
b r i c k s ( 1 ) . m i n z = −80e −3;
11 b r i c k s ( 1 ) . max x = 80 e −3;
b r i c k s ( 1 ) . max y = 80 e −3;
13 b r i c k s ( 1 ) . max z = 80 e −3;
bricks ( 1 ) . material type = 4;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
↑y
900
120 60
−10 θ = 90o
xy plane
150 −20 30
−30
↑φ
x
180 0 →
210 330
240 300
dB 270 RCSθ, f=1 GHz
RCSφ, f=1 GHz
voltage sources = [ ] ;
4 current sources = [ ] ;
diodes = [ ] ;
6 resistors = [];
inductors = [ ] ;
8 capacitors = [ ] ;
incident plane wave = [ ] ;
10
% d e f i n e s o u r c e waveform t y p e s and p a r a m e t e r s
12 waveforms . g a u s s i a n ( 1 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 0 ;
waveforms . g a u s s i a n ( 2 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 15;
14
% Define i n c i d e n t p l a n e wave , a n g l e s a r e i n d e g r e e s
16 incident plane wave . E theta = 1;
incident plane wave . E phi = 0;
18 incident plane wave . t h e t a i n c i d e n t = 45;
incident plane wave . phi incident = 30;
20 incident plane wave . waveform type = ’ gaussian ’ ;
incident plane wave . waveform index = 1;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
% mode o f o p e r a t i o n
14 run simulation = true ;
show material mesh = true ;
16 show problem space = true ;
18 % f a r f i e l d c a l c u l a t i o n parameters
f a r f i e l d . f r e q u e n c i e s ( 1 ) = 1 . 0 e9 ;
20 f a r f i e l d . number of cells from outer boundary = 13;
22 % f r e q u e n c y domain p a r a m e t e r s
f r e q u e n c y d o m a i n . s t a r t = 20 e6 ;
24 f r e q u e n c y d o m a i n . end = 4 e9 ;
f r e q u e n c y d o m a i n . s t e p = 20 e6 ;
26
28 % d e f i n e sampled e l e c t r i c f i e l d s
% component : v e c t o r component í x í , í y í , í z í , o r m a g n i t u d e í m í
30 % d i s p l a y plot = true , in order to plot f i e l d during simulation
s a m p l e d e l e c t r i c f i e l d s ( 1 ) . x = 0;
32 s a m p l e d e l e c t r i c f i e l d s ( 1 ) . y = 0;
s a m p l e d e l e c t r i c f i e l d s ( 1 ) . z = 0;
34 s a m p l e d e l e c t r i c f i e l d s ( 1 ) . component = ’ x ’ ;
sampled electric fields (1). display plot = false ;
The geometry of the problem in consideration is shown in Fig. 11.18. A dielectric slab, having
dielectric constant 4 and thickness 20 cm, penetrates into the CPML boundaries in xn, xp, yn, and
y p directions. The problem space is composed of cells having 0.5 cm size on a side. The source of
the simulation is an x-polarized incident field traveling in the positive z direction. Two sampled
electric fields are defined to capture the x component of the electric field at two points, each 5 cm
away from the slab—one below the slab and the other above the slab as illustrated in Fig. 11.18.
The definition of the problem space boundary conditions, incident field, the slab, and the sampled
electric fields are shown in Listings 11.17, 11.18, 11.19, and 11.20, respectively. Notice that the
CPML parameters has been modified for better performance.
In the previous sections scattered field formulation has been demonstrated for calculating the
scattered field when an incident field is used to excite the problem space. The sampled electric field
therefore is the one being captured while the simulation is running. The reflected field from the
slab is the scattered field, and the ratio of the reflected field to incident field is required to calculate
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
↑z
θ 0 0 θ
← →
30 30
−10 φ = 0o
xz plane
60 −20 60
−30
x
90 90 →
120 120
150 150
dB 180 RCSθ, f=1 GHz
RCSφ, f=1 GHz
−30
y
90 90 →
120 120
150 150
dB 180 RCSθ, f=1 GHz
RCS , f=1 GHz
φ
0
MoM
−2 FDTD
−4
−6
−8
RCS [dB]
−10
θ
−12
−14
−16
−18
−20
0 20 40 60 80 100 120 140 160 180
o o
θ , [φ =0]
Figure 11.16 Calculated RCS θ at 1 GHz in the x z plane compared with the MoM solution.
0
MoM
FDTD
−5
−10
RCS [dB]
−15
φ
−20
−25
−30
0 20 40 60 80 100 120 140 160 180
θo , [φo=90]
Figure 11.17 Calculated RCS φ at 1 GHz in the x z plane compared with the MoM solution.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Sample electric
field point 2
dielectric
slab
Sample electric
z field point 1
y
outer PEC boundaries
x
CPML inner boundaries
Einc
| Escat |
|| = , (11.23)
| Einc |
where is the reflection coefficient. Here the scattered field is the one sampled at a point below
the slab, and the incident field shall be sampled at the same point as well. Therefore, the section
of code shown in Listing 11.21 is added to the subroutine capture sampled electric fields to
sample the incident electric field as the time-marching loop proceeds.
The ratio of the transmitted field to incident field is required to calculate the transmission
coefficient, where the transmitted field is the total field that is the sum of the incident and scattered
fields. Then the transmission coefficient can be calculated using
where T is the transmission coefficient. Here the scattered field is the one sampled at a point
above the slab, and the incident field is sampled at the same point as well.
b o u n d a r y . t y p e x n = ’ cpml ’ ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
26 boundary . a i r b u f f e r n u m b e r o f c e l l s x n = 0 ;
b o u n d a r y . c p m l n u m b e r o f c e l l s x n = −8;
28
b o u n d a r y . t y p e x p = ’ cpml ’ ;
30 boundary . a i r b u f f e r n u m b e r o f c e l l s x p = 0 ;
b o u n d a r y . c p m l n u m b e r o f c e l l s x p = −8;
32
b o u n d a r y . t y p e y n = ’ cpml ’ ;
34 boundary . a i r b u f f e r n u m b e r o f c e l l s y n = 0 ;
b o u n d a r y . c p m l n u m b e r o f c e l l s y n = −8;
36
b o u n d a r y . t y p e y p = ’ cpml ’ ;
38 boundary . a i r b u f f e r n u m b e r o f c e l l s y p = 0 ;
b o u n d a r y . c p m l n u m b e r o f c e l l s y p = −8;
40
b o u n d a r y . t y p e z n = ’ cpml ’ ;
42 boundary . a i r b u f f e r n u m b e r o f c e l l s z n = 10;
boundary . c p m l n u m b e r o f c e l l s z n = 8 ;
44
b o u n d a r y . t y p e z p = ’ cpml ’ ;
46 boundary . a i r b u f f e r n u m b e r o f c e l l s z p = 10;
boundary . c p m l n u m b e r o f c e l l s z p = 8 ;
48
14 % Define i n c i d e n t p l a n e wave , a n g l e s a r e i n d e g r e e s
incident plane wave . E theta = 1;
16 incident plane wave . E phi = 0;
incident plane wave . theta incident = 0;
18 incident plane wave . phi incident = 0;
incident plane wave . waveform type = ’ d e r i v a t i v e g a u s s i a n ’ ;
20 incident plane wave . waveform index = 1;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
23 % d e f i n e sampled e l e c t r i c f i e l d s
% component : v e c t o r component í x í , í y í , í z í , o r m a g n i t u d e í m í
25 % d i s p l a y plot = true , in order to plot f i e l d during simulation
s a m p l e d e l e c t r i c f i e l d s ( 1 ) . x = 0;
27 s a m p l e d e l e c t r i c f i e l d s ( 1 ) . y = 0;
s a m p l e d e l e c t r i c f i e l d s ( 1 ) . z = −0.025;
29 s a m p l e d e l e c t r i c f i e l d s ( 1 ) . component = ’ x ’ ;
sampled electric fields (1). display plot = false ;
31
31 sw i t ch ( s a m p l e d e l e c t r i c f i e l d s ( i n d ) . component )
case ’ x ’
33 s a m p l e d v a l u e = 0 . 5 * sum ( E x i c ( i s −1: i s , j s , k s ) ) ;
case ’ y ’
35 s a m p l e d v a l u e = 0 . 5 * sum ( E y i c ( i s , j s −1: j s , k s ) ) ;
case ’ z ’
37 s a m p l e d v a l u e = 0 . 5 * sum ( E z i c ( i s , j s , ks −1: k s ) ) ;
c a s e ’m ’
39 s v x = 0 . 5 * sum ( E x i c ( i s −1: i s , j s , k s ) ) ;
s v y = 0 . 5 * sum ( E y i c ( i s , j s −1: j s , k s ) ) ;
41 s v z = 0 . 5 * sum ( E z i c ( i s , j s , ks −1: k s ) ) ;
sampled value = sqrt ( svx ˆ2 + svy ˆ2 + svz ˆ 2 ) ;
43 end
s a m p l e d e l e c t r i c f i e l d s ( ind ) . i n c i d e n t f i e l d v a l u e ( time step ) . . .
45 = sampled value ;
end
47 end
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
0.8
0.6
0.4
|Γ| FDTD
|T| FDTD
0.2
|Γ| exact
|T| exact
0
0 0.2 0.4 0.6 0.8 1
frequency (GHz)
solution is obtained using the program published in [43]. A very good agreement can be observed
between the simulated results and exact solution up to 1 GHz.
11.6 EXERCISES
11.1 Consider the problem demonstrated in Section 11.5.1, where the RCS of a dielectric
sphere is calculated due to an incident field traveling in the positive z direction. In the
given example the direction of incidence is defined as θ = 0◦ and φ = 0◦ . Change the
incident angle such that θ = 45◦ and φ = 0◦ , run the simulation, and obtain the RCS at 1
GHz. Examine the RCS plots, and verify that the RCS in the xz plane is the same as the
one shown in Fig. 11.7, except that it is rotated by 45◦ about the y axis.
11.2 Consider the scattering problem constructed for Exercise 11.1, where the RCS of a di-
electric sphere is calculated due to an incident field. The RCS calculations are based on
the scattered fields; the fictitious electric and magnetic current densities used for NF–FF
transformation are calculated using the scattered field electric and magnetic fields. The
total field in the problem space is the sum of the incident field and the scattered field.
Modify the program such that the RCS calculations are performed based on the total fields
rather than on the scattered fields. It is necessary to modify the code of the subroutine
calculate JandM. Run the simulation and obtain the RCS of the sphere. Verify that the
RCS data are the same as the ones obtained from Exercise 11.1. Notice that the incident
field does not contribute to far-field scattering at all.
11.3 Consider the dielectric slab problem demonstrated in Section 11.5.3. You can perform the
reflection and transmission coefficient calculation for stacked slabs composed of multiple
layers with different dielectric constants. For instance, create two slabs in the problem
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Exercises 367
space, each 10 cm thick. Then set the dielectric constant of the bottom slab as 4 and the
dielectric constant of the top slab as 2. Run the simulation, and then calculate the reflection
and transmission coefficients. Compare your result with the exact solution of the same
problem. For the exact solution you can refer to [43]. As an alternative, you can construct
a one-dimensional FDTD code similar to the one presented in Chapter 1 based on the
scattered field formulation to solve the same problem.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
12
Graphics Processing Unit
Acceleration of Finite-Difference
Time-Domain
Since the dawn of the computing age, research has relied on the power of the central processing
unit (CPU) to perform the variety of computational tasks needed. Over the years great progress has
been made in harnessing the power of the CPU by introducing faster clock speeds, larger caches,
faster memory, multiple processors, and even multiple cores in a single chip. This, however, has
also been accompanied by users ever expanding needs: from browsing the Internet to watching
videos and playing games. Due to these needs of the general computer user, the instruction set
of the average commercial processor has expanded well past 300 separate instructions in addition
to the core instructions of the processor. The CPU has been forced to be a jack-of-all-trades
for computing tasks, allowing it to do a great number of tasks but not specializing in any
particular area.
Conversely, the graphics processing unit (GPU) is designed to be very narrow in nature in
that it only needs to perform relatively few operations. The video card has been designed with
only one purpose: to process instructions and data necessary to provide graphics to the user.
Over the past few years, advancements in the design of GPUs has been occurring at a much
greater pace than with CPUs due to the narrow nature in which it was intended to be used. The
current generational rate for graphics processors has been on the order of 12 months, whereas
with CPUs it has been 18 months. This has led to the development of very powerful processing
units for computer graphics. As of the time of writing, current-generation GPUs are running at
approximately 600 MHz with a 384-bit data bus and memory bandwidth approaching 86 GB/sec.
While GPU clock speed seems slow compared with modern dual-core Pentium 4 CPUs, GPUs
are very specialized processors that incorporate many simultaneous instruction pipelines coupled
with a memory bandwidth an order of magnitude faster than modern system memory, as seen in
Table 12.1. In fact, the number of transistors in the latest GPUs almost match the number used in
a quad-core CPU. This leads to a GPUs ability to perform the specialized instructions for which
it was designed an order of magnitude or faster than just using a CPU, as seen in Fig. 12.1. While
the majority of silicon in CPUs is dedicated to performing noncomputational tasks like branch
prediction, out-of-order-execution, and cache operations, the majority of transistors on the GPU
is dedicated to its computational tasks. It must be noted that the GPU was designed specifically for
rendering graphics, not for doing computational electromagnetics. Luckily, the different processes
used in rendering graphics are analogous to many generic vector math operations. Here we look
369
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
at how to relate the various functions available in the graphics card to various computational
electromagnetic applications.
Solvers for electromagnetic simulations based on finite-difference time-domain (FDTD) have
been around for many years; however, the recent advances in computer technology are what
have made this method widely used. As computers become more powerful and systems with
larger memory are introduced, applications for FDTD grow as well. FDTD is increasingly used
to simulate larger and larger problems, which require more memory and faster processing to
complete the simulation in reasonable amounts of time. Even with current-generation computers,
the FDTD method is still limited in speed for practical simulations to be performed. Most
of the research on the FDTD method has been regarding introducing new formulations for
600
400
GFlops
300
200
100
0
2003 2004 2005 2006 2007
Year
solving problems and more efficient absorbing boundary conditions (ABCs). In the past few years
researchers have begun to explore different ways to implement FDTD solvers in alternative
methods to gain increases in speed. Work has been done recently in hardware-based solvers using
programmable gate arrays to essentially create chips specifically designed to solve FDTD. This
method, however, can be quite complex in its creation. As another alternative, graphics processors
have been shown to offer orders-of-magnitude speed increases in simple vector operations. In
the application of GPUs to solving FDTD operations, much detailed programming knowledge
has been required previously to implement the operations in the graphics card [44,45,46]. To
program a GPU to perform mathematical operations, the shader units inside each GPU must be
programmed. Sample FDTD applications on GPUs have required the programmer to understand
vast details about hardware functions in the graphics card as well as to learn custom register-level
programming languages for programming the shader units in these cards.
Even in the general use of graphics cards for scientific applications, these barriers have prevented
a wide adoption of these techniques since it requires a steep learning curve. Although most
programmers and engineers are adept at high-level programming languages such as MATLAB, C,
and FORTRAN, learning the intricacies of specialized low-level hardware languages can be quite
a daunting challenge for them. Currently several languages exist to allow GPU programming:
CUDA from nVidia, CTM from ATI, and an independent language called Brook [47]. Each
language offers its own advantages and disadvantages, mainly in its implementation. CUDA and
CTM are both highly tied into the hardware from their respective vendors, so a program written in
CUDA could only be run on certain nVidia boards, and the same goes for CTM. However, Brook
is not tied to any particular vendor and can operate on any compatible graphics card. Brook was
introduced for general programming environments as a subset of the C programming language.
This subset negates the need for detailed low-level programming knowledge by introducing
a few, relatively simple commands in the C language. By using these new commands in the
general high-level languages, Brook can then automatically generate the low-level code for the
programmer without any knowledge of the hardware systems of the target video card while
maintaining over 90% of the speed of the hand-coded low-level code. Therefore, instead of
having to manually program the shader units of the video cards, programmers can simply create a
standard C program with the added commands and have the compiler generate the necessary code
for them.
Video cards are developed with a single goal: to process and display images on the computer
screen. This may vary from a simple display of text for a user to complex three-dimensional
processing for the newest computer games. The processes the video card provides for rendering
three-dimensional objects can be utilized for performing computational electromagnetics (CEM)
applications with a significant speed-up factor.
In the realm of graphics processing, two different types of data are operated upon: geometry
and texture maps. Geometry data usually relate the three-dimensional shapes (vertices) of various
objects to the GPU. Texture maps, on the other hand, are two-dimensional matrices that relate
surface characteristics of the object to the GPU (e.g., color, reflectivity, roughness). Geometry
objects may be composed of several texture maps combined (e.g., the ball may be red, highly
reflective, bumpy). To apply various texture maps to the geometries in many different ways, the
GPU must be able to perform a variety of arithmetic functions on the texture maps. For example,
it may need to add, subtract, multiply, or divide across the texture maps, which is performed
simply by using vector math on these textures. Because the graphics cards are designed to display
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Streaming Non-streaming
high-quality graphics, the processing accompanying this must be able to provide high computa-
tional rates among many different data sets. This leads to a high order of parallelism inside the
GPU to process all the different objects that might be used, for example, in a game.
This math among texture maps occurs mainly in a section of the GPU called the fragment
processor, or pixel shader. In modern cards there are 4 to 64 of these fragment processors in par-
allel, depending on the video card type. Each one of these fragment processors currently has 4
or 5 subprocessors and is fully programmable and has separate and dedicated connections into
the main GPU cache. The purpose of the fragment processor in our case is to apply the math-
ematics across the texture maps to create a generalized vector processor. In the GPU many
fragment processors are running in parallel; each fragment processor usually runs the exact same
program as the others, with each operating on different points. Since there are many fragment
processors it is important for the cache to operate as efficiently as possible; otherwise, a fetch
stall will occur. A fetch stall happens when the cache does not contain the data necessary for
the operation and the fragment processor then stalls until the cache has been updated with the
necessary information. Mathematical operations with sequential elements (e.g., simple vector
addition) perform the fastest, as the methodology to retrieve the sequential elements of the pro-
gram is fairly straightforward. This is the basis of streaming processes that GPUs use. The GPU
is designed such that data are streamed into the separate processors where the operations are
performed and streamed back out to the memory. Operations such as vector or matrix multi-
plication suffer a larger performance penalty as the necessary matrix elements for the operation
are much more random in nature. This randomness causes the cache to replenish at a much
slower rate and therefore provides a greater chance of program stalls; this difference is shown
in Fig. 12.2.
For the majority of texture processes, the math involves only operations across the same
element of the various matrices. In this light, the shaders (the parts of the GPU that perform
vector operations on texture maps) operate on data that are streamed into them. In other words,
since the elements in the texture maps are only used once and in the same order across all maps,
the GPU can stream the entire matrix from memory instead of having to randomly access the
individual elements. When data are accessed in this sequential manner, as opposed to randomly
accessing elements, data can be processed at a maximal rate. As the number of random accesses
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
that must be performed is increased, the larger a performance hit will occur. For example, in a
Nvidia GeForce 8800 GTX, sequential elements can be read in at upward of 60 GB/sec, whereas
totally random elements can only be read in at 16 GB/sec. While cache speeds on most modern
cards are quite a bit faster than the cache speeds of their CPU counterparts, most matrices will
not fit entirely inside the cache.
Texture maps inside the GPU are natively two-dimensional structures, which follows logically
since monitors are only capable of displaying two-dimensional images. While different video cards
may have varied limits on the size of the texture maps, currently the limits for the latest cards are on
the order of 8192×8192 (about 67 million elements). Because the matrices are two-dimensional,
problems containing three or more dimensions require a translation procedure to be performed
for these matrices to be stored inside the video card memory.
Before any discussion of FDTD programming implementations on GPUs, several terms need
to be introduced. These terms deal with the programming of general applications inside a video
card and should be understood before attempting any program.
1. Streams: Streams are how the matrices are fed into the GPU for processing. By default a
stream is simply sequential elements of a matrix or array that are “fed” into the processor.
If in processing, elements of a matrix are used more than once or in a random order, this is
reflected in the stream being of longer length or taking longer to stream.
2. iters: iters are the boundaries of the streams that are operated upon. For example, in a certain
application we might wish to perform an operation only on interior elements of the matrix,
so the iter would be defined as the interior limits of that stream (e.g., if the stream went
from (0)→(X) the interior iter would be (1)→(X-1).
3. Kernels: Kernels are the custom functions implemented inside the GPU that perform oper-
ations on the streams. These are usually cross-compiled into a shader language (depending
on the video card) to implement the function in the most efficient possible way.
It should be noted that the fragment processors programmed with the kernel are only capable of
straight mathematical operations. Logical- and program-flow-related operators (e.g., if/then/else,
bitwise operators) cannot be implemented inside a kernel.
To maximize efficiency of programs being run on the GPU it is necessary to understand how
these fragment processors were designed to operate. As was stated, each fragment processor has
four or five subproccesing units in them. The current NVidia chips have four identical full math
subprocessors per group, and the ATI chips have four subprocessors that can do simple math and
one subprocessor that can do advanced math per group. The reason for this grouping goes back
to the primary use of the GPU: to display images on the screen. When doing the calculations
for displaying images, the textures contain four pieces of data relating to how it will be applied.
Textures contain red, blue, green, and alpha (or transparency) information. In this model, having
the subprocessor grouped in four (or five) makes sense since each texture has four separate
parts. Care needs to be taken when formulating problems to achieve maximum utilization of the
processing power. For example, if two arrays are simply added to each other, only one subprocessor
per group is used as each data point only has one value. Conversly, if we consider doing equations
of electromagnetic fields we can utilize the nature of the field components (E and H having three
components x, y, and z) to better utilize more of the processing power of the GPU.
languages such as C to facilitate the implementation of programs in the video card. Brook
is a free and open source system developed by Stanford University Graphics Lab (http://
graphics.stanford.edu/projects/brookgpu/), and current versions may be found on the open
source repository Sourceforge.net under the title Brook (http://sourceforge.net/-projects/
brook/). As Brook is not tied to any particular vendor, programs developed on it may be used on
many common graphics cards that are OpenGL and DirectX compliant. Using Brook the general
program flow for a GPU implementation varies only slightly from a standard C program as can
be seen in Table 12.2.
The Brook package includes installation instructions and details on where to locate the necessary
dependencies required to compile GPU programs necessary on PC-compatible systems. Brook
does require a few third-party tools to ensure interoperability among various graphics cards,
systems, and DirectX calls. While it is possible to integrate Brook into programming systems
such as Microsoft Visual Studio, the default installation and compilation of the system uses the
PC version of the GNU programming tools Cygwin (http://www.cygwin.com/). Cygwin acts just
as a UNIX shell would and provides the necessary programming tools to compile Brook and its
programs. The installation instructions in the Brook package also details what items in Cygwin are
needed beyond the default installation. Other items that are needed to include shader compilers
from nvidia, the free Microsoft C++ compiler (if Visual Studio is not installed), and the Microsoft
DirectX SDK. The details of each of these items are in the Brook documentation. The Brook
package also includes a wide variety of sample programs that can be examined to see how various
problems from fast Fourier transforms to simple matrix solvers can be implemented on the GPU.
Installation instructions and the Brook source code can be downloaded from their repository at
http://www.sourceforge.net/projects/brook, where all Brook files and additional examples can also
be found.
Compiling programs under Brook is very simple once it has been installed. Cygwin is a com-
mand line shell similar to what is found on most UNIX systems. Setting up new programs to
compile is fairly simple if the Makefile in each of the sample directories is examined. The Makefile
tells the Cygwin shell in what directories to look for source code and what the names of the source
code files are. A replacement folder for the “prog” directory in the Brook folder is included with
the sample codes to allow easier compilation. Once this “prog” folder has been replaced, all that
is necessary is to use the “make” command in the Brook directory to compile the provided sample
two-dimensional program. Brook compiles the program and places the executable in the “bin”
directory. Lastly, Brook programs require an environment variable to use DirectX, OpenGL,
or a GPU emulation to run the program. To use DirectX set the environment variable named
BRT RUNTIME to d x9 and for OpenGL use ogl.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
7 f l o a t a <100>;
f l o a t b<100>;
9 f l o a t c <100>;
i t e r f l o a t i t <1,98>
11 test ( a ,b , it , c ) ;
Brook operates by taking a source file written in a C style format with Brook extensions and
then replacing the Brook code with C and shader code. This is then compiled using a standard C
compiler. Thus, instead of having to write complicated shader and interfacing code, Brook uses
simple extensions to create this code automatically. Listing 12.1 shows a simple Brook code for
the addition of two matrices. This fragment of code is just to demonstrate the use of the different
parameters and cannot be compiled as such.
The code in Listing 12.1 adds each element of arrays “a” and “b”, bounded by the limits of
the iter “it”, and stores them in array “c”. In other words, this example performs the function
c[i]=a[i]+b[i] for elements 1 through 98 inside the GPU memory.
As can be seen in Listing 12.1, the kernel does not have any direct output back to the program.
Unlike a standard C function, the kernel operates on the streams and alters them directly; thereby,
it does not require the output to be sent back to the calling statement. In this particular kernel,
the “out” statement associated with the C stream identifies this particular stream as one that will
be modified by the kernel. The empty brackets “[ ]” after the declaration of “a” and “b” identify
these variables as incoming one-dimensional streams in which any element may be accessed by
the kernel. The “iter” statement identifies the variable “it” as containing the current location of
the output stream being operated on. The “<>” after the streams “it” and “c” identify the single
values at the location specified by the “iter”.
number of iterations, the size of the domain in x, and the size of the domain in y. In this example
the code was compiled as TM2D.exe and could be called from the command prompt as
C:\TM2D-Example\TM2D.exe 1000 100 150
This instructs the code to run 1,000 iterations with the domain extending 100 cells in x and
150 cells in y. It should be noted that domain size includes the default 10 cells on each edge for the
perfectly matched layer (PML) boundary. This sample code includes the convolutional perfectly
matched layer (CPML) boundary [23,48], a point source in the approximate center of the domain,
and a dielectric scattering object 10 cells forward in the x direction from the center extending
10 cells in x and 16 cells in y. The code also exports four sets of data when the run is complete.
Port.txt is the Ez field component 10 cells back from the point source for every iteration the code
is run. Ezdata.txt, Hxdata.txt, and Hydata.txt export the final field states for each of the three fields
calculated in the code. It is possible to run the simulation for several different number of iterations
and to examine the field data, for example, after 100, 200, 500, and 1,000 iterations.
Once all the streams are copied into the GPU, the program can then iterate over time by calling
the kernels just as one would normally call a function or subroutine. Each of the kernels takes
the streams and the iter as the inputs and passes back the resulting updated field. The derivitives
are calculated by the use of an offset term such as float2 t0 = float2(0.0f, 1.0f). When this term is
added to the iter in the calculation such as in (Ez[it]–Ez[it+t0]), it provides the proper function
derivative. The kernel is applied to every element of the stream inside the boundaries of the iter.
The variable it contains the current location (in this case it will be a float2 type to specify the x and
y location such as Ez[54][60]). By adding another constant that is also a float2 type, it is possible
to specify the location offset for the calculations. In the given example, the calculation takes the
form of (Ez[X][Y]–Ez[X][Y+1]).
Once the streams have been iterated over the appropriate number of time steps, the streams
can be passed back to the C arrays using commands like streamWrite(Ez, outputEz). The C arrays
can then be outputted to data files for use elsewhere.
In part 1 of the sample two-dimensional transverse magnetic (TM) FDTD code the custom
GPU kernels are defined for the field computations needed to be performed. For this sample three
kernels are defined: one to do the calculations on the H fields, one for the E fields, and one to
facilitate the extraction of field points for postprocessing. The first part of each kernel defines the
variables that is passed to it and also the variables that are sent out of it. The dimensionality of
each variable is defined for the inputs (a single set of brackets to signify a one-dimensional array,
or a double set of brackets to signify two dimensions) and the output dimensionality is assumed.
In the two sections of the code, first the CPML portions are calculated and updated, and then the
actual field components with the CPML are calculated and updated. The last kernel is used to
copy one stream to another and to extract field points to be saved and examined later.
Part 2 starts the initialization section of the main C code. Like any other C code in this section
all the variables and constants needed for the program are defined. The constants are given their
values, and variables are cleared for use later. In this code all of the array structures are dynamically
allocated so that the domain size can be defined at runtime through command line arguments.
The values of many of the constants and variables are also written to a text file so that they may
be examined later.
Part 3 sets the initialization of all arrays to the initial (free space) values, including all the
CPML coefficients as well. In addition, a perfect electric conductor (PEC) boundary is defined
along the outer edges of the domain. It should be noted that all of the arrays in the C code are
one-dimensional regardless of their implied dimensionality. This has been done due to the way
the GPU portions transfer data back and forth with the CPU section. Even in a three-dimensional
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
code it is suggested to still use one-dimensional arrays in the CPU portion to ensure proper
transfer to the GPU.
Part 4 details the initialization of the CPML coefficients so that the absorbing boundaries
may be applied. Each of these arrays are one-dimensional and span the length of either x or y
domains depending on their use. The assignments in this section are only applied within the
CPML boundaries of the domain. Finally, the source point for this sample code is assigned to the
approximate center of the domain.
Part 5 starts the initialization of the GPU section of the code. In this section all of the GPU
streams are defined to their proper sizes, and the arrays are passed from the CPU to the GPU. It
should be noted that while the sizes of the two-dimensional streams are defined in the order of
variable < ys i ze, xs i ze >, they are accessed in the kernel in the reverse order variable[x][y]. For
all the variables that are updated throughout the iterations there are two copies of each, because
certain video cards cannot update streams that are also passed as inputs. So duplicate streams are
created to "ping-pong" between the current and previous sets during the iterations.
Part 6 is the code that will iterate the fields over the requested number of time steps. Here it
can be seen how the two sets of streams are used to update each other in the various time steps.
For example, in the first time step the old fields are defined as Hx and Hy and the updated values
are placed in o Hx and o Hy. The copy kernel is also called to extract the value of a single Ez
point, which is then copied back to the CPU and written to a data file. The “.domain” operator
is used when calling the copy kernel to specify which point in the Ez data stream will be copied.
This operator requires two commands to tell it where to start and stop. In this example they are
the same values to indicate only a single value is needed. At the end the value of the input pulse is
written to a file for later examination.
The last section transfers the final values of the fields back to the CPU and then writes them to
files. This example shows how to transfer the values out of the GPU for processing at a later time.
It is also possible to transfer single points out of the GPU at each time step if required. Consult
the Brook documentation for more examples and deeper explanation of all the various functions
that are used.
Figures 12.3 and 12.4 show example data from the compiled and executed program showing Ez
values at certain time steps for a 200×200 domain as well as the value of a single Ez observation
point across 1,000 time steps. Figure 12.5 shows the speedup factors over an equivalent CPU
based code for a 1000×1000 domain for several different graphics cards. Listings 12.2 to 12.8 are
provided for the reader as one Brook program titled “tm2d.br.”
Efficient implementations of basic FDTD techniques on GPUs have been recently documented;
however, including absorbing boundary conditions can present a few challenges. Certain common
boundary types such as Mur [49] or Liao [50] may not have easy implementation due to the
nature of the time and spatial dependency of their updating equations, especially for higher-
order absorbing boundaries. Furthermore, this problem becomes more complicated for three-
dimensional problems where the three-dimensional to two-dimensional translation is necessary
for storage inside the GPU card, as seen in Fig. 12.6. Because of this translation, the various x,
y, and z boundaries inside the domain are scattered among the various tiles. Thus, applying the
boundary conditions on the individual boundaries becomes very complicated.
Figure 12.6 shows an example of how a three-dimensional domain can be translated into a
two-dimensional structure. The various levels along the z axis are sliced and tiled along the y
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Figure 12.3 Sample TM2D with CPML E z data at various time steps.
20
10
0
Ez Value
-10
-20
-30
-40
0 100 200 300 400 500 600 700 800 900 1000
time steps
One of the major advantages of applying the FDTD method on GPU devices is the speed in
which simulations can be executed. On modern graphics cards many simple devices such as patch
antennas and microstrip filters similar to those in [14] can be solved in a matter of seconds. In the
course of designing or teaching of many common devices, analytic methods can lead to a good
approximation for the final design. However, until the design has been simulated, the final results
can not be totally known. For example, while teaching these devices one might assign the design
of these sample cases as homework to achieve the desired result since the demonstration of it in
class can be prohibitive due to time constraints. Since the use of GPU can reduce the FDTD
simulation time to acceptable levels, one can now use this method inside the classroom given the
proper tools.
The first example of this application of the GPU-based FDTD method is the simulation of
the basic rectangular patch antenna. For this example, the configuration of this antenna is from
[14]. This is a simple offset fed patch antenna on a known dielectric substrate of r = 2.2 with a
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
70
DirectX 9.0c-ATI x1900
DirectX 9.0c-ATI x800
60 DirectX 9.0c-ATI 9550
50
speedup factor
40
30
20
10
0
0 500 1000 1500 2000 2500 3000 3500 4000
Iterations
{
13 f l o a t 2 t0 = f l o a t 2 ( 0 . 0 f , 1.0 f ) ;
f l o a t 2 t1 = f l o a t 2 ( 1 . 0 f , 0.0 f ) ;
15
f l o a t pxy , p y x ;
17
p x y = ( Bhy [ i t . y ] * p s i H x y [ i t ] ) + ( Chy [ i t . y ] * ( E z [ i t +t 0 ]− E z [ i t ] ) ) ;
19 p y x = ( Bhx [ i t . x ] * p s i H y x [ i t ] ) + ( Chx [ i t . x ] * ( E z [ i t +t 1 ]− E z [ i t ] ) ) ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
21 o p s i H x y =p x y ;
o p s i H y x =p y x ;
23
29 }
31
/ / GPU F u n c t i o n F o r E F i e l d s
33 k e r n e l void p r o c e s s f i e l d E z ( f l o a t Ez [ ] [ ] , f l o a t Ceze [ ] [ ] ,
f l o a t C e z h [ ] [ ] , f l o a t Hx [ ] [ ] , f l o a t Hy [ ] [ ] ,
35 f l o a t C s [ ] [ ] , f l o a t Kex [ ] , f l o a t Key [ ] ,
f l o a t Bex [ ] , f l o a t Bey [ ] ,
37 f l o a t Cex [ ] , f l o a t Cey [ ] ,
float psiEzx [ ] [ ] , float psiEzy [ ] [ ] ,
39 f l o a t dx , f l o a t dy ,
f l o a t g a u s s , i t e r f l o a t 2 i t <>,
41 o u t f l o a t o E z <>, o u t f l o a t o p s i E z x <>,
o u t f l o a t o p s i E z y <> )
43
{
45 f l o a t 2 t 0 = f l o a t 2 ( 0 . 0 f , −1.0 f ) ;
f l o a t 2 t1 = f l o a t 2 ( −1.0 f , 0 . 0 f ) ;
47
f l o a t pzx , p z y ;
49
p z x = ( Bex [ i t . x ] * p s i E z x [ i t ] ) + ( C e x [ i t . x ] * ( Hy [ i t ]−Hy [ i t +t 1 ] ) ) ;
51 p z y = ( Bey [ i t . y ] * p s i E z y [ i t ] ) + ( C e y [ i t . y ] * ( Hx [ i t ]−Hx [ i t +t 0 ] ) ) ;
53 o p s i E z x =p z x ;
o p s i E z y =p z y ;
55
o Ez = ( Ceze [ i t ] * Ez [ i t ] ) + ( Kex [ i t . x ] * ( C e z h [ i t ] / dx ) *
57 ( Hy [ i t ]−Hy [ i t +t 1 ] ) ) + ( Key [ i t . y ] * ( C e z h [ i t ] / dy ) *
( Hx [ i t ]−Hx [ i t +t 0 ] ) ) − ( Cs [ i t ]* gauss ) +
59 ( Cezh [ i t ] * pzx ) + ( Cezh [ i t ] * pzy ) ;
61 }
63
/ / Copy K e r n e l To E x t r a c t S i n g l e P o i n t s From a S t r e a m
65 k e r n e l v o i d Copy ( f l o a t i n p u t <>, o u t f l o a t o u t p u t <> )
67 {
output = input ;
69 }
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
// I n i t i a l i z e Variables
4 i n t i , j , N , nx , ny , x s i z e , y s i z e , i n s i z e x , i n s i z e y ;
i n t iPML , kappa , m;
6 f l o a t s i g m a x , s i g m a y , amax ;
f l o a t s i g 1 , s i g 2 , a1 , a2 , k1 , k2 , i i ;
8 f l o a t eps0 , mu0 , c , pi , dx , dy , dx2 , dy2 , d f a c t o r ;
f l o a t dt , Nc , tau , t0 , fmax , c e ;
10 f l o a t * t =NULL ;
f l o a t * g a u s s=NULL ;
12 f l o a t * o u t p u t P o r t =NULL ;
14 float * aHx=NULL ;
float * aHy=NULL ;
16 float * a E z=NULL ;
float * a C e z e=NULL ;
18 float * aChxh=NULL ;
float * aChyh=NULL ;
20 float * a C e z h=NULL ;
float * a C h x e=NULL ;
22 float * a C h y e=NULL ;
float * a C s=NULL ;
24
f l o a t * o u t p u t E z = NULL ;
26 f l o a t * o u t p u t H x = NULL ;
f l o a t * o u t p u t H y = NULL ;
28
float * aKex=NULL ;
30 float * aKey=NULL ;
float * aKhx=NULL ;
32 float * aKhy=NULL ;
34 float * a b e x=NULL ;
float * abey=NULL ;
36 float * a c e x=NULL ;
float * a c e y=NULL ;
38
float * abhx=NULL ;
40 float * abhy=NULL ;
float * a c h x=NULL ;
42 float * a c h y=NULL ;
44 f l o a t * a p s i =NULL ;
46
FILE * pFile ;
48 FILE * pFile2 ;
FILE * pFile3 ;
50
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
/ / Define Constants
52 pi =3.14159265;
c = 2 . 9 9 8 e8 ;
54
/ / Br oken Down b e c a u s e o f f l o a t i n g p o i n t
56 / / problems with c e r t a i n c o m p l i e r s
eps0 =8.854;
58 e p s 0=e p s 0 * 1 e −6;
e p s 0=e p s 0 * 1 e −6;
60 mu0= 4 * p i ;
mu0= mu0 * 1 e −4;
62 mu0= mu0 * 1 e −3;
64 / / D e f i n e dx & dy
dx=1e −3;
66 dy=1e −3;
dx2 = ( 1 / dx ) * ( 1 / dx ) ;
68 dy2 = ( 1 / dy ) * ( 1 / dy ) ;
70 / / D e f i n e t i m e s t e p s and domain s i z e
/ / N, xsize , y s i z e are a l l defined
72 / / By r u n t i m e a r g u m e n t s
N = atoi ( argv [ 1 ] ) ;
74 x s i z e = atoi ( argv [ 2 ] ) ;
y s i z e = atoi ( argv [ 3 ] ) ;
76 nx =( i n t ) x s i z e ;
ny =( i n t ) y s i z e ;
78 dfactor =.9;
d t = ( 1 / ( c * s q r t ( dx2 + dy2 ) ) ) * d f a c t o r ;
80 c e=d t / ( 2 * e p s 0 ) ;
82 / / D e f i n e s o u r c e waveform c o n s t a n t s
Nc =25;
84 t a u =( Nc * d t ) / ( 2 * s q r t ( 2 . 0 ) ) ;
t0 =4.5* tau ;
86 fmax = 1 / ( t a u ) ;
88 / / D e f i n e PML C o n s t a n t s
iPML =10;
90 kappa =8;
m=4;
92 s i g m a x = ( 0 . 8 * m+ 1 ) / ( 1 5 0 * p i * dx ) ;
s i g m a y = ( 0 . 8 * m+ 1 ) / ( 1 5 0 * p i * dy ) ;
94 amax = ( fmax / 2 . 1 ) * 2 * p i * ( e p s 0 / 1 0 ) ;
102 / / D y n a m i c a l l y A l l o c a t e A r r a y s t o A l l o w m a t r i x s i z e t o be
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
/ / S e t a t Runtime
104 g a u s s= ( f l o a t * ) m a l l o c ( N* s i z e o f ( f l o a t ) ) ;
t= ( f l o a t * ) m a l l o c ( N* s i z e o f ( f l o a t ) ) ;
106 o u t p u t P o r t= ( f l o a t * ) malloc ( 1 * s i z e o f ( f l o a t ) ) ;
10 cell air gap to the CMPL boundary, as seen in Fig. 12.8. Options for this patch antenna includes
setting the height, width, the location, and width of the feed line; height of the substrate; and
optional inset feed parameters.
A three-dimensional code was created for this geometry that accepts command line parameters
for A, B, C, D, E, F, and H as seen in Fig. 12.8. These parameters specify the left width, feed
width, right width, inset width, inset height, total height, and substrate thickness of the patch. In
addition, the permittivity of the substrate and simulation cell parameters can be adjusted. From this
a MATLAB GUI was created to allow interactive adjustment of these parameters and viewing of
the return loss. MATLAB was chosen for its ability to create simple user interfaces and processing
of results. Here the MATLAB GUI titled “PatchUI2” is run to display a simple interface for the
GPU program as seen in Fig. 12.9. Parameters on this interface may be adjusted, as well as the
number of time steps by the user. After the “Run Simulation” button has been pressed, MATLAB
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
3 t [0]= dt ;
gauss [0]=0;
5
11
/ / Define E x t e r i o r Size
13 insizex = xsize ;
insizey = ysize ;
15
// I n i t i a l i z e o u r C f i e l d and c o n s t a n t a r r a y s
17
/ / 1D X A r r a y s
19 f o r ( i =0; i <nx ; i ++) {
aKex [ i ] = 1 ;
21 aKhx [ i ] = 1 ;
abex [ i ] = 0 ;
23 abhx [ i ] = 0 ;
acex [ i ]=0;
25 achx [ i ]=0;
}
27
/ / 1D Y A r r a y s
29 f o r ( i =0; i <ny ; i ++) {
aKey [ i ] = 1 ;
31 aKhy [ i ] = 1 ;
abey [ i ] = 0 ;
33 abhy [ i ] = 0 ;
acey [ i ]=0;
35 achy [ i ]=0;
}
37
/ / 2D A r r a y s
39 f o r ( j =0; j <ny ; j ++) {
f o r ( i =0; i <nx ; i ++) {
41 aHy [ nx * j + i ] = 0 ;
aHx [ nx * j + i ] = 0 ;
43 a E z [ nx * j + i ] = 0 ;
a C s [ nx * j + i ] = 0 ;
45 a C e z e [ nx * j + i ] = 1 . 0 ;
aChxh [ nx * j + i ] = 1 . 0 ;
47 aChyh [ nx * j + i ] = 1 . 0 ;
a C e z h [ nx * j + i ] = ( d t / e p s 0 ) ;
49 a C h x e [ nx * j + i ] = ( d t / mu0 ) ;
a C h y e [ nx * j + i ] = ( d t / mu0 ) ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
51 a p s i [ nx * j + i ] = 0 ;
}
53 }
55 / / S e t PEC Boundary
/ / ( E a s y way , f i l l w i t h PEC t h e n f i l l i n t e r n a l with a i r )
57
4 i i =( f l o a t ) i ;
i i =(1+ iPML )− i i ;
6
16 aKex [ i +1]=1/ k1 ;
aKhx [ i ] = 1 / k2 ;
18
22 a b e x [ i +1]= exp ( ( − d t / e p s 0 ) * ( ( s i g 1 / k1 )+ a1 ) ) ;
a c e x [ i + 1 ] = ( ( s i g 1 / dx ) / ( ( s i g 1 * k1 ) + ( a1 * k1 * k1 ) ) ) *
24 ( exp ( ( − d t / e p s 0 ) * ( ( s i g 1 / k1 )+ a1 ) ) − 1 ) ;
26
aKey [ i +1]=1/ k1 ;
40 aKhy [ i ] = 1 / k2 ;
64
/ / P l a c e Our P o i n t S o u r c e ( P l a c e d i n t h e a p p r o x i m a t e c e n t e r )
66 a C s [ nx * ( y s i z e / 2 ) + ( x s i z e / 2 ) ] = 1 / dx ;
68 / / P l a c e Sample S c a t t e r i n g O b j e c t E r = 1 0 . 2
74 f o r ( j = ( ( y s i z e / 2 ) − 8 ) ; j < ( ( y s i z e / 2 ) + 9 ) ; j ++) {
f o r ( i = ( ( x s i z e / 2 ) + 1 0 ) ; i < ( ( x s i z e / 2 ) + 2 0 ) ; i ++) {
76 a C e z e [ nx * j + i ] = 1 ;
a C e z h [ nx * j + i ] = ( 2 * c e ) / ( 1 0 . 2 ) ;
78 }
}
80
/ / I n i t i a l i z e the streams
8 f l o a t Obs <1 ,1 >;
f l o a t Hy<i n s i z e y , i n s i z e x >, Hx<i n s i z e y , i n s i z e x >;
10 f l o a t o E z <i n s i z e y , i n s i z e x >, o Hy<i n s i z e y , i n s i z e x >;
f l o a t o Hx<i n s i z e y , i n s i z e x >;
12 f l o a t Ceze<i n s i z e y , i n s i z e x >, Chxh<i n s i z e y , i n s i z e x >;
f l o a t Chyh<i n s i z e y , i n s i z e x >;
14 f l o a t Cezh<i n s i z e y , i n s i z e x >, Chxe<i n s i z e y , i n s i z e x >;
f l o a t Chye<i n s i z e y , i n s i z e x >, Cs<i n s i z e y , i n s i z e x >;
16 f l o a t Ez<i n s i z e y , i n s i z e x >;
f l o a t Kex<i n s i z e x >, Khx<i n s i z e x >;
18 f l o a t Bex<i n s i z e x >, Bhx<i n s i z e x >;
f l o a t Cex<i n s i z e x >, Chx<i n s i z e x >;
20 f l o a t Key<i n s i z e y >, Khy<i n s i z e y >;
f l o a t Bey<i n s i z e y >, Bhy<i n s i z e y >;
22 f l o a t Cey<i n s i z e y >, Chy<i n s i z e y >;
f l o a t p s i E z x <i n s i z e y , i n s i z e x >, o p s i E z x <i n s i z e y , i n s i z e x >;
24 f l o a t p s i E z y <i n s i z e y , i n s i z e x >, o p s i E z y <i n s i z e y , i n s i z e x >;
f l o a t p s i H x y <i n s i z e y , i n s i z e x >, o p s i H x y <i n s i z e y , i n s i z e x >;
26 f l o a t p s i H y x <i n s i z e y , i n s i z e x >, o p s i H y x <i n s i z e y , i n s i z e x >;
28
/ / Copy o u r C a r r a y s i n t o t h e S t r e a m s s o t h e GPU
30 / / can p r o c e s s them
s t r e a m R e a d ( Ez , a E z ) ;
32 s t r e a m R e a d ( Hy , aHy ) ;
s t r e a m R e a d ( Hx , aHx ) ;
34 streamRead ( o Ez , aEz ) ;
s t r e a m R e a d ( o Hy , aHy ) ;
36 s t r e a m R e a d ( o Hx , aHx ) ;
s t r e a m R e a d ( Ceze , a C e z e ) ;
38 s t r e a m R e a d ( Chxh , aChxh ) ;
s t r e a m R e a d ( Chyh , aChyh ) ;
40 s t r e a m R e a d ( Cezh , a C e z h ) ;
s t r e a m R e a d ( Chxe , a C h x e ) ;
42 s t r e a m R e a d ( Chye , a C h y e ) ;
s t r e a m R e a d ( Cs , a C s ) ;
44
s t r e a m R e a d ( Kex , aKex );
46 s t r e a m R e a d ( Khx , aKhx );
s t r e a m R e a d ( Bex , abex );
48 s t r e a m R e a d ( Bhx , abhx );
s t r e a m R e a d ( Cex , acex );
50 s t r e a m R e a d ( Chx , achx );
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
52 s t r e a m R e a d ( Key , aKey ) ;
s t r e a m R e a d ( Khy , aKhy ) ;
54 s t r e a m R e a d ( Bey , abey ) ;
s t r e a m R e a d ( Bhy , abhy ) ;
56 s t r e a m R e a d ( Cey , acey ) ;
s t r e a m R e a d ( Chy , achy ) ;
58
/ / Do t h e r e q u e s t e d number o f i t e r a t i o n s
5 f o r ( i =0; i <N ; i ++){
7 / / We u s e t o 2 s e t s o f f i e l d s t r e a m s t o have
/ / a " New " and " Old " s e t
9 i f ( i %2==0) {
15 p r o c e s s f i e l d E z ( Ez , Ceze , Cezh , o Hx , o Hy , Cs ,
Kex , Key , Bex , Bey , Cex , Cey , p s i E z x , p s i E z y ,
17 dx , dy , g a u s s [ i ] , i t , o E z , o p s i E z x , o p s i E z y ) ;
s t r e a m W r i t e ( Obs , o u t p u t P o r t ) ;
25 f p r i n t f ( p F i l e 2 , " %e \n " , o u t p u t P o r t [ 0 ] ) ;
27 } else {
43 s t r e a m W r i t e ( Obs , o u t p u t P o r t ) ;
f p r i n t f ( p F i l e 2 , " %e \n " , o u t p u t P o r t [ 0 ] ) ;
45
}
47
f p r i n t f ( p F i l e , " %e %e \n " , g a u s s [ i ] , t [ i ] ) ;
49 }
4 / / C h e c k which i s t h e l a s t s t r e a m s u p d a t e d
6 i f ( i %2==0) {
streamWrite ( Ez , o u t p u t E z ) ;
8 streamWrite ( Hx , o u t p u t H x ) ;
streamWrite ( Hy , o u t p u t H y ) ;
10 } else {
streamWrite ( o Ez , outputEz ) ;
12 streamWrite ( o Hx , o u t p u t H x ) ;
streamWrite ( o Hy , o u t p u t H y ) ;
14 }
16
/ / C l o s e The O b s e r v a t i o n and D a t a F i l e s
18 fclose ( pFile ) ;
fclose ( pFile2 ) ;
20
/ / Output the f i e l d s t a t e s i n t o a t e x t f i l e
22 p F i l e = fopen ( " E z d a t a . t x t " , " wt " ) ;
p F i l e 2 = fopen ( " H x d a t a . t x t " , " wt " ) ;
24 p F i l e 3 = fopen ( " H y d a t a . t x t " , " wt " ) ;
38 // Close Field F il e s
fclose ( pFile ) ;
40 fclose ( pFile2 ) ;
fclose ( pFile3 ) ;
42 p r i n t f ( " Program c o m p l e t e \n " ) ;
return 0;
44 }
calls the GPU FDTD program and runs the simulation for the requested parameters and time
steps. After the simulation has finished, the GUI performs the postprocessing on the data and
displays the return loss for the selected configuration. In addition to the return loss, the tran-
sient input port voltage and current and the input impedance are also displayed as shown in
Figs. 12.10, 12.11, and 12.12, respectively. The graphical user interface (GUI) also includes a
calculator section that analyzes or synthesizes the proper antenna given the requested target
frequency or antenna size. By using this GUI, it is possible to vary any of the parameters inter-
actively and to have the results shown in a matter of seconds. Figure 12.13 shows the results for
return loss with the default input parameters. The entire simulation including the postprocess-
ing was accomplished very quickly, allowing for its use in a wide variety of teaching or research
situations.
As a second example for the three-dimensional GUI interface, a simple microstrip filter was
chosen from [14]. This is a simple offset microstrip filter placed on a known dielectric substrate of
r = 2.2 with a 10 cell air gap to the CMPL boundary as seen in Fig. 12.14. In this case we again
have seven parameters that can be adjusted: specifying the filter bar width, spacing of the left feed
Figure 12.13 Return loss results for default microstrip patch antenna.
arm from the edge of the end of the filter bar, first feed line width, the spacing between the feed
arms, second feed line width, the spacing of the right feed arm from the edge of the filter bar, and
the height of the substrate.
A different GUI was created in MATLAB to handle this geometry as now there is both return
loss and transmission to be calculated and viewed. This interface can be seen in Fig. 12.15. This
interface is set up with the default parameters from [14] and shows the calculated results for
S11 and S21 . The parameters can be changed to specify different configurations, and the results
calculated show in seconds on personal computers with modest configuration. Figure 12.16 shows
the results for the default parameters of the microstrip filter. Both the microstrip patch antenna
and the microstrip filter examples executable codes and their corresponding MATLAB GUI are
provided on the CD for further experiments by the reader.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Figure 12.16 Return loss and transmission results for default microstrip filter.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
A
One-Dimensional FDTD Code
Listing A.1 MATLAB code for one-dimensional FDTD
% T h i s program d e m o n s t r a t e s a one−d i m e n s i o n a l FDTD s i m u l a t i o n .
2 % The problem g e o m e t r y i s composed o f two PEC p l a t e s e x t e n d i n g t o
% i n f i n i t y i n y , and z d i m e n s i o n s , p a r a l l e l t o e a c h o t h e r w i t h 1 meter
4 % s e p a r a t i o n . The s p a c e between t h e PEC p l a t e s i s f i l l e d w i t h a i r .
% A s h e e t o f c u r r e n t s o u r c e p a r a l l e t o t h e PEC p l a t e s i s p l a c e d
6 % a t t h e c e n t e r o f t h e problem s p a c e . The c u r r e n t s o u r c e e x c i t e s f i e l d s
% i n t h e problem s p a c e due t o a z−d i r e c t e d c u r r e n t d e n s i t y J z ,
8 % which h a s a G a u s s i a n waveform i n t i m e .
10 % Define i n i t i a l constants
e p s 0 = 8 . 8 5 4 1 8 7 8 1 7 e −12; % p e r m i t t i v i t y of f r e e space
12 mu 0 = 4 * p i * 1 e −7; % permeability of f r e e space
c = 1 / s q r t ( mu 0 * e p s 0 ) ; % speed of l i g h t
14
% D e f i n e problem g e o m e t r y and p a r a m e t e r s
16 domain size = 1; % 1D problem s p a c e l e n g t h i n m e t e r s
dx = 1e −3; % c e l l s i z e in meters
18 d t = 3e −12; % d u r a t i o n of time s t e p in seconds
number of time steps = 2000; % number o f i t e r a t i o n s
20 nx = round ( d o m a i n s i z e / dx ) ; % number o f c e l l s i n 1D problem s p a c e
source position = 0.5; % p o s i t i o n of the current source J z
22
% Initialize f i e l d and m a t e r i a l a r r a y s
24 Ceze = z e r o s ( nx + 1 , 1 ) ;
Cezhy = z e r o s ( nx + 1 , 1 ) ;
26 Cezj = z e r o s ( nx + 1 , 1 ) ;
Ez = z e r o s ( nx + 1 , 1 ) ;
28 Jz = z e r o s ( nx + 1 , 1 ) ;
eps r z = o n e s ( nx + 1 , 1 ) ; % f r e e s p a c e
30 sigma e z = z e r o s ( nx + 1 , 1 ) ; % f r e e s p a c e
399
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
40 % C a l c u l a t e FDTD u p d a t i n g c o e f f i c i e n t s
Ceze = ( 2 * e p s r z * eps 0 − dt * sigma e z ) . . .
42 . / ( 2 * e p s r z * eps 0 + dt * sigma e z ) ;
44 C e z h y = ( 2 * d t / dx ) . . .
. / ( 2 * e p s r z * eps 0 + dt * sigma e z ) ;
46
Cezj = ( −2 * d t ) . . .
48 . / ( 2 * e p s r z * eps 0 + dt * sigma e z ) ;
50 Chyh = ( 2 * m u r y * mu 0 − d t * s i g m a m y ) ...
. / ( 2 * m u r y * mu 0 + d t * s i g m a m y ) ;
52
C h y e z = ( 2 * d t / dx ) . . .
54 . / ( 2 * m u r y * mu 0 + d t * s i g m a m y ) ;
56 Chym = ( −2 * d t ) . . .
. / ( 2 * m u r y * mu 0 + d t * s i g m a m y ) ;
58
% D e f i n e t h e G a u s s i a n s o u r c e waveform
60 time = dt * [ 0 : number of time steps − 1 ] . ’ ;
J z w a v e f o r m = exp ( − ( ( time −2e − 1 0 ) / 5 e − 1 1 ) . ˆ 2 ) ;
62 s o u r c e p o s i t i o n i n d e x = round ( nx * s o u r c e p o s i t i o n / d o m a i n s i z e ) + 1 ;
64 % Subroutine to i n i t i a l i z e p l o t t i n g
initialize plotting parameters ;
66
% FDTD l o o p
68 for time step = 1: number of time steps
70 % Update J z f o r t h e c u r r e n t t i m e s t e p
J z ( s o u r c e p o s i t i o n i n d e x ) = Jz waveform ( time step ) ;
72
% Update m a g n e t i c f i e l d
74 Hy ( 1 : nx ) = Chyh ( 1 : nx ) . * Hy ( 1 : nx ) . . .
+ C h y e z ( 1 : nx ) . * ( E z ( 2 : nx + 1) − E z ( 1 : nx ) ) ...
76 + Chym ( 1 : nx ) . * My ( 1 : nx ) ;
78 % Update e l e c t r i c f i e l d
E z ( 2 : nx ) = C e z e ( 2 : nx ) . * E z ( 2 : nx ) . . .
80 + C e z h y ( 2 : nx ) . * ( Hy ( 2 : nx ) − Hy ( 1 : nx − 1 ) ) ...
+ C e z j ( 2 : nx ) .* J z ( 2 : nx ) ;
82
Ez ( 1 ) = 0 ; % A p p l y PEC b o u n d a r y c o n d i t i o n a t x = 0 m
84 E z ( nx + 1 ) = 0 ; % A p p l y PEC b o u n d a r y c o n d i t i o n a t x = 1 m
E z p o s i t i o n s = [ 0 : nx ] * dx ;
4 H y p o s i t i o n s = ( [ 0 : nx − 1 ] + 0 . 5 ) * dx ;
v = [ 0 −0.1 −0.1; 0 −0.1 0 . 1 ; 0 0 . 1 0 . 1 ; 0 0 . 1 −0.1; . . .
6 1 −0.1 −0.1; 1 −0.1 0 . 1 ; 1 0 . 1 0 . 1 ; 1 0 . 1 − 0 . 1 ] ;
f = [1 2 3 4; 5 6 7 8 ] ;
8 a x i s ( [ 0 1 −0.2 0 . 2 −0.2 0 . 2 ] ) ;
l e z = l i n e ( E z p o s i t i o n s , E z * 0 , Ez , ’ C o l o r ’ , ’ b ’ , ’ L i n e W i d t h ’ , 1 . 5 ) ;
10 l h y = l i n e ( H y p o s i t i o n s , 3 7 7 * Hy , Hy * 0 , ’ C o l o r ’ , ’ r ’ , . . .
’ L i n e W i d t h ’ , 1 . 5 , ’ l i n e s t y l e ’ , ’ −. ’ ) ;
12 s e t ( gca , ’ f o n t s i z e ’ , 1 2 , ’ F o n t W e i g h t ’ , ’ b o l d ’ ) ;
axis square ;
14 l e g e n d ( ’ E { z } ’ , ’ H { y } \ t i m e s 377 ’ , ’ L o c a t i o n ’ , ’ N o r t h E a s t ’ ) ;
x l a b e l ( ’ x [m] ’ ) ;
16 y l a b e l ( ’ [ A /m] ’ ) ;
z l a b e l ( ’ [ V /m] ’ ) ;
18 g r i d on ;
p = patch ( ’ v e r t i c e s ’ , v , ’ f a c e s ’ , f , ’ f a c e c o l o r ’ , ’ g ’ , ’ f a c e a l p h a ’ , 0 . 2 ) ;
20 t e x t ( 0 , 1 , 1 . 1 , ’ PEC ’ , ’ h o r i z o n t a l a l i g n m e n t ’ , ’ c e n t e r ’ , ’ f o n t w e i g h t ’ , ’ b o l d ’ ) ;
t e x t ( 1 , 1 , 1 . 1 , ’ PEC ’ , ’ h o r i z o n t a l a l i g n m e n t ’ , ’ c e n t e r ’ , ’ f o n t w e i g h t ’ , ’ b o l d ’ ) ;
3 delete ( lez ) ;
delete ( lhy ) ;
5 l e z = l i n e ( E z p o s i t i o n s , E z * 0 , Ez , ’ C o l o r ’ , ’ b ’ , ’ L i n e W i d t h ’ , 1 . 5 ) ;
l h y = l i n e ( H y p o s i t i o n s , 3 7 7 * Hy , Hy * 0 , ’ C o l o r ’ , ’ r ’ , . . .
7 ’ L i n e W i d t h ’ , 1 . 5 , ’ l i n e s t y l e ’ , ’ −. ’ ) ;
t s = num2str ( t i m e s t e p ) ;
9 t i = num2str ( d t * t i m e s t e p * 1 e9 ) ;
t i t l e ( [ ’ time s t e p = ’ t s ’ , time = ’ t i ’ ns ’ ] ) ;
11 drawnow ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
B
Convolutional Perfectly
Matched Layer Regions and
Associated Field Updates for a
Three-Dimensional Domain
Modify the coefficient arrays for Ce xhy and Ce xhz in the CPML regions:
Ce xhz = 1/κe y Ce xhz , in the yn and yp regions.
Ce xhy = (1/κe z ) Ce xhy , in the zn and zp regions.
n+ 1
Calculate ψe xy 2 for the yn and y p regions:
n+ 1 n− 1 n+ 1
ψe xy 2 (i, j, k) = b e y ψe xy 2 (i, j, k) + a e y Hz 2 (i, j, k) − Hzn+ (i, j − 1, k) ,
403
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
(a) E x is updated in yn and yp using ψex y (b) E x is updated in zn and zp using ψex z
where
σ pe y
ae y = bey − 1 ,
y σ pe y κe y + αe y κe y
2
σ y
− κpe +α pe y t
bey = e ey ε
0 .
n+ 1
Calculate ψe xz 2 for the zn and zp regions:
n+ 1 n− 1 n+ 1 n+ 1
ψe xz 2 (i, j, k) = b e z ψe xz 2 (i, j, k) + a e z Hy 2 (i, j, k) − Hy 2 (i, j, k − 1) ,
where
σ pe z
ae z = [b e z − 1] ,
z σ pe z κe z + αe z κe2z
σ z
− κpe +α pe z t
bez = e ez 0ε
.
n+ 1
E xn+1 = E xn+1 + Cψe xy × ψe xy 2 .
n+ 1
E xn+1 = E xn+1 + Cψe xz × ψe xz 2 .
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
(a) E y is updated in zn and zp using ψeyz (b) E y is updated in x n and x p using ψeyx
Modify the coefficient arrays for Ce yhz and Ce yhx in the CPML regions:
n+ 1
Calculate ψe y z 2 for the zn and zp regions:
n+ 1 n− 1
n+ 1 n+ 1
ψe y z 2 (i, j, k) = b e z ψe y z 2 (i, j, k) + a e z Hx 2 (i, j, k) − Hx 2 (i, j, k − 1) ,
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
where
σ pe z
ae z = [b e z − 1] ,
z σ pe z κe z + αe z κe2z
σ z
− κpe +α pe z t
bez = e ez 0ε
.
n+ 1
Calculate ψe y x 2 for the xn and xp regions:
n+ 1 n− 1
n+ 1 n+ 1
ψe y x 2 (i, j, k) = b e x ψe y x 2 (i, j, k) + a e x Hz 2 (i, j, k) − Hz 2 (i − 1, j, k) ,
where
σ pe x
ae x = [b e x − 1] ,
x σ pe x κe x + αe x κe2x
σ t
− pe x +α
b e x = e ( κe x pe x ) ε0 .
n+ 1
E yn+1 = E yn+1 + Cψe y z × ψe y z 2 .
n+ 1
E yn+1 = E yn+1 + Cψe y x × ψe y x 2 .
Modify the coefficient arrays for Ce zhx and Ce zhy in the CPML regions:
n+ 1
Calculate ψe zx 2 for the xn and xp regions:
n+ 1 n− 1
n+ 1 n+ 1
ψe zx 2 (i, j, k) = b e x ψe zx 2 (i, j, k) + a e x Hy 2 (i, j, k) − Hy 2 (i − 1, j, k) ,
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
(a) E z is updated in x n and x p using ψezx (b) E z is updated in yn and yp using ψezy
where
σ pe x
ae x = [b e x − 1] ,
x σ pe x κe x + αe x κe2x
σ t
− pe x +α
b e x = e ( κe x pe x ) ε0 .
n+ 1
Calculate ψe zy 2 for the yn and y p regions:
n+ 1 n− 1 n+ 1 n+ 1
ψe zy 2 (i, j, k) = b e y ψe zy 2 (i, j, k) + a e y Hx 2 (i, j, k) − Hx 2 (i, j − 1, k) ,
where
σ pe y
ae y = bey − 1 ,
y σ pe y κe y + αe y κe y
2
σ y
− κpe +α pe y t
bey = e ey ε 0 .
n+ 1
E zn+1 = E zn+1 + Cψe zx × ψe zx 2 .
n+ 1
E zn+1 = E zn+1 + Cψe zy × ψe zy 2 .
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
(a) H x is updated in yn and yp using ψhx y (b) H x is updated in zn and zp using ψhx z
Modify the coefficient arrays for C hxe y and C hxe z in the CPML regions:
C hxe z = 1/κmy C hxe z , in the yn and yp regions.
C hxe y = (1/κmz ) C hxe y , in the zn and zp regions.
n+ 12 n− 12
Hx (i, j, k) = C hxh (i, j, k) × Hx (i, j, k)
+ C hxe z (i, j, k) × E zn (i, j + 1, k) − E zn (i, j, k)
+ C hxe y (i, j, k) × E yn (i, j, k + 1) − E yn (i, j, k) .
Calculate ψhxy
n
for the yn and y p regions:
ψhxy
n
(i, j, k) = b my ψhxy
n−1
(i, j, k) + a my E zn (i, j + 1, k) − E zn (i, j, k) ,
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
where
σ pmy
a my = b my − 1 ,
y σ pmy κmy + αmy κmy
2
σ
− κpmy +α pmy µt
b my = e my 0 .
Calculate ψhxz
n
for the zn and zp regions:
ψhxz
n
(i, j, k) = b mz ψhxz
n−1
(i, j, k) + a mz E yn (i, j, k + 1) − E yn (i, j, k) ,
where
σ pmz
a mz = [b mz − 1] ,
z σ pmz κmz + αmz κmz
2
σ
− κpmz +α pmz µt
b mz = e mz 0 .
n+ 12 n+ 12
Hx = Hx + Cψhxy × ψhxy
n
.
n+ 12 n+ 12
Hx = Hx + Cψhxz × ψhxz
n
.
Modify the coefficient arrays for C hye z and C hye x in the CPML regions:
n+ 12 n− 12
Hy (i, j, k) = C hyh (i, j, k) × Hy (i, j, k)
+ C hye x (i, j, k) × E xn (i, j, k + 1) − E xn (i, j, k)
+ C hye z (i, j, k) × E zn (i + 1, j, k) − E zn (i, j, k) .
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
(a) H y is updated in zn and zp using ψhyz (b) H y is updated in x n and x p using ψhyx
Calculate ψhy
n
z for the zn and zp regions:
n
ψhy
n
z (i, j, k) = b mz ψhy z (i, j, k) + a mz E x (i, j, k + 1) − E x (i, j, k) ,
n−1 n
where
σ pmz
a mz = [b mz − 1] ,
z σ pmz κmz + αmz κmz
2
σ
− κpmz +α pmz µt
b mz = e mz 0 .
Calculate ψhy
n
x for the xn and xp regions:
n
ψhy
n
x (i, j, k) = b mx ψhy x (i, j, k) + a mx E z (i + 1, j, k) − E z (i, j, k) ,
n−1 n
where
σ pmx
a mx = [b mx − 1] ,
x σ pmx κmx + αmx κmx
2
σ t
− pmx +α
b mx = e ( κmx pmx ) µ0 .
n+ 12 n+ 12
Hy = Hy + Cψhy z × ψhy
n
z.
n+ 12 n+ 12
Hy = Hy + Cψhy x × ψhy
n
x.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
(a) H z is updated in x n and x p using ψhzx (b) H z is updated in yn and yp using ψhzy
Modify the coefficient arrays for C hze x and C hze y in the CPML regions:
n+ 12 n− 12
Hz (i, j, k) = C hzh (i, j, k) × Hz (i, j, k)
+ C hze y (i, j, k) × E yn (i + 1, j, k) − E yn (i, j, k)
+ C hze x (i, j, k) × E xn (i, j + 1, k) − E xn (i, j, k) .
Calculate ψhzx
n
for the xn and xp regions:
ψhzx
n
(i, j, k) = b mx ψhzx
n−1
(i, j, k) + a mx E yn (i + 1, j, k) − E yn (i, j, k) ,
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
where
σ pmx
a mx = [b mx − 1] ,
x σ pmx κmx + αmx κmx
2
σ t
− pmx +α
b mx = e ( κmx pmx ) µ0 .
Calculate ψhzy
n
for the yn and y p regions:
ψhzy
n
(i, j, k) = b my ψhzy
n−1
(i, j, k) + a my E yn (i, j + 1, k) − E yn (i, j, k) ,
where
σ pmy
a my = b my − 1 ,
y σ pmy κmy + αmy κmy
2
σ
− κpmy +α pmy µt
b my = e my 0 .
n+ 12 n+ 12
Hz = Hz + Cψhzx × ψhzx
n
.
n+ 12 n+ 12
Hz = Hz + Cψhzy × ψhzy
n
.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
C
MATLAB Code for Plotting
Far-Field Patterns
% t h i s f u n c t i o n p l o t s two p o l a r p l o t s i n t h e same f i g u r e
7 plot range = s t e p s i z e * number of rings ;
min val = max val − p l o t r a n g e ;
9
hold on ;
11 th = 0 : ( pi / 5 0 ) : 2 * pi ; c i r c l e x = cos ( th ) ; c i r c l e y = sin ( th ) ;
f o r mi = 1 : n u m b e r o f r i n g s
13 r = ( 1 / n u m b e r o f r i n g s ) * mi ;
plot ( r * c i r c l e x , r * c i r c l e y , ’ : ’ , ’ color ’ , ’ k ’ , ’ linewidth ’ ,1);
15 t e x t ( 0 . 0 4 , r , [ num2str ( m i n v a l + s t e p s i z e * mi ) ] ,...
’ v e r t i c a l a l i g n m e n t ’ , ’ bottom ’ , ’ c o l o r ’ , ’ k ’ ,...
17 ’ f o n t w e i g h t ’ , ’ demi ’ , ’ f o n t s i z e ’ , 1 0 ) ;
end
19
r =[0:0.1:1];
21 f o r mi = 0 : 1 1
t h=mi * p i / 6 ;
23 plot ( r * cos ( th ) , r * sin ( th ) , ’ : ’ , ’ c o l o r ’ , ’ k ’ , ’ l i n e w i d t h ’ , 1 ) ;
t e x t ( 1 . 1 * c o s ( t h ) , 1 . 1 * s i n ( t h ) , [ num2str ( 3 0 * mi ) ] , . . .
25 ’ horizontalalignment ’ , ’ center ’ , ’ color ’ , ’k ’ , . . .
’ f o n t w e i g h t ’ , ’ demi ’ , ’ f o n t s i z e ’ , 1 0 ) ;
27 end
413
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
35 x1 = p a t t e r n 1 . * c o s ( p h i ) ;
y1 = p a t t e r n 1 . * s i n ( p h i ) ;
37
x2 = p a t t e r n 2 . * c o s ( p h i ) ;
39 y2 = p a t t e r n 2 . * s i n ( p h i ) ;
41 % p l o t d a t a on t o p o f g r i d
p = p l o t ( x1 , y1 , l i n e s t y l e 1 , x2 , y2 , l i n e s t y l e 2 , ’ l i n e w i d t h ’ , 2 ) ;
43 t e x t ( 1 . 2 * cos ( pi / 4 ) , 1 . 2 * sin ( pi / 4 ) , . . .
[ ’ \ t h e t a = ’ num2str ( c o n s t a n t t h e t a ) ’ ˆ o ’ ] , . . .
45 ’ c o l o r ’ , ’ b ’ , ’ f o n t w e i g h t ’ , ’ demi ’ ) ;
legend ( p , legend 1 , legend 2 , ’ l o c a t i o n ’ , ’ s o u t h e a s t ’ ) ;
47 t e x t ( −1 , −1.1 , s c a l e t y p e , ’ f o n t s i z e ’ , 1 2 ) ;
t e x t ( 1 . 0 2 * 1 . 1 , 0 . 1 3 * 1 . 1 , ’ ¼ ’ , ’ fontname ’ , ’ s y m b o l ’ , . . .
49 ’ c o l o r ’ , ’ b ’ , ’ f o n t w e i g h t ’ , ’ demi ’ ) ;
t e x t ( 1 . 0 8 * 1.1 , 0.13 * 1.1 , ’ \ phi ’ , . . .
51 ’ fontname ’ , ’ a r i a l ’ , ’ c o l o r ’ , ’ b ’ , ’ f o n t w e i g h t ’ , ’ demi ’ , ’ f o n t s i z e ’ , 1 2 ) ;
53 i f c o n s t a n t t h e t a == 90
text (1.2 , 0 . 0 6 , ’ x ’ , ’ fontname ’ , ’ a r i a l ’ , . . .
55 ’ c o l o r ’ , ’ b ’ , ’ f o n t w e i g h t ’ , ’ demi ’ ) ;
t e x t ( 1 . 2 , 0 , ’ ¹ ’ , ’ fontname ’ , ’ s y m b o l ’ , . . .
57 ’ c o l o r ’ , ’ b ’ , ’ f o n t w e i g h t ’ , ’ demi ’ ) ;
t e x t ( 0 . 0 6 , 1 . 2 3 , ’ y ’ , ’ fontname ’ , ’ a r i a l ’ , . . .
59 ’ c o l o r ’ , ’ b ’ , ’ f o n t w e i g h t ’ , ’ demi ’ ) ;
t e x t ( 0 , 1 . 2 3 , ’ ¼ ’ , ’ fontname ’ , . . .
61 ’ s y m b o l ’ , ’ c o l o r ’ , ’ b ’ , ’ f o n t w e i g h t ’ , ’ demi ’ ) ;
t e x t ( 1 . 2 * cos ( pi / 4 ) , 1 . 1 8 * sin ( pi / 4 ) − 0 . 1 2 , . . .
63 ’ x y p l a n e ’ , ’ c o l o r ’ , ’ b ’ , ’ f o n t w e i g h t ’ , ’ demi ’ ) ;
end
65
a x i s ( [ − 1 . 2 1 . 2 −1.2 1 . 2 ] ) ;
67 a x i s ( ’ equal ’ ) ; a x i s ( ’ o f f ’ ) ;
hold o f f ;
69 s e t ( gcf , ’ PaperPositionMode ’ , ’ auto ’ ) ;
s e t ( gca , ’ f o n t s i z e ’ , 1 2 ) ;
% t h i s f u n c t i o n p l o t s two p o l a r p l o t s i n t h e same f i g u r e
7 plot range = s t e p s i z e * number of rings ;
min val = max val − p l o t r a n g e ;
9
hold on ;
11 th = 0 : ( pi / 5 0 ) : 2 * pi ; c i r c l e x = cos ( th ) ; c i r c l e y = sin ( th ) ;
f o r mi = 1 : n u m b e r o f r i n g s
13 r = ( 1 / n u m b e r o f r i n g s ) * mi ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
r =[ −1:0.1:1];
21 f o r mi = 3 : 8
t h=mi * p i / 6 ;
23 plot ( r * cos ( th ) , r * sin ( th ) , ’ : ’ , ’ c o l o r ’ , ’ k ’ , ’ l i n e w i d t h ’ , 1 ) ;
t e x t ( 1 . 1 * c o s ( t h ) , 1 . 1 * s i n ( t h ) , [ num2str ( 3 0 * ( mi − 3 ) ) ] , . . .
25 ’ horizontalalignment ’ , ’ center ’ , ’ color ’ , ’k ’ , . . .
’ f o n t w e i g h t ’ , ’ demi ’ , ’ f o n t s i z e ’ , 1 0 ) ;
27 t e x t ( − 1 . 1 * c o s ( t h ) , 1 . 1 * s i n ( t h ) , [ num2str ( 3 0 * ( mi − 3 ) ) ] , . . .
’ horizontalalignment ’ , ’ center ’ , ’ color ’ , ’k ’ , . . .
29 ’ f o n t w e i g h t ’ , ’ demi ’ , ’ f o n t s i z e ’ , 1 0 ) ;
end
31 t e x t ( 0 , − 1 . 1 , ’ 180 ’ , . . .
’ horizontalalignment ’ , ’ center ’ , ’ color ’ , ’k ’ , . . .
33 ’ f o n t w e i g h t ’ , ’ demi ’ , ’ f o n t s i z e ’ , 1 0 ) ;
x2 = −p a t t e r n 2 . * c o s ( t h e t a +p i / 2 ) ;
45 y2 = p a t t e r n 2 . * s i n ( t h e t a +p i / 2 ) ;
47 % p l o t d a t a on t o p o f g r i d
p = p l o t ( x1 , y1 , l i n e s t y l e 1 , x2 , y2 , l i n e s t y l e 2 , ’ l i n e w i d t h ’ , 2 ) ;
49 t e x t ( 1 . 2 * cos ( pi / 4 ) , 1 . 2 * sin ( pi / 4 ) , . . .
[ ’ \ p h i = ’ num2str ( c o n s t a n t p h i ) ’ ˆ o ’ ] , . . .
51 ’ c o l o r ’ , ’ b ’ , ’ f o n t w e i g h t ’ , ’ demi ’ ) ;
legend ( p , legend 1 , legend 2 , ’ l o c a t i o n ’ , ’ s o u t h e a s t ’ ) ;
53 t e x t ( −1 , −1.1 , s c a l e t y p e , ’ f o n t s i z e ’ , 1 2 ) ;
t e x t ( 0 . 2 , 1 . 0 2 , ’ ¹ ’ , ’ fontname ’ , ’ s y m b o l ’ , ’ c o l o r ’ , ’ b ’ , ’ f o n t w e i g h t ’ , ’ demi ’ ) ;
55 t e x t ( 0 . 2 , 1 . 0 8 , ’ \ t h e t a ’ , ’ fontname ’ , ’ a r i a l ’ , ’ c o l o r ’ , ’ b ’ , . . .
’ f o n t w e i g h t ’ , ’ demi ’ , ’ f o n t s i z e ’ , 1 2 ) ;
57 t e x t ( − 0 . 2 1 , 1 . 0 2 , ’ \ l e f t a r r o w ’ , ’ c o l o r ’ , ’ b ’ , ’ f o n t w e i g h t ’ , ’ demi ’ ) ;
t e x t ( − 0 . 2 , 1 . 0 8 , ’ \ t h e t a ’ , ’ fontname ’ , ’ a r i a l ’ , ’ c o l o r ’ , ’ b ’ , . . .
59 ’ f o n t w e i g h t ’ , ’ demi ’ , ’ f o n t s i z e ’ , 1 2 ) ;
61 i f c o n s t a n t p h i == 0
t e x t ( 1 . 2 , 0 . 0 6 , ’ x ’ , ’ fontname ’ , ’ a r i a l ’ , ’ c o l o r ’ , ’ b ’ , ’ f o n t w e i g h t ’ , ’ demi ’ ) ;
63 t e x t ( 1 . 2 , 0 , ’ ¹ ’ , ’ fontname ’ , ’ s y m b o l ’ , ’ c o l o r ’ , ’ b ’ , ’ f o n t w e i g h t ’ , ’ demi ’ ) ;
t e x t ( 0 . 0 6 , 1 . 2 3 , ’ z ’ , ’ fontname ’ , ’ a r i a l ’ , ’ c o l o r ’ , ’ b ’ , ’ f o n t w e i g h t ’ , ’ demi ’ ) ;
65 t e x t ( 0 , 1 . 2 3 , ’ ¼ ’ , ’ fontname ’ , ’ s y m b o l ’ , ’ c o l o r ’ , ’ b ’ , ’ f o n t w e i g h t ’ , ’ demi ’ ) ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
a x i s ( [ − 1 . 2 1 . 2 −1.2 1 . 2 ] ) ;
79 a x i s ( ’ equal ’ ) ; a x i s ( ’ o f f ’ ) ;
hold o f f ;
81 s e t ( gcf , ’ PaperPositionMode ’ , ’ auto ’ ) ;
s e t ( gca , ’ f o n t s i z e ’ , 1 2 ) ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
Bibliography
[1] A. Taflove and S. C. Hagness, Computational Electrodynamics: The Finite Difference Time Domain Method,
3rd ed. Norwood, MA: Artech House Publishers, 2005.
[2] K. S. Yee, “Numerical solution of inital boundary value problems involving Maxwell’s equations in
isotropic media,” IEEE Transactions on Antennas and Propagation, vol. 14, pp. 302–307, 1966.
[3] R. Courant, K. Friedrichs, and H. Lewy, “On the Partial Difference Equations of Mathematical
Physics,” IBM Journal of Research and Development, vol. 11, no. 2, pp. 215–234, 1967.
[4] J. A. Kong, Electromagnetic Wave Theory. Cambridge, MA: EMW Publishing, 2000.
[5] S. Dey and R. Mittra, “Conformal finite-difference time-domain technique for modeling cylindrical
dielectric resonators,” IEEE Transactions on Microwave Theory and Techniques, vol. 47, no. 9, pp. 1737–
1739, September 1999.
[6] R. Schechter, M. Kragalott, M. Kluskens, and W. Pala, “Splitting of material cells and averaging prop-
erties to improve accuracy of the FDTD method at interfaces,” Applied Computational Electromagnetics
Society Journal, vol. 17, no. 3, pp. 198–208, 2002.
[7] D. E. Aspnes, “Bounds on allowed values of the effective dielectric function of two-component com-
posites at finite frequencies,” Physical Review B, vol. 25, no. 2, pp. 1358–1361, January 1982.
[8] N. Kaneda, B. Houshmand, and T. Itoh, “FDTD analysis of dielectric resonators with curved surfaces,”
IEEE Transactions on Microwave Theory and Techniques, vol. 45, no. 9, pp. 1645–1649, 1997.
[9] J.-Y. Lee and N.-H. Myung, “Locally tensor conformal FDTD method for modeling arbitrary dielectric
surfaces,” Microwave and Optical Technology Letters, vol. 23, no. 4, pp. 245–249, 1999.
[10] R. F. Harrington, Time-Harmonic Electromagnetic Fields. Hoboken, NJ: Wiley-IEEE Press, 2001.
[11] J. Fang and D. Xeu, “Numerical errors in the computation of impedances by the FDTD method and
ways to eliminate them,” IEEE Microwave and Guided Wave Letters, vol. 5, no. 1, pp. 6–8, January 1995.
[12] R. W. Anderson, “S-parameter techniques for faster, more accurate network design,” Hewlett-Packard
Company, Tech. Rep., November 1996.
[13] K. Kurokawa, “Power waves and the scattering matrix,” IEEE Transactions on Microwave Theory, vol. 13,
no. 2, pp. 194–202, 1965.
[14] D. Sheen, S. Ali, M. Abouzahra, and J. Kong, “Application of the three-dimensional finite-difference
time-domain method to the analysis of planar microstrip circuits,” IEEE Transactions on Microwave
Theory, vol. 38, no. 7, pp. 849–857, 1990.
[15] J.-P. Berenger, “A perfectly matched layer for the absorption of electromagnetic waves,” Journal of
Computational Physics, vol. 114, no. 2, pp. 185–200, October 1994.
[16] ——, “Three-dimensional perfectly matched layer for the absorption of electromagnetic waves,” Journal
of Computational Physics, vol. 127, no. 2, pp. 363–379, September 1996.
[17] W. V. Andrew, C. A. Balanis, and P. A. Tirkas, “Comparison of the Berenger perfectly matched layer
and the Lindman higher-order ABC’s for the FDTD method,” IEEE Microwave and Guided Wave
Letters, vol. 5, no. 6, pp. 192–194, 1995.
[18] J.-P. Berenger, “Perfectly matched layer for the FDTD solution of wave-structure interaction prob-
lems,” IEEE Transactions on Antennas and Propagation, vol. 44, no. 1, pp. 110–117, 1996.
[19] J. C. Veihl and R. Mittra, “Efficient implementation of Berenger’s perfectly matched layer (PML) for
finite-difference time-domain mesh truncation,” IEEE Microwave and Guided Wave Letters, vol. 6, no. 2,
pp. 94–96, 1996.
[20] S. D. Gedney, “An anisotropic perfectly matched layer-absorbing medium for the truncation of FDTD
lattices,” IEEE Transactions on Antennas and Propagation, vol. 44, no. 12, pp. 1630–1639, 1996.
[21] A. Taflove, Computational Electrodynamics: The Finite Difference Time Domain Method. Norwood, MA:
Artech House Publishers, 1995.
417
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
418 Bibliography
Bibliography 419
[45] M. J. Inman and A. Z. Elsherbeni, “3D FDTD accelleration using graphical processing units,” Applied
Computational Electromagnetics Society (ACES) Conference, Miami, FL, 2006.
[46] ——, “Programming video cards for computational electromagnetics applications,” Antennas and Prop-
agation Magazine, IEEE, vol. 47, no. 6, pp. 71–78, December 2005.
[47] I. Buck, Brook Spec v0.2. Stanford, CA: Stanford University, 2003.
[48] M. Inman, A. Elsherbeni, B. N. Baker, and J. Maloney, “Practical implementation of a CPML absorbing
boundary for GPU accelerated FDTD technique,” IEEE APS Symposium, Honolulu, HI, 2006.
[49] G. Mur, “Absorbing boundary conditions for the finite difference approximation of the time domain
electromagnetic field equations,” IEEE Transactions on Electromagnetic Compatibility, vol. 23, no. 4, pp.
377–382, 1981.
[50] Z. P. Liao, H. L. Wong, B.-P. Yang, and Y.-F. Yuan, “A transmitting boundary for transient wave
analysis,” Scientia Sinica, Ser. A, vol. 27, no. 10, pp. 1063–1076, 1984.
[51] M. J. Inman and A. Z. Elsherbeni, “Interactive GPU based FDTD simulations for teaching applica-
tions,” Applied Computational Electromagnetics Society (ACES) Conference, Naigara Falls, Canada,
March 2008.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
421
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
and Antenna Optimization Using Taguchi’s Method (Morgan & Claypool, 2007), and is the main au-
thor of the chapters “Handheld Antennas” and “The Finite Difference Time Domain Technique
for Microstrip Antennas” in Handbook of Antennas in Wireless Communications (CRC Press, 2001).
He has served as the main advisor for 31 M.S. and 8 Ph.D. students.
Dr. Elsherbeni is a fellow member of IEEE and of ACES. He is editor-in-chief of ACES Journal
and associate editor of the Radio Science Journal. He serves on the editorial board of the book series
on Progress in Electromagnetic Research, the Electromagnetic Waves and Applications Journal, and
the Computer Applications in Engineering Education Journal. He was chair of the engineering and
physics division of the Mississippi Academy of Science and was chair of the Educational Activity
Committee for the IEEE Region 3 Section.
Index
A Courant-Friedrichs-Lewy (CFL), 33, 34, 36, 45
cputime, 119, 129, 249
absorbing boundary, 36, 187–229, 274 create bricks, 58, 61
absorbing boundary conditions (ABC), 36, 187, 371, create PEC plates, 65
377, 419 create spheres, 61
air buffer number of cells, 47, 201, 241 curl equation, 3, 13, 15, 23, 27, 71, 72, 331
Ampere’s law, 15, 52, 110 current source, 75–76, 81, 86, 90, 96, 101,
animation, 111, 114, 118, 128, 219, 222, 229, 355 122
anisotropic, 1, 43, 188, 236, 417, 418
axial ratio, 279
D
B define geometry, 48, 49, 61, 67, 69, 133, 137, 138,
163, 172, 181, 201, 222, 255, 264, 302, 308,
backward difference, 5–10 320, 322, 351, 358, 364
bandwidth, 151, 153, 164, 369 derivative of Gaussian waveform, 149–150, 151f
Berenger, 232 dielectric resonator antenna (DRA), 307
Berenger’s PML, 232 diode, 81–85–88, 104, 123, 124
bistatic RCS, 340, 350, 354f, 355f, 359f, 361 DirectX, 374, 380f
Blackman-Harris window, 143–144 discrete convolution, 234, 235
Boltzmann’s constant, 82 discrete Fourier transformation (DFT), 225, 229f,
boundary conditions, 47, 118, 187 272, 273f, 277, 284, 340
bricks, 48f, 58–59, 69, 312 dispersion relation, 38–40
Brook, 371, 373–374, 375–377 divergence equations, 3
C E
capacitor, 77, 81, 86, 104, 138–139, 139f, 141f, 161 electric charge, 2
central difference, 5f, 6, 7, 9f, 10, 12, 13, 16, 18, 23, electric conductivity, 3, 15, 47, 55, 56, 57
28, 38, 72, 78, 196, 233, 318 electric current, 2, 71, 125, 204, 276, 287
central processing unit (CPU), 369, 370, 376, 377 electric displacement, 2, 53
CFL condition, 34–37 electric field, 2, 3, 15, 17, 31
CFL limit, 36 evanescent modes, 240
characteristic impedance, 168, 261–267, 268f
circularly polarized (CP), 279
complex frequency-shifted PML (CFS-PML), 231, F
232, 240
constitutive relations, 2, 3 Faraday’s law, 15, 315
convolution, 233, 234, 235 far field, 271, 272, 273, 275, 277–280, 281, 307,
convolutional PML (CPML), 231, 232, 236–240, 322, 339, 351, 357, 366, 413
242–250, 269 far field calculation, 274, 276, 277, 278, 288, 291,
cosine modulated Gaussian, 151 296
cosine modulated Gaussian pulse, 143, 151 far field condition, 271, 272
cosine modulated Gaussian waveform, 151–152, far field pattern, 271, 279, 281, 288, 357,
152f, 153f, 161–166 413–416
courant factor, 46 far field radiation, 277, 281, 322
423
fdtd_ind SPIB005-Elsherbeni & Demir November 13, 2009 19:43
424 Index
M
G magnetic charge, 2
magnetic conductivity, 3, 15, 47, 62, 67
Gaussian pulse, 41, 143, 147, 151 magnetic current, 2, 204, 276, 282, 284
Gaussian waveform, 29, 146–149, 149–151, magnetic field, 3, 4, 15, 18, 73, 108, 110f, 111, 114,
151–152, 153, 161–166 119, 125, 126f, 190, 193, 197, 207, 208,
graphical processing unit (GPU), 369, 370, 371, 210–215, 218, 234–236, 237f, 238, 247, 248f,
373, 372, 376, 377, 379 249, 287, 315, 316f, 318, 337, 345,
Green’s function, 1, 274 347, 348
magnetic flux, 2, 54
magnitude, 31, 36, 40, 41, 74, 114, 125, 148f, 225,
226f, 227f, 228f, 229f
H
matching condition, 192, 194, 233
material arrays, 55, 58
hard voltage source, 74–75
material cell, 50, 52f, 53f
material type, 47, 48, 55, 56, 59, 67, 69
Maxwell’s equations, 2, 4, 188, 189, 192, 193, 195,
I 199, 273
method of moments (MoM), 355
image theory, 276, 277f
impedance matching condition, 187, 192
impressed current, 71, 90, 98, 122, 204, 225
impressed current density, 3, 71, 79, 222
N
impressed electric current, 122, 204
near field, 271–310, 339
impressed magnetic current, 119, 204, 215
near sources, 143, 204
incident field, 72, 143, 331, 333, 336, 338, 341–344,
near zone sources, 331
345, 346, 347, 353, 360, 363, 366
negative direction, 47, 86
incident plane wave, 195, 336–341, 343, 349, 351
Newton-Raphson method, 83, 84, 124, 125
inductor, 71, 77f, 78–79, 90, 103, 122
nonlinear, 1, 71, 82, 83, 85, 150
ITERS, 373
number of cells per wavelength, 46, 146, 147,
153
number of time steps, 44, 46, 89, 117, 131, 161
K numerical dispersion, 37–41
numerical dispersion relation, 38, 39
Kernels, 373, 376 numerical stability, 33–37, 40
fdtd_ind SPIB005-Elsherbeni & Demir November 13, 2009 19:43
Index 425
426 Index
updating equation, 13, 22, 23, 25, 26–31, 74, 76, 79, W
86, 90, 96, 97, 98, 101, 103, 196, 197, 199–201,
233, 236–238, 249, 315, 318, 332–336, 344, wave equation, 33, 37, 38
403, 405, 406, 409, 411 waveforms, 29, 40, 87, 143–166, 338
wavelength, 146, 147, 153, 271
V wavenumber, 271, 291
voltage, 71, 72–74, 80, 85, 86, 90, 95, 98, 101,
108–111, 121, 128, 131, 134, 135f, 136f, Y
138–139, 180, 252f
voltage source, 72–75, 80, 86, 89, 96, 98, 101, Yee cell, 13, 14, 16, 23, 55, 56f, 59, 62, 110, 121,
121–122, 131, 161, 180, 307 125
voltage source updating equation, 101 Yee grid, 43–67, 63f