Sei sulla pagina 1di 453

fdtd_fm

SPIB005-Elsherbeni & Demir

November 24, 2008

The Finite-Difference
Time-Domain Method for
Electromagnetics

with MATLAB Simulations
R

Atef Z. Elsherbeni
and
Veysel Demir

SciTech Publishing, Inc


Raleigh, NC
scitechpublishing.com

20:7

fdtd_fm

SPIB005-Elsherbeni & Demir

November 24, 2008

SciTech Publishing, Inc.,


911 Paverstone Drive, Suite B
Raleigh, NC 27615
919) 847-2434, fax (919) 847-2568
scitechpublishing.com.
Copyright (c) 2009 by SciTech Publishing, Raleigh, NC All rights reserved.
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means,
electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108
of the 1976 United Stated Copyright Act, without either the prior written permission of the Publisher, or authorization
through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA
01923, (978) 750-8400, fax (978) 646-8600, or on the web at copyright.com. Requests to the Publisher for permission
should be addressed to the Publisher, SciTech Publishing, Inc., 911 Paverstone Drive, Suite B, Raleigh, NC 27615, (919)
847-2434, fax (919) 847-2568, or email editor@scitechpub.com.
The publisher and the author make no representations or warranties with respect to the accuracy or completeness of
the contents of this work and specifically disclaim all warranties, including without limitation warranties of fitness for a
particular purpose.
Editor: Dudley R. Kay
Production Director: Susan Manning
Production Coordinator: Robert Lawless
Cover Design: Kathy Palmisano
Typesetting: Aptara / MPS Limited, a Macmillan Company
Printer: Hamilton Printing Company
This book is available at special quantity discounts to use as premiums and sales promotions, or for use in corporate
training programs. For more information and quotes, please contact the publisher.
ISBN: 9781891121715
Library of Congress Cataloging-in-Publication Data
Elsherbeni, Atef Z.

The finite-difference time-domain method for electromagnetics with MATLAB


simulations / Atef Z. Elsherbeni and Veysel Demir.
p. cm.
Includes bibliographical references and index.
ISBN 978-1-891121-71-5 (hardcover : alk. paper) 1. Antenna radiation patternsComputer simulation. 2. Electromagnetic wavesComputer simulation. 3. Antennas (Electronics)Computer simulation. 4. MATLAB. I. Demir, Veysel, 1974II. Title.
TK6565.A6E47 2008
621.3824dc22
2008043068
Printed in the United States of America
10 9 8 7 6 5 4 3
Disclaimer
The simulation examples, code sections, and all plots and calculations presented in this book were done using MATLAB
version 7.5 (R2007b). MATLAB is a registered trademark of The MathWorks Inc., 3 Apple Hill Drive, Natick, MA 017602098 USA. http://www.mathworks.com.
Information provided in this book was developed with the authors and publishers utmost care and professionalism.
However, neither the publisher nor the authors guarantee the accuracy or completeness of any provided information in
this book and will not be responsible for any errors, omission, or damages arising from this information. Using the material
presented in this book and the MATLAB and other codes by any entity or person is strictly at will. The authors and the
publisher are neither liable nor responsible for any material or nonmaterial losses, for personal or property damages of
any kind, or for any other damages of any and all types that may be incurred by using this book

20:7

fdtd_fm

SPIB005-Elsherbeni & Demir

November 24, 2008

To my wife, Magda, my daughters, Dalia and Donia, my son, Tamer


To my mother and to the memory of my father
Atef Z. Elsherbeni
To my parents, Abdurrahman and Aysan, and my wife, Minmei Hou
Veysel Demir

20:7

fdtd_fm

SPIB005-Elsherbeni & Demir

November 24, 2008

20:7

fdtd_fm

SPIB005-Elsherbeni & Demir

November 24, 2008

Contents
Preface
Author Acknowledgements
Acknowledgement of Reviewers

xxi
xxv
xxvii

Chapter 1

Introduction to FDTD
1.1 The Finite-Difference Time-Domain Method Basic Equations
1.2 Approximation of Derivatives by Finite Differences
1.3 FDTD Updating Equations for Three-Dimensional Problems
1.4 FDTD Updating Equations for Two-Dimensional Problems
1.5 FDTD Updating Equations for One-Dimensional Problems
1.6 Exercises

1
2
4
13
22
26
32

Chapter 2

Numerical Stability and Dispersion

33

2.1 Numerical Stability


2.1.1 Stability in Time Domain Algorithm
2.1.2 CFL Condition for the FDTD Method
2.2 Numerical Dispersion
2.3 Exercises

33
33
34
37
41

Chapter 3

Building Objects in the Yee Grid


3.1 Denition of Objects
3.1.1 Dening the Problem Space Parameters
3.1.2 Dening the Objects in the Problem Space
3.2 Material Approximations
3.3 Subcell Averaging Schemes for Tangential and Normal Components
3.4 Dening Objects Snapped to the Yee Grid
3.5 Creation of the Material Grid
3.6 Improved Eight-Subcell Averaging
3.7 Exercises

43
43
44
48
50
52
55
57
67
67

Chapter 4

Active and Passive Lumped Elements


4.1 FDTD Updating Equations for Lumped Elements
4.1.1 Voltage Source
4.1.2 Hard Voltage Source
4.1.3 Current Source
4.1.4 Resistor
4.1.5 Capacitor
4.1.6 Inductor
4.1.7 Lumped Elements Distributed over a Surface or within
a Volume
4.1.8 Diode
4.1.9 Summary

71
71
72
74
75
76
77
78

vii

79
81
85

20:7

fdtd_fm

SPIB005-Elsherbeni & Demir

viii

November 24, 2008

Contents

4.2 Denition, Initialization, and Simulation of Lumped Elements


4.2.1 Denition of Lumped Elements
4.2.2 Initialization of FDTD Parameters and Arrays
4.2.3 Initialization of Lumped Element Components
4.2.4 Initialization of Updating Coefcients
4.2.5 Sampling Electric and Magnetic Fields, Voltages and Currents
4.2.6 Denition and Initialization of Output Parameters
4.2.7 Running an FDTD Simulation: The Time-Marching
Loop
4.2.8 Displaying FDTD Simulation Results
4.3 Simulation Examples
4.3.1 A Resistor Excited by a Sinusoidal Voltage Source
4.3.2 A Diode Excited by a Sinusoidal Voltage Source
4.3.3 A Capacitor Excited by a Unit-Step Voltage Source
4.4 Exercises
Chapter 5

Chapter 6

Chapter 7

Source Waveforms and Transformation from Time Domain to


Frequency Domain
5.1 Common Source Waveforms for FDTD Simulations
5.1.1 Sinusoidal Waveform
5.1.2 Gaussian Waveform
5.1.3 Normalized Derivative of a Gaussian Waveform
5.1.4 Cosine-Modulated Gaussian Waveform
5.2 Denition and Initialization of Source Waveforms for FDTD
Simulations
5.3 Transformation from Time Domain to Frequency Domain
5.4 Simulation Examples
5.4.1 Recovering a Time Waveform from Its Fourier
Transform
5.4.2 An RLC Circuit Excited by a Cosine-Modulated Gaussian
Waveform
5.5 Exercises

86
86
89
90
97
108
111
118
130
131
131
134
138
139

143
143
143
146
149
151
152
154
158
160
161
166

Scattering Parameters

169

6.1 S-Parameters and Return Loss Denitions


6.2 S-Parameter Calculations
6.3 Simulation Examples
6.3.1 Quarter-Wave Transformer
6.4 Exercises

169
170
178
178
184

Perfectly Matched Layer Absorbing Boundary

187

7.1 Theory of PML


7.1.1 Theory of PML at the VacuumPML Interface
7.1.2 Theory of PML at the PMLPML Interface
7.2 PML Equations for Three-Dimensional Problem Space
7.3 PML Loss Functions

187
187
190
193
195

20:7

fdtd_fm

SPIB005-Elsherbeni & Demir

November 24, 2008

Contents

ix

7.4 FDTD Updating Equations for PML and MATLAB Implementation


7.4.1 PML Updating EquationsTwo-Dimensional TEz
Case
7.4.2 PML Updating EquationsTwo-Dimensional TMz
Case
7.4.3 MATLAB Implementation of the Two-Dimensional FDTD
Method with PML
7.5 Simulation Examples
7.5.1 Validation of PML Performance
7.5.2 Electric Field Distribution
7.5.3 Electric Field Distribution Using DFT
7.6 Exercises
Chapter 8

Chapter 9

The Convolutional Perfectly Matched Layer


8.1 Formulation of CPML
8.1.1 PML in Stretched Coordinates
8.1.2 Complex Stretching Variables in CFS-PML
8.1.3 The Matching Conditions at the PMLPML Interface
8.1.4 Equations in the Time Domain
8.1.5 Discrete Convolution
8.1.6 The Recursive Convolution Method
8.2 The CPML Algorithm
8.2.1 Updating Equations for CPML
8.2.2 Addition of Auxiliary CPML Terms at Respective
Regions
8.3 CPML Parameter Distribution
8.4 MATLAB Implementation of CPML in the Three-Dimensional
FDTD Method
8.4.1 Denition of CPML
8.4.2 Initialization of CPML
8.4.3 Application of CPML in the FDTD Time-Marching
Loop
8.5 Simulation Examples
8.5.1 Microstrip Low-Pass Filter
8.5.2 Microstrip Branch Line Coupler
8.5.3 Characteristic Impedance of a Microstrip Line
8.6 Exercises

196
196
199
201
215
215
219
225
229
231
231
231
232
233
233
234
235
236
236
238
239
240
241
242
248
250
250
252
261
267

Near-Field to Far-Field Transformation

271

9.1 Implementation of the Surface Equivalence Theorem


9.1.1 Surface Equivalence Theorem
9.1.2 Equivalent Surface Currents in FDTD Simulation
9.1.3 Antenna on Innite Ground Plane
9.2 Frequency Domain Near-Field to Far-Field Transformation
9.2.1 Time-Domain to Frequency-Domain Transformation
9.2.2 Vector Potential Approach

272
272
274
276
277
277
277

20:7

fdtd_fm

SPIB005-Elsherbeni & Demir

November 24, 2008

Contents

9.2.3 Polarization of Radiation Field


9.2.4 Radiation Efciency
9.3 MATLAB Implementation of Near-Field to Far-Field Transformation
9.3.1 Denition of NFFF Parameters
9.3.2 Initialization of NFFF Parameters
9.3.3 NFFF DFT during Time-Marching Loop
9.3.4 Postprocessing for Far-Field Calculation
9.4 Simulation Examples
9.4.1 Inverted-F Antenna
9.4.2 Strip-Fed Rectangular Dielectric Resonator Antenna
9.5 Exercises

279
280
281
281
282
284
288
299
299
307
310

Chapter 10

Thin-Wire Modeling
10.1 Thin-Wire Formulation
10.2 MATLAB Implementation of the Thin-Wire Formulation
10.3 Simulation Examples
10.3.1 Thin-Wire Dipole Antenna
10.4 Exercises

315
315
319
322
322
327

Chapter 11

Scattered Field Formulation


11.1 Scattered Field Basic Equations
11.2 The Scattered Field Updating Equations
11.3 Expressions for the Incident Plane Waves
11.4 MATLAB Implementation of the Scattered Field Formulation
11.4.1 Denition of the Incident Plane Wave
11.4.2 Initialization of the Incident Fields
11.4.3 Initialization of the Updating Coefcients
11.4.4 Calculation of the Scattered Fields
11.4.5 Postprocessing and Simulation Results
11.5 Simulation Examples
11.5.1 Scattering from a Dielectric Sphere
11.5.2 Scattering from a Dielectric Cube
11.5.3 Reection and Transmission Coefcients of a Dielectric
Slab
11.6 Exercises

331
331
332
336
340
340
341
344
344
348
350
350
355

Chapter 12

Appendix A

358
366

Graphics Processing Unit Acceleration of Finite-Difference


Time-Domain

369

12.1
12.2
12.3
12.4
12.5

371
373
375
377
379

Graphics Processors and General Math


Introduction to Brook
Sample Two-Dimensional FDTD Implementation Using Brook
Extension to Three-Dimensional
Three-Dimensional Parameter Exploration

One-Dimensional FDTD Code

399

20:7

fdtd_fm

SPIB005-Elsherbeni & Demir

November 24, 2008

Contents

Appendix B

xi

Convolutional Perfectly Matched Layer Regions and Associated Field


Updates for a Three-Dimensional Domain
B.1 Updating E x at Convolutional Perfectly Matched Layer (CPML)
Regions
B.2 Updating E y at CPML Regions
B.3 Updating E z at CPML Regions
B.4 Updating Hx at CPML Regions
B.5 Updating Hy at CPML Regions
B.6 Updating Hz at CPML Regions

Appendix C MATLAB Code for Plotting


Bibliography
About the Authors
Index

403
403
405
406
408
409
411
413
417
421
423

20:7

fdtd_fm

SPIB005-Elsherbeni & Demir

November 24, 2008

20:7

fdtd_fm

SPIB005-Elsherbeni & Demir

November 24, 2008

List of Figures
1.1(a).
1.1(b).
1.1(c).
1.2(a).
1.2(b).

1.2(c).
1.2(d).
1.3.
1.4.
1.5.
1.6.
1.7.
1.8.
1.9.
1.10.
1.11.
1.12.
1.13.
1.14(a).
1.14(b).
1.14(c).
1.14(d).
2.1.
2.2.
2.3.
2.4.
2.5(a).

Approximation of the derivative of f (x) at x by nite differences: forward


difference.
Approximation of the derivative of f (x) at x by nite differences: backward
difference.
Approximation of the derivative of f (x) at x by nite differences: central
difference.
f (x), f  (x), and differences between f  (x) and nite difference approximations
of f  (x) for x = /5 and x = /10. f (x) = sin(x)e 0.3x
f (x), f  (x), and differences between f  (x) and nite 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 nite difference approximations of f  (x) for x = /5.
f (x), f  (x), and differences between f  (x) and nite difference approximations
of f  (x) for x = /5 and x = /10: error( f  (x)) for x = /5.
f (x), f  (x), and differences between f  (x) and nite difference approximations
of f  (x) for x = /5 and x = /10: error( f  (x)) for x = /10.
Sample points of f (x).
A three-dimensional FDTD computational space composed of (Nx Ny Nz )
Yee cells.
Arrangement of eld components on a Yee cell indexed as (i, j, k).
Material parameters indexed on a Yee cell.
Field components around E x (i, j, k).
Field components around Hx (i, j, k).
Explicit FDTD procedure.
Two-dimensional T E z FDTD eld components.
Two-dimensional T Mz FDTD eld components.
One-dimensional FDTDpositions of eld components E y and Hz .
One-dimensional FDTD positions of eld components E z and Hy .
Snapshots of a one-dimensional FDTD simulation: elds observed after 100
time steps.
Snapshots of a one-dimensional FDTD simulation: elds observed after 300
time steps.
Snapshots of a one-dimensional FDTD simulation: elds observed after 615
time steps.
Snapshots of a one-dimensional FDTD simulation: elds observed after 700
time steps.
The timespace domain grid with error  propagating with = 1/2.
The timespace domain grid with error  propagating with = 1.
The timespace domain grid with error  propagating with = 2.
Maximum magnitude of E z in the one-dimensional problem space for
simulations with t = 3.3356 ps and t = 3.3357 ps.
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.

xiii

4
5
5
8

8
9
9
13
14
14
16
16
18
22
24
25
27
28
29
30
30
31
34
35
35
37
40

20:7

fdtd_fm

SPIB005-Elsherbeni & Demir

xiv

2.5(b).
3.1.
3.2.
3.3.
3.4.
3.5.
3.6.
3.7.
3.8.
3.9.
3.10.
3.11.
3.12.
3.13.
3.14.
3.15.
4.1.
4.2.
4.3.
4.4.
4.5.
4.6.
4.7.
4.8.
4.9.
4.10.
4.11.
4.12.
4.13.
4.14.
4.15.
4.16.

November 24, 2008

List of Figures

Maximum magnitude of E z in the one-dimensional problem space: simulation


with x = 4 mm.
Parameters dening a brick and a sphere in Cartesian coordinates.
An FDTD problem space and the objects dened in it.
A cell around material component z (i, j, k) partially lled with two media.
A cell around material component z (i, j, k) divided into eight subcells.
Material component z (i, j, k) parallel to the boundary of two different media
partially lling a material cell.
Material component z (i, j, k) normal to the boundary of two different media
partially lling a material cell.
Material component z (i, j, k) located between four Yee cells lled with four
different material types.
Material component z (i, j, k) located between two Yee cells lled with two
different material types.
A PEC plate with zero thickness surrounded by four e material components.
An FDTD problem space and the objects approximated by snapping to cells.
Positions of the E x components on the Yee grid for a problem space composed
of (Nx Ny Nz) cells.
Positions of the Hx components on the Yee grid for a problem space composed
of (Nx Ny Nz) cells.
Material grid on three plane cuts.
The FDTD problem space of Exercise 3.1.
The FDTD problem space of Exercise 3.3.
Field components around E z (i, j, k).
Voltage sources placed between nodes (i, j, k) and (i, j, k + 1).
Lumped elements placed between nodes (i, j, k) and (i, j, k + 1).
Lumped elements placed between nodes (i, j, k) and (i, j, k + 1).
Parallel perfect electric conductor (PEC) plates excited by a voltage source at
one end and terminated by a resistor at the other end.
A voltage source distributed over a surface and a resistor distributed over a
volume.
Diodes placed between nodes (i, j, k) and (i, j, k + 1).
A function f (x) and the points approaching to the root of the function
iteratively calculated using the Newton-Raphson Method.
A diode dened between the nodes (is , j s , ks ) and (ie, j e, ke).
A z-directed voltage source dened between the nodes (is , j s , ks ) and
(ie, j e, ke).
A volume between PEC plates where a z-directed sampled voltage is required.
A surface enclosed by magnetic eld components and z-directed current
owing through it.
The y components of the magnetic and electric elds around the node
(is , j s , ks ).
A voltage source terminated by a resistor.
Sinusoidal voltage source waveform with 500 MHz frequency and sampled
voltage and current.
Sinusoidal voltage source waveform with 500 MHz frequency and sampled
voltage.

41
48
50
51
51
52
53
55
56
57
62
63
63
66
68
68
72
73
75
77
80
80
82
84
96
99
109
110
126
132
135
136

20:7

fdtd_fm

SPIB005-Elsherbeni & Demir

November 24, 2008

List of Figures

4.17.
4.18.
4.19.
4.20.
5.1(a).
5.1(b).
5.2(a).
5.2(b).
5.3(a).
5.3(b).
5.4.
5.5(a).
5.5(b).

Unit step voltage source waveform and sampled voltage.


Dimensions of 50  stripline.
A 50  stripline terminated by a resistor.
A circuit composed of a voltage source, a capacitor, and a diode.
A sinusoidal waveform excited for 4 seconds: x(t).
A sinusoidal waveform excited for 4 seconds: X() magnitude.
A sinusoidal waveform excited for 8 seconds: x(t).
A sinusoidal waveform excited for 8 seconds: X() magnitude.
A Gaussian waveform and its Fourier transform: g(t).
A Gaussian waveform and its Fourier transform: G() magnitude.
Gaussian waveform shifted by t0 = 4.5 in time.
Normalized derivative of a Gaussian waveform and its Fourier transform: g(t).
Normalized derivative of a Gaussian waveform and its Fourier transform: G()
magnitude.
5.6(a). Cosine Gaussian waveform and its Fourier transform: g(t).
5.6(b). Cosine Gaussian waveform and its Fourier transform: G() magnitude.
5.7(a). A Gaussian waveform and its Fourier transform: g(t).
5.7(b). A Gaussian waveform and its Fourier transform: G().
5.7.
A Gaussian waveform and its Fourier transform: g(t) recovered from G().
5.8.
An RLC circuit.
5.9.
Time-domain response, Vo , compared with source waveform, Vs .
5.10(a). Frequency-domain response of source waveform Vs and output voltage Vo :
Fourier transform of Vs .
5.10(b). Frequency-domain response of source waveform Vs and output voltage Vo :
Fourier transform of Vo .
()
.
5.11.
Transfer function T() = VVos ()
6.1.
An N-port network.
6.2(a). A microstrip low-pass lter terminated by a voltage source and a resistor on
two ends: three-dimensional view.
6.2(b). A microstrip low-pass lter terminated by a voltage source and a resistor on
two ends: dimensions.
6.3(a). S-parameters of the microstrip low-pass lter: S11 .
6.3(b). S-parameters of the microstrip low-pass lter: S21 .
6.4.
Sampled voltage at the second port of the microstrip low-pass lter.
6.5.
Sampled voltage at the second port of the microstrip low-pass lter with
e = 0.2.
6.6(a). S-parameters of the microstrip low-pass lter with e = 0.2: S11 .
6.6(b). S-parameters of the microstrip low-pass lter with e = 0.2: S21 .
6.7.
The geometry and dimensions of a microstrip quarter-wave transformer
matching a 100  line to 50  line.
6.8.
The S11 and S21 of the microstrip quarter-wave transformer circuit.
6.9.
The problem space for the low-pass lter with absorbers on the xn, xp, yn, y p,
and zp sides.
7.1.
The eld decomposition of a T E z polarized plane wave.
7.2.
The plane wave transition at the interface between two PML media.
7.3.
The loss distributions in two-dimensional PML regions.

xv

139
140
141
141
144
145
145
146
147
148
149
150
151
152
153
161
162
162
163
166
166
167
167
170
171
171
176
177
177
178
179
179
180
181
185
188
190
192

20:7

fdtd_fm

SPIB005-Elsherbeni & Demir

xvi

7.4.
7.5.
7.6.
7.7.
7.8.
7.9.
7.10.
7.11.
7.12(a).
7.12(b).
7.13(a).
7.13(b).
7.14.
7.15.
7.16.
7.17.
7.18.
7.19.
7.20.
8.1.
8.2.
8.3.
8.4.
8.5.
8.6.
8.7.
8.8.
8.9.
8.10.
8.11.
8.12.
8.13.
8.14.
8.15.
8.16.
8.17.
8.18.
8.19.

November 24, 2008

List of Figures

Nonzero regions of PML conductivities for a three-dimensional FDTD


simulation domain.
Nonzero T E z regions of PML conductivities.
Nonzero T Mz regions of PML conductivities.
A two-dimensional FDTD problem space with PML boundaries.
TEz eld components in the PML regions.
Field components updated by PML equations.
TMz eld components in the PML regions.
Field components updated by PML equations.
A two-dimensional TEz FDTD problem terminated by PML boundaries and
its simulation results: an empty two-dimensional problem space.
A two-dimensional TEz FDTD problem terminated by PML boundaries and
its simulation results: sampled Hz in time.
A two-dimensional TEz FDTD problem used as open boundary reference and
its simulation results: an empty two-dimensional problem space.
A two-dimensional TEz FDTD problem used as open boundary reference and
its simulation results: sampled Hz in time.
Error in time and frequency domains.
A two-dimensional problem space including a cylinder and a line source.
Sampled electric eld at a point between the cylinder and the line source.
Magnitude of electric eld distribution calculated by FDTD.
Magnitude of electric eld distribution calculated by BVS.
Magnitude of electric eld distribution calculated by FDTD using DFT at 1
GHz.
Magnitude of electric eld distribution calculated by FDTD using DFT at 2
GHz.
The FDTD owchart including the steps of CPML algorithm.
Regions where CPML parameters are dened.
A problem space with 20 20 4 cells brick.
Positions of the electric eld components updated by CPML in the xp region.
Positions of the magnetic eld components updated by CPML in the xp region.
Source voltage and sampled voltages observed at the ports of the low-pass lter.
Sampled currents observed at the ports of the low-pass lter.
S11 of the low-pass lter.
S21 of the low-pass lter.
An FDTD problem space including a microstrip branch line coupler.
S-parameters of the branch line coupler.
An FDTD problem space including a microstrip line.
Source voltage and sampled voltage of the microstrip line.
Current on the microstrip line.
S11 of the microstrip line.
Characteristic impedance of the microstrip line.
The problem space for the quarter-wave transformer with CPML boundaries
on the xn, xp, yn, y p, and zp sides.
The problem space for the quarter-wave transformer with the substrate
penetrating into the CPML boundaries on the xn and xp sides.
The microstrip line reference case.

194
198
200
203
207
208
210
211
217
218
220
220
221
222
226
226
227
228
229
237
239
242
248
248
252
253
253
254
254
261
262
266
266
267
268
268
269
269

20:7

fdtd_fm

SPIB005-Elsherbeni & Demir

November 24, 2008

List of Figures

9.1.
9.2.
9.3.
9.4.
9.5.
9.6.
9.7.
9.8.
9.9.
9.10.
9.11.
9.12.
9.13.
9.14.
9.15.
9.16.
9.17.
9.18.
9.19.
9.20.
9.21.
9.22.
9.23.
9.24.
9.25.
10.1.
10.2.
10.3.
10.4.
10.5.
10.6.
10.7.
10.8.
10.9.
10.10.
11.1.
11.2.
11.3.
11.4.
11.5.

Near-eld to far-eld transformation technique: equivalent currents on an


imaginary surface.
Two paths of the near-eld to far-eld transformation technique are
implemented to achieve different computation objectives.
Surface equivalence theorem.
An imaginary surface is selected to enclose the antennas or scatterers.
Equivalent surface currents on the imaginary closed surface.
An imaginary closed surface on an innite PEC ground plane using the image
theory.
The equivalent surface current source and far eld.
E x eld components on the yn face of the NFFF imaginary surface and the
magnetic currents generated by them.
Hx eld components around the yn face of the NFFF imaginary surface and
the electric currents generated by them.
Position vectors for sources on the zn and zp faces.
Position vectors for sources on the xn and xp faces.
Position vectors for sources on the yn and y p faces.
An inverted-F antenna.
Return loss of the inverted-F antenna.
Radiation patterns in the xy plane cut.
Radiation patterns in the xz plane cut.
Radiation patterns in the y z plane cut.
A strip-fed rectangular dielectric resonator antenna.
Return loss of the strip-fed rectangular DRA.
Radiation patterns in the xy plane cut.
Radiation patterns in the xz plane cut.
Radiation patterns in the y z plane cut.
A dipole antenna.
A microstrip patch antenna.
A microstrip patch antenna with a microstrip line feeding.
A thin wire with its axis coinciding with Ez (i, j, k) and eld components
surrounding Hy (i, j, k).
Magnetic eld components surrounding the thin wire.
A thin-wire dipole antenna.
Return loss of the thin-wire dipole antenna.
Input impedance of the thin-wire dipole antenna.
Radiation pattern in the xy plane cut.
Radiation pattern in the xz plane cut.
Radiation pattern in the y z plane cut.
An antenna array composed of two thin-wire dipole antennas.
A thin-wire loop.
An incident plane wave.
An incident plane wave delayed in time and shifted in space.
Two incident plane waves: one traveling toward the origin and the other
traveling away from the origin.
An FDTD problem space including a dielectric sphere.
Scattered electric eld captured at the origin and the incident eld waveform.

xvii

272
273
273
275
275
277
278
287
288
296
297
298
300
305
305
306
306
307
310
311
311
312
313
313
314
316
316
325
325
326
326
327
328
328
329
337
338
339
351
353

20:7

fdtd_fm

SPIB005-Elsherbeni & Demir

xviii

11.6.
11.7.
11.8.
11.9.
11.10.
11.11.
11.12.
11.13.
11.14.
11.15.
11.16.
11.17.
11.18.
11.19.
12.1.
12.2.
12.3.
12.4.
12.5.
12.6.
12.7.
12.8.
12.9.
12.10.
12.11.
12.12.
12.13.
12.14.
12.15.
12.16.
B.1.
B.2.
B.3.
B.4.
B.5.
B.6.

November 24, 2008

List of Figures

Bistatic RCS at 1 GHz in the xy plane.


Bistatic RCS at 1 GHz in the xz plane.
Bistatic RCS at 1 GHz in the y z plane.
Calculated RCS at 1 GHz in the xz plane compared with the analytical
solution.
Calculated RCS at 1 GHz in the y z plane compared with the analytical
solution.
Scattered eld due to a sphere captured on the xz plane cut.
An FDTD problem space including a cube, and the surface mesh of the cube
used by the MoM solver.
Bistatic RCS at 1 GHz in the xy plane.
Bistatic RCS at 1 GHz in the xz plane.
Bistatic RCS at 1 GHz in the y z plane.
Calculated RCS at 1 GHz in the xz plane compared with the MoM solution.
Calculated RCS at 1 GHz in the xz plane compared with the MoM solution.
An FDTD problem space including a dielectric slab.
Reection and transmission coefcients of the dielectric slab.
Theoretical maximum processing power of CPUs and GPUs.
Streaming versus nonstreaming operations.
Sample TM2D with CPML E z data at various time steps.
TM2D with CPML E z value at observation point.
TM2D with CPML speedup factors.
Simple tiling from three-dimensional structure to two-dimensional texture.
PML boundaries of a three-dimensional simulation domain in a
two-dimensional texture.
Example microstrip patch antenna.
MATLAB GUI for the microstrip patch antenna.
The transient voltage at the input port.
The transient current at the input port.
The input port impedance versus frequency.
Return loss results for default microstrip patch antenna.
Example microstrip lter.
MATLAB GUI for microstrip lter.
Return loss and transmission results for default microstrip lter.
CPML regions where E x is updated.
CPML regions where E y is updated.
CPML regions where E z is updated.
CPML regions where Hx is updated.
CPML regions where Hy is updated.
CPML regions where Hz is updated.

354
354
355
356
356
357
358
359
361
361
362
362
363
366
370
372
378
379
380
391
392
392
393
393
394
394
395
395
396
397
404
405
407
408
410
411

20:7

fdtd_fm

SPIB005-Elsherbeni & Demir

November 24, 2008

List of Tables
1.1.

12.1.
12.2.

Finite difference formulas for the rst- 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.
CPU versus GPU feature comparison.
Brook program ow.

xix

13
370
374

20:7

fdtd_fm

SPIB005-Elsherbeni & Demir

November 24, 2008

20:7

fdtd_fm

SPIB005-Elsherbeni & Demir

November 24, 2008

Preface
The contents of this book have evolved gradually and carefully from many years of teaching graduate level courses in computational electromagnetics generally, and the FDTD method specically,
at The University of Mississippi. Also, the rst author, Atef Elsherbeni, has further rened 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 condence 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
conrmation. No previous experience with nite-difference methods is assumed of readers to use
this book.
IMPORTANT TOPICS

The main topics in the book include the following:

r the nite-difference approximation of the differential form of Maxwells equations


r the geometry construction in discrete space, including the treatment of the normal and
r
r
r
r
r
r
r
r
r

tangential electric and magnetic eld components at the boundaries between different media
the outer-boundary conditions treatment
the procedures for the appropriate selection of time and spatial increments
the proper selection of the source waveform
the correct parameters for the time-to-frequency-domain transformation
the simulation of thin wires
the representation of lumped passive and active elements in the FDTD simulation
the scattered versus total eld formulations
the denition and formulation of near and far zone sources
the use of graphical processing units for accelerating the FDTD simulations.

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 nal 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-les provided with this book.
xxi

20:7

fdtd_fm

SPIB005-Elsherbeni & Demir

xxii

November 24, 2008

Preface

The book includes a CD-ROM which contains the MATLAB M-les for all programming
examples shown in the text as well as all book gures in full-color. Readers may wish to check
the publishers web page for additional examples or other electronic les and gures 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 unied notation.
r Second, many three-dimensional gures 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 difculties 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
conguration, its FDTD parameters and setup procedure, and nally the frequency and/or
time domain corresponding solutions.
At the end of each chapter, readers will nd 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 conguration of
each in almost all of these exercises is provided in a three dimensional gure.
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 condence, the simulation of a variety of
electromagnetic problems.
HOW TO USE THE CD

The CD should start by itself when inserted in a personal computer CD or DVD drive; however,
due to the many different congurations of personal computers, if the auto-run function does not
start, a double click on the le index.html will get it started. Links to all chapters and appendices
will show up in the rst page. By clicking on any of these links the reader will be directed to the
appropriate chapter list of gures 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-les and can be obtained by contacting the publisher.

20:7

fdtd_fm

SPIB005-Elsherbeni & Demir

Preface

November 24, 2008

xxiii

ERRORS AND SUGGESTIONS

The authors welcome any reader feedback related to suspected errors and to suggestions for
improving the presentation of the topics provided in this book. Errata will be posted on the
publishers web page for this book.

20:7

fdtd_fm

SPIB005-Elsherbeni & Demir

November 24, 2008

20:7

fdtd_fm

SPIB005-Elsherbeni & Demir

November 24, 2008

Author Acknowledgements
The authors would like to rst 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 sacrice 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 verications for some of the presented examples.
The rst 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
nalized. 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 encouragement, patience, and useful suggestions during the course of the development of the manuscript
and production of the book.

xxv

20:7

fdtd_fm

SPIB005-Elsherbeni & Demir

November 24, 2008

20:7

fdtd_fm

SPIB005-Elsherbeni & Demir

November 24, 2008

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 benet all who will use this book to further their knowledge
of the Finite-Difference Time-Domain method in their studies and work.

Prof. Mohamed Bakr McMaster University


Prof. Kent Chamberlin University of New Hampshire
Prof. Christos Christodoulou University of New Mexico
Prof. Islam Eshrah University of Cairo
Prof. Allen Glisson University of Mississippi
Prof. Randy Haupt Pennsylvania State University
Dr. Paul Huang SiGe Semiconductor
Mr. Jay Kralovec Harris Corporation
Prof. Wan Kuang Boise State University
Prof. Anthony Q. Martin Clemson University
Prof. Andrew Peterson Georgia Institute of Technology
Dr. Kurt Shlager Lockheed Martin Corporation
Prof. William Wieserman University of Pittsburgh Johnstown
Prof. Thomas Wu University of Central Florida
Prof. Fan Yang University of Mississippi
Mr. Taeyoung Yang Virginia Institute of Technology

xxvii

20:7

fdtd_fm

SPIB005-Elsherbeni & Demir

November 24, 2008

20:7

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

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 classied into two
categories. The rst 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 Maxwells 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 nite sums, whereas the differential equation methods provide approximations for
differential equations as nite 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 rst 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 conned 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 timedomain 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 differential equation approach, namely, the nite-difference time-domain (FDTD) method for CEM
applications, is covered in this book, along with applications related to antenna designs, microwave
lter 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
Maxwells equations. It is based on simple formulations that do not require complex asymptotic
or Greens functions. Although it solves the problem in time, it can provide frequency-domain responses 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 parallel computation algorithms. These features of the FDTD method have made it the most attractive technique of computational electromagnetics for many microwave devices and antenna
applications.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Introduction to FDTD

FDTD has been used to solve numerous types of problems arising while studying many applications, including the following:

r
r
r
r
r
r
r
r
r
r

scattering, radar cross-section


microwave circuits, waveguides, ber optics
antennas (radiation, impedance)
propagation
medical applications
shielding, coupling, electromagnetic compatibility (EMC), electromagnetic pulse (EMP)
protection
nonlinear and other special materials
geological applications
inverse scattering
plasma

1.1 THE FINITE-DIFFERENCE TIME-DOMAIN METHOD BASIC EQUATIONS

The starting point for the construction of an FDTD algorithm is Maxwells time-domain
equations. The differential time-domain Maxwells equations needed to specify the eld behavior
over time are

D

+ J,
t
B

M,
E =
t
 = e ,
D

 =
H

B = m ,

(1.1a)
(1.1b)
(1.1c)
(1.1d)

 is the electric displacement vector


where E is the electric eld strength vector in volts per meter, D
 is the magnetic eld strength vector in amperes per meter, B
in coulombs per square meter, H
is the magnetic ux density vector in webers per square meter, J is the electric current density
 is the magnetic current density vector in volts per square
vector in amperes per square meter, M
meter, e is the electric charge density in coulombs per cubic meter, and m is the magnetic charge
density in webers per cubic meter.
Constitutive relations are necessary to supplement Maxwells equations and characterize the
material media. Constitutive relations for linear, isotropic, and nondispersive materials can be
written as
 = E,

D

(1.2a)


B = H,

(1.2b)

where is the permittivity, and is the permeability of the material. In free space
= 0 8.854 1012
= 0 = 4 10

farad/meter,

henry/meter.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

FDTD Basic Equations

We only need to consider curl equations (1.1a) and (1.1b) while deriving FDTD equations
because the divergence equations can be satised 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,
 i , where M
 c = m H.
 =M
c + M
 Here e is the electric conductivity in siemens per meter, and
M
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 Maxwells curl equations as

 = E + e E + Ji ,
H
t

H
M
i.
E =
mH
t

(1.3a)
(1.3b)

 and not the uxes D


 and B.

This formulation treats only the electromagnetic elds E and H
All four constitutive parameters , , e , and m are present so that any linear isotropic material
can be specied. 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 eld
 = E and B = H
 from the predicted E and H
 elds, the
response, so that after forming D


resulting D and B must satisfy the divergence equations.
Equation (1.3) is composed of two vector equations, and each vector equation can be decomposed into three scalar equations for three-dimensional space. Therefore, Maxwells curl
equations can be represented with the following six scalar equations in a Cartesian coordinate
system (x, y, z):

Hz Hy
e

x E x Ji x ,
y
z


1 Hx
Hz

ye E y Ji y ,
y
z
x


1 Hy
Hx

ze E z Ji z ,
z x
y


1 Ey
Ez
m

x Hx Mi x ,
x
z
y


1 Ez Ex
m

y Hy Mi y ,
y x
z


Ey
1 Ex
m

z Hz Mi z .
z y
x

1
Ex
=
t
x
Ey
=
t
Ez
=
t
Hx
=
t
Hy
=
t
Hz
=
t

(1.4a)
(1.4b)
(1.4c)
(1.4d)
(1.4e)
(1.4f)

The material parameters x , y , and z are associated with electric eld 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 eld components Hx , Hy , and
Hz through constitutive relations Bx = x Hx , B y = y Hy , and Bz = z Hz , respectively. Similar

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

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 eld components are placed at certain discrete positions in space, and it solves Maxwells
equations in time at discrete time instances. This can be implemented by rst approximating
the time and space derivatives appearing in Maxwells equations by nite differences and next
by constructing a set of equations that calculate the values of elds at a future time instant from
the values of elds at a past time instant, therefore constructing a time marching algorithm that
simulates the progression of the elds in time [2].
1.2 APPROXIMATION OF DERIVATIVES BY FINITE DIFFERENCES

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 sufcient relative
to the functions 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(ac), sampled at discrete points. The expression for the derivative of f (x) at point x can be written as
f  (x) = lim

x0

f (x + x) f (x)
.
x

(1.5)

f (x + x)

f (x x)
f (x)

x x

x + x

Figure 1.1 (a) Approximation of the derivative of f (x ) at x by finite differences: forward difference.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Approximation of Derivatives by Finite Differences

f (x + x)

f (x x)
f (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

Figure 1.1 (c) Approximation of the derivative of f (x ) at x by finite differences: central difference.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Introduction to FDTD

However, since x is a nonzero xed number, the derivative of f (x) can be approximately
taken as
f  (x)

f (x + x) f (x)
.
x

(1.6)

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) f (x x)
.
x

(1.7)

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)

f (x + x) f (x x)
.
2x

(1.8)

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
f (x + x) = f (x) + x f  (x) +

(x)2 
(x)3 
(x)4 
f (x) +
f (x) +
f (x) + . . . .
2
6
24

(1.9)

This equation gives an exact expression for f (x + x) as a series in terms of x and derivatives
of f (x), if f (x) satises certain conditions and innite number of terms, theoretically, are being
used. Equation (1.9) can be rearranged to express f  (x) as
f  (x) =

f (x + x) f (x) x 
(x)2 
(x)3 

f (x)
f (x)
f (x) . . . .
x
2
6
24

(1.10)

Here it can be seen that the rst term on the right-hand side of (1.10) is the same as the forward
difference formula given by (1.6). The sum of the rest of the terms is the difference between the
approximate derivative given by the forward difference formula and the exact derivative f  (x), and
hence is the amount of error introduced by the forward difference formula. Equation (1.10) can
be rewritten as
f  (x) =

f (x + x) f (x)
+ O(x),
x

(1.11)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Approximation of Derivatives by Finite Differences

where O(x) represents the error term. The most signicant term in O(x) is x/2, and the
order of x in this most signicant term is one. Therefore, the forward difference formula is
rst-order accurate. The interpretation of rst-order accuracy is that the most signicant term in
the error introduced by a rst-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):
f (x x) = f (x) x f  (x) +

(x)2 
(x)3 
(x)4 
f (x)
f (x) +
f (x) + . . . .
2
6
24

(1.12)

This equation can be rearranged to express f  (x) as


f  (x) =

f (x) f (x x) x 
(x)2 
(x)3 
+
f (x)
f (x) +
f (x) . . . .
x
2
6
24

(1.13)

The rst 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) f (x x)
+ O(x).
x

(1.14)

The order of x in the most signicant term of O(x) is one; hence the backward difference
formula is rst-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
f (x + x) f (x x) = 2x f  (x) +

2(x)3 
f (x) + . . . .
6

(1.15)

This equation can be rearranged to express f  (x) as


f  (x) =

f (x +x) f (x
f (x + x) f (x x) (x)2 
f (x) + . . . =

2x
6
2x

x)

+ O((x)2 ),
(1.16)

where the rst 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 signicant 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 signicant 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 rst-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
rst-order derivative of this function is
f  (x) = cos(x)e 0.3x 0.3 sin(x)e 0.3x .

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Introduction to FDTD

1
0.8
0.6
0.4

f (x)

0.2
0
0.2
0.4
0.6
0.8
1
0

10

15

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
forward difference
backward difference
central difference

0.8
0.6

x = /5

0.4

f (x)

0.2
0
0.2
0.4
0.6
0.8
1
0

10

15

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.

14:16

SPIB005-Elsherbeni & Demir

October 13, 2009

Approximation of Derivatives by Finite Differences

0.2
0.15

forward difference
backward difference
central difference

x = /5

error [f (x)]

0.1
0.05
0
0.05
0.1
0.15
0.2
0

10

15

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
0.15

forward difference
backward difference
central difference

x = /10

0.1

error [f (x)]

fdtd_main

0.05
0
0.05
0.1
0.15
0.2
0

10

15

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.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

10

October 13, 2009

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 nite 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 nite 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 nite 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(ad)

1

%
N
x
f
f

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
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
e x a c t = l i n s p a c e ( 0 , 6 * pi , N e x a c t ) ;
e x a c t = s i n ( x e x a c t ) . * exp ( 0 . 3 * x e x a c t ) ;
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 ) ;

11

13

% plot exact function


figure ( 1 ) ;
p l o t ( x e x a c t , f e x a c t , k , l i n e w i d t h , 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 ) ;
a x i s ( [ 0 6 * p i 1 1 ] ) ; g r i d on ;
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 e x , FontSize ,16);

15

17

19

21

%
%
N
x
f
f

c r e a t e exact function f o r pi /5 sampling period


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
a = 3 1 ; % number o f p o i n t s f o r p i / 5 s a m p l i n g p e r i o d
a = l i n s p a c e ( 0 , 6 * pi , N a ) ;
a = s i n ( x a ) . * exp ( 0 . 3 * x a ) ;
d e r i v a t i v e a = c o s ( x a ) . * exp ( 0 . 3 * x a ) . . .
0.3 * s i n ( x a ) . * exp ( 0 . 3 * x a ) ;

23

25

27

29

31

33

dx a = pi / 5 ;
f derivative
f derivative
f derivative
f derivative
(f a
f derivative
(f a
f derivative
(f a

f o r w a r d a = zeros (1 , N a ) ;
backward a = zeros (1 , N a ) ;
c e n t r a l a = zeros (1 , N a ) ;
f o r w a r d a ( 1 : N a 1) = . . .
( 2 : N a ) f a ( 1 : N a 1 ) ) / d x a ;
backward a (2: N a ) = . . .
( 2 : N a ) f a ( 1 : N a 1 ) ) / d x a ;
c e n t r a l a ( 2 : N a 1) = . . .
( 3 : N a ) f a ( 1 : N a 2 ) ) / ( 2 * d x a ) ;

35

% c r e a t e exact function f o r pi /10 sampling period

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

Approximation of Derivatives by Finite Differences


37

39

41

43

45

47

49

51

%
N
x
f
f

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
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
b = l i n s p a c e ( 0 , 6 * pi , N b ) ;
b = s i n ( x b ) . * exp ( 0 . 3 * x b ) ;
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 ) ;
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 ) ;
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 ) ;
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 ;
f derivative backward b (2: N b ) = . . .
( f b ( 2 : N b ) f b ( 1 : N b 1 ) ) / d x b ;
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

55

57

59

61

63

65

67

69

% 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
% d e r i v a t i v e s using pi /5 sampling period
figure ( 2 ) ;
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 , . . .
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 , . . .
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 ) ;
a x i s ( [ 0 6 * p i 1 1 ] ) ;
g r i d on ;
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 ) ;
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);
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

73

75

% plot error for f i n i t e difference derivatives


% using pi /5 sampling period
error forward a = f derivative a f derivative forward a ;
error backward a = f d e r i v a t i v e a f derivative backward a ;
error central a = f derivative a f derivative central a ;

77

79

81

figure ( 3 ) ;
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 . , . . .
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

85

87

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 ) ;
a x i s ( [ 0 6 * p i 0.2 0 . 2 ] ) ;
g r i d on ;
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 );

October 13, 2009

11

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

12
89

91

Introduction to FDTD

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);
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

95

97

% plot error for f i n i t e difference derivatives


% using pi /10 sampling period
error forward b = f derivative b f derivative forward b ;
error backward b = f d e r i v a t i v e b f derivative backward b ;
error central b = f derivative b f derivative central b ;

99

101

103

figure ( 4 ) ;
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 . , . . .
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

107

109

111

113

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 ) ;
a x i s ( [ 0 6 * p i 0.2 0 . 2 ] ) ;
g r i d on ;
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 );
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);
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 sufciently accurate for most electromagnetics applications and simple in implementation and understanding.
It is possible to obtain nite-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
f (x + x) + f (x x) = 2 f (x) + (x)2 f  (x) +

(x)4 
f (x) + . . . .
12

(1.17)

After rearranging the equation to have f  (x) on the left-hand side, we get
f  (x) =

f (x + x) 2 f (x) + f (x x) (x)2 


f (x) + . . .

(x)2
12

f (x + x) 2 f (x) + f (x x)


+ O((x)2 ).
=
(x)2

(1.18)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

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.
Derivative f/ x

Derivative 2 f/ x 2

Difference Scheme

Type Error

Difference Scheme

Type Error

fi+1 fi
x

FD O(x)

fi+2 2 fi+1 + fi
(x)2

FD O(x)
BD O(x)

fi fi1
x

BD O(x)

fi 2 fi1 + fi2
(x)2

fi+1 fi1
2x

CD O((x)2 )

fi+1 2 fi + fi1
(x)2

CD O((x)2 )

fi+2 +4 fi+1 3 fi
2x

FD O((x)2 )

fi+2 +16 fi+1 30 fi +16 fi1 fi2


12(x)2

CD O((x)4 )

3 fi 4 fi1 + fi2
2x

BD O((x)2 )

fi+2 +8 fi+1 8 fi1 + fi2


12x

CD O((x)4 )

Using (1.18) we can obtain a central difference formula for the second-order derivative f  (x) as
f  (x)

f (x + x) 2 f (x) + f (x x)


,
(x)2

(1.19)

which is second-order accurate due to O(x)2 .


Similarly, some other nite difference formulas can be obtained for the rst- and second-order
derivatives with different orders of accuracy based on different sampling points. A list of nite
difference formulas is given for the rst- and second-order derivatives in Table 1.1 as a reference.
1.3 FDTD UPDATING EQUATIONS FOR THREE-DIMENSIONAL PROBLEMS

In 1966, Yee originated a set of nite-difference equations for the time-dependent Maxwells 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 eld 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

fi2

fi1

fi

fi+1

fi+2

x 2x

x x

x + x

x + 2x

Figure 1.3 Sample points of f (x ).

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

14

October 13, 2009

Introduction to FDTD

Figure 1.4 A three-dimensional FDTD computational space composed of (N x N y N z ) Yee cells.

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 eld components have a specic arrangement in the Yee
cell, as demonstrated in Fig. 1.5. The electric eld vector components are placed at the centers
of the edges of the Yee cells and oriented parallel to the respective edges, and the magnetic eld
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).

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Three-Dimensional FDTD

15

to the respective faces. This provides a simple picture of three-dimensional space being lled
by an interlinked array of Faradays law and Amperes law contours. It can be easily noticed in
Fig. 1.5 that each magnetic eld vector is surrounded by four electric eld vectors that are curling
around the magnetic eld vector, thus simulating Faradays law. Similarly, if the neighboring cells
are also added to the picture, it would be apparent that each electric eld vector is surrounded
by four magnetic eld vectors that are curling around the electric eld vector, thus simulating
Amperes law.
Figure 1.5 shows the indices of the eld 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 eld components with respect to an origin coinciding with the position of the
node (1, 1, 1) can easily be calculated as
E x (i, j, k) ((i 0.5)x, ( j 1)y, (k 1)z),
E y (i, j, k) ((i 1)x, ( j 0.5)y, (k 1)z),
E z (i, j, k) ((i 1)x, ( j 1)y, (k 0.5)z),
Hx (i, j, k) ((i 1)x, ( j 0.5)y, (k 0.5)z),
Hy (i, j, k) ((i 0.5)x, ( j 1)y, (k 0.5)z),
Hz (i, j, k) ((i 0.5)x, ( j 0.5)y, (k 1)z).
The FDTD algorithm samples and calculates the elds at discrete time instants; however, the electric and magnetic eld components are not sampled at the same time instants.
For a time-sampling period t, the electric eld components are sampled at time instants
0, t, 2t, . . . , nt, . . . ; however, the magnetic eld components are sampled at time instants
1
t, (1 + 12 )t, . . . , (n + 12 )t, . . . . Therefore, the electric eld components are calculated at in2
teger time steps, and magnetic eld components are calculated at half-integer time steps, and they
are offset from each other by t/2. The eld components need to be referred by not only their spatial 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 eld 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 eld 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 eld components; therefore, they are
indexed the same as their respective eld 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 eld components in both time
and space, Maxwells curl equations (1.4) that are given in scalar form can be expressed in terms
of nite differences. For instance, consider again (1.4a):
Ex
1
=
t
x


Hz Hy
e

x E x Ji x .
y
z

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

16

October 13, 2009

Introduction to FDTD

Figure 1.6 Material parameters indexed on a Yee cell.

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 eld component
positions given in Fig. 1.7, we can write

Figure 1.7 Field components around E x (i, j, k).

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Three-Dimensional FDTD

17
n+ 12

1
Hz
E xn+1 (i, j, k) E xn (i, j, k)
=
t
x (i, j, k)

n+ 12

Hy
1

x (i, j, k)

n+ 12

(i, j, k) Hz
y

(i, j 1, k)

n+ 12

(i, j, k) Hy
z

(i, j, k 1)

xe (i, j, k) n+ 12
1
n+ 1
E x (i, j, k)
Ji x 2 (i, j, k).
x (i, j, k)
x (i, j, k)

(1.20)

It has already been mentioned that the electric eld components are dened at integer time steps;
however, the right-hand side of (1.20) includes an electric eld 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
n+ 12

Ex

(i, j, k) =

E xn+1 (i, j, k) + E xn (i, j, k)


.
2

(1.21)

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
2x (i, j, k) + txe (i, j, k) n+1
2x (i, j, k) txe (i, j, k) n
E x (i, j, k) =
E x (i, j, k)
2x (i, j, k)
2x (i, j, k)
 n+ 1

t
n+ 1
+
Hz 2 (i, j, k) Hz 2 (i, j 1, k)
x (i, j, k)y
 n+ 1

t
n+ 1
Hy 2 (i, j, k) Hy 2 (i, j, k 1)

x (i, j, k)z

t
n+ 1
Ji x 2 (i, j, k).
x (i, j, k)

(1.22)

After some manipulations, we get


E xn+1 (i, j, k) =

2x (i, j, k) txe (i, j, k) n


E (i, j, k)
2x (i, j, k) + txe (i, j, k) x
 n+ 1

2t
n+ 12
2

H
(i,
j,
k)

H
(i,
j

1,
k)
+
z
z
2x (i, j, k) + txe (i, j, k) y
 n+ 1

2t
n+ 12
2

H

(i,
j,
k)

H
(i,
j,
k

1)
y
y
2x (i, j, k) + txe (i, j, k) z

2t
n+ 1
Ji x 2 (i, j, k).
e
2x (i, j, k) + tx (i, j, k)

(1.23)

The form of (1.23) demonstrates how the future value of an electric eld component can be
calculated by using the past values of the electric eld component, the magnetic eld components, 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

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

18

Introduction to FDTD

Figure 1.8 Field components around H x (i, j, k).

(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 eld components following the
same methodology. However, while applying the central difference formula to the time derivative
of the magnetic eld components, the central point in time shall be taken as nt. For instance,
(1.4c), which is


1 Ey
Ez
Hx
=

xm Hx Mi x ,
t
x
z
y
can be approximated using nite differences based on the eld positions (as shown in
Fig. 1.8) as
n+ 12

Hx

n 12

(i, j, k) Hx
t

(i, j, k)

E yn (i, j, k + 1) E yn (i, j, k)
1
x (i, j, k)
z

E zn (i, j + 1, k) E zn (i, j, k)
1
x (i, j, k)
y

xm (i, j, k) n
1
H (i, j, k)
Mn (i, j, k).
x (i, j, k) x
x (i, j, k) i x
n+ 1

(1.24)

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
n+ 12

Hx

(i, j, k) =

2x (i, j, k) txm (i, j, k) n 12


Hx (i, j, k)
2x (i, j, k) + txm (i, j, k)
 n

2t
n

E
(i,
j,
k
+
1)

E
(i,
j,
k)
+
y
y
2x (i, j, k) + txm (i, j, k) z

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Three-Dimensional FDTD

19


 n
2t


E z (i, j + 1, k) E zn (i, j, k)
m
2x (i, j, k) + tx (i, j, k) y

2t
Mn (i, j, k).
2x (i, j, k) + txm (i, j, k) i x

(1.25)

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 nite differences and can be arranged to
construct the following six FDTD updating equations for the six components of electromagnetic
elds by introduction of respective coefcient terms:
E xn+1 (i, j, k) = Ce xe (i, j, k) E xn (i, j, k)
 n+ 1

n+ 1
+ Ce xhz (i, j, k) Hz 2 (i, j, k) Hz 2 (i, j 1, k)
 n+ 1

n+ 1
+ Ce xhy (i, j, k) Hy 2 (i, j, k) Hy 2 (i, j, k 1)
n+ 12

+ Ce x j (i, j, k) Ji x

(i, j, k),

(1.26)

where
Ce xe (i, j, k) =

2x (i, j, k) txe (i, j, k)


,
2x (i, j, k) + txe (i, j, k)

2t

Ce xhz (i, j, k) = 
,
2x (i, j, k) + txe (i, j, k) y
2t

Ce xhy (i, j, k) = 
,
2x (i, j, k) + txe (i, j, k) z
Ce x j (i, j, k) =

2t
.
2x (i, j, k) + txe (i, j, k)

E yn+1 (i, j, k) = Ce ye (i, j, k) E yn (i, j, k)


 n+ 1

n+ 1
+ Ce yhx (i, j, k) Hx 2 (i, j, k) Hx 2 (i, j, k 1)
 n+ 1

n+ 1
+ Ce yhz (i, j, k) Hz 2 (i, j, k) Hz 2 (i 1, j, k)
n+ 12

+ Ce y j (i, j, k) Ji y

(i, j, k),

(1.27)

where
Ce ye (i, j, k) =

2 y (i, j, k) t 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

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

20

Introduction to FDTD

2t

Ce yhz (i, j, k) = 
,
2 y (i, j, k) + t ye (i, j, k) x
Ce y j (i, j, k) =

2t
.
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
Ce ze (i, j, k) =

2z (i, j, k) tze (i, j, k)


2z (i, j, k) + tze (i, j, k),

2t

Ce zhy (i, j, k) = 
,
2z (i, j, k) + tze (i, j, k) x
Ce zhx (i, j, k) = 
Ce zj (i, j, k) =
n+ 12

Hx

2t

,
2z (i, j, k) + tze (i, j, k) y

2t
.
2z (i, j, k) + tze (i, j, k)
n 12

(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)
+ C hxm (i, j, k) Minx (i, j, k),

where
C hxh (i, j, k) =

2x (i, j, k) txm (i, j, k)


,
2x (i, j, k) + txm (i, j, k)

2t

C hxe y (i, j, k) = 
,
2x (i, j, k) + txm (i, j, k) z
C hxe z (i, j, k) = 
C hxm (i, j, k) =

2t

,
2x (i, j, k) + txm (i, j, k) y

2t
.
2x (i, j, k) + txm (i, j, k)

(1.29)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Three-Dimensional FDTD
n+ 12

Hy

21
n 1

(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
C hyh (i, j, k) =

2 y (i, j, k) t ym (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
C hye x (i, j, k) = 
C hym (i, j, k) =
n+ 12

Hz

2t

,
2 y (i, j, k) + t ym (i, j, k) z

2t
.
2 y (i, j, k) + t ym (i, j, k)
n 12

(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
C hzh (i, j, k) =

2z (i, j, k) tzm (i, j, k)


,
2z (i, j, k) + tzm (i, j, k)

2t

C hze x (i, j, k) = 
,
2z (i, j, k) + tzm (i, j, k) y
2t

C hze y (i, j, k) = 
,
2z (i, j, k) + tzm (i, j, k) x
C hzm (i, j, k) =

2t
.
2z (i, j, k) + tzm (i, j, k)

It should be noted that the rst two subscripts in each coefcient refer to the corresponding
eld component being updated. For three subscripts coefcients, the third subscript refers to
the type of the eld or source (electric or magnetic) that this coefcient is multiplied by. For
four subscripts coefcients, the third and fourth subscripts refer to the type of the eld that this
coefcient is multiplied by.
Having derived the FDTD updating equations, a time-marching algorithm can be constructed
as illustrated in Fig. 1.9. The rst step in this algorithm is setting up the problem spaceincluding
the objects, material types, and sourcesand dening any other parameters that will be used during
the FDTD computation. Then the coefcient terms appearing in (1.26)(1.31) can be calculated
and stored as arrays before the iteration is started. The eld components need to be dened as
arrays as well and shall be initialized with zeros since the initial values of the elds in the problem

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

22

Introduction to FDTD

Start

Set problem space and define parameters


Compute field coefficients

Update magnetic field components


at time instant (n+0.5)t

Update electric field components


at time instant (n+1)t

Output data

Apply boundary conditions


Increment time step, n

No

Yes
Stop

n+1

Last iteration?

Figure 1.9 Explicit FDTD procedure.

space in most cases are zeros, and elds will be induced in the problem space due to sources as the
iteration proceeds. At every step of the time-marching iteration the magnetic eld components
are updated for time instant (n + 0.5)t using (1.29)(1.31); then the electric eld components
are updated for time instant (n + 1)t using (1.26)(1.28). The problem space has a nite size, and
specic boundary conditions can be enforced on the boundaries of the problem space. Therefore,
the eld 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 elds are updated and boundary conditions are enforced, the current values of any desired eld
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.
1.4 FDTD UPDATING EQUATIONS FOR TWO-DIMENSIONAL PROBLEMS

The FDTD updating equations given in (1.26)(1.31) can be used to solve three-dimensional
problems. In the two-dimensional case where there is no variation in the problem geometry and

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Two-Dimensional FDTD

23

eld distributions in one of the dimensions, a simplied set of updating equations can be obtained
starting from the Maxwells 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
e
(1.32a)
=
x E x Ji x ,
t
x y


Ey
Hz
1

(1.32b)
=
ye E y Ji y ,
t
y
x


Ez
1 Hy
Hx
(1.32c)
=

ze E z Ji z ,
t
z x
y


Ez
Hx
1
m

(1.32d)
=
x Hx Mi x ,
t
x
y


Hy
1 Ez
m
(1.32e)
=
y Hy Mi y ,
t
y x


Ey
Hz
1 Ex
m
(1.32f)
=

z Hz Mi z .
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 rst set(1.32a), (1.32b), and (1.32f )all the electric eld components are transverse to
the reference dimension z; therefore, this set of equations constitutes the transverse electric to z
caseT E z . In the second set(1.32c), (1.32d), and (1.32e)all the magnetic eld components are
transverse to the reference dimension z; therefore, this set of equations constitutes the transverse
magnetic to z caseT Mz . Most two-dimensional problems can be decomposed into two separate
problems, each including separate eld 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 eld 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 ),

where
Ce xe (i, j ) =

2x (i, j ) txe (i, j )


,
2x (i, j ) + txe (i, j )

2t

Ce xhz (i, j ) = 
,
2x (i, j ) + txe (i, j ) y
Ce x j (i, j ) =

2t
.
2x (i, j ) + txe (i, j )

(1.33)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

24

Introduction to FDTD

Figure 1.10 Two-dimensional TEz FDTD field components.

 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
Ce ye (i, j ) =

2 y (i, j ) t 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
.
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 ),
Ce y j (i, j ) =

where
C hzh (i, j ) =

2z (i, j ) tzm (i, j )


,
2z (i, j ) + tzm (i, j )

2t

C hze x (i, j ) = 
,
2z (i, j ) + tzm (i, j ) y

(1.35)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Two-Dimensional FDTD

25

Figure 1.11 Two-dimensional T M z FDTD field components.

C hze y (i, j ) = 
C hzm (i, j ) =

2t

,
2z (i, j ) + tzm (i, j ) x

2t
.
2z (i, j ) + tzm (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 coefcients 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 eld
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)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

26

Introduction to FDTD

where
Ce ze (i, j ) =

2z (i, j ) tze (i, j )


,
2z (i, j ) + tze (i, j )

2t

Ce zhy (i, j ) = 
,
2z (i, j ) + tze (i, j ) x
2t

Ce zhx (i, j ) = 
,
2z (i, j ) + tze (i, j ) y
Ce zj (i, j ) =
n+ 12

Hx

n 12

(i, j ) = C hxh (i, j ) Hx

2t
.
2z (i, j ) + tze (i, j )



(i, j ) + C hxe z (i, j ) E zn (i, j + 1) E zn (i, j )

+ C hxm (i, j ) Minx (i, j ),

(1.37)

where
C hxh (i, j ) =

2x (i, j ) txm (i, j )


,
2x (i, j ) + txm (i, j )

2t

C hxe z (i, j ) = 
,
2x (i, j ) + txm (i, j ) y
C hxm (i, j ) =
n+ 12

Hy

n 12

(i, j ) = C hyh (i, j ) Hy

2t
.
2x (i, j ) + txm (i, j )


(i, j ) + C hye z (i, j ) E zn (i + 1, j ) E zn (i, j )

+ C hym (i, j ) Miny (i, j ),

(1.38)

where
C hyh (i, j ) =

2 y (i, j ) t ym (i, j )
2 y (i, j ) + t ym (i, j )

2t

C hye z (i, j ) = 
,
2 y (i, j ) + t ym (i, j ) x
C hym (i, j ) =

2t
.
2 y (i, j ) + t ym (i, j )

1.5 FDTD UPDATING EQUATIONS FOR ONE-DIMENSIONAL PROBLEMS

In the one-dimensional case there is no variation in the problem geometry and eld distributions
in two of the dimensions. For instance, if the y and z dimensions have no variation, the derivative with respect to the y and z dimensions vanish in Maxwells curl equations. Therefore, the

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

One-Dimensional FDTD

27

Figure 1.12 One-dimensional FDTDpositions of field components E y and H z .

two-dimensional curl equations (1.32a)(1.32f ) reduce to



Ex
1 e
=
x E x Ji x ,
t
x


Ey
Hz
1
e

=
y E y Ji y ,
t
y
x


Ez
1 Hy
e
=
z E z Ji z ,
t
z x

Hx
1  m
x Hx Mi x ,
=
t
x


Hy
1 Ez
m
=
y Hy Mi y ,
t
y x


Ey
Hz
1
m

=
z Hz Mi z .
t
z
x

(1.39a)
(1.39b)
(1.39c)
(1.39d)
(1.39e)
(1.39f)

It should be noted that (1.39a) and (1.39d) include time derivatives but not space derivatives.
Therefore, these equations do not represent propagating elds, hence the eld components E x and
Hx , which only exist in these two equations, do not propagate. The other four equations represent
propagating elds, and both the electric and magnetic eld components existing in these equations
are transverse to the x dimension. Therefore, transverse electric and magnetic to x (T E Mx ) elds
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 eld 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
Ce ye (i) =

2 y (i) t ye (i)
2 y (i) + t ye (i)

2t

Ce yhz (i) = 
,
2 y (i) + t ye (i) x
Ce y j (i) =

2t
,
2 y (i) + t ye (i)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

28

Introduction to FDTD

Figure 1.13 One-dimensional FDTD positions of field components E z and H y .

and
n+ 12

Hz

n 12

(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
C hzh (i) =

2z (i) tzm (i)


,
2z (i) + tzm (i)

2t

C hze y (i) = 
,
2z (i) + tzm (i) x
C hzm (i) =

2t
.
2z (i) + tzm (i)

Similarly, FDTD updating equations can be obtained for (1.39c) and (1.39e) using the central difference formula based on the eld 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
Ce ze (i) =

2z (i) tze (i)


2z (i) + tze (i),

2t

Ce zhy (i) = 
,
2z (i) + tze (i) x
Ce zj (i) =

2t
,
2z (i) + tze (i)

and
n+ 12

Hy

n 12

(i) = C hyh (i) Hy



(i) + C hye z (i) E zn (i + 1) E zn (i) + C hym (i) Miny (i),

(1.43)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

One-Dimensional FDTD

29

Figure 1.14 (a) Snapshots of a one-dimensional FDTD simulation: fields observed after 100 time steps.

where
C hyh (i) =

2 y (i) t ym (i)
2 y (i) + t ym (i)

2t

C hye z (i) = 
,
2 y (i) + t ym (i) x
C hym (i) =

2t
.
2 y (i) + t ym (i)

A MATLAB code is given in Appendix A for a one-dimensional FDTD implementation based


on the updating equations (1.42) and (1.43). The code calculates electric and magnetic eld
components generated by a z-directed current sheet, Jz , placed at the center of a problem space
lled with air between two parallel, perfect electric conductor (PEC) plates extending to innity in
the y and z dimensions. Figure 1.14 shows snapshots of E z and Hy within the FDTD computational
domain-demonstrating the propagation of the elds and their reection from the PEC plates at
the left and right boundaries.
In the demonstrated problem, the parallel plates are 1 m apart. The one-dimensional problem
space is represented by cells having width x = 1 mm. The current sheet at the center excites a
current with 1 A/m2 density and Gaussian waveform
Jz (t) = e



10 2
t21011
510

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

30

October 13, 2009

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.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

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 103 A/m. The surface current density
causes a discontinuity in magnetic eld and generates Hy , which satises 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 104 A/m. Since the elds are propagating in free space, the magnitude
of the generated electric eld is 0 5 104 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 eld positioning scheme
given in Fig. 1.13, where the E z components are dened at node positions and the Hy components
are dened 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 eld component (E z in this
case) vanishes on the PEC surface. Therefore, this condition can be enforced on the electric eld
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 elds from time step 650 to 700 in Fig. 1.14 reveals the correct behavior of
the incident and reected waves for a PEC plate. This is evident by the reversal of the direction
of the peak value of E z after reection from the PEC boundaries, which represents a reection
coefcient equal to 1 while the behavior of the reected Hy component represents the reection
coefcient that is equal to +1 as expected.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

32

October 13, 2009

Introduction to FDTD

1.6 EXERCISES

1.1

Follow the steps presented in Section 1.2 to develop the appropriate approximations for the
rst 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 gures 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
eld 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 eld. Pay
sufcient attention to the selection of the indices of each individual eld 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
eld components.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

2
Numerical Stability and Dispersion
2.1 NUMERICAL STABILITY

The nite-difference time-domain (FDTD) algorithm samples the electric and magnetic elds 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.
2.1.1 Stability in Time Domain Algorithm

An important issue in designing a time-domain numerical algorithm is the stability condition. To


understand the stability concept, lets start with a simple wave equation:
u(x, t) u(x, t)
+
= 0,
t
x

u(x, t = 0) = u 0 (x),

(2.1)

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:
u(x, t) = u 0 (x t).

(2.2)

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 nite-difference scheme is used to
compute the derivatives, and the following equation is obtained:
n
u n ui+1
uin+1 uin1
+ i1
= 0.
2t
2x

33

(2.4)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

34

Numerical Stability and Dispersion

t
5/8

-5/8

n+5
/2

/2

/2

n+4
n+3
n+2

/8

5/8
/4

/2
/2

n+1

-/8

-5/8
/4
-/2

n-1
i-2

i-1

i+1

i+2

Figure 2.1 The timespace domain grid with error propagating with = 1/2.

After a simple manipulation, a time-domain numerical scheme can be derived such that

 n
n
uin+1 = uin1 + ui+1
,
ui1

t
.
x

(2.5)

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 lets 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.
2.1.2 CFL Condition for the FDTD Method

The numerical stability of the FDTD method is determined by the CFL condition, which
requires that the time increment t has a specic bound relative to the lattice space increments,

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Numerical Stability

35

n+5

n+3

n+4

n+1

n+2

n
n-1

x
i-2

i-1

i+1

i+2

Figure 2.2 The timespace domain grid with error propagating with = 1.

t
66

50

n+5
4

n+4
n+3
n+2

-25
8

-8
7

n+1

4
-8
4
-2

n
n-1

x
i-2

i-1

i+1

i+2

Figure 2.3 The timespace domain grid with error propagating with = 2.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

36

Numerical Stability and Dispersion

such that
t 
1
c (x)
2 +

1
1
(y)2

1
(z)2

(2.6)

where c is the speed of light in free space. Equation (2.6) can be rewritten as

c t

1
1
1
+
+
1.
2
2
(x)
(y)
(z)2

(2.7)

For a cubical spatial grid where x = y = z, the CFL condition reduces to
x
t .
c 3

(2.8)

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
t x/c

or

c t x.

(2.9)

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 elds 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 eld magnitude is captured at every time step and plotted in Fig. 2.4.
The spikes of the electric eld magnitude are due to the additive interference of the elds when
elds pass through the center of the problem space, and the nulls are due to the vanishing of
electric elds on PEC when the elds hit the PEC boundary walls. However, while the iterations
proceed, the electric eld 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 inuenced
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.

14:16

SPIB005-Elsherbeni & Demir

October 13, 2009

Numerical Dispersion

37

3
t = 3.3356 ps
t = 3.3357 ps

2.5
maximum Ez [V/m]

fdtd_main

1.5

0.5

0
0

3
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.
2.2 NUMERICAL DISPERSION

The FDTD method provides a solution for the behavior of elds that is usually a good approximation to the real physical behavior of the elds. The nite-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
E z (x, t) = E0 cos(kx x t),

(2.10a)

Hy (x, t) = H0 cos(kx x t).

(2.10b)

Here E z (x, t) satises the wave equation


2
2
E

E z = 0.
z
0
0
x2
t 2

(2.11)

Substituting (2.10a) in (2.11) yields the equation


kx2 = 2 0 0 =

 2
c

(2.12)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

38

Numerical Stability and Dispersion

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 nite difference approximation of Maxwells curl equations as follows. For the onedimensional case previously discussed, the plane wave expressions E z (x, t) and Hy (x, t) satisfy the
Maxwells one-dimensional curl equations, which are given for the source-free region as
1 Hy
Ez
=
,
t
0 x

(2.13a)

Hy
1 Ez
=
.
t
0 x

(2.13b)

These equations can be rewritten using the central difference formula based on the eld positioning
scheme in Fig. 1.13 as
n+ 12

E zn+1 (i) E zn (i)


1 Hy
=
t
0
n+ 12

Hy

n 12

(i) Hy
t

(i)

n+ 12

(i) Hy
x

(i 1)

1 E zn (i + 1) E zn (i)
.
0
x

(2.14a)
(2.14b)

The plane wave equations (2.10) are in continuous time and space, and they can be expressed in
discrete time and space with
E zn (i) = E0 cos(kx ix nt),
E zn+1 (i) = E0 cos(kx ix (n + 1)t),

(2.15b)

+ 1) = E0 cos(kx (i + 1)x nt),

(2.15c)

E zn (i

n+ 12

(i) = H0 cos(kx (i + 0.5)x (n + 0.5)t),

(2.15d)

(i 1) = H0 cos(kx (i 0.5)x (n + 0.5)t),

(2.15e)

Hy
n+ 12

Hy

(2.15a)

n 12

Hy

(i) = H0 cos(kx (i + 0.5)x (n 0.5)t).

(2.15f)

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)].
0 x
Using the trigonometric identity
cos(u v) cos(u + v) = 2 sin(u) sin(v)

(2.16)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

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 righthand side with u = kx ix (n + 0.5)t and v = 0.5x, one can obtain
E0
H0
sin(0.5t) =
sin(0.5kx x).
t
0 x

(2.17)

Similarly, using the terms (2.15a), (2.15c), (2.15d), and (2.15f ) in (2.14b) leads to
E0
H0
sin(0.5t) =
sin(0.5kx x).
t
0 x

(2.18)

Combining (2.17) and (2.18) one can obtain the numerical dispersion relation for the onedimensional case as






1
1
t 2
kx x 2
=
.
(2.19)
sin
sin
c t
2
x
2
One should notice that the numerical dispersion relation (2.19) is different from the ideal dispersion relation (2.12). The difference means there is a deviation from the actual solution of a
problem and, hence, an error introduced by the nite-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 onedimensional case. It is possible to obtain a numerical dispersion relation for the two-dimensional
case using a similar approach:







ky y 2
1
1
1
t 2
kx x 2
=
+
,
(2.20)
sin
sin
sin
c t
2
x
2
y
2
where there is no variation of elds or geometry in the z dimension. For the particular case where
x = y = ,


t = ,
c 2

and

kx = k y ,

the ideal dispersion relation for the two-dimensional case can be recovered as
 2
kx2 + k2y =
.
c

(2.21)

The extension to the three-dimensional case is straightforward but tedious, yielding











ky y 2
t 2
kx x 2
kz z 2
1
1
1
1
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
(2.23)
kx2 + k2y + kz2 =
c
for specic choices of t, x, y, z, and angle of propagation.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

40

Numerical Stability and Dispersion

Figure 2.5 (a) Maximum magnitude of E z in the one-dimensional problem space: simulation with x = 1 mm.

Lets rewrite (2.22) in the following form:

sin(t/2)
2c (t/2)

kx sin(kx x/2)
=
2 (kx x/2)

ky sin(ky y/2)
+
2 (ky y/2)

kz sin(kz z/2)
+
2 (kz z/2)

2
.

(2.24)

Since limx0 (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 eld
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 eld

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

Exercises

October 13, 2009

41

Figure 2.5 (b) Maximum magnitude of E z in the one-dimensional problem space: simulation with x = 4 mm.

distribution at time instant 3 ns as calculated by the program when x = 1 mm and Jz = 1 A/m2 .


Similarly Fig. 2.5(b) shows the eld distribution at time instant 3 ns when x = 4 mm. In this
second simulation the magnitude of Jz is taken as 0.25 A/m2 to maintain the magnitude of the
surface current density K z as 1 103 A/m; hence, the magnitudes of electric and magnetic elds
are almost the same. Figure 2.5(a) shows that the Gaussian pulse is not distorted; even though
there is numerical dispersion, it is not signicant. However, in Fig. 2.5(b) the Gaussian pulse is
distorted due to use of a larger cell size, and the error introduced by numerical dispersion is more
pronounced.
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 propagates 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.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

3
Building Objects in the Yee Grid
In Chapter 1 we discussed the derivation of the nite-difference time-domain (FDTD) updating equations based on the staircased grid composed of Yee cells in Cartesian coordinates. We
dened material components , , e , and m associated with the eld components such that
they represent linear, anisotropic, nondispersive media. Due to the staircase gridding, the objects in an FDTD problem space can be represented in terms of the size of the cells building
the grid. Therefore, the staircased gridding imposes some restrictions on the accurate representation of the objects in the problem space. Some advanced modeling techniques called local
subcell models are available for dening objects with ne features, and some other FDTD formulations based on nonorthogonal and unstructured grids have been introduced for problems
that contain objects that do not conform with the staircased grid [1]. However, the staircased
FDTD model can provide sufciently accurate results for many practical problems. In this chapter we discuss construction of objects in the staircased FDTD grid through some MATLAB code
examples.

3.1 DEFINITION OF OBJECTS

Throughout this book, while describing the concepts of the FDTD method we illustrate the construction 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 problems of moderate difculty. In this chapter, we start to provide the blocks of a three-dimensional
FDTD program.
We name the main MATLAB program le 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 le is not in the nal 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 efcient 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 efcient while
writing their own code. However, we tried to be as explicit as possible while linking the FDTD
concepts with the respective codes.
43

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

44

October 13, 2009

Building Objects in the Yee Grid

Listing 3.1 fdtd solve.m



2

10

12

14

16

18

20

% i n i t i a l i z e the matlab workspace


clear all ; close all ; clc ;
% d e f i n e t h e problem
define problem space parameters ;
define geometry ;
define sources and lumped elements ;
define output parameters ;
% 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 ;
display problem space ;
display material mesh ;
if run simulation
initialize fdtd parameters and arrays ;
initialize sources and lumped elements ;
initialize updating coefficients ;
initialize boundary conditions ;
initialize output parameters ;
initialize display parameters ;
% FDTD t i m e m a r c h i n g l o o p
run fdtd time marching loop ;

22

24

% display simulation results


post process and display results ;

26

end

In the FDTD algorithm, before the time-marching iterations are performed the problem
should be set up as the rst step as indicated in the concise ow chart in Fig. 1.9. Problem setup
can be performed in two sets of routines: (1) routines that dene the problem; and (2) routines
that initialize the problem space and FDTD parameters. The problem denition 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 specic 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 coefcients, eld 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.
3.1.1 Defining the Problem Space Parameters

Listing 3.1 starts with the initialization of MATLAB workspace. The MATLAB command clear
all removes all items from the current workspace and frees the memory, close all deletes all open
gures, and clc clears the command window. After the MATLAB workspace initialization, there
are four subroutines listed in Listing 3.1 for denition of the problem and other subroutines

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

Definition of Objects

October 13, 2009

45

for initialization of the FDTD procedure. In this chapter, we implement the subroutines define 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
MATLABs command window. Here the string argument of disp indicates that the program is
executing the routine in which the problem space parameters are dened. 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 ) ;
% maximum number o f t i m e s t e p s t o run FDTD s i m u l a t i o n
number of time steps = 700;

% 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
courant factor = 0.9;

11

13

15

% 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;
% 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;
dy = 2.0 e 3;
dz = 2.2 e 3;

17

19

21

% ==<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
% 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
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

25

27

b o u n d a r y . t y p e x 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 x n = 5 ;
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

31

33

b o u n d a r y . t y p e y 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 y n = 5 ;
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

37

39

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 ;
%
%
%
%

===< 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
eps r
: relative permittivity
mu r
: relative permeability

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

46
43

October 13, 2009

Building Objects in the Yee Grid

% 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

47

49

51

53

55

57

% air
material
material
material
material
material

types
types
types
types
types

(1).
(1).
(1).
(1).
(1).

eps r
= 1;
mu r
= 1;
sigma e = 0;
sigma m = 0 ;
color
= [1 1 1];

% 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;
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 ;
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

61

63

65

67

69

71

% 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
material types ( 3 ) . eps r
= 1;
m a t e r i a l t y p e s ( 3 ) . mu r
= 1;
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 ;
material types ( 3 ) . color
= [0 1 0];
% a dielectric
material types
material types
material types
material types
material types

(4).
(4).
(4).
(4).
(4).

eps r
= 2.2;
mu r
= 1;
sigma e = 0;
sigma m = 0 . 2 ;
color
= [0 0 1];

% a dielectric
material types
material types
material types
material types
material types

(5).
(5).
(5).
(5).
(5).

eps r
= 3.2;
mu r
= 1.4;
sigma e = 0 . 5 ;
sigma m = 0 . 3 ;
color
= [1 1 0];

73

75

77

79

81

83

% i n d i c e s o f m a t e r i a l t y p e s d e f i n i n g a i r , PEC , and PMC


material type index air = 1;
material type index pec = 2;
material type index pmc = 3;

The total number of time steps that the FDTD time-marching iterations will run for is dened
in line 4 of Listing 3.2 with the parameter number of time steps. Line 8 denes 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 dened 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.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

Definition of Objects

October 13, 2009

47

On lines 14, 15, and 16 the dimensions of a unit cell constructing the uniform FDTD problem
grid are dened 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 elds propagating outside the nite problem space to innity. 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
2137 of Listing 3.2 the boundary types of these six faces are dened using a data structure called
boundary. The structure boundary has two types of elds: type and air buffer number of cells.
These eld names have extensions indicating the specic 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 eld type denes the type of the boundary under consideration, and in this case
all boundaries are dened as PEC by the keyword pec. Other types of boundaries are identied
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 lled with air, and the distance in between is given
in terms of the number of cells. Hence, the parameter air buffer number of cells denes 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 dene 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 4779 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 dened by its
electromagnetic parameters: relative permittivity r , relative permeability r , electric conductivity
e , and magnetic conductivity m ; hence, elds eps r, mu r, sigma e, and sigma m are used with
parameter material types(i), respectively, to dene 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 fth eld 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 gure. The eld 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 dening 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
dene 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.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

48

Building Objects in the Yee Grid

(a) Parameters defining a brick

(b) Parameters defining a sphere

Figure 3.1 Parameters defining a brick and a sphere in Cartesian coordinates.

3.1.2 Defining the Objects in the Problem Space

In the previous section we discussed the denition of some problem space parameters including
the boundary types and material types. In this section we discuss the implementation of the routine
define geometry contents, which are given in Listing 3.3. Different types of three-dimensional
objects can be placed in a problem geometry. We show example implementations using prisms and
spheres due to their geometrical simplicity, and it is possible to construct more complicated shapes
by using a combination of these simple objects. Here we will use the term brick to indicate a prism. A
brick, which has its faces parallel to the Cartesian coordinate axes, can be represented by two corner
points: (1) the point with lower x, y, and z coordinates; and (2) the point with upper x, y, and z
coordinates as illustrated in Fig. 3.1(a). Therefore, a structure array called bricks is used in Listing
3.3 together with the elds min x, min y, min z, max x, max y, and max z corresponding to their
respective positions in Cartesian coordinates. Each element of the array bricks is a brick object
indexed by i and is referred to by bricks(i). Another eld of the parameter bricks(i) is the parameter
material type, which refers to the index of the material type of the i th brick. In Listing 3.3
bricks(1).material type is 4, indicating that brick 1 is made of material types(4), which is dened
in Listing 3.2 as a dielectric with r = 2.2 and m = 0.2. Similarly, bricks(2).material type
is 2, indicating that brick 2 is made of material types(2), which is dened as a PEC.
A sphere can be dened by its center coordinates and radius as illustrated in Fig. 3.1(b). Therefore, a structure array spheres is used in Listing 3.3 together with the elds center x, center y,
center z, and radius which correspond to the respective parameters in Cartesian coordinates.
Similar to the brick case, the eld material type is used together with spheres(i) to dene the
material type of the i th sphere. For example, in Listing 3.3 two spheres are dened with coinciding
centers. Sphere 1 is a dielectric of material types(5) with a radius of 20 mm, and sphere 2 is a
dielectric of material types(1) with a radius of 15 mm. If these two spheres are created in the
problem space in sequence (sphere 1 rst and sphere 2 second), their combination is going to
form a hollow shell of thickness 5 mm since the material type of the inner sphere material types(1) is air. One should notice that Listing 3.3 starts with two lines dening two arrays, bricks
and spheres, and initializes them by null. Even though we are not going to dene an object
corresponding to some of these arrays, we still dene them and initialize them as empty arrays.
Later, when the program executes, these arrays will be accessed by some routines of the program.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

Definition of Objects

October 13, 2009

14:16

49

Listing 3.3 define geometry.m



d i s p ( d e f i n i n g t h e problem g e o m e t r y ) ;
2

10

12

bricks = [ ] ;
spheres = [ ] ;
% define a b r i c k with material type 4
b r i c k s ( 1 ) . min x = 0 ;
b r i c k s ( 1 ) . min y = 0 ;
b r i c k s ( 1 ) . min z = 0 ;
b r i c k s ( 1 ) . max x = 24 e 3;
b r i c k s ( 1 ) . max y = 20 e 3;
b r i c k s ( 1 ) . max z = 11 e 3;
bricks ( 1 ) . material type = 4;

14

16

18

20

22

24

26

28

% define a b r i c k with material type 2


b r i c k s ( 2 ) . m i n x = 20e 3;
b r i c k s ( 2 ) . m i n y = 20e 3;
b r i c k s ( 2 ) . m i n z = 11e 3;
b r i c k s ( 2 ) . max x = 0 ;
b r i c k s ( 2 ) . max y = 0 ;
b r i c k s ( 2 ) . max z = 0 ;
bricks ( 2 ) . material type = 2;
% define a
spheres ( 1 ) .
spheres ( 1 ) .
spheres ( 1 ) .
spheres ( 1 ) .
spheres ( 1 ) .

sphere with material type 5


radius
= 20 e 3;
center x = 0;
center y = 0;
c e n t e r z = 40 e 3;
material type = 5;

% define a
spheres ( 2 ) .
spheres ( 2 ) .
spheres ( 2 ) .
spheres ( 2 ) .
spheres ( 2 ) .

sphere with material type 1


radius
= 15 e 3;
center x = 0;
center y = 0;
c e n t e r z = 40 e 3;
material type = 1;

30

32

34

36

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 dene these arrays even
though they are empty.
So far we have dened an FDTD problem space and dened some objects existing in it.
Combining the denitions 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 dened in Listing 3.2. Furthermore, the objects are placed in
the three-dimensional space with the positions and dimensions as dened in Listing 3.3, and their
colors are set as their corresponding material type colors.

fdtd_main

SPIB005-Elsherbeni & Demir

50

October 13, 2009

Building Objects in the Yee Grid

Figure 3.2 An FDTD problem space and the objects defined in it.

3.2 MATERIAL APPROXIMATIONS

In a three-dimensional FDTD problem space the eld components are dened at discrete locations, and the associated material components are dened 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 lled 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
lled 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 lling the material cell, a simple weighted volume

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

Material Approximations

October 13, 2009

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.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

52

October 13, 2009

Building Objects in the Yee Grid

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
z (i, j, k) =

1 + 2 + 3 + 4 + 5 + 6 + 7 + 8
.
8

(3.1)

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.
3.3 SUBCELL AVERAGING SCHEMES FOR TANGENTIAL AND NORMAL COMPONENTS

The methods discussed thus far do not account for the orientation of the eld component associated with the material component under consideration with respect to the boundary interface
between two different media. For instance, Figs. 3.5 and 3.6 show two such cases where a material
cell is partially lled with two different types of media. In the rst case the material component
is parallel to the boundary of the two media, whereas in the second case the material component is normal to the boundary. Two different averaging schemes can be developed to obtain an
equivalent medium type to be assigned to the material component.
For instance, Amperes law can be expressed in integral form based on the conguration in
Fig. 3.5 as


d
 d s = d Dz (A1 + A2 ),

H dl =
D
dt
dt

Figure 3.5 Material component z (i, j, k) parallel to the boundary of two different media partially filling a
material cell.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Subcell Averaging Schemes

53

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 eld components in the two media are E z1 and E z2 . The total
electric ux through the cell cross-section can be expressed as
Dz (A1 + A2 ) = 1 E z1 A1 + 2 E z2 A2 = eff E z (A1 + A2 ),
where E z is the electric eld component (i, j, k), which is assumed to be uniform in the crosssection 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 eld are continuous such that
E z1 = E z2 = E z ; therefore, one can write
1 A1 + 2 A2 = eff (A1 + A2 ) eff = z (i, j, k) =

1 A1 + 2 A2
.
(A1 + A2 )

(3.2)

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
ux conservation is maintained.
For the case where the material component is normal to the media boundary we can employ
Faradayss law in integral form based on the conguration in Fig. 3.6, which reads

d
E dl =
dt

B d s

= x E x (i, j, k) + x E x (i, j + 1, k) + zE z (i, j, k) zE z (i + 1, j, k),

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

54

Building Objects in the Yee Grid

where E z is the equivalent electric eld 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
eld 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 eld terms shall satisfy
zE z (i, j, k) = (l 1 + l 2 ) E z (i, j, k) = l 1 E z1 + l 2 E z2 .

(3.3)

 are continuous such


On the boundary of the media the normal components of the electric ux D
that Dz1 = Dz2 = Dz (i, j, k); therefore, one can write
Dz (i, j, k) = 1 E z1 = 2 E z2 = eff E z (i, j, k),

(3.4)

which can be expressed in the form


E z1 =

Dz (i, j, k)
,
1

Dz (i, j, k)
,
2

E z2 =

E z (i, j, k) =

Dz (i, j, k)
.
eff

(3.5)

Using (3.5) in (3.3) and eliminating the terms Dz (i, j, k) yields


l1 + l2
l1
l2
1 2 (l 1 + l 2 )
.
=
+
eff = z (i, j, k) =
eff
1
2
(l 1 2 + l 2 1 )

(3.6)

Hence, an expression for the equivalent permittivity has been obtained in (3.6), by which the
magnetic ux conservation is maintained.
The averaging schemes given by (3.2) and (3.6) are specic 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
eff =

1 A1 + 2 A2
,
(A1 + A2 )

eff =

1 2 (l 1 + l 2 )
,
(l 1 2 + l 2 1 )

parallel to media boundary,

normal to media boundary.

(3.7a)
(3.7b)

These schemes serve as good approximations for low values of e and m as well, where they can
be written as
e
=
eff

1e A1 + 2e A2
,
(A1 + A2 )

e
=
eff

1e 2e (l 1 + l 2 )
,
(l 1 2e + l 2 1e )

parallel to media boundary,


e

normal to media boundary,

(3.8a)
(3.8b)

and
m
=
eff

1m A1 + 2m A2
,
(A1 + A2 )

m
=
eff

1m 2m (l 1 + l 2 )
,
(l 1 2m + l 2 1m )

m
m

parallel to media boundary,


normal to media boundary.

(3.9a)
(3.9b)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Objects in the Yee Grid

55

3.4 DEFINING OBJECTS SNAPPED TO THE YEE GRID

The averaging schemes provided in the previous section are usually discussed in the context of
subcell modeling techniques in which effective material parameter values are introduced while
the staircased gridding scheme is maintained. Although there are some other more advanced
subcell modeling techniques that have been introduced for modeling ne features in the FDTD
method, in this section we discuss modeling of three-dimensional objects assuming that the
objects are conforming to the staircased Yee grid. Therefore, each Yee cell is lled with a single material type. Although this assumption gives a crude model compared with the subcell
modeling techniques discussed before, we consider this case since it does not require complicated programming effort and since it is sufcient to obtain reliable results for many problems.
Furthermore, we still employ the aforementioned subcell averaging schemes for obtaining effective values for the material components lying on the boundaries of cells lled with different
material types.
For instance, consider Fig. 3.7, where the material component z (i, j, k) is located in between
four Yee cells, each of which is lled with a material type. Every Yee cell is indexed by a respective
node. Since every cell is lled with a material type, three-dimensional material arrays can be
utilized, each element of which corresponds to the material type lling the respective cell. For
instance, (i 1, j 1, k) holds the permittivity value of the material lling the cell (i 1, j
1, k). Consider the permittivity parameters that are indexed as (i 1, j 1, k), (i 1, j, k),
(i, j 1, k), and (i, j, k) in Fig. 3.7. The material component z (i, j, k) is tangential to the
four surrounding media types; therefore, we can employ (3.2) to get the equivalent permittivity
z (i, j, k) as
z (i, j, k) =

(i, j, k) + (i 1, j, k) + (i, j 1, k) + (i 1, j 1, k)
.
4

(3.10)

Since the electric conductivity material components are dened 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.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

56

Building Objects in the Yee Grid

Figure 3.8 Material component z (i, j, k) located between two Yee cells filled with two different material types.

electric conductivity ze (i, j, k) as


ze (i, j, k) =

e (i, j, k) + e (i 1, j, k) + e (i, j 1, k) + e (i 1, j 1, k)
.
4

(3.11)

Unlike the permittivity and electric conductivity components, the material components associated with magnetic eld 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)
.
(i, j, k) + (i, j, k 1)

(3.12)

2 m (i, j, k) m (i, j, k 1)
.
m (i, j, k) + m (i, j, k 1)

(3.13)

z (i, j, k) =
Similarly, we can write zm (i, j, k) as
zm (i, j, k) =
Defining Zero Thickness PEC Objects

In many electromagnetics problems, especially in planar circuits, some very thin objects exist, most
of the time in the form of microstrip or stripline structures. In these cases, when constructing an
FDTD simulation, it may not be feasible to choose the unit cell size as small as the thickness of
the strip, since this will lead to a very large number of cells and, hence to an excessive amount
of computer memory that prevents practical simulations with current computer resources. Then
if the cell size is larger than the strip thickness, subcell modeling techniques, some of which are
discussed in the previous sections, can be employed for accurate modeling of the thin strips in the
FDTD method. Usually the subcell modeling of thin strips is studied in the context of thin-sheet

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Creation of the Material Grid

57

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
e
, to these material components, such that
the conductivity of PEC, pec
e
xe (i, j, k) = pec
,

e
xe (i, j + 1, k) = pec
,

e
ye (i, j, k) = pec
,

and

e
ye (i + 1, j, k) = pec
.

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 sufcient 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 eld variation around a thin wire is large, the sampling of the elds 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.
3.5 CREATION OF THE MATERIAL GRID

At the beginning of this chapter we discussed how we can dene 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

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

58

October 13, 2009

Building Objects in the Yee Grid

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
coefcients.
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.
Listing 3.4 initialize fdtd material grid.m
d i s p ( i n i t i a l i z i n g FDTD m a t e r i a l g r i d ) ;
2

% 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
% 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 ;

10

12

14

16

% Array to s t o r e material type i n d i c e s for every c e l l


% i n t h e problem s p a c e . By d e f a u l t t h e s p a c e i s f i l l e d
% w i t h a i r by i n i t i a l i z i n g t h e a r r a y by o n e s
m a t e r i a l 3 d s p a c e = o n e s ( nx , ny , nz ) ;
% 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
% to material 3d space
% create spheres
create spheres ;

18

20

22

24

26

28

30

32

34

% create bricks
create bricks ;
% 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
eps r x
= o n e s ( nx
, nyp1 , nzp1 ) ;
eps r y
= o n e s ( nxp1 , ny
, nzp1 ) ;
eps r z
= o n e s ( nxp1 , nyp1 , nz ) ;
mu r x
= o n e s ( nxp1 , ny
, nz ) ;
mu r y
= o n e s ( nx
, nyp1 , nz ) ;
mu r z
= o n e s ( nx
, ny
, nzp1 ) ;
sigma e x
= z e r o s ( nx
, nyp1 , nzp1 ) ;
sigma e y
= z e r o s ( nxp1 , ny
, nzp1 ) ;
sigma e z
= z e r o s ( nxp1 , nyp1 , nz ) ;
sigma m x
= z e r o s ( nxp1 , ny
, nz ) ;
sigma m y
= z e r o s ( nx
, nyp1 , nz ) ;
sigma m z
= z e r o s ( nx
, ny
, nzp1 ) ;

36

38

40

% 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
calculate material component values ;
% 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 ;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Creation of the Material Grid

59

The rst 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 lled 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 lling 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 lled with air.
Listing 3.5 calculate domain size.m

d i s p ( c a l c u l a t i n g t h e number o f c e l l s i n t h e problem s p a c e ) ;
2

10

12

14

16

18

20

22

24

26

28

30

32

number of spheres = size ( spheres , 2 ) ;


number of bricks = size ( bricks , 2 ) ;
% f i n d t h e minimum and maximum c o o r d i n a t e s o f a
% box e n c a p s u l a t i n g t h e o b j e c t s
number of objects = 1;
f o r i =1: n u m b e r o f s p h e r e s
min x ( n u m b e r o f o b j e c t s ) = s p h e r e s ( i ) . c e n t e r
min y ( n u m b e r o f o b j e c t s ) = s p h e r e s ( i ) . c e n t e r
min z ( n u m b e r o f o b j e c t s ) = s p h e r e s ( i ) . c e n t e r
max x ( n u m b e r o f o b j e c t s ) = s p h e r e s ( i ) . c e n t e r
max y ( n u m b e r o f o b j e c t s ) = s p h e r e s ( i ) . c e n t e r
max z ( n u m b e r o f o b j e c t s ) = s p h e r e s ( i ) . c e n t e r
number of objects = number of objects + 1;
end
f o r i =1: n u m b e r o f b r i c k s
min x ( n u m b e r o f o b j e c t s ) = b r i c k s ( i ) . min x ;
min y ( n u m b e r o f o b j e c t s ) = b r i c k s ( i ) . min y ;
min z ( n u m b e r o f o b j e c t s ) = b r i c k s ( i ) . min z ;
max x ( n u m b e r o f o b j e c t s ) = b r i c k s ( i ) . max x ;
max y ( n u m b e r o f o b j e c t s ) = b r i c k s ( i ) . max y ;
max z ( n u m b e r o f o b j e c t s ) = b r i c k s ( i ) . max z ;
number of objects = number of objects + 1;
end
fdtd
fdtd
fdtd
fdtd
fdtd
fdtd

domain . min
domain . min
domain . min
d o m a i n . max
d o m a i n . max
d o m a i n . max

x
y
z
x
y
z

=
=
=
=
=
=

min ( m i n
min ( min
min ( m i n
max ( max
max ( max
max ( max

x
y
z
x
y
z

x
y
z
x
y
z

+
+
+

spheres
spheres
spheres
spheres
spheres
spheres

(
(
(
(
(
(

i
i
i
i
i
i

);
);
);
);
);
);

34

36

% 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
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 ;

).
).
).
).
).
).

radius
radius
radius
radius
radius
radius

;
;
;
;
;
;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

60
38

40

42

44

46

Building Objects in the Yee Grid

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
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
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
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
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

...
of
...
of
...
of
...
of
...
of

cells yn ;
cells zn ;
cells xp ;
cells yp ;
cells zp ;

48

50

52

54

56

% D e t e r m i n i n g t h e problem
fdtd domain . s i z e x = fdtd
fdtd domain . s i z e y = fdtd
fdtd domain . s i z e z = fdtd
% number o f c e l l s i n x ,
nx = round ( f d t d d o m a i n .
ny = round ( f d t d d o m a i n .
nz = round ( f d t d d o m a i n .

space s i z e
d o m a i n . max x f d t d d o m a i n . m i n x ;
d o m a i n . max y f d t d d o m a i n . m i n y ;
d o m a i n . max z f d t d d o m a i n . m i n z ;

y , and z
s i z e x / dx
s i z e y / dy
s i z e z / dz

directions
);
);
);

58

60

62

64

66

68

70

% a d j u s t domain
fdtd domain . s i z e
fdtd domain . s i z e
fdtd domain . s i z e

size
x =
y =
x =

by
nx
ny
nz

snapping to c e l l s
* dx ;
* dy ;
* dz ;

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 ;
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 ;
% some
nxp1 =
nxm1 =
nym2 =

f r e q u e n t l y used
nx +1;
nyp1 =
nx 1;
nxm2 =
ny 2;
nzm1 =

a u x i l i a r y parameters
ny +1;
nzp1 = nz +1;
nx 2;
nym1 = ny 1;
nz 1;
nzm2 = nz 2;

72

74

76

78

80

82

84

86

88

% c r e a t e a r r a y s s t o r i n g the center coor dinates of the c e l l s


f d t d d o m a i n . c e l l c e n t e r c o o r d i n a t e s x = z e r o s ( nx , ny , nz ) ;
f d t d d o m a i n . c e l l c e n t e r c o o r d i n a t e s y = z e r o s ( nx , ny , nz ) ;
f d t d d o m a i n . c e l l c e n t e r c o o r d i n a t e s z = z e r o s ( nx , ny , nz ) ;
f o r i n d = 1 : nx
f d t d d o m a i n . c e l l c e n t e r c o o r d i n a t e s x ( ind , : , : ) = . . .
( i n d 0 . 5 ) * dx + f d t d d o m a i n . m i n x ;
end
f o r i n d = 1 : ny
f d t d d o m a i n . c e l l c e n t e r c o o r d i n a t e s y ( : , ind , : ) = . . .
( i n d 0 . 5 ) * dy + f d t d d o m a i n . m i n y ;
end
f o r i n d = 1 : nz
fdtd domain . c e l l c e n t e r c o o r d i n a t e s z ( : , : , ind ) = . . .
( i n d 0 . 5 ) * dz + f d t d d o m a i n . m i n z ;
end

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Creation of the Material Grid

14:16

61

Listing 3.6 create spheres.m


disp ( c r e a t i n g spheres ) ;
2

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 ;
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 ;

10

12

14

f o r i n d =1: n u m b e r o f s p h e r e s
% 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 . . .
+ ( spheres ( ind ) . c e n t e r y cy ) . 2 . . .
+ ( spheres ( ind ) . c e n t e r z cz ) . 2 ) ;
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 ;
end
clear cx cy cz ;

After this point we nd the cells overlapping with the objects dened 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, rst 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 dened in define geometry. This means that if more than one object overlaps in the same cell, the object dened last will overwrite the objects dened before. So one should dene 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 changing the priorities would be sufcient to have the objects created in the desired sequence in the
problem space.
Listing 3.7 create bricks.m
1

disp ( c r e a t i n g b r i c k s ) ;
for ind = 1: number of bricks
% c o n v e r t b r i c k end c o o r d i n a t e s t o node i n d i c e s
b l x = round ( ( b r i c k s ( i n d ) . m i n x f d t d d o m a i n . m i n x ) / dx ) + 1 ;
b l y = round ( ( b r i c k s ( i n d ) . m i n y f d t d d o m a i n . m i n y ) / dy ) + 1 ;
b l z = round ( ( b r i c k s ( i n d ) . m i n z f d t d d o m a i n . m i n z ) / dz ) + 1 ;
bux = round ( ( b r i c k s ( i n d ) . max x f d t d d o m a i n . m i n x ) / dx ) + 1 ;
buy = round ( ( b r i c k s ( i n d ) . max y f d t d d o m a i n . m i n y ) / dy ) + 1 ;
buz = round ( ( b r i c k s ( i n d ) . max z f d t d d o m a i n . m i n z ) / dz ) + 1 ;

11

% a s s i g n material type of the b r i c k to the c e l l s


m a t e r i a l 3 d s p a c e ( b l x : bux 1 , b l y : buy 1 , b l z : buz 1) . . .
= b r i c k s ( ind ) . m a t e r i a l t y p e ;

13

15

end

fdtd_main

SPIB005-Elsherbeni & Demir

62

October 13, 2009

Building Objects in the Yee Grid

Figure 3.10 An FDTD problem space and the objects approximated by snapping to cells.

For example, the array material 3d space is lled with the material parameter indices of
the objects that were dened 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 eld component. This is due to the specic positioning
scheme of the eld components on the Yee cell as shown in Fig. 1.5. For instance, the distribution of
the x components of the electric eld, 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

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

Creation of the Material Grid

October 13, 2009

63

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.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

64

October 13, 2009

Building Objects in the Yee Grid

Since we have created and lled 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.
Listing 3.8 calculate material component values.m

d i s p ( f i l l i n g m a t e r i a l components a r r a y s ) ;
2

10

12

14

% 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
% 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 )
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 ;
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 ;
end
%
%
t
t

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
m u r ( f i n d ( t m u r = = 0 ) ) = 1e 20;
s i g m a m ( f i n d ( t s i g m a m = = 0 ) ) = 1e 20;

16

18

20

22

24

45

47

49

51

73

75

77

disp ( C a l c u l a t i n g e p s r x ) ;
% 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)
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 ) ) . . .
+ 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 ) ) . . .
+ 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 ) ;
% 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)
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 ) ) . . .
+ 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 ) ) . . .
+ 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 ) ;
% 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 ) = . . .
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 ) ) ) . . .
. / ( 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 ) ) ) ;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Creation of the Material Grid


96

98

100

102

14:16

65

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 )
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 ) ) . . .
. * 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 ) ) . . .
+ 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 dened bricks for zero thickness and assigns their materials
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 distribution 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.
Listing 3.9 create PEC plates.m
1

d i s p ( c r e a t i n g PEC p l a t e s on t h e m a t e r i a l g r i d ) ;

for ind = 1: number of bricks


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 ;

% convert coordinates to
b l x = round ( ( b r i c k s ( i n d ) .
b l y = round ( ( b r i c k s ( i n d ) .
b l z = round ( ( b r i c k s ( i n d ) .

11

node i n d i c e s
min x fdtd
min y fdtd
min z fdtd

on t h e FDTD g r i d
d o m a i n . m i n x ) / dx ) + 1 ;
d o m a i n . m i n y ) / dy ) + 1 ;
d o m a i n . m i n z ) / dz ) + 1 ;

bux = round ( ( b r i c k s ( i n d ) . max x f d t d d o m a i n . m i n x ) / dx ) + 1 ;


buy = round ( ( b r i c k s ( i n d ) . max y f d t d d o m a i n . m i n y ) / dy ) + 1 ;
buz = round ( ( b r i c k s ( i n d ) . max z f d t d d o m a i n . m i n z ) / dz ) + 1 ;

13

15

% 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 )
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 ;
end
i f ( b l y == buy )
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 ;
end
i f ( b l z == buz )
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 ;
end

17

19

21

23

25

27

29

end

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

66

Building Objects in the Yee Grid

(a) Relative permittivity components

(b) Relative permeability components


Figure 3.13 Material grid on three plane cuts.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Improved Eight-Subcell Averaging

67

3.6 IMPROVED EIGHT-SUBCELL AVERAGING

In Section 3.2 we described how any cell can be divided into eight subcells and how every material
parameter component is located in between eight surrounding cells as illustrated in Fig. 3.4.
A simple averaging scheme as (3.1) was used to nd an equivalent value for a given material
component. We can combine the averaging schemes discussed in Section 3.3 with the eightsubcell modeling scheme to obtain an improved approach for modeling the material components
in the FDTD grid.
Consider the eight subcells in Fig. 3.4, each of which is lled with a material type. We can
assume an equivalent permittivity p for the four subcells with permittivities 1 , 4 , 5 , and 8 ,
which can be calculated as p = 0.25 (1 + 4 + 5 + 8 ). Similarly, we can assume an equivalent
permittivity n for the four subcells with permittivities 2 , 3 , 6 , and 7 that can be calculated
as n = 0.25 (2 + 3 + 6 + 7 ). The permittivity component z (i, j, k) is located between the
half-cells lled with materials of permittivities p and n , and it is oriented normal to the boundaries
of these half-cells. Therefore, using (3.6) we can write
z (i, j, k) =

2 p n
.
p + n

(3.14)

The same approach can be used for parameter components permeability and for electric and
magnetic conductivities as well. Furthermore, it should be noted that the improved eight-subcell
averaging scheme presented here is based on the application of the more general approach for
eight subcells [8].
3.7 EXERCISES

3.1

The le fdtd solve is the main program used to run FDTD simulations. Open this subroutine and examine its contents. It calls several subroutines that are not implemented yet. In
the code disable the lines 7, 8, and 1427 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 dene 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. Dene 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. Dene 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 dene the problem geometry. Dene 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 les there are some additional les prepared as plotting routines that you can use together with your code. These routines are called in fdtd solve
after the denition 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 gure including a three-dimensional view of the geometry you have dened and another program named as Display Material Mesh that helps you
examine the material mesh created for the dened geometry. For instance, Fig. 3.14(b) shows
the relative permittivity distribution of the FDTD problem space in three plane cuts generated 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.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

68

October 13, 2009

Building Objects in the Yee Grid

(a) Geometry of the problem

(b) Relative permittivity distribution

Figure 3.14 The FDTD problem space of Exercise 3.1.

(a) Geometry of the problem


Figure 3.15 The FDTD problem space of Exercise 3.3.

(b) Electric conductivity distribution

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

Exercises

October 13, 2009

69

3.2

Consider the problem you constructed in Exercise 3.1. Now dene 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 rst 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 denition sequence of these two bricks in define geometry; dene the
second brick rst with index 1 and the rst 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 dening 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. Dene a brick as a PEC
plate with zero thickness placed between the coordinates given in millimeters as (0, 0, 0) and
(8, 8, 0). Dene 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. Dene a brick as a PEC
plate with zero thickness placed between the coordinates given in millimeters as (0, 0, 0) and
(3, 8, 0). Dene 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 dened are
different.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

4
Active and Passive Lumped
Elements
4.1 FDTD UPDATING EQUATIONS FOR 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 owing through these circuit elements can be represented
by the impressed current density term, Ji , in Maxwells curl equation

 = E + e E + Ji .
H
t

(4.1)

Impressed currents are used to represent sources or known quantities. In this sense, they are the
sources that cause the electric and magnetic elds 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 owing between these two nodes. This relationship can be
incorporated into Maxwells curl equation (4.1) by expressing E in terms of V using
E = V

(4.2)

and by expressing J in terms of I using the relation


J d s ,

I=

(4.3)

where S is the cross-sectional area of a unit cell normal to the ow 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 nite differences. Then, the nite-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 denition, initialization,
and simulation of these elements.
71

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

72

Active and Passive Lumped Elements

Figure 4.1 Field components around E z (i, j, k).


4.1.1 Voltage Source

In any electromagnetics simulation, one of the necessary components is the inclusion of sources.
Types of sources vary depending on the problem type; scattering problems require incident elds
from far zone sources, such as plane waves, to excite objects in a problem space, whereas many
other problems require near zone sources, which are usually in the forms of voltage or current
sources. In this section we derive updating equations that simulate the effects of a voltage source
present in the problem space.
Consider the scalar curl equation (1.4c) repeated here for convenience:


1 Hy
Hx
Ez
(4.4)
=

ze E z Ji z .
t
z x
y
This equation constitutes the relation between the current density Ji z owing in the z direction and
the electric and magnetic eld vector components. Application of the central difference formula
to the time and space derivatives based on the eld positioning scheme illustrated in Fig. 4.1 yields
n+ 12

E zn+1 (i, j, k) E zn (i, j, k)


1
Hy
=
t
z (i, j, k)

n+ 12

Hx
1

z (i, j, k)

n+ 12

(i, j, k) Hy
x

(i 1, j, k)

n+ 12

(i, j, k) Hx
y

(i, j 1, k)


ze (i, j, k)  n+1
E z (i, j, k) + E zn (i, j, k)
2z (i, j, k)

1
n+ 1
Ji z 2 (i, j, k).
z (i, j, k)

(4.5)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

FDTD Updating Equations for Lumped Elements

73

(a) Voltage source with internal resistance


(soft source)

(b) Voltage source without internal resistance (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 voltagecurrent relation for this circuit can be written as
I=

V + Vs
,
Rs

(4.6)

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
n+ 12

V = z E z

(i, j, k) = z

E zn+1 (i, j, k) + E zn (i, j, k)


,
2

(4.7)

in discrete form at time instant (n + 0.5)t. Current I is the current owing through the surface
enclosed by the magnetic eld 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

Ji z

(i, j, k) =



z
1
n+ 1
E zn+1 (i, j, k) + E zn (i, j, k) +
Vs 2 .
2xy Rs
xy Rs

(4.9)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

74

Active and Passive Lumped Elements

Equation (4.9) includes the voltagecurrent relation for a voltage source tying Vs and Rs to electric
eld 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 eld component E zn+1 can be calculated using other terms,
which yields our standard form updating equations such that
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 zs (i, j, k) Vs

(i, j, k),

(4.10)

where
Ce ze (i, j, k) =

2z (i, j, k) tze (i, j, k)


2z (i, j, k) + tze (i, j, k) +

Ce zhy (i, j, k) = 

tz
Rs xy
tz
Rs xy

2t
2z (i, j, k) + tze (i, j, k) +

Ce zhx (i, j, k) = 
Ce zs (i, j, k) = 

tz
Rs xy

2t
2z (i, j, k) + tze (i, j, k) +

tz
Rs xy

2t
2z (i, j, k) +

tze (i,

j, k) +

tz
Rs xy

x


y

(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 .
4.1.2 Hard Voltage Source

In some applications it may be desired that a voltage difference is enforced between two points in
the problem space. This can be achieved by using a voltage source without any internal resistances,
which is called a hard voltage source. For instance, Fig. 4.2(b) illustrates such a scenario, where a
voltage source with Vs volts magnitude is placed between the nodes (i, j, k) and (i, j, k + 1). The
FDTD updating equation for this voltage source can simply be obtained by letting Rs 0 in
(4.10), which can be written as
E zn+1 (i, j, k) = E zn (i, j, k)

2 n+ 12
Vs (i, j, k).
z

(4.11)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

FDTD Updating Equations for Lumped Elements

75

To conform with the general form of the FDTD updating equations, (4.11) can be expressed as
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 zs (i, j, k) Vs

(i, j, k),

(4.12)

where
Ce ze (i, j, k) = 1,

Ce zhy (i, j, k) = 0,

Ce zhx (i, j, k) = 0,

Ce zs (i, j, k) =

2
.
z

4.1.3 Current Source

Figure 4.3(a) illustrates a current source with Is amperes magnitude and Rs internal resistance,
where Is is a function of time with a time-varying waveform. The voltagecurrent relation for the
current source can be written as
I = Is +

(a) Current source with internal resistance

V
.
Rs

(4.13)

(b) Resistor

Figure 4.3 Lumped elements placed between nodes (i, j, k) and (i, j, k + 1).

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

76

Active and Passive Lumped Elements


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

Ji z

(i, j, k) =



z
1
n+ 1
Is 2 .
E zn+1 (i, j, k) + E zn (i, j, k) +
2xy Rs
xy

(4.14)

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
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 zs (i, j, k) Is

(i, j, k),

(4.15)

where
Ce ze (i, j, k) =

2z (i, j, k) tze (i, j, k)


2z (i, j, k) + tze (i, j, k) +

tz
Rs xy
tz
Rs xy

2t
Ce zhy (i, j, k) = 
2z (i, j, k) + tze (i, j, k) +

tz
Rs xy

2t
Ce zhx (i, j, k) = 
2z (i, j, k) + tze (i, j, k) +

tz
Rs xy

2t
Ce zs (i, j, k) = 
2z (i, j, k) + tze (i, j, k) +

tz
Rs xy

x


y

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
V
(i,
j,
k) term in
s
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 owing in
the positive z direction as indicated in Fig. 4.3(a). To model a current source with the opposite
ow 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

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

FDTD Updating Equations for Lumped Elements


n+ 12

Is

77

(i, j, k) in (4.15) to zero results the updating equation for a resistor as


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) ,

(4.16)

where
Ce ze (i, j, k) =

2z (i, j, k) tze (i, j, k)


2z (i, j, k) + tze (i, j, k) +

tz
Rxy
tz
Rxy

2t
Ce zhy (i, j, k) = 
2z (i, j, k) + tze (i, j, k) +
Ce zhx (i, j, k) = 

tz
Rxy

2t
2z (i, j, k) + tze (i, j, k) +

tz
Rxy

x


y

4.1.5 Capacitor

Figure 4.4(a) illustrates a capacitor with C farads capacitance. The voltagecurrent relation for
the capacitor can be written as
I =C

(a) Capacitor

d V
.
dt

(4.17)

(b) Inductor

Figure 4.4 Lumped elements placed between nodes (i, j, k) and (i, j, k + 1).

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

78

Active and Passive Lumped Elements

This relation can be expressed in discrete time and space as


1

I n+ 2 = C

V n+1 V n
.
t

(4.18)

Using V in (4.7) and I n+ 2 in (4.8) together with (4.18), one can obtain
n+ 12

Ji z

(i, j, k) =



Cz
E zn+1 (i, j, k) E zn (i, j, k) .
txy

(4.19)

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
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) ,

(4.20)

where
Ce ze (i, j, k) =

2z (i, j, k) tze (i, j, k) +


2z (i, j, k) + tze (i, j, k) +

2Cz
xy
2Cz
xy

2t
Ce zhy (i, j, k) = 
2z (i, j, k) + tze (i, j, k) +
Ce zhx (i, j, k) = 

2Cz
xy

2t
2z (i, j, k) + tze (i, j, k) +

2Cz
xy

x


y

4.1.6 Inductor

Figure 4.4(b) illustrates an inductor with L henrys inductance. The inductor is characterized by
the voltagecurrent relation
V=L

dI
.
dt

(4.21)

This relation can be expressed in discrete time and space using the central difference formula at
time instant nt as
V n =


L  n+ 1
1
I 2 I n 2 .
t

(4.22)

Using the discrete domain relation (4.7) and (4.8) one can obtain
n+ 12

Ji z

n 12

(i, j, k) = Ji z

(i, j, k) +

tz n
E (i, j, k).
Lxy z

(4.23)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

FDTD Updating Equations for Lumped Elements

79
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 eld1 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 modication, which is rewritten here for convenience as
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),

(4.24)

where
Ce ze (i, j, k) =

2z (i, j, k) tze (i, j, k)


,
2z (i, j, k) + tze (i, j, k)

2t

Ce zhy (i, j, k) = 
,
2z (i, j, k) + tze (i, j, k) x
Ce zhx (i, j, k) = 
Ce zj (i, j, k) =

2t

,
2z (i, j, k) + tze (i, j, k) y

2t
.
2z (i, j, k) + tze (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).
4.1.7 Lumped Elements Distributed over a Surface or within a Volume

In previous sections we have demonstrated the derivation of FDTD updating equations for
common lumped element circuit components. These components were assumed to be placed
between two neighboring nodes along the edge of a cell oriented in a certain direction (x, y, or z).
However, in some applications it may be desired to simulate a lumped element component
behavior over a surface or within a volume, which extends to a number of cells in the discrete space.
For instance, consider the voltage source in Fig. 4.5. Such a source can be used to feed a strip
with a uniform potential Vs across its cross-section at its edge. Similarly, a resistor is illustrated
in Fig. 4.5, which is distributed over a volume and maintains a resistance R between the top and
bottom strips. Similarly, the other types of lumped elements as well can be distributed over a
surface or a volume. In such cases, the lumped element behavior extends over a number of cells,
and the surfaces or volumes of the elements can be indicated by the indices of the nodes at the
lower points and upper points of the cell groups. For instance, the voltage source is indicated
by the nodes (vis , v j s , vks ) and (vie, v j e, vke), whereas the resistor is indicated by the nodes
(ris , r j s , rks ) and (rie, r j e, rke), as illustrated in Fig. 4.6.
The lumped element updating equations derived in previous sections still can be used to model
the elements distributed over a number of cells, but a modication of parameter values is required

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

80

Active and Passive Lumped Elements

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 eld 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 eld 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 eld component. Each individual voltage source in Fig. 4.6 then should be assigned a
voltage value Vs ,
Vs =

Vs
,
(vke vks )

(4.25)

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.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

FDTD Updating Equations for Lumped Elements

81

Rs shall be set as


Rs = Rs

(vie vis + 1) (v j e v j s + 1)
.
(vke vks )

(4.26)

Having applied these modications to Vs and Rs , the electric eld 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)
,
(rke rks )

R = R

(4.27)

and (4.16) can be used to update the electric eld 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 dened as
L = L

(ie is + 1) ( j e j s + 1)
,
(ke ks )

(4.28)

and (4.24) can be used to update the electric eld 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 dened as
C = C

(ke ks )
,
(ie is + 1) ( j e j s + 1)

(4.29)

and (4.19) can be used to update the electric eld 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 modifying Is and resistance Rs such that
Is =

Is
,
(ie is + 1) ( j e j s + 1)

(4.30)

and
Rs = Rs

(vie vis + 1) (v j e v j s + 1)
.
(vke vks )

(4.31)

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 reected 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 voltagecurrent relations in discrete time and space. However, one of the strengths of the

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

82

Active and Passive Lumped Elements

(a) Diode oriented in the positive


z direction

(b) Diode oriented in the negative 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 owing only in the positive z direction, as indicated by
direction of the current Id and characterized by the voltagecurrent relation
I = Id = I0 [e (q Vd /kT) 1],

(4.32)

where q is the absolute value of electron charge in coulombs, k is Boltzmanns constant, and T is
the absolute temperature in kelvins. This equation can be expressed in discrete form as
n+ 12

Ji z

(i, j, k) =

I0
n+1
n
[e (q z/2kT)(Ez (i, j,k)+Ez (i, j,k)) 1],
xy

(4.33)

where the relation Vd = V = zE z is used. Equation 4.33 can be used in (4.5), which yields
n+ 12

E zn+1 (i, j, k) E zn (i, j, k)


1
Hy
=
t
z (i, j, k)

n+ 12

Hx
1

z (i, j, k)

n+ 12

(i, j, k) Hy
x

(i 1, j, k)

n+ 12

(i, j, k) Hx
y

(i, j 1, k)


ze (i, j, k)  n+1
E z (i, j, k) + E zn (i, j, k)
2z (i, j, k)

I0
n+1
n
[e (q z/2kT)(Ez (i, j,k)+Ez (i, j,k)) 1].
z (i, j, k)xy

(4.34)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

FDTD Updating Equations for Lumped Elements

83

This equation can be expanded as


E zn+1 (i, j, k) +

ze (i, j, k)t n+1


e (i, j, k)t n
E z (i, j, k) = E zn (i, j, k) z
E (i, j, k)
2z (i, j, k)
2z (i, j, k) z
n+ 12

(i, j, k) Hy
x

n+ 12

(i, j, k) Hx
y

Hy
t
+
z (i, j, k)

Hx
t

z (i, j, k)

n+ 12

(i 1, j, k)

n+ 12

(i, j 1, k)

I0 t
n
n+1
e (q z/2kT)Ez (i, j,k) e (q z/2kT)Ez (i, j,k)
z (i, j, k)xy

I0 t
z (i, j, k)xy

(4.35)

and can be arranged in the following form


Ae Bx + x + C = 0,

(4.36)

where
x = E zn+1 (i, j, k),

A = Ce zd (i, j, k)e BEz (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),
Ce ze (i, j, k) =

2z (i, j, k) tze (i, j, k)


,
2z (i, j, k) + tze (i, j, k)

Ce zhy (i, j, k) = 

2t

,
2z (i, j, k) + tze (i, j, k) x

2t

Ce zhx (i, j, k) = 
,
2z (i, j, k) + tze (i, j, k) y
Ce zd (i, j, k) =

2t I0
.
2z (i, j, k)xy + tze (i, j, k)xy

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 eld 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 nding 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 nd the value of x that satises f (x) = 0. We can start with an initial guess x0 as shown
in the gure. The derivative of the function f (x) at point x0 is the slope of the tangential line

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

84

Active and Passive Lumped Elements

60
50

f (x) = 2x 10 + e0.4

f(x)

40

f (x0 )

f (x0 )

30
20

f (x1 )
f (x1 )

10

xn
0
1

x2
2

x1
5

x0
6

10

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
x1 = x0

f (x0 )
.
f  (x0 )

(4.37)

Then x1 can be used as the reference point, and a second point x2 can be obtained similarly by
x2 = x1

f (x1 )
.
f  (x1 )

(4.38)

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
| f (xn )| < ,

(4.39)

where is a very small positive number accepted as the error tolerance accepted for f (x) approximately 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 eld component

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

FDTD Updating Equations for Lumped Elements

85

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 voltagecurrent relation (4.32). A diode oriented in the negative z
direction, as shown in 4.7(b), can be characterized by the voltagecurrent relation
I = Id = I0 [e (q Vd /kT) 1]

(4.40)

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
x = E zn+1 (i, j, k),

A = Ce zd (i, j, k)e BEz (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),
Ce ze (i, j, k) =

2z (i, j, k) tze (i, j, k)


,
2z (i, j, k) + tze (i, j, k)

2t

Ce zhy (i, j, k) = 
,
2z (i, j, k) + tze (i, j, k) x
2t

Ce zhx (i, j, k) = 
,
2z (i, j, k) + tze (i, j, k) y
Ce zd (i, j, k) =

2t I0
.
2z (i, j, k)xy + tze (i, j, k)xy

Here, one should notice that only the coefcients B and Ce zd (i, j, k) are reversed when compared
with the respective coefcients of (4.36), and the rest of the terms are the same.
Due to the nonlinear nature of the diode voltagecurrent relation, it is not convenient to dene
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 modeling some common lumped element circuit components. We have shown the construction of

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

86

October 13, 2009

Active and Passive Lumped Elements

updating equations for components placed between two neighboring nodes and have illustrated 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 voltagecurrent relations, express them
in discrete time and space, and establish the relation between the impressed current densities and
the eld components. Then impressed current density terms can be used in the general form of
the updating equation to obtain the specic updating equations that model the lumped element
circuit under consideration.

4.2 DEFINITION, INITIALIZATION, AND SIMULATION OF LUMPED ELEMENTS

We discussed modeling of several types of lumped element components in the FDTD method in
previous sections. In this section we demonstrate the implementation of the aforementioned concepts in MATLAB. Furthermore, we show the implementation of other routines that initialize the
FDTD problem space, including some auxiliary parameters, eld arrays, and updating coefcient
arrays. Then the MATLAB workspace will be ready to run an FDTD simulation, and we show
how the FDTD time-marching loop can be implemented and some sample results of interest can
be obtained.
4.2.1 Definition of Lumped Elements

First we show the implementation of the denition of the lumped element components. As
discussed before, these components can be dened as prism-like objects distributed over a volume
in the FDTD problem space. Any prism-like object can be dened with its lower and upper
coordinates in the Cartesian coordinate system. Therefore, we dene the positions of the lumped
components the same as the brick object, as demonstrated in Section 3.1. Referring to the FDTD
solver main program fdtd solve, which is shown in Listing 3.1, the implementation of the denition
of lumped element components is done in the subroutine define sources and lumped elements, a
sample content of which is given as a template in Listing 4.1. As can be seen in Listing 4.1, the
structure arrays voltage sources, current sources, resistors, inductors, capacitors, and diodes
are dened to store the properties of the respective types of lumped components, and these arrays
are initialized as empty arrays. Similar to a brick, the positions and dimensions of these components
are indicated by the parameters min x, min y, min z, max x, max y, and max z. One should be
careful when dening the coordinates of diodes; as discussed in Section 4.8, we assume diodes as
objects having zero thickness in two dimensions.
Besides the parameters dening the positioning, some additional parameters as well are needed
to specify the properties of these components. The lumped element components are modeled in
FDTD by the way the respective electric eld components are updated due to the voltagecurrent
relations. These eld components that need specic updates are determined by the functional
directions of these components. For voltage sources, current sources, and diodes there are six directions in which they can be dened in the staircased FDTD grid: xn, xp, yn, yp, zn, or zp.
Here p refers to positive direction, whereas n refers to negative direction. The other lumped
elements (resistors, capacitors, and inductors) can be dened with the directions x, y, or z. The
other parameters needed to specify the lumped components are magnitude, resistance, inductance, and capacitance, which represent the characteristics of the lumped elements as shown in
Listing 4.1.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation of Lumped Elements

Listing 4.1 define sources and lumped elements.m



d i s p ( d e f i n i n g s o u r c e s and lumped e l e m e n t components ) ;
2

10

12

voltage sources = [ ] ;
current sources = [ ] ;
diodes = [ ] ;
resistors = [];
inductors = [ ] ;
capacitors = [ ] ;
% 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 ;
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

16

18

20

22

24

26

28

30

32

34

36

38

40

42

% voltage sources
% 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
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 ;
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;
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;
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;
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 ;
v o l t a g e s o u r c e s ( 1 ) . waveform index = 2;
% current sources
% 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
: amperes
c u r r e n t s o u r c e s ( 1 ) . m i n x = 30 * dx ;
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 ;
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 ;
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 ;
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 ;
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

46

48

50

% resistors
% direction :
% resistance
resistors (1).
resistors (1).
resistors (1).

x , y
: ohms
min x =
mi n y =
min z =

, or z
7 . 0 e 3;
0;
0;

87

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

88

52

54

resistors
resistors
resistors
resistors
resistors

Active and Passive Lumped Elements


(1).
(1).
(1).
(1).
(1).

max x = 8 . 0 e 3;
max y = 2 . 0 e 3;
max z = 4 . 0 e 3;
direction = z ;
r e s i s t a n c e = 50;

56

58

60

62

64

66

% inductors
% direction :
% inductance
inductors ( 1 ) .
inductors ( 1 ) .
inductors ( 1 ) .
inductors ( 1 ) .
inductors ( 1 ) .
inductors ( 1 ) .
inductors ( 1 ) .
inductors ( 1 ) .

x , y , or z
: henrys
m i n x = 30 * dx ;
m i n y = 10 * dy ;
m i n z = 10 * dz ;
max x = 36 * dx ;
max y = 10 * dy ;
max z = 13 * dz ;
direction = x ;
i n d u c t a n c e = 1e 9;

68

70

72

74

76

78

% capacitors
% d i r e c t i o n : x , y , or z
% capacitance : farads
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 ;
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 ;
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 ;
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

82

84

86

88

% diodes
% d i r e c t i o n : xp , xn , yp ,
d i o d e s ( 1 ) . m i n x = 30 * dx ;
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 ;
d i o d e s ( 1 ) . max x = 36 * dx ;
d i o d e s ( 1 ) . max y = 10 * dy ;
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 ;

yn ,

zp , o r zn

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 dene the parameters specic 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 denition 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 dened. In Listing 4.1 two elds are dened in the parameter
waveforms: sinusoidal and unit step. Later on we can add new parameters representing other

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

Simulation of Lumped Elements

October 13, 2009

14:16

89

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 specic 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 dened 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 parameters 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. Similarly, 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.
4.2.2 Initialization of FDTD Parameters and Arrays

Some constant parameters and auxiliary parameters are needed in various stages of an FDTD
program. These parameters can be dened in the subroutine initialize fdtd parameters and arrays, which is shown in Listing 4.2. The most frequently used ones of these parameters are
permittivity, permeability of free space, and speed of light in free space, which are represented in
the code with the parameters eps 0, mu 0, and c, respectively. Duration of a time step is denoted
by dt and is calculated based on the CFL stability limit (2.7) and the courant factor described
in Section 3.1.1. Once the duration of a time step is calculated, an auxiliary one-dimensional
array, time, of size number of time steps can be constructed to store the time instant values
Listing 4.2 initialize fdtd parameters and arrays.m
1

d i s p ( i n i t i a l i z i n g FDTD p a r a m e t e r s and a r r a y s ) ;
% 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
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

% Duration of a time s t e p in seconds


d t = 1 / ( c * s q r t ( ( 1 / dx 2 ) + ( 1 / dy 2 ) + ( 1 / dz 2 ) ) ) ;
dt = c o u r a n t f a c t o r * dt ;

11

13

15

% time a r r a y
time = ( [ 1 : n u m b e r o f t i m e s t e p s ] 0.5)* dt ;
% 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

19

21

23

Hx
Hy
Hz
Ex
Ey
Ez

=
=
=
=
=
=

zeros
zeros
zeros
zeros
zeros
zeros

( nxp1 , ny , nz ) ;
( nx , nyp1 , nz ) ;
( nx , ny , nzp1 ) ;
( nx , nyp1 , nzp1 ) ;
( nxp1 , ny , nzp1 ) ;
( nxp1 , nyp1 , nz ) ;

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

90

Active and Passive Lumped Elements

at the middle of the FDTD time steps. When a new simulation starts, the initial values of
electric and magnetic elds are zero. Therefore, the three-dimensional arrays representing
the vector components of the elds can be created and initialized using the MATLAB function 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 eld 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 dened to represent impressed
currents. The answer is that we do not need to dene 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 voltagecurrent relations for
the lumped element components and the nal 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 eld components
need to be updated using the inductor updating equations, it is sufcient to create auxiliary arrays
representing these impressed currents that have the limited size based on the number of eld
components associated with the respective inductors. The creation and initialization of these
arrays are performed in the subroutine where the updating coefcients of the lumped element
components are initialized.
4.2.3 Initialization of Lumped Element Components

We have shown templates for dening some types of source waveforms, voltage and current
sources, and other lumped element components. The initialization of these components is performed in initialize sources and lumped elements as shown in Listing 4.3.
Listing 4.3 initialize sources and lumped elements.m

1

d i s p ( i n i t i a l i z i n g s o u r c e s and lumped e l e m e n t components ) ;


number
number
number
number
number
number

of voltage sources
= size ( voltage sources , 2 ) ;
of current sources
= size ( current sources , 2 ) ;
of resistors
= size ( resistors , 2 ) ;
of inductors
= size ( inductors , 2 ) ;
of capacitors = size ( capacitors , 2 ) ;
of diodes
= s i z e ( diodes , 2 ) ;

11

13

15

17

19

21

% i n i t i a l i z e waveforms
initialize waveforms ;
% 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
i s = round ( ( v o l t a g e s o u r c e s ( i n d ) . m i n
j s = round ( ( v o l t a g e s o u r c e s ( i n d ) . m i n
k s = round ( ( v o l t a g e s o u r c e s ( i n d ) . m i n
i e = round ( ( v o l t a g e s o u r c e s ( i n d ) . max
j e = round ( ( v o l t a g e s o u r c e s ( i n d ) . max
ke = round ( ( v o l t a g e s o u r c e s ( i n d ) . max
v o l t a g e s o u r c e s ( ind ) . i s = i s ;

x
y
z
x
y
z

fdtd
fdtd
fdtd
fdtd
fdtd
fdtd

domain . min
domain . min
domain . min
domain . min
domain . min
domain . min

x
y
z
x
y
z

) / dx ) + 1 ;
) / dy ) + 1 ;
) / dz ) + 1 ;
) / dx ) + 1 ;
) / dy ) + 1 ;
) / dz ) + 1 ;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation of Lumped Elements


voltage
voltage
voltage
voltage
voltage

23

25

sources
sources
sources
sources
sources

( ind
( ind
( ind
( ind
( ind

91
).
).
).
).
).

js
ks
ie
je
ke

=
=
=
=
=

js ;
ks ;
ie ;
je ;
ke ;

27

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
n fields = ie is ;
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
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 ) ;
case z
n f i e l d s = 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 + j e j s ) / ( ke k s ) ;
end
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 = . . .
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
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 ;
end
v o l t a g e s o u r c e s ( ind ) . resistance per component = . . .
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 ;

29

31

33

35

37

39

41

43

45

47

% c o p y waveform o f t h e waveform t y p e t o waveform o f t h e s o u r c e


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 ; ] ;
eval ( e v a l s t r ) ;
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 f i e l d = . . .
v m a g n i t u d e f a c t o r * a waveform ;
v o l t a g e s o u r c e s ( i n d ) . waveform = . . .
v m a g n i t u d e f a c t o r * a waveform * n f i e l d s ;

49

51

53

55

57

59

61

63

65

67

69

71

73

end
% current sources
for ind = 1: number of current sources
i s = round ( ( c u r r e n t s o u r c e s ( i n d ) . m i n
j s = round ( ( c u r r e n t s o u r c e s ( i n d ) . m i n
k s = round ( ( c u r r e n t s o u r c e s ( i n d ) . m i n
i e = round ( ( c u r r e n t s o u r c e s ( i n d ) . max
j e = round ( ( c u r r e n t s o u r c e s ( i n d ) . max
ke = round ( ( c u r r e n t s o u r c e s ( i n d ) . max
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 ;
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 ;
c u r r e n t s o u r c e s ( ind ) . j e = j e ;

x
y
z
x
y
z

fdtd
fdtd
fdtd
fdtd
fdtd
fdtd

domain . min
domain . min
domain . min
domain . min
domain . min
domain . min

x
y
z
x
y
z

) / dx ) + 1 ;
) / dy ) + 1 ;
) / dz ) + 1 ;
) / dx ) + 1 ;
) / dy ) + 1 ;
) / dz ) + 1 ;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

92

Active and Passive Lumped Elements


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 ) )
case x
n f i e l d s = ( 1 + j e j s ) * ( 1 + ke k s ) ;
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
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 ) ;
case z
n fields = (1 + ie is ) * (1 + je js ) ;
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
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 = . . .
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
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 ;
end
c u r r e n t s o u r c e s ( ind ) . resistance per component = . . .
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 ;

77

79

81

83

85

87

89

91

93

95

% c o p y waveform o f t h e waveform t y p e t o waveform o f t h e s o u r c e


w t s t r = c u r r e n t s o u r c e s ( ind ) . waveform type ;
w i s t r = num2str ( c u r r e n t 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 ; ] ;
eval ( e v a l s t r ) ;
c u r r e n t s o u r c e s ( ind ) . c u r r e n t p e r e f i e l d = . . .
i m a g n i t u d e f a c t o r * a waveform ;
c u r r e n t s o u r c e s ( i n d ) . waveform = . . .
i m a g n i t u d e f a c t o r * a waveform * n f i e l d s ;

97

99

101

103

105

107

109

111

113

115

117

119

121

123

125

end
% resistors
for ind = 1: n u m b e r o f r e s i s t o r s
i s = round ( ( r e s i s t o r s ( i n d ) . m i n x
j s = round ( ( r e s i s t o r s ( i n d ) . min y
k s = round ( ( r e s i s t o r s ( i n d ) . m i n z
i e = round ( ( r e s i s t o r s ( i n d ) . max x
j e = round ( ( r e s i s t o r s ( i n d ) . max y
ke = round ( ( r e s i s t o r s ( i n d ) . max z
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 ;
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 ;
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 ;
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
r magnitude factor = (1 + je

fdtd
fdtd
fdtd
fdtd
fdtd
fdtd

domain . min
domain . min
domain . min
domain . min
domain . min
domain . min

x
y
z
x
y
z

) / dx ) + 1 ;
) / dy ) + 1 ;
) / dz ) + 1 ;
) / dx ) + 1 ;
) / dy ) + 1 ;
) / dz ) + 1 ;

j s ) * ( 1 + ke k s ) / ( i e i s ) ;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation of Lumped Elements


case y
r magnitude factor =
case z
r magnitude factor =
end
r e s i s t o r s ( ind ) . resistance
r magnitude factor *

127

129

131

133

135

137

139

141

143

145

147

149

151

153

155

157

159

161

163

165

167

169

171

173

175

177

93

( 1 + i e i s ) * ( 1 + ke k s ) / ( j e j s ) ;
( 1 + i e i s ) * ( 1 + j e j s ) / ( ke k s ) ;
per component = . . .
r e s i s t o r s ( ind ) . r e s i s t a n c e ;

end
% inductors
for ind = 1: number of inductors
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 ;
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 ;
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 ;
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 ;
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 ;
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 ;
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
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
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
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
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 ;
end
% capacitors
for ind = 1: number of capacitors
i s = round ( ( c a p a c i t o r s ( i n d ) . m i n x f d t d
j s = round ( ( c a p a c i t o r s ( i n d ) . m i n y f d t d
k s = round ( ( c a p a c i t o r s ( i n d ) . m i n z f d t d
i e = round ( ( c a p a c i t o r s ( i n d ) . max x f d t d
j e = round ( ( c a p a c i t o r s ( i n d ) . max y f d t d
ke = round ( ( c a p a c i t o r s ( i n d ) . max z f d t d
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 ;
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 ;
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 ;
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
c magnitude factor = ( ie is ) . . .

domain . min
domain . min
domain . min
domain . min
domain . min
domain . min

x
y
z
x
y
z

) / dx ) + 1 ;
) / dy ) + 1 ;
) / dz ) + 1 ;
) / dx ) + 1 ;
) / dy ) + 1 ;
) / dz ) + 1 ;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

94

Active and Passive Lumped Elements


/ ((1 +
case y
c magnitude
/ ((1 +
case z
c magnitude
/ ((1 +
end
c a p a c i t o r s ( ind ) .
c magnitude

179

181

183

185

187

j e j s ) * ( 1 + ke k s ) ) ;
factor = ( je js ) . . .
i e i s ) * ( 1 + ke k s ) ) ;
f a c t o r = ( ke k s ) . . .
ie is ) * (1 + je js ) ) ;
capacitance per component = . . .
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

sigma pec = m a t e r i a l t y p e s ( m a t e r i a l t y p e i n d e x p e c ) . sigma e ;


191

193

195

197

199

201

203

205

% diodes
for ind = 1: number of diodes
i s = round ( ( d i o d e s ( i n d ) . m i n
j s = round ( ( d i o d e s ( i n d ) . m i n
k s = round ( ( d i o d e s ( i n d ) . m i n
i e = round ( ( d i o d e s ( i n d ) . max
j e = round ( ( d i o d e s ( i n d ) . max
ke = round ( ( d i o d e s ( i n d ) . max
diodes ( ind ) . i s = i s ;
diodes ( ind ) . j s = j s ;
diodes ( ind ) . ks = ks ;
diodes ( ind ) . i e = i e ;
diodes ( ind ) . j e = j e ;
d i o d e s ( i n d ) . ke = ke ;

fdtd
fdtd
fdtd
fdtd
fdtd
fdtd

domain . min
domain . min
domain . min
domain . min
domain . min
domain . min

x
y
z
x
y
z

) / dx ) + 1 ;
) / dy ) + 1 ;
) / dz ) + 1 ;
) / dx ) + 1 ;
) / dy ) + 1 ;
) / dz ) + 1 ;

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
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
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
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

207

209

211

213

215

x
y
z
x
y
z

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 components. 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 chapter. In subroutine initialize waveforms for every waveform type the respective waveforms are
calculated as functions of time based on the waveform type specic parameters. Then the calculated 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 dened with the parameter waveforms.sinusoidal(i).frequency and t is the discrete time array time storing the time instants of the
time steps.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation of Lumped Elements

14:16

95

Listing 4.4 initialize waveforms.m


1

11

13

disp ( i n i t i a l i z i n g s o u r c e waveforms ) ;
% 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 )
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 ) ;
end
% 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 )
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 ;
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 dened waveform types they can be copied
to waveform elds 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) dened 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
eld 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 eld 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. Therefore, 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

96

October 13, 2009

Active and Passive Lumped Elements

Based on the discussion in Section 4.7, if a lumped element is associated with more than one
eld component, the value of the lumped element should be assigned to the eld components
after a modication. Therefore, new parameters are dened in the structures representing the
lumped elements, which store the value of the lumped element per eld component. For instance,
resistance per component is dened in voltage sources(i), which stores the resistance of the
voltage source per eld 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 dened and
calculated by (4.27). For a current source resistance per component is dened 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 components 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 eld components.
We assume that a diode is dened as a one-dimensional object, such as a line section, extending
over a number of electric eld 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 eld 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 eld 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

Figure 4.9 A diode defined between the nodes (i s, j s, ks ) and (i e, j e, ke).

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation of Lumped Elements

97

with the electric eld 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.
4.2.4 Initialization of Updating Coefficients

After initializing the lumped element components by determining the indices of nodes identifying
their positions in the FDTD problem space grid and by setting other parameters necessary to
characterize them, we can construct the FDTD updating coefcients. We calculate and store
updating coefcients in three-dimensional arrays before the FDTD time-marching loop begins
and use them while updating the elds during the time-marching loop. The initialization of the
updating coefcients is done in the subroutine initialize updating coefficients, which is given in
Listing 4.5.
Listing 4.5 initialize updating coefficients.m
1

disp ( i n i t i a l i z i n g general updating c o e f f i c i e n t s ) ;


% 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
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 ) ;
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 ) ;

11

13

% C o e f f i e c i e n t s updating Ey
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 ) ;
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

17

19

% C o e f f i e c i e n t s updating Ez
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 ) ;
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

23

25

27

29

31

33

35

% General magnetic 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 u p d a t i n g Hx
Chxh = ( 2 * 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 ) ;
C h x e z = (2 * d t / dy ) . / ( 2 * m u r x * mu 0 + d t * s i g m a m x ) ;
C h x e y = ( 2 * d t / dz ) . / ( 2 * m u r x * mu 0 + d t * s i g m a m x ) ;
% 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 ) . . .
. / ( 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 ) ;
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 ) ;
% 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 )

...

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

98
37

39

41

43

45

47

October 13, 2009

Active and Passive Lumped Elements

. / ( 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 ) ;
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 ) ;
% 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 ;
initialize current source updating coefficients ;
initialize resistor updating coefficients ;
initialize capacitor updating coefficients ;
initialize inductor updating coefficients ;
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 voltagecurrent 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
coefcients can be calculated for the whole problem space using the general updating equation
coefcients appearing in (1.26)(1.31) and excluding the impressed current terms. Then the updating coefcients can be recalculated only for the position indices where the lumped components
exist. The additional coefcients required for the lumped elements (e.g., voltage sources, current
sources, and inductors), can be calculated and stored in separate arrays associated with these components. Then during the FDTD time-marching iterations, at every time step, the electric eld
components can be updated using the general updating equations (1.26)(1.31) excluding the impressed current terms, and then the additional terms can be added to the electric eld 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 efciently generate these arrays.
In Listing 4.5 the updating coefcients, except for the impressed current terms, dened 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 coefcient
arrays are the same as the sizes of the material component arrays that have been used to construct
them. Then the updating coefcients 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 Coefcients The updating coefcients 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 dened between the nodes
(is , j s , ks ) and (ie, j e, ke) and the associated electric eld components as illustrated in Fig. 4.10.
These indices of the nodes are used to identify the indices of the eld components that need the
special updates due to the voltage sources. The indices of the eld components are determined
by taking into account the directions of the voltage sources. Since these eld components will be

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

Simulation of Lumped Elements

October 13, 2009

14:16

99

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 eld 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 eld 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 sufcient. 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 rst 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

100

October 13, 2009

Active and Passive Lumped Elements

Listing 4.6 initialize voltage source updating coefficients.m


1

11

disp ( i n i t i a l i z i n g voltage source updating c o e f f i c i e n t s ) ;


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 ;
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 ;
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 ;
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 ;
i f ( R == 0 ) R = 1e 20; end
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
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 ) ;
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 ) . . .
. / ( 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 ) . . .
. / ( 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 ) . . .
. / ( 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 ) ) . . .
. / ( 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
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 ) ;
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 ) . . .
. / ( 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 ) . . .
. / ( 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 ) . . .
. / ( 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 ) ) . . .
. / ( 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
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 ) ;
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 ) . . .
. / ( 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 ) . . .
. / ( 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 ) . . .
. / ( 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 ) ) . . .
. / ( 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
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 ;

13

15

17

19

21

23

25

27

29

31

33

35

37

39

41

43

45

47

49

51

end

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation of Lumped Elements

14:16

101

Listing 4.7 create linear index list.m



2

10

12

14

16

18

20

22

% a function that generates a l i s t of l i n e a r ind ices


function [ f i ] = c r e a t e l i n e a r i n d e x l i s t ( array 3d , i l i s t , j l i s t , k l i s t )
i s i z e = size ( i l i s t , 2 ) ;
j s i z e = size ( j l i s t , 2 ) ;
k size = size ( k list , 2 ) ;
number of indices = i s i z e * j s i z e * k size ;
I = zeros ( number of indices , 1 ) ;
J = zeros ( number of indices , 1 ) ;
K = zeros ( number of indices , 1 ) ;
ind = 1;
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 )
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 ;
J ( i n d ) = mj ;
K ( i n d ) = mk ;
ind = ind + 1;
end
end
end
f i = sub2ind ( s i z e ( array 3d ) , I , J , K ) ;

Once the eld component indices needing special updates are determined as fi in Listing 4.6,
the respective components of the general updating coefcients 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 coefcient 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 eld components 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 eld components while updating the electric eld components during the
time-marching loop.

4.2.4.2 Initialization of Current Source Updating Coefcients The initialization of current source
updating coefcients is performed in the subroutine initialize current source updating coefficients, which is shown in Listing 4.8. The initialization of current source coefcients is
the same as the initialization of voltage source coefcients and follows the updating equation
given in (4.15).

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

102

Active and Passive Lumped Elements

Listing 4.8 initialize current source updating coefficients.m


disp ( i n i t i a l i z i n g current source updating c o e f f i c i e n t s ) ;
2

for ind = 1: number of current


i s = c u r r e n t s o u r c e s ( ind ) .
j s = c u r r e n t s o u r c e s ( ind ) .
ks = c u r r e n t s o u r c e s ( ind ) .
i e = c u r r e n t s o u r c e s ( ind ) .
j e = c u r r e n t s o u r c e s ( ind ) .
ke = c u r r e n t s o u r c e s ( i n d ) .

sources
is ;
js ;
ks ;
ie ;
je ;
ke ;

10

R = c u r r e n t s o u r c e s ( ind ) . resistance per component ;


12

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 ) )
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 ) ;
a t e r m = ( d t * dx ) / ( R * dy * dz ) ;
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 ) . . .
. / ( 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 ) . . .
. / ( 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 ) . . .
. / ( 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 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 ) ;
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 ) ;
a t e r m = ( d t * dy ) / ( R * dz * dx ) ;
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 ) . . .
. / ( 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 ) . . .
. / ( 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 ) . . .
. / ( 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 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 ) ;
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 ) ;
a t e r m = ( d t * dz ) / ( R * dx * dy ) ;
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 ) . . .
. / ( 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 ) . . .
. / ( 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 ) . . .
. / ( 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 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 ) ;
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 ;

14

16

18

20

22

24

26

28

30

32

34

36

38

40

42

44

46

48

50

52

end

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation of Lumped Elements

14:16

103

Listing 4.9 initialize inductor updating coefficients.m


disp ( i n i t i a l i z i n g inductor updating c o e f f i c i e n t s ) ;
2

for ind = 1: number of


i s = i n d u c t o r s ( ind
j s = i n d u c t o r s ( ind
ks = i n d u c t o r s ( ind
i e = i n d u c t o r s ( ind
j e = i n d u c t o r s ( ind
ke = i n d u c t o r s ( i n d

inductors
). is ;
). js ;
) . ks ;
) . ie ;
) . je ;
) . ke ;

10

L = i n d u c t o r s ( ind ) . inductance per component ;


12

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 ) )
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 ) ;
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 ) ) ;
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 ) ;
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 ) ;
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 ) ) ;
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 ) ;
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 ) ;
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 ) ) ;
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 ) ;
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 ;

14

16

18

20

22

24

26

28

30

32

34

end

4.2.4.3 Initialization of Inductor Updating Coefcients The updating coefcients for modeling inductors 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 observe 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 coefcients that have
been initialized as general updating coefcients. However, a coefcient term Ce zj has not been
dened in the implementation of the general updating equations. Therefore, the coefcient term
Ce zj associated with the inductor is dened as inductors(i).Cezj in Listing 4.9. Furthermore,
the Ji z term is also associated with the inductor, and it is also dened 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

the new value of Ji z

n 12

(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

104

Active and Passive Lumped Elements

updating E zn+1 (i, j, k) using (4.24). Equation (4.23) can be rewritten as


n+ 12

Ji z

tz n
E (i, j, k)
Lxy z

n 12

(i, j, k) +

n 12

(i, j, k) + C j e z (i, j, k) E zn (i, j, k),

(i, j, k) = Ji z
= Ji z

where
C j e z (i, j, k) =

tz
.
Lxy

Therefore, C j e z is an additional coefcient 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.4 Initialization of Resistor Updating Coefcients The initialization of updating coefcients
related to resistors is performed in the subroutine initialize resistor updating coefficients, which
is shown in Listing 4.10. The initialization of resistor coefcients is straightforward; the indices
of eld components associated with a resistor are determined in the temporary parameter fi, and
the elements of the general coefcient arrays are accessed through fi and are recalculated based
on the resistor updating equation (4.16).
4.2.4.5 Initialization of Capacitor Updating Coefcients The initialization of updating coefcients
related to capacitors is performed in the subroutine initialize capacitor updating coefficients,
which is shown in Listing 4.11. The initialization of capacitor coefcients is similar to the initialization of resistor coefcients and is based on the updating equation (4.20).
4.2.4.6 Initialization of Diode Updating Coefcients The algorithm for modeling diodes is signicantly different compared with other lumped element components, and it requires the initialization of a different set of parameters. The updating coefcients for modeling diodes are initialized 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 eld 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 dened between the nodes (is , j s , ks ) and (ie, j e, ke),
only the eld 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 eld component associated with a
diode is obtained by the solution of the equation
Ae Bx + x + C = 0,

(4.42)

where
x = E zn+1 (i, j, k),

A = Ce zd (i, j, k)e BEz (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).

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation of Lumped Elements

14:16

105

Listing 4.10 initialize resistor updating coefficients.m



disp ( i n i t i a l i z i n g

r e s i s t o r updating c o e f f i c i e n t s ) ;

for ind = 1: n u m b e r o f
i s = r e s i s t o r s ( ind
j s = r e s i s t o r s ( ind
ks = r e s i s t o r s ( ind
i e = r e s i s t o r s ( ind
j e = r e s i s t o r s ( ind
ke = r e s i s t o r s ( i n d

resistors
). is ;
). js ;
) . ks ;
) . ie ;
) . je ;
) . ke ;

10

R = r e s i s t o r s ( ind ) . resistance per component ;


12

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 ) )
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 ) ;
a t e r m = ( d t * dx ) / ( R * dy * dz ) ;
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 ) . . .
. / ( 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 ) . . .
. / ( 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 ) . . .
. / ( 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
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 ) ;
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 ) . . .
. / ( 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 ) . . .
. / ( 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 ) . . .
. / ( 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
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 ) ;
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 ) . . .
. / ( 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 ) . . .
. / ( 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 ) . . .
. / ( 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
r e s i s t o r s ( ind ) . f i e l d i n d i c e s = f i ;

14

16

18

20

22

24

26

28

30

32

34

36

38

40

42

44

46

end

fdtd_main

SPIB005-Elsherbeni & Demir

106

October 13, 2009

Active and Passive Lumped Elements

Listing 4.11 initialize capacitor updating coefficients.m



disp ( i n i t i a l i z i n g c a p a c i t o r updating c o e f f i c i e n t s ) ;
2

for ind = 1: number of capacitors


i s = c a p a c i t o r s ( ind ) . i s ;
j s = c a p a c i t o r s ( ind ) . j s ;
ks = c a p a c i t o r s ( ind ) . ks ;
i e = c a p a c i t o r s ( ind ) . i e ;
j e = c a p a c i t o r s ( ind ) . j e ;
ke = c a p a c i t o r s ( i n d ) . ke ;

10

C = c a p a c i t o r s ( ind ) . capacitance per component ;


12

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 ) )
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 ) ;
a t e r m = ( 2 * C * dx ) / ( dy * dz ) ;
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 ) . . .
. / ( 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 ) . . .
. / ( 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 ) . . .
. / ( 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
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 = ( 2 * C * dy ) / ( dz * dx ) ;
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 ) . . .
. / ( 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 ) . . .
. / ( 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 ) . . .
. / ( 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
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 = ( 2 * C * dz ) / ( dx * dy ) ;
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 ) . . .
. / ( 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 ) . . .
. / ( 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 ) . . .
. / ( 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
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 ;

14

16

18

20

22

24

26

28

30

32

34

36

38

40

42

44

46

end

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation of Lumped Elements

14:16

107

Listing 4.12 initialize diode updating coefficients.m


disp ( i n i t i a l i z i n g diode updating c o e f f i c i e n t s ) ;
2

10

12

14

q
k
T
I

=
=
=
0

1 . 6 0 2 * 1 e 19;
1 . 3 8 0 6 6 e 23;
273+27;
= 1e 14;

%
%
%
%

for ind = 1: number


i s = diodes ( ind
j s = diodes ( ind
ks = diodes ( ind
i e = diodes ( ind
j e = diodes ( ind
ke = d i o d e s ( i n d

c h a r g e o f an e l e c t r o n
Boltzman c o n s t a n t , j o u l e / k e l v i n
K e l v i n ; room t e m p e r a t u r e
saturation current
of diodes
). is ;
). js ;
) . ks ;
) . ie ;
) . je ;
) . ke ;

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;
else
sgn = 1;
end
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
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
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 = . . .
s g n * ( 2 * d t * I 0 / ( dy * dz ) ) . . .
. / ( 2 * e p s r x ( f i ) * eps 0 + dt * sigma e
d i o d e s ( i n d ) . Exn = 0 ;
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 ( eps r y , is
d i o d e s ( i n d ) . B = s g n * q * dy / ( 2 * k * T ) ;
d i o d e s ( i n d ) . Ceyd = . . .
s g n * ( 2 * d t * I 0 / ( dz * dx ) ) . . .
. / ( 2 * e p s r y ( f i ) * eps 0 + dt * sigma e
d i o d e s ( i n d ) . Eyn = 0 ;
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
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 = . . .
s g n * ( 2 * d t * I 0 / ( dx * dy ) ) . . .
. / ( 2 * e p s r z ( f i ) * eps 0 + dt * sigma e
d i o d e s ( i n d ) . Ezn = 0 ;
end
diodes ( ind ) . f i e l d i n d i c e s = f i ;

16

18

20

22

24

26

28

30

32

34

36

38

40

42

44

, js , ks ) ;

x ( fi ));

, js , ks ) ;

y ( fi ));

, js , ks ) ;

z ( fi ));

end

Here the E zn+1 (i, j, k) is the electric eld 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 eld components.

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

108

Active and Passive Lumped Elements

Comparing the rst 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 coefcients Ce ze , Ce zhy , and Ce zhx are different only by a minus sign. These coefcients
were initialized as Ceze, Cezhy, and Cezhx in the subroutine initialize updating coefficients,
and there is no need to redene 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 coefcients 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 coefcient, Ce zd (i, j, k), which has
not been dened before. Therefore, a parameter, diodes(i).Cezd, is dened to store the value of
Ce zd (is , j s , ks ) in Listing 4.12.
An additional parameter that is dened 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 eld component at the previous time step. This parameter is used to recalculate the coefcient 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 Sampling Electric and Magnetic Fields, Voltages and Currents

The reason for performing an FDTD simulation is to obtain some results that characterize the
response of an electromagnetics problem. The types of results that can be obtained from an
FDTD simulation vary based on the type of the electromagnetics problem at hand. However, the
fundamental result that can be obtained from an FDTD simulation is the behavior of electric and
magnetic elds in time due to a source exciting the problem space, since these are the fundamental
quantities that the FDTD algorithm is based on. Other types of available results can be obtained
only by the translation of transient electric and magnetic elds into other parameters. For instance,
in a microwave circuit simulation, once the transient electric and magnetic elds are obtained,
it is easy to calculate transient voltages and currents. Then the transient voltages and currents
can be translated into the frequency domain by using the Fourier transform, and scattering
parameters (S-parameters) of the microwave circuit can be obtained. Similarly, radiation patterns
of an antenna or radar cross-section of a scatterer can be obtained by employing the appropriate
transforms.
4.2.5.1 Calculation of Sampled Voltages The voltages and currents that will be sampled are represented similar to lumped element components by prism-like volumes and their directions. The
voltages across and the currents owing through these volumes will be calculated using the electric
eld components across and the magnetic eld components around these volumes, respectively,
during the time-marching loop.
For instance, consider the volume dened 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)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation of Lumped Elements

109

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 conguration in
Fig. 4.11, the voltage between the upper and lower PEC plates can be expressed in discrete
form as
V = d z

ke1


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
j e ke1
ie 


d z

V=
E z (i, j, k).
(ie is + 1) ( j e j s + 1) i=is j = j s k=ks

(4.45)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

110

Active and Passive Lumped Elements

This expression can be written in the form


V = Csvf

j e ke1
ie 



E z (i, j, k),

(4.46)

i=is j = j s k=ks

where
Csvf =

d z
.
(ie is + 1) ( j e j s + 1)

(4.47)

The coefcient Csvf is a scaling factor multiplied by the sum of the eld 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 owing through a surface we can
employ Amperes law in integral form, which is given by

 dl,
H
(4.48)
Ifree =
where Ifree is the total free current. We need to describe the integral in (4.48) as a summation
of magnetic eld components in the discrete space. For instance, consider the case shown in
Fig. 4.12. The gure shows magnetic eld components enclosing a surface. The positions of the
elds are given with respect to the Yee cell, and indices of the elds are given with respect to
the nodes (is , j s , ks ) and (ie, j e, ke). These elds 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.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation of Lumped Elements

111

current by
Iz (ke 1) = d x

ie


Hx (i, j s 1, ke 1) + d y

ie


Hy (ie, j, ke 1)

j= js

i=is

dx

je


Hx (i, j e, ke 1) d y

i=is

je


Hy (is 1, j, ke 1).

(4.49)

j= js

Here we indexed Iz by (ke 1) since the magnetic eld 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
identied 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 eld components that are used to calculate the current as illustrated in Fig. 4.12. It is possible that the
volume identied 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 eld 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 multiple 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 eld components and currents are calculated from magnetic eld
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].
4.2.6 Definition and Initialization of Output Parameters

Denition of types of results sought from a simulation is part of the construction of an electromagnetics problem in the FDTD method. This can be done in the denition stage of the main FDTD
program fdtd solve as shown in Listing 3.1, in the subroutine define output parameters. In this
section we demonstrate how the electric eld, magnetic eld, voltages, and currents can be dened
as output parameters in Listing 4.13. We also demonstrate how to set up some auxiliary parameters
that would be used to display the three-dimensional view of the objects in the problem space, the
material mesh of the problem space, and a runtime animation of elds on some plane cuts while the
simulation is running. The denition of other types of parameters is discussed in the subsequent
chapters and their implementation are added to the subroutine define output parameters.
Listing 4.13 starts with the denition and initialization of the empty structure arrays
sampled electric fields, sampled magnetic fields, sampled voltages, and sampled currents
for representing the respective parameters to be sampled at every time step of the FDTD loop as
functions of time. As these parameters are captured during the FDTD loop, they can be plotted on
MATLAB gures to display the progress of the sampled parameters. However, it is not meaningful
to display the progress of these parameters at every time step, as it may slow down the simulation
considerably. It is better to refresh the plots at a rate dened with the parameter plotting step.
For instance, a value of 10 implies that the gures will be refreshed once every 10 time steps.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

112

Active and Passive Lumped Elements

Listing 4.13 define output parameters.m



1

disp ( d e f i n i n g output parameters ) ;


sampled
sampled
sampled
sampled

electric fields = [];


magnetic fields = [ ] ;
voltages = [ ] ;
currents = [ ] ;

11

13

% figure refresh rate


p l o t t i n g s t e p = 10;
% mode o f o p e r a t i o n
run simulation = true ;
show material mesh = true ;
show problem space = true ;

15

17

19

21

23

25

27

29

31

% 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
% 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 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 ;
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 ;
sampled electric fields ( 1 ) . display plot = true ;
% 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
% 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 ;
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 ;
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

35

37

39

41

% define
sampled
sampled
sampled
sampled
sampled
sampled
sampled
sampled

sampled
voltages
voltages
voltages
voltages
voltages
voltages
voltages
voltages

voltages
( 1 ) . m i n x = 5 . 0 e 3;
( 1 ) . min y = 0 ;
( 1 ) . min z = 0 ;
( 1 ) . max x = 5 . 0 e 3;
( 1 ) . max y = 2 . 0 e 3;
( 1 ) . max z = 4 . 0 e 3;
( 1 ) . d i r e c t i o n = zp ;
( 1 ) . display plot = true ;

% define
sampled
sampled
sampled
sampled
sampled
sampled

sampled
currents
currents
currents
currents
currents
currents

currents
( 1 ) . min x
( 1 ) . min y
( 1 ) . min z
( 1 ) . max x
( 1 ) . max y
( 1 ) . max z

43

45

47

49

=
=
=
=
=
=

5 . 0 e 3;
0;
4 . 0 e 3;
5 . 0 e 3;
2 . 0 e 3;
4 . 0 e 3;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

Simulation of Lumped Elements


51

October 13, 2009

14:16

113

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

55

57

59

61

63

65

67

69

71

73

75

77

79

81

83

85

87

89

91

% d i s p l a y problem s p a c e p a r a m e t e r s
problem space display . labels = true ;
problem space display . a x i s a t o r i g i n = false ;
problem space display . axis outside domain = true ;
problem space display . grid xn = false ;
problem space display . grid xp = true ;
problem space display . grid yn = false ;
problem space display . grid yp = true ;
problem space display . grid zn = true ;
problem space display . grid zp = false ;
problem space display . outer boundaries = true ;
problem space display . cpml boundaries = true ;
% define animation
% 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
% 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 ;
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 ;
animation ( 1 ) . plane cut ( 1 ) . p o s i t i o n = 0;
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;
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;
animation ( 1 ) . enable = true ;
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 ;
animation
animation
animation
animation
animation
animation
animation
animation
animation

(2).
(2).
(2).
(2).
(2).
(2).
(2).
(2).
(2).

field type = h ;
component = x ;
p l a n e c u t ( 1 ) . t y pe = xy ;
p l a n e c u t ( 1 ) . p o s i t i o n = 5;
p l a n e c u t ( 2 ) . t y pe = xy ;
plane cut ( 2 ) . position = 5;
enable = true ;
display grid = true ;
display objects = 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 dened. If this parameter is true, then the program proceeds with running 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

114

Active and Passive Lumped Elements

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 subroutine 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 elds are calculated all over
the problem space at their respective positions on the Yee grid. Since all of the eld components
are available, any of them can be captured, plotted, or stored. For instance, some eld components
on some plane cuts can be captured and plotted on gures so as to demonstrate the real-time progression of elds on these plane cuts. Or some elds can be captured and stored for postprocessing.
Here we limit our implementation to eld components sampled at nodes of the FDTD grid. To
dene a node, we need its position in the Cartesian coordinates. Therefore, the parameters x, y,
and z are dened in the structures sampled electric fields(i) and sampled magnetic fields(i).
Since the elds 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 dened with
sampled electric fields(i) and sampled magnetic fields(i). If the component takes the value
m then the magnitude of the eld 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 eld component will be plotted while the simulation is running or not.
Meanwhile, the volumes representing the sampled voltages and currents are identied 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 dened 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 eld components are available at every time step of the
simulation, they can be captured on desired plane cuts and plotted; thus, a propagation of elds
on these plane cuts can be simulated. The denition 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 gure that displays the elds. An element animation(i) has the following subelds that are used
to dene the properties of the animation. The subeld field type can take a value either e or h,
determining whether the electric eld or magnetic eld will be animated, respectively. Then the
subeld component is used to dene which component of the eld to display, and it takes one of
the values x, y, z, or m. Then several plane cuts can be dened to be displayed on a gure using
the subeld 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 subelds 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 implemented in the subroutine initialize output parameters, as shown in Listing 4.14. Here the
parameter sampled electric fields represents the sampled electric eld components, and
sampled magnetic fields represents the sampled magnetic eld components. Similarly, the

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation of Lumped Elements

115

parameters sampled voltages and sampled currents represent sampled voltages and currents,
respectively. As indicated before, the electric and magnetic eld components are sampled at specied 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 ) ;


number
number
number
number

of
of
of
of

sampled electric
sampled magnetic
sampled voltages
sampled currents

fields
fields
= size
= size

= size ( sampled electric fields , 2 ) ;


= size ( sampled magnetic fields , 2 ) ;
( sampled voltages , 2 ) ;
( sampled currents , 2 ) ;

11

13

15

17

19

21

23

25

27

29

31

33

35

37

39

% 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
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
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
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
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 ;
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 ;
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 ) ;
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 ;
end
% 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
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 ;
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 ;
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 ;
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 ;
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
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 = . . .
( [ 1 : number of time steps ] 0.5)* dt ;
end

...
...
...

= ...

...
...
...

= ...

41

43

% i n i t i a l i z e sampled v o l t a g e 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 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 ;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

116

Active and Passive Lumped Elements


j s = round ( ( s a m p l e d
k s = round ( ( s a m p l e d
i e = round ( ( s a m p l e d
j e = round ( ( s a m p l e d
ke = round ( ( s a m p l e d
sampled voltages ( ind
sampled voltages ( ind
sampled voltages ( ind
sampled voltages ( ind
sampled voltages ( ind
sampled voltages ( ind
sampled voltages ( ind

45

47

49

51

53

55

57

October 13, 2009

v o l t a g e s ( ind ) . min y fdtd domain . min


v o l t a g e s ( ind ) . min z fdtd domain . min
v o l t a g e s ( i n d ) . max x f d t d d o m a i n . m i n
v o l t a g e s ( i n d ) . max y f d t d d o m a i n . m i n
v o l t a g e s ( i n d ) . max z f d t d d o m a i n . m i n
). is = is ;
). js = js ;
) . ks = ks ;
) . ie = ie ;
) . je = je ;
) . ke = ke ;
) . sampled value = . . .
zeros (1 , number of time steps ) ;

y
z
x
y
z

) / dy ) + 1 ;
) / dz ) + 1 ;
) / dx ) + 1 ;
) / dy ) + 1 ;
) / dz ) + 1 ;

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
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 ) * ( kek s + 1 ) ) ;
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 ) ;
s a m p l e d v o l t a g e s ( i n d ) . C s v f = dy / ( ( kek s + 1 ) * ( i e i s + 1 ) ) ;
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 ( 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 ) ) ;
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 )
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 ;
end
sampled voltages ( ind ) . f i e l d i n d i c e s = f i ;
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 ;

59

61

63

65

67

69

71

73

75

end
77

79

81

83

85

87

89

91

93

95

% i n i t i a l i z e sampled c u r r e n t 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 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 ;
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 ;
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 ;
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 ;
sampled currents ( ind ) . j s = j s ;
sampled currents ( ind ) . ks = ks ;
sampled currents ( ind ) . i e = i e ;
sampled currents ( ind ) . j e = j e ;
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 = . . .
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 ;
end

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

Simulation of Lumped Elements

October 13, 2009

117

component while the FDTD iterations proceed. Another one-dimensional array with size number 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
eld and magnetic eld 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 elds that are used to
calculate sampled voltages are determined and assigned to the parameter field indices. Then
coefcient 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 dened four types of outputs for
an FDTD simulation: namely, sampled electric and magnetic elds, voltages, and currents. While
the FDTD simulation is running, the progress of these sampled parameters can be displayed
on MATLAB gures. In the subroutine define output parameters, while dening the sampled
components, a parameter display plot is associated to each dened component indicating whether
the real-time progress of this component displayed. If there are any components dened for
runtime display, gures displaying these components can be opened and their properties can
be set before the FDTD time-marching loop starts. This gure initialization process can be
performed in the subroutine initialize display parameters, which is given in Listing 4.15. Here
gures are launched for every sampled component that is displayed, and their axis labels are set.
Furthermore, the number of the gure associated with each sampled component is stored in the
parameter figure number.
Listing 4.15 initialize display parameters.m

1

11

13

15

17

19

21

23

25

disp ( i n i t i a l i z i n g d i s p l a y parameters ) ;
% 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
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 ;
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 ) ;
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 [ . . .
num2str ( i n d ) ] ] , f o n t s i z e , 1 2 ) ;
g r i d on ;
hold on ;
end
end
% 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
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 ;
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 ) ;
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 ) ] ] , . . .
fontsize ,12);
g r i d on ;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

118

October 13, 2009

Active and Passive Lumped Elements


hold on ;

27

end
29

31

33

35

37

39

41

43

45

47

49

51

53

55

57

59

end
% 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
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 ;
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 ) ;
ylabel ( ( volt ) , fontsize ,12);
t i t l e ( [ sampled v o l t a g e [ num2str ( i n d ) ] ] , . . .
fontsize ,12);
g r i d on ;
hold on ;
end
end
% 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
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 ;
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 ) ;
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 ) ] ] , . . .
fontsize ,12);
g r i d on ;
hold on ;
end
end
% 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 initialization of parameters for eld animation on the plane cuts dened in define output parameters.
Furthermore, gures and display parameters for other types of sampled outputs can be initialized in this routine.

4.2.7 Running an FDTD Simulation: The Time-Marching Loop

So far we have discussed all denition and initialization routines in fdtd solve as given in Listing
3.1 except the subroutines initialize boundary conditions and run fdtd time marching loop. The
only boundary type we have discussed is the PEC boundary. We only need to ensure that the
tangential electric eld components on the boundaries of the problem space are zeros to satisfy
the PEC boundary conditions. Therefore, there is no need for special initialization routines for
PEC boundaries. The subroutine run fdtd time marching loop is reserved for other types of
boundaries, we have not discussed yet and are the subject of another chapter.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

Simulation of Lumped Elements

October 13, 2009

14:16

119

Therefore, so far we have constructed the necessary components for starting an FDTD simulation 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 denition 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 rst 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 rst the magnetic eld components are updated in the subroutine
update magnetic fields, as given in Listing 4.17. Here the new values of the magnetic eld components 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 dened.
Listing 4.16 run fdtd time marching loop.m
2

disp ( [ S t a r t i n g the time marching loop ] ) ;


d i s p ( [ T o t a l number o f t i m e s t e p s : . . .
num2str ( n u m b e r o f t i m e s t e p s ) ] ) ;

10

12

14

16

18

20

22

24

s t a r t t i m e = cputime ;
current time = 0;
for time step = 1: number of time steps
update magnetic fields ;
capture sampled magnetic fields ;
capture sampled currents ;
update electric fields ;
update voltage sources ;
update current sources ;
update inductors ;
update diodes ;
capture sampled electric fields ;
capture sampled voltages ;
display sampled parameters ;
end
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 ;
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

120

October 13, 2009

Active and Passive Lumped Elements

Listing 4.17 update magnetic fields.m


1

% update magnetic f i e l d s
current time

= current time + dt / 2 ;

Hx = Chxh . * Hx+C h x e y . * ( E y ( 1 : nxp1 , 1 : ny , 2 : nzp1 ) E y ( 1 : nxp1 , 1 : ny , 1 : nz ) )


+ C h x e z . * ( E z ( 1 : nxp1 , 2 : nyp1 , 1 : nz ) E z ( 1 : nxp1 , 1 : ny , 1 : nz ) ) ;

...

Hy = Chyh . * Hy+C h y e z . * ( E z ( 2 : nxp1 , 1 : nyp1 , 1 : nz ) E z ( 1 : nx , 1 : nyp1 , 1 : nz ) )


+ C h y e x . * ( E x ( 1 : nx , 1 : nyp1 , 2 : nzp1 ) E x ( 1 : nx , 1 : nyp1 , 1 : nz ) ) ;

...

11

Hz = Chzh . * Hz+C h z e x . * ( E x ( 1 : nx , 2 : nyp1 , 1 : nzp1 ) E x ( 1 : nx , 1 : ny , 1 : nzp1 ) )


+ C h z e y . * ( E y ( 2 : nxp1 , 1 : ny , 1 : nzp1 ) E y ( 1 : nx , 1 : ny , 1 : nzp1 ) ) ;

...

4.2.7.2 Updating Electric Fields Then the next important step in an FDTD iteration is the update
of electric elds, which is performed in the subroutine update electric fields and is shown in
Listing 4.18. The electric eld 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 eld 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 eld components that are tangential to the
boundaries are excluded in the updating. The reason is the specic arrangement of eld positions
Listing 4.18 update electric fields.m
2

10

12

14

16

18

20

22

% u p d a t e e l e c t r i c f i e l d s e x c e p t t h e t a n g e n t i a l components
% on t h e b o u n d a r i e s
current time

= current time + dt / 2 ;

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 ) . * . . .
( 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 ) . * . . .
( Hy ( 1 : nx , 2 : ny , 2 : nz )Hy ( 1 : nx , 2 : ny , 1 : nz 1 ) ) ;
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 ) . *
...
( 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 ) . *
...
( Hz ( 2 : nx , 1 : ny , 2 : nz )Hz ( 1 : nx 1 ,1: ny , 2 : nz ) ) ;
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 ) . *
...
( 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 ) . * . . .
( Hx ( 2 : nx , 2 : ny , 1 : nz )Hx ( 2 : nx , 1 : ny 1 ,1: nz ) ) ;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation of Lumped Elements

14:16

121

on the Yee cell. While updating an electric eld component, the magnetic eld components
encircling it are required. However, for an electric eld component resting tangential to the
boundary of the problem space, at least one of the required magnetic eld components would be
out of the problem space and thus would be undened. Therefore, the electric eld 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 eld components.
The updating coefcient values that model the lumped element components were assigned to
the respective positions in the updating coefcient arrays; therefore, the updating of the electric
eld 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 elds 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 specic 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 eld components that are associated with the voltage sources. The
indices of the electric eld components requiring an additional update are stored in the parameter
voltage sources(i).field indices. The coefcient 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 eld components due to voltage sources is performed in update voltage sources as shown
in Listing 4.19.
Listing 4.19 update voltage sources.m
2

10

12

14

16

% u p d a t i n g e l e c t r i c f i e l d components
% a s s o c i a t e d with the v o l t a g e 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
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 ;
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
Ex ( f i ) = Ex ( f i ) + v o l t a g e s o u r c e s ( ind ) .
* 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
case y
Ey ( f i ) = Ey ( f i ) + v o l t a g e s o u r c e s ( ind ) .
* 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
case z
Ez ( f i ) = Ez ( f i ) + v o l t a g e s o u r c e s ( ind ) .
* 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
end
end

Cexs . . .
e field ( time step ) ;
Ceys . . .
e field ( time step ) ;
Cezs . . .
e field ( time step ) ;

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

122

Active and Passive Lumped Elements

Listing 4.20 update current sources.m



1

% u p d a t i n g e l e c t r i c f i e l d components
% a s s o c i a t e d with the current sources

11

13

15

17

for ind = 1: number of current sources


f i = 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 ;
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 ) )
case x
Ex ( f i ) = Ex ( f i ) + c u r r e n t s o u r c e s ( ind ) .
* c u r r e n t s o u r c e s ( ind ) . c u r r e n t p e r
case y
Ey ( f i ) = Ey ( f i ) + c u r r e n t s o u r c e s ( ind ) .
* c u r r e n t s o u r c e s ( ind ) . c u r r e n t p e r
case z
Ez ( f i ) = Ez ( f i ) + c u r r e n t s o u r c e s ( ind ) .
* c u r r e n t s o u r c e s ( ind ) . c u r r e n t p e r
end
end

Cexs . . .
e field ( time step ) ;
Ceys . . .
e field ( time step ) ;
Cezs . . .
e field ( time step ) ;

4.2.7.4 Updating Electric Fields Associated with Current Sources Updating of the eld 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 specic term,
n+ 12

Ce zs (i, j, k) Is

(i, j, k).

(4.51)

The additional update of electric eld 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 coefcients 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 eld component,
n
E z , based on equation (4.23), before adding 1the terms in equation (4.52) to E zn+1 . However,
n+
since update electric
fields overwrites E zn , Ji z 2 must be calculated before update electric fields.
1
n+
Therefore, Ji z 2 can be recalculated after updating the electric elds due to inductors for use in
the following time step. The algorithm for updating electric eld components and calculating
the impressed currents can be followed in Listing 4.21, which shows the implementation of
update inductors.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation of Lumped Elements

14:16

123

Listing 4.21 update inductors.m



1

% u p d a t i n g e l e c t r i c f i e l d components
% a s s o c i a t e d with the i n d u c t o r s

11

13

15

17

19

21

23

for ind = 1: number of inductors


f i = i n d u c t o r s ( ind ) . f i e l d i n d i c e s ;
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 ) )
case x
Ex ( f i ) = Ex ( f i ) + i n d u c t o r s ( ind ) . C e x j . . .
. * i n d u c t o r s ( ind ) . J i x ;
i n d u c t o r s ( ind ) . J i x = i n d u c t o r s ( ind ) . J i x . . .
+ i n d u c t o r s ( ind ) . C j e x . * Ex ( f i ) ;
case y
Ey ( f i ) = Ey ( f i ) + i n d u c t o r s ( ind ) . C e y j . . .
. * i n d u c t o r s ( ind ) . J i y ;
i n d u c t o r s ( ind ) . J i y = i n d u c t o r s ( ind ) . J i y . . .
+ i n d u c t o r s ( ind ) . C j e y . * Ey ( f i ) ;
case z
Ez ( f i ) = Ez ( f i ) + i n d u c t o r s ( ind ) . C e z j . . .
. * i n d u c t o r s ( ind ) . J i z ;
i n d u c t o r s ( ind ) . J i z = i n d u c t o r s ( ind ) . J i z . . .
+ i n d u c t o r s ( ind ) . C j e z . * Ez ( f i ) ;
end
end

4.2.7.6 Updating Electric Fields Associated with Diodes Update of electric eld 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 eld component associated with a diode is obtained
by the solution of the equation
Ae Bx + x + C = 0,

(4.53)

where
x = E zn+1 (i, j, k),

A = Ce zd (i, j, k)e BEz (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)
The coefcients B, and Ce zd are constructed as parameters diodes(i).B and diodes(i).Cezd in
the subroutine initialize diode updating coefficients. However, the coefcients A and C must be
recalculated at every time step using the equations just shown. As discussed before, the coefcients
Ce ze , Ce zhy , and Ce zhx are negatives of the corresponding coefcients appearing in the general
updating equations, which were executed in update electric fields. Therefore, after execution
of update electric fields the electric eld component associated with the diode, E zn+1 , would be
holding the negative value of the sum of rst three terms on the right-hand side of equation (4.54).

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

124

Active and Passive Lumped Elements

Then the coefcient C can be expressed as


C = E zn+1 (i, j, k) + Ce zd (i, j, k).

(4.55)

At this point, to calculate C we need the previous time step value of the electric eld component, 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 eld 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 eld 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 eld
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 understanding this complicated updating process. Finally, a function with name solve diode equation is
Listing 4.22 update diodes.m
1

% u p d a t i n g e l e c t r i c f i e l d components
% a s s o c i a t e d with the diodes

11

13

15

17

19

21

23

25

27

29

for ind = 1: number of diodes


f i = diodes ( ind ) . f i e l d i n d i c e s ;
B = diodes ( ind ) . B ;
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
E = d i o d e s ( i n d ) . Exn ;
C = E x ( f i ) + d i o d e s ( i n d ) . C e x d ;
A = d i o d e s ( i n d ) . C e x d * exp ( B * E ) ;
E = solve diode equation (A , B, C , E ) ;
Ex ( f i ) = E ;
d i o d e s ( i n d ) . Exn = E ;
case y
E = d i o d e s ( i n d ) . Eyn ;
C = E y ( f i ) + d i o d e s ( i n d ) . Ceyd ;
A = d i o d e s ( i n d ) . Ceyd * exp ( B * E ) ;
E = solve diode equation (A , B, C , E ) ;
Ey ( f i ) = E ;
d i o d e s ( i n d ) . Eyn = E ;
case z
E = d i o d e s ( i n d ) . Ezn ;
C = E z ( f i ) + d i o d e s ( i n d ) . C e z d ;
A = d i o d e s ( i n d ) . C e z d * exp ( B * E ) ;
E = solve diode equation (A , B, C , E ) ;
Ez ( f i ) = E ;
d i o d e s ( i n d ) . Ezn = E ;
end
end

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

Simulation of Lumped Elements

October 13, 2009

14:16

125

implemented for solving (4.53) based on the the Newton-Raphson method, and its implementation
is given in Listing 4.23.
Listing 4.23 solve diode equation.m
2

10

12

14

function [ x ] = solve diode equation ( A , B , C , x )


% F u n c t i o n used to s o l v e the diode equation
% which i s i n t h e form Ae { Bx}+ x+C=0
% u s i n g t h e NewtonRaphson method
t o l e r a n c e = 1e 25;
max iter = 50;
i t e r = 0;
f = A * exp ( B * x ) + x + C ;
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 ;
x = x f / fp ;
f = A * exp ( B * x ) + x + C ;
i t e r = i t e r + 1;
end

4.2.7.7 Capturing the Sampled Magnetic Field Components After the magnetic eld components are
updated by update magnetic fields, they can be sampled for the current time step. As mentioned
before, although all of the eld components in the problem space can be captured, for now we limit
our discussion with sampling the magnetic eld values at predened positions coinciding with the
nodes of the problem space. The indices of the nodes for which the magnetic eld will be sampled
are stored in the parameters is, js, and ks. However, examining the eld positioning scheme of
the Yee cell reveals that the magnetic eld components are not dened at the node positions.
But it is possible to take the average of the four surrounding eld components as the eld 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 eld 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 eld vector is sought, the x, y, and z components of the eld 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 owing through a
given surface can be calculated using the magnetic elds components circling around the surface.
Therefore, after the magnetic eld components are updated by update magnetic fields, the currents 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 eld components are
updated by update electric fields, they can be sampled for the current time step. Since there is not
an electric eld component dened at the position of the sampling node (is , j s , ks ), an average
of the two eld components around the node can be used as the sampled value. For instance,
to sample the y component of the electric eld, an average of the components E y (is , j s , ks ) and

fdtd_main

SPIB005-Elsherbeni & Demir

126

October 13, 2009

Active and Passive Lumped Elements

(a) Magnetic field components

(b) Electric field components

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 eld components are captured in the subroutine update electric fields, which is shown in
Listing 4.26.
Listing 4.24 capture sampled magnetic fields.m
1

% Capturing magnetic f i e l d s
f o r i n d =1: n u m b e r
is = sampled
js = sampled
ks = sampled

of sampled magnetic fields


m a g n e t i c f i e l d s ( ind ) . i s ;
m a g n e t i c f i e l d s ( ind ) . j s ;
m a g n e t i c f i e l d s ( ind ) . ks ;

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 )
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 ) ) ) ;
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 ) ) ) ;
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 ) ) ) ;
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 ) ) ) ;
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 ) ) ) ;
sampled value = sqrt ( svx 2 + svy 2 + svz 2 ) ;
end
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 ;

11

13

15

17

19

21

23

end

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation of Lumped Elements

14:16

127

Listing 4.25 capture sampled currents.m


% C a p t u r i n g sampled c u r r e n t s
2

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 = sampled currents ( ind ) . i s ;
j s = sampled currents ( ind ) . j s ;
ks = sampled currents ( ind ) . ks ;
i e = sampled currents ( ind ) . i e ;
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 ) )
case x
sampled value = . . .
+ 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 ) ) ) ) . . .
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 ) ) ) ) ;
case y
sampled value = . . .
+ 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 ) ) ) ) . . .
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 ) ) ) ) ;
case z
sampled value = . . .
+ 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 ) ) ) ) . . .
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 ) ) ) ) ;
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 )
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
sampled currents ( ind ) . sampled value ( time step ) = sampled value ;

12

14

16

18

20

22

24

26

28

30

32

34

end

Listing 4.26 capture sampled electric fields.m


% Capturing e l e c t r i c

fields

10

12

f o r i n d =1: n u m b e r
is = sampled
js = sampled
ks = s a m p l e d

of sampled electric fields


e l e c t r i c f i e l d s ( ind ) . i s ;
e l e c t r i c f i e l d s ( ind ) . j s ;
e l e c t r i c f i e l d s ( ind ) . ks ;

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
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
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

128

Active and Passive Lumped Elements


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
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 ) ) ;
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 ) ;

14

16

18

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 ;

20

22

October 13, 2009

end

4.2.7.10 Capturing the Sampled Voltages The indices of the eld 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 dened as a coefcient that would transform
the sum of the electric eld 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 elds are updated and the sampled parameters are captured, the sampled parameters dened 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 gure is activated
using the respective gure number. Then the sampled parameter is plotted from the rst time
step to current time step using MATLABs plot function.
Finally, at the end of display sampled parameters another subroutine display animation is
called to display the elds captured on the predened plane cuts.
Listing 4.27 capture sampled voltages.m
1

11

13

15

% C a p t u r i n g 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
fi
= sampled voltages ( ind ) . f i e l d i n d i c e s ;
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 ) )
case x
s a m p l e d v a l u e = C s v f * sum ( E x ( f i ) ) ;
case y
s a m p l e d v a l u e = C s v f * sum ( E y ( f i ) ) ;
case z
s a m p l e d v a l u e = C s v f * sum ( E z ( f i ) ) ;
end
sampled voltages ( ind ) . sampled value ( time step ) = sampled value ;
end

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

Simulation of Lumped Elements

Listing 4.28 display sampled parameters.m



% d i s p l a y i n g sampled p a r a m e t e r s
2

i f mod ( t i m e s t e p , p l o t t i n g s t e p ) = 0
return ;
end

10

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 ) . . .
* ( cputimes 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 . . .
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

14

16

18

20

22

24

26

% d i s p l a y sampled e l e c t r i c f i e l d s
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
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 ;
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 ) ;
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 ) ;
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 , . . .
linewidth ,1.5);
drawnow ;
end
end

28

30

32

34

36

38

40

42

% d i s p l a y sampled m a g n e t i c f i e l d s
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
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 ;
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 ) ;
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 ) ;
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 , . . .
linewidth ,1.5);
drawnow ;
end
end

44

46

48

50

% d i s p l a y sampled v o l t a g e s
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
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 ;
sampled value = . . .

October 13, 2009

129

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

130

October 13, 2009

Active and Passive Lumped Elements


sampled voltages ( ind ) . sampled value ( 1 : time step ) ;
f i g u r e ( sampled voltages ( ind ) . figure number ) ;
delete ( sampled voltages ( ind ) . plot handle ) ;
sampled voltages ( 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 , . . .
linewidth ,1.5);
drawnow ;
end

52

54

56

58

end
60

62

64

66

68

70

72

74

% d i s p l a y sampled c u r r e n t s
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
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 ;
sampled value = . . .
sampled currents ( ind ) . sampled value ( 1 : time step ) ;
f i g u r e ( sampled currents ( ind ) . figure number ) ;
delete ( sampled currents ( ind ) . plot handle ) ;
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 , . . .
linewidth ,1.5);
drawnow ;
end
end

76

78

% d i s p l a y animated f i e l d s
display animation ;

4.2.8 Displaying FDTD Simulation Results

After the FDTD time-marching loop is completed, the output parameters can be displayed. Furthermore, the output parameters may be postprocessed to obtain some other types of outputs. The
postprocessing and display of the simulation results are performed in the subroutine post process and display results following run fdtd time marching loop in fdtd solve. Listing 4.29 shows the
contents of this subroutine. So far we have dened four types of outputs: sampled electric and
magnetic elds, voltages, and currents. All these outputs are captured during the simulation and are
stored in the arrays sampled value. The variations of these components are obtained as functions
of time; hence, they are called the transient parameters.
Listing 4.29 includes a subroutine display transient parameters, which is used to plot these
sampled transient parameters. As other types of output parameters are dened for the FDTD
solution, new subroutines that implement the postprocessing and displaying of these output
parameters can be added to post process and display results.
Listing 4.29 post process and display results.m
1

disp ( d i s p l a y i n g simulation r e s u l t s ) ;
display transient parameters ;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

Simulation Examples

October 13, 2009

14:16

131

Listing 4.30 display transient parameters.m


disp ( p l o t t i n g the t r a n s i e n t parameters ) ;
2

10

12

14

16

18

20

22

% 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
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
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 ) ;
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 [ . . .
num2str ( i n d ) ] ] , f o n t s i z e , 1 2 ) ;
g r i d on ; hold on ;
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 ) ;
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
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 ;
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 ) ;
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);
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 eld 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 gure is launched and initialized for it. Then the sampled data are
plotted.
4.3 SIMULATION EXAMPLES

So far we have discussed all the basic components for performing an FDTD simulation, including
the denition of the problem, initialization of the problem workspace, running an FDTD timemarching loop, and capturing and displaying the outputs. In this section we provide examples of
some FDTD simulations. We provide the denitions of the problems and show the simulation
results.
4.3.1 A Resistor Excited by a Sinusoidal Voltage Source

The rst example is a simulation of a resistor excited by a voltage source. The geometry of the
problem is shown in Fig. 4.14, and the partial code sections for the denition of the problem are
given in Listings 4.31, 4.32, 4.33, and 4.34. The code sections given next are not complete and
can be completed by the reader referring to the code listings given before.
In Listing 4.31, the size of a unit cell is set to 1 mm on each side. The number of time steps
to run the simulation is 3000. In Listing 4.32, two parallel PEC plates are dened as 4 mm apart.
Between these two plates a voltage source is placed at one end and a resistor is placed at the other
end. Then in Listing 4.33 sinusoidal and unit step waveforms are dened. A voltage source with
50 internal resistance is dened, and the sinusoidal source waveform with frequency 500 MHz
is assigned to the voltage source. Then a resistor with 50 resistance is dened. Listing 4.34

fdtd_main

SPIB005-Elsherbeni & Demir

132

October 13, 2009

Active and Passive Lumped Elements

Figure 4.14 A voltage source terminated by a resistor.

Listing 4.31 define problem space parameters.m



3

% maximum number o f t i m e s t e p s t o run FDTD s i m u l a t i o n


number of time steps = 3000;

% 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
courant factor = 0.9;

11

13

15

% 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;
% 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;
dy = 1.0 e 3;
dz = 1.0 e 3;

17

19

21

% ==<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
% 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
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

54

56

58

% 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;
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 ;
m a t e r i a l t y p e s ( 2 ) . sigma m = 0 ;
material types ( 2 ) . color
= [1 0 0];

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

Simulation Examples

October 13, 2009

14:16

133

Listing 4.32 define geometry.m


6

10

12

% d e f i n e a PEC p l a t e
b r i c k s ( 1 ) . min x = 0 ;
b r i c k s ( 1 ) . min y = 0 ;
b r i c k s ( 1 ) . min z = 0 ;
b r i c k s ( 1 ) . max x = 8e 3;
b r i c k s ( 1 ) . max y = 2e 3;
b r i c k s ( 1 ) . max z = 0 ;
bricks ( 1 ) . material type = 2;

14

16

18

20

22

% d e f i n e a PEC p l a t e
b r i c k s ( 2 ) . min x = 0 ;
b r i c k s ( 2 ) . min y = 0 ;
b r i c k s ( 2 ) . m i n z = 4e 3;
b r i c k s ( 2 ) . max x = 8e 3;
b r i c k s ( 2 ) . max y = 2e 3;
b r i c k s ( 2 ) . max z = 4e 3;
bricks ( 2 ) . material type = 2;

Listing 4.33 define sources and lumped elements.m


11

13

15

17

19

21

23

25

27

% 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 ;
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;
% voltage sources
% 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
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 ;
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;
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;
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;
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 ;
v o l t a g e s o u r c e s ( 1 ) . waveform index = 2;

29

31

33

35

37

39

% resistors
% direction :
% resistance
resistors (1).
resistors (1).
resistors (1).
resistors (1).
resistors (1).
resistors (1).
resistors (1).
resistors (1).

x , y , or z
: ohms
m i n x = 7 . 0 e 3;
mi n y = 0 ;
min z = 0 ;
max x = 8 . 0 e 3;
max y = 2 . 0 e 3;
max z = 4 . 0 e 3;
direction = z ;
r e s i s t a n c e = 50;

fdtd_main

SPIB005-Elsherbeni & Demir

134

October 13, 2009

Active and Passive Lumped Elements

Listing 4.34 define output parameters.m



9

11

13

% figure refresh rate


p l o t t i n g s t e p = 100;
% mode o f o p e r a t i o n
run simulation = true ;
show material mesh = true ;
show problem space = true ;

15

17

19

21

23

% define
sampled
sampled
sampled
sampled
sampled
sampled
sampled
sampled

sampled
voltages
voltages
voltages
voltages
voltages
voltages
voltages
voltages

voltages
( 1 ) . m i n x = 5 . 0 e 3;
( 1 ) . min y = 0 ;
( 1 ) . min z = 0 ;
( 1 ) . max x = 5 . 0 e 3;
( 1 ) . max y = 2 . 0 e 3;
( 1 ) . max z = 4 . 0 e 3;
( 1 ) . d i r e c t i o n = zp ;
( 1 ) . display plot = true ;

% define
sampled
sampled
sampled
sampled
sampled
sampled
sampled
sampled

sampled
currents
currents
currents
currents
currents
currents
currents
currents

currents
( 1 ) . m i n x = 5 . 0 e 3;
( 1 ) . min y = 0 ;
( 1 ) . m i n z = 4 . 0 e 3;
( 1 ) . max x = 5 . 0 e 3;
( 1 ) . max y = 2 . 0 e 3;
( 1 ) . max z = 4 . 0 e 3;
( 1 ) . d i r e c t i o n = xp ;
( 1 ) . display plot = true ;

25

27

29

31

33

shows the outputs dened for this simulation. A sampled voltage is dened between the parallel
PEC plates. Furthermore, a sampled current is dened 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) conrms that the sum of the
resistances is 100 .

4.3.2 A Diode Excited by a Sinusoidal Voltage Source

The second example is the simulation of a diode excited by a sinusoidal voltage source. The
geometry of the problem is given in Fig. 4.16, and the partial code sections for the denition of
the problem are given in Listings 4.35, 4.36, and 4.37.
In Listing 4.35, two parallel PEC plates are dened 1 mm apart. Between these two plates a
voltage source is placed at one end and a diode is placed at the other end. Then in Listing 4.36
sinusoidal and unit step waveforms are dened. A voltage source with 50 internal resistance is
dened, and the sinusoidal source waveform with frequency 500 MHz is assigned to the voltage
source. Then a diode in the negative z direction is dened. Listing 4.37 shows the output dened
for this simulation; a sampled voltage is dened across the diode.

14:16

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation Examples

135

(volt)

0.5

0.5

1
0

voltage source
sampled voltage
1

3
time (ns)

(a) Source waveform and sampled voltage

0.01
0.008
0.006
0.004
(ampere)

fdtd_main

0.002
0
0.002
0.004
0.006
0.008
sampled current
0.01
0

3
time (ns)

(b) Sampled current


Figure 4.15 Sinusoidal voltage source waveform with 500 MHz frequency and sampled voltage and current.

14:16

SPIB005-Elsherbeni & Demir

October 13, 2009

136

Active and Passive Lumped Elements

(a) A voltage source terminated by a diode

10
5
(volt)

fdtd_main

0
5
voltage source
sampled voltage

10
0

3
time (ns)

(b) Source waveform and sampled voltage


Figure 4.16 Sinusoidal voltage source waveform with 500 MHz frequency and sampled voltage.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation Examples

14:16

137

Listing 4.35 define geometry.m


7

11

13

15

17

19

21

% d e f i n e a PEC p l a t e
b r i c k s ( 1 ) . min x = 0 ;
b r i c k s ( 1 ) . min y = 0 ;
b r i c k s ( 1 ) . min z = 0 ;
b r i c k s ( 1 ) . max x = 2e 3;
b r i c k s ( 1 ) . max y = 2e 3;
b r i c k s ( 1 ) . max z = 0 ;
bricks ( 1 ) . material type = 2;
% d e f i n e a PEC p l a t e
b r i c k s ( 2 ) . min x = 0 ;
b r i c k s ( 2 ) . mi n y = 0 ;
b r i c k s ( 2 ) . m i n z = 1e 3;
b r i c k s ( 2 ) . max x = 2e 3;
b r i c k s ( 2 ) . max y = 2e 3;
b r i c k s ( 2 ) . max z = 1e 3;
bricks ( 2 ) . material type = 2;

Listing 4.36 define sources and lumped elements.m


11

13

15

17

19

21

23

25

27

% 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 ;
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;
% voltage sources
% 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
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 ;
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 . 0 e 3;
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 = 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 ;
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;
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

31

33

35

37

% diodes
% d i r e c t i o n : xp , xn , yp ,
d i o d e s ( 1 ) . m i n x = 2 . 0 e 3;
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;
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;
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 ;

yn ,

zp , o r zn

fdtd_main

SPIB005-Elsherbeni & Demir

138

October 13, 2009

Active and Passive Lumped Elements

Listing 4.37 define output parameters.m


9

11

13

% figure refresh rate


p l o t t i n g s t e p = 10;
% mode o f o p e r a t i o n
run simulation = true ;
show material mesh = true ;
show problem space = true ;

15

17

19

21

23

% define
sampled
sampled
sampled
sampled
sampled
sampled
sampled
sampled

sampled
voltages
voltages
voltages
voltages
voltages
voltages
voltages
voltages

voltages
( 1 ) . m i n x = 2 . 0 e 3;
( 1 ) . m i n y = 1 . 0 e 3;
( 1 ) . min z = 0 ;
( 1 ) . max x = 2 . 0 e 3;
( 1 ) . max y = 1 . 0 e 3;
( 1 ) . max z = 1 . 0 e 3;
( 1 ) . d i r e c t i o n = zp ;
( 1 ) . display plot = true ;

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.
4.3.3 A Capacitor Excited by a Unit-Step Voltage Source

The third example is the simulation of a capacitor excited by a unit step voltage source. The
geometry of the problem is given in Fig. 4.17, and the partial code sections for the denition of
the problem are given in Listings 4.38 and 4.39.
Listing 4.38 define geometry.m
7

11

13

15

17

19

21

% d e f i n e a PEC p l a t e
b r i c k s ( 1 ) . min x = 0 ;
b r i c k s ( 1 ) . mi n y = 0 ;
b r i c k s ( 1 ) . min z = 0 ;
b r i c k s ( 1 ) . max x = 1e 3;
b r i c k s ( 1 ) . max y = 1e 3;
b r i c k s ( 1 ) . max z = 0 ;
bricks ( 1 ) . material type = 2;
% d e f i n e a PEC p l a t e
b r i c k s ( 2 ) . min x = 0 ;
b r i c k s ( 2 ) . mi n y = 0 ;
b r i c k s ( 2 ) . m i n z = 1e 3;
b r i c k s ( 2 ) . max x = 1e 3;
b r i c k s ( 2 ) . max y = 1e 3;
b r i c k s ( 2 ) . max z = 1e 3;
bricks ( 2 ) . material type = 2;

14:16

SPIB005-Elsherbeni & Demir

October 13, 2009

Exercises

139

0.8

0.6
(volt)

fdtd_main

0.4

0.2
sampled voltage
analytical solution
voltage source

0
0

time (ns)

(a) A voltage source terminated by


a capacitor

(b) Sampled voltage and analytical solution

Figure 4.17 Unit step voltage source waveform and sampled voltage.

In Listing 4.38, two parallel PEC plates are dened 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
tt0

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.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

140

October 13, 2009

Active and Passive Lumped Elements

Figure 4.18 Dimensions of 50 stripline.

Listing 4.39 define sources and lumped elements.m



11

13

15

17

19

21

23

25

27

% 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 ;
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;
% voltage sources
% 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
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 ;
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 . 0 e 3;
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 = 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 ;
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 ;
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

31

33

35

37

39

% capacitors
% d i r e c t i o n : x , y , or z
% capacitance : farads
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 ;
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;
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;
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;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

Exercises

October 13, 2009

141

Figure 4.19 A 50 stripline terminated by a resistor.

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

Figure 4.20 A circuit composed of a voltage source, a capacitor, and a diode.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

142

October 13, 2009

Active and Passive Lumped Elements

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.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

5
Source Waveforms
and Transformation from
Time Domain to Frequency Domain
Sources are necessary components of a nite-difference time-domain (FDTD) simulation and
their types vary depending on the type of problem under consideration. Usually sources are of
two types: (1) near, such as the voltage and current sources described in Chapter 4; and (2) far,
such as the incident elds appearing in scattering problems. In any case a source excites electric
and magnetic elds with a waveform as a function of time. The type of waveform can be selected
specic to the problem under consideration. However, some limitations of the FDTD method
should be kept in mind while constructing the source waveforms to obtain a valid and accurate
simulation result.
One of the considerations for the source waveform construction is the spectrum of the frequency
components of the waveform. A temporal waveform is the sum of time-harmonic waveforms with a
spectrum of frequencies that can be obtained using the Fourier transform. The temporal waveform
is said to be in time domain, and its Fourier transformed form is said to be in frequency domain. The
Fourier transform of the source waveforms and other output parameters can be used to obtain
some useful results in the frequency domain. In this chapter we discuss selected types of waveforms
and then introduce the numerical algorithms for calculating the Fourier transform of temporal
functions in discrete time.
5.1 COMMON SOURCE WAVEFORMS FOR FDTD SIMULATIONS

A source waveform should be chosen such that its frequency spectrum includes all the frequencies
of interest for the simulation, and it should have a smooth turn-on and turn-off to minimize
the undesired effects of high-frequency components. A sine or a cosine function is a singlefrequency waveform, whereas other waveforms such as Gaussian pulse, time derivative of Gaussian
pulse, cosine-modulated Gaussian pulse, and Blackman-Harris window are multiple frequency
waveforms. The type and parameters of the waveforms can be chosen based on the frequency
spectrum of the waveform of interest.
5.1.1 Sinusoidal Waveform

Denition and construction of a sinusoidal waveform was presented in Chapter 4. As mentioned


before, a sinusoidal waveform is ideally a single-frequency waveform. However, in an FDTD
simulation the waveform can be excited for a limited duration, and the turn-on and turn-off of the
143

14:16

SPIB005-Elsherbeni & Demir

October 13, 2009

144

Source Waveforms

nite 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 nite 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)

while the inverse Fourier transform is


1
x(t) =
2

X()e j t d .

(5.2)

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 nite 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.

1
0.8
0.6
0.4
magnitude

fdtd_main

0.2
0
0.2
0.4
0.6
0.8
1
2

4
time (s)

Figure 5.1 (a) A sinusoidal waveform excited for 4 seconds: x (t).

14:16

SPIB005-Elsherbeni & Demir

October 13, 2009

Common Source Waveforms

145

2.5

magnitude

1.5

0.5

0
3

0
1
frequency (Hz)

10

Figure 5.1 (b) A sinusoidal waveform excited for 4 seconds: X () magnitude.

1
0.8
0.6
0.4
magnitude

fdtd_main

0.2
0
0.2
0.4
0.6
0.8
1
2

4
time (s)

Figure 5.2 (a) A sinusoidal waveform excited for 8 seconds: x (t).

14:16

SPIB005-Elsherbeni & Demir

October 13, 2009

146

Source Waveforms

4.5
4
3.5
3
magnitude

fdtd_main

2.5
2
1.5
1
0.5
0
3

0
1
frequency (Hz)

Figure 5.2 (b) A sinusoidal waveform excited for 8 seconds: X () magnitude.

If it is intended to observe the response of an electromagnetic problem due to a sinusoidal


excitation, the simulation should be run long enough such that the transient response due to the
turn on of the sources die out and only the sinusoidal response persists.
5.1.2 Gaussian Waveform

Running an FDTD simulation will yield numerical results for a dominant frequency as well as
for other frequencies in the spectrum of the nite sinusoidal excitation. However, the sinusoidal
waveform is not an appropriate choice if simulation results for a wideband of frequencies are
sought.
The frequency spectrum of the source waveform determines the range of frequencies for which
valid and accurate results can be obtained. As the frequency increases, the wavelength decreases
and becomes comparable to the cell size of the problem space. If the cell size is too large compared
with a fraction of a wavelength, the signal at that frequency cannot be sampled accurately in space.
Therefore, the highest frequency in the source waveform spectrum should be chosen such that the
cell size is not larger than a fraction of the highest-frequency wavelength. For many applications,
setting the highest-frequency wavelength larger than 20 cells size is sufcient for a reasonable
FDTD simulation. A Gaussian waveform is the best choice for a source waveform, since it can
be constructed to contain all frequencies up to a highest frequency that is tied to a cell size by a
factor. This factor, which is the proportion of the highest frequency wavelength to the unit cell
size, is referred as number of cells per wavelength nc .
A Gaussian waveform can be written as a function of time as
t2

g(t) = e 2 ,

(5.3)

14:16

SPIB005-Elsherbeni & Demir

October 13, 2009

Common Source Waveforms

147

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
fmax =

c
min

c
,
nc s max

(5.5)

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 nd
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 transform 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

1
0.9
0.8
0.7
magnitude

fdtd_main

0.6
0.5
0.4
0.3
0.2
0.1
0
8

0
time (s)

Figure 5.3 (a) A Gaussian waveform and its Fourier transform: g (t).

14:16

SPIB005-Elsherbeni & Demir

October 13, 2009

148

Source Waveforms

3
max
2.5

2
magnitude

fdtd_main

1.5

1
10% of max
0.5

fmax
0
0.5

0
frequency (Hz)

0.5

Figure 5.3 (b) A Gaussian waveform and its Fourier transform: G () magnitude.

magnitude as illustrated in Fig. 5.3(b). Therefore, by solving the equation


0.1 = e

2
2 max
4

we can nd a relation between and fmax , such that

2.3
=
.
fmax

(5.6)

Using (5.5) in (5.6), we can tie nc and s max to as

2.3nc s max nc s max


.
=
c
2c

(5.7)

Once the parameters nc and s max are dened, the parameter can be calculated and can be used
in (5.3) to construct the Gaussian waveform spectrum that allows one to obtain a valid frequency
response up to fmax .
Determination of the parameter is not enough to construct the Gaussian waveform that
can be directly used in an FDTD simulation. One should notice in Fig. 5.3(a) that the Gaussian
waveforms maximum coincides with time instant zero. However, in an FDTD simulation the
initial conditions of the elds are zero; hence, the sources must also be zero. This can be achieved
by shifting the Gaussian waveform in time such that at time instant zero the waveform value is
zero or is (practically) negligible. Furthermore, time shifting preserves the frequency content of
the waveform.

14:16

SPIB005-Elsherbeni & Demir

October 13, 2009

Common Source Waveforms

149

1
0.9
0.8
0.7
magnitude

fdtd_main

0.6
0.5
0.4
0.3
0.2

0.1
0
2

6
time (s)

10

12

14

Figure 5.4 Gaussian waveform shifted by t0 = 4.5 in time.

With time shifting the Gaussian waveform takes the form


g(t) = e

(tt0 )2
2

(5.8)

where t0 is the amount of time shift. We can nd 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 nd

t0 = 20
(5.9)
= 4.5.
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 .
5.1.3 Normalized Derivative of a Gaussian Waveform

In some applications it may be desired to excite the problem space with a pulse that has a
wide frequency spectrum but does not include zero frequency or very low-frequency components.
Furthermore, if it is not necessary, it is better to avoid the simulation of low-frequency components
since simulation of these components need long simulation time. For such cases the derivative of
the Gaussian waveform is a suitable choice. The derivative of a Gaussian waveform normalized to
the maximum can be found as

2e t22
te .
(5.10)
g(t) =

14:16

SPIB005-Elsherbeni & Demir

October 13, 2009

150

Source Waveforms

The Fourier transform of this function can be determined as

j 2 e 2 2
G() =
e 4 .

(5.11)

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 nd 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

(tt0 )2
2e
(t t0 )e 2 .
(5.12)
g(t) =

The time shift value t0 can be obtained as well using the readily available equation (5.9).

1
0.8
0.6
0.4
magnitude

fdtd_main

0.2
0
0.2
0.4
0.6
0.8
1
8

0
time (s)

Figure 5.5 (a) Normalized derivative of a Gaussian waveform and its Fourier transform: g (t).

14:16

SPIB005-Elsherbeni & Demir

October 13, 2009

Common Source Waveforms

151

2.5

2
magnitude

fdtd_main

1.5

1
10% of max

10% of max

0.5

0
0

f min
0.1

f max
0.2

0.3
0.4
0.5
frequency (Hz)

0.6

0.7

0.8

Figure 5.5 (b) Normalized derivative of a Gaussian waveform and its Fourier transform: G () magnitude.
5.1.4 Cosine-Modulated Gaussian Waveform

Another common waveform used in FDTD applications is the cosine-modulated Gaussian waveform. A Gaussian waveform includes frequency components over a band centered at zero frequency
as illustrated in Fig. 5.3(b). Modulating a signal with a cosine function having frequency fc corresponds to shifting the frequency spectrum of the modulated signal by fc in the frequency domain.
Therefore, if it is desired to perform a simulation to obtain results for a frequency band centered
at a frequency fc , the cosine-modulated Gaussian pulse is a suitable choice. One can rst construct
a Gaussian waveform with a desired bandwidth and then can multiply the Gaussian pulse with a
cosine function with frequency fc . Then the corresponding waveform can be expressed as
t2

g(t) = cos(c t)e 2 ,


while its Fourier transform can be written as

2 (c )2
2 (+c )2
4
4
G() =
+
,
e
e
2
2

(5.13)

(5.14)

where c = 2 fc . A cosine-modulated Gaussian waveform and its Fourier transform are illustrated in Fig. 5.6. To construct a cosine-modulated Gaussian waveform with spectrum having  f
bandwidth centered at fc , rst we nd in (5.14) that satises the  f bandwidth requirement.
We can utilize (5.6) to nd such that

2 2.3 0.966
=
.
(5.15)
=
f
f

14:16

SPIB005-Elsherbeni & Demir

October 13, 2009

152

Source Waveforms

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
nd the required time shift value, t0 . Then the nal equation for the cosine-modulated Gaussian
waveform takes the form
g(t) = cos(c (t t0 )) e

(tt0 )2
2

(5.16)

5.2 DEFINITION AND INITIALIZATION OF SOURCE WAVEFORMS FOR FDTD SIMULATIONS

In the previous section we discussed some common types of source waveforms that can be used
to excite an FDTD problem space, and we derived equations for waveform function parameters
to construct waveforms for desired frequency spectrum properties. In this section we discuss the
denition and implementation of these source waveforms in an FDTD MATLAB code.
In Section 4.2.1 we showed that we can dene the parameters specic to various types of
waveforms in a structure named waveforms. We have shown how a unit step function and a
sinusoidal waveform can be dened as subelds of the structure waveforms. We can add new
subelds to the structure waveforms to dene the new types of source waveforms. For instance,
consider the Listing 5.1, where a sample section of the subroutine define sources and lumped elements illustrates the denition of the source waveforms. In addition to the unit step function and
sinusoidal waveform, the Gaussian waveform is dened as the subeld waveforms.gaussian, the
derivative of a Gaussian waveform is dened as waveforms.derivative gaussian, and the cosinemodulated Gaussian waveform is dened as waveforms.cosine modulated gaussian. Each of
these subelds is an array, so more than one waveform of the same type can be dened in

1
0.8
0.6
0.4
magnitude

fdtd_main

0.2
0
0.2
0.4
0.6
0.8
1
8

0
time (s)

Figure 5.6 (a) Cosine modulated Gaussian waveform and its Fourier transform: g (t).

14:16

SPIB005-Elsherbeni & Demir

October 13, 2009

Initialization of Source Waveforms

153

0.9
0.8
0.7
0.6
magnitude

fdtd_main

0.5
0.4
0.3
0.2
f

0.1
0
4

1
0
1
frequency (Hz)

2
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 dened. 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 dened in the subroutine define problem space parameters will be used
as the default value.
The cosine-modulated Gaussian waveform has the parameter bandwidth, which species 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 dened, 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 subelds in the source structures in initialize sources and lumped elements.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

154

Source Waveforms

Listing 5.1 define sources and lumped elements.m



d i s p ( d e f i n i n g s o u r c e s and lumped e l e m e n t components ) ;
2

10

12

14

16

18

20

22

24

26

28

30

32

voltage sources = [ ] ;
current sources = [ ] ;
diodes = [ ] ;
resistors = [];
inductors = [ ] ;
capacitors = [ ] ;
% 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 ;
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;
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;
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 ;
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 ;
% voltage sources
% 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
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 ;
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;
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;
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;
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 ;
v o l t a g e s o u r c e s ( 1 ) . waveform index = 2;

5.3 TRANSFORMATION FROM TIME DOMAIN TO FREQUENCY DOMAIN

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 inputoutput 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)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Transformation from Time Domain to Frequency Domain

Listing 5.2 initialize waveforms.m



1

disp ( i n i t i a l i z i n g s o u r c e waveforms ) ;
% 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 )
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 = . . .
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 ;
end
end

11

13

15

17

19

% i n i t i a l i z e u n i t s t e p waveforms
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 )
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 ;
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 ;
end
end

21

23

25

27

29

31

33

35

37

% i n i t i a l i z e G a u s s i a n waveforms
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 )
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 ;
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 ;
end
w a v e f o r m s . g a u s s i a n ( i n d ) . maximum frequency = . . .
c / ( nc * max ( [ dx , dy , dz ] ) ) ;
t a u = ( nc * max ( [ dx , dy , dz ] ) ) / ( 2 * c ) ;
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 ;
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 ) ;
end
end

39

41

43

45

47

49

% 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
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 )
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
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
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 ;
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 = . . .

155

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

156

53

55

57

61

63

65

67

69

71

73

Source Waveforms
c / ( nc * max ( [ dx , dy , dz ] ) ) ;
t a u = ( nc * max ( [ dx , dy , dz ] ) ) / ( 2 * c ) ;
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 ;
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 = . . .
( 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

51

59

October 13, 2009

end
% 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 )
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 = . . .
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 ;
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 ;
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 = . . .
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
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.
Listing 5.3 time to frequency domain.m
1

f u n c t i o n [ 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 )
% x : a r r a y i n c l u d i n g t h e sampled v a l u e s a t d i s c r e t e t i m e s t e p s
% d t : s a m p l i n g p e r i o d , d u r a t i o n o f an FDTD t i m e s t e p
% f r e q u e n c y a r r a y : l i s t o f f r e q u e n c i e s f o r which t r a n s f o r m i s p e r f o r m e d
% t i m e s h i f t : a v a l u e i n o r d e r t o a c c o u n t f o r t h e t i m e s h i f t between
% e l e c t r i c and m a g n e t i c f i e l d s

11

13

15

number of time steps = size ( x , 2 ) ;


number of frequencies = size ( frequency array , 2 ) ;
X = zeros (1 , number of frequencies ) ;
w = 2 * pi * f r e q u e n c y a r r a y ;
for n = 1: number of time steps
t = n * dt + t i m e s h i f t ;
X = X + x ( n ) * exp ( j * w * t ) ;
end
X = X * dt ;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Transformation from Time Domain to Frequency Domain

14:16

157

Another input parameter that needs consideration is time shift. As discussed in previous chapters, the electric eld-related values and magnetic eld-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 eld-related values (e.g., sampled voltages), time shift can take the value 0, whereas for the magnetic eld-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 efcient 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) =



 
m=M1
X(0) + m=1
X(m)e j t + X (m)e j t ,
2

(5.18)

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.
Listing 5.4 frequency to time domain.m

2

f u n c t i o n [ x ] = f r e q u e n c y t o t i m e d o m a i n ( X , df , t i m e a r r a y )
% X : a r r a y i n c l u d i n g t h e sampled v a l u e s a t d i s c r e t e f r e q u e n c y s t e p s
% d f : s a m p l i n g p e r i o d i n f r e q u e n c y domain
% t i m e a r r a y : l i s t o f t i m e s t e p s f o r which
%
i n v e r s e transform i s performed

10

12

14

16

number of frequencies = size ( X , 2 ) ;


number of time points = size ( time array , 2 ) ;
x = zeros (1 , number of time points ) ;
dw = 2 * p i * d f ;
x = X ( 1 ) ; % z e r o f r e q u e n c y component
for m = 2: number of frequencies
w = ( m1) * dw ;
x = x + X (m) * exp ( j * w * t i m e a r r a y )+ c o n j ( X (m ) )
* exp ( j * w * t i m e a r r a y ) ;
end
x = x * df ;

...

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

158

Source Waveforms

Listing 5.5 define output parameters.m


16

18

% 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 = 1 e7 ;
f r e q u e n c y d o m a i n . end
= 1 e9 ;
f r e q u e n c y d o m a i n . s t e p = 1 e7 ;

In general, we can dene a list of frequencies for which we seek the frequency-domain response
in the define output parameters subroutine, which is illustrated in Listing 5.5. Here a structure
frequency domain is dened to store the frequency-domain-specic parameters. The subelds
start, end, and step correspond to the respective values of a uniformly sampled list of frequencies.
The desired list of frequencies is calculated and assigned to an array frequency domain.frequencies in the initialize output parameters subroutine as shown in Listing 5.6.
The initialization of output parameters is implemented in the subroutine initialize output parameters, as shown in Listing 5.6.
The post processing and display of the simulation results are performed in the subroutine
post process and display results following run fdtd time marching loop in fdtd solve. We can
add two new subroutines to post process and display results as illustrated in Listing 5.7: calculate frequency domain outputs and display frequency domain outputs. The time-to-frequencydomain transformations can be performed in calculate frequency domain outputs, for which the
sample code is shown in Listing 5.8. In this subroutine the time-domain arrays of sampled values
are transformed to frequency domain using the function time to frequency domain, and the
calculated frequency-domain arrays are assigned to the frequency domain value subeld of the
respective structures. Finally, the subroutine display frequency domain outputs, a partial section
of which is listed in Listing 5.9, can be called to display the frequency-domain outputs.
5.4 SIMULATION EXAMPLES

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 specic 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

10

12

% 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 :
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 = . . .
s i z e ( frequency domain . frequencies , 2 ) ;

...

Listing 5.7 post process and display results.m


1

disp ( d i s p l a y i n g simulation r e s u l t s ) ;
display transient parameters ;
calculate frequency domain outputs ;
display frequency domain outputs ;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation Examples

14:16

159

Listing 5.8 calculate frequency domain outputs.m


1

d i s p ( g e n e r a t i n g f r e q u e n c y domain o u t p u t s ) ;

frequency array = frequency domain . frequencies ;

11

% 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
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;
[ 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 ;
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

33

35

37

39

41

43

45

47

% sampled c u r r e n t 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 c u r r e n t s
x = sampled currents ( ind ) . sampled value ;
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 ) ;
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 ;
end
% 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
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;
[ 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 ;
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

Listing 5.9 display frequency domain outputs.m


41

43

45

47

49

51

53

55

57

% 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
f r e q u e n c i e s = s a m p l e d v o l t a g e s ( i n d ) . f r e q u e n c i e s * 1 e 9;
f d v a l u e = sampled voltages ( ind ) . frequency domain value ;
figure ;
t i t l e ( [ sampled v o l t a g e [ num2str ( i n d ) ] ] , f o n t s i z e , 1 2 ) ;
subplot ( 2 , 1 , 1 ) ;
p l o t ( f r e q u e n c i e s , abs ( f d v a l u e ) , b , 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 ) ;
y l a b e l ( magnitude , f o n t s i z e , 1 2 ) ;
g r i d on ;
subplot ( 2 , 1 , 2 ) ;
p l o t ( f r e q u e n c i e s , a n g l e ( f d v a l u e ) * 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 ) ;
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 ;
drawnow ;
end

fdtd_main

SPIB005-Elsherbeni & Demir

160

October 13, 2009

Source Waveforms

5.4.1 Recovering a Time Waveform from Its Fourier Transform

The rst example illustrates how the functions time to frequency domain and frequency to time domain can be used. Consider the program recover a time waveform given in Listing 5.10.
Listing 5.10 recover a time waveform.m
1

11

13

15

17

19

clc ; close all ; clear all ;


% C o n s t r u c t a G a u s s i a n Waveform i n time , f r e q u e n c y s p e c t r u m o f which
% h a s i t s m a g n i t u d e a t 1 GHz a s 10% o f t h e maximum .
maximum frequency = 1 e9 ;
t a u = s q r t ( 2 . 3 ) / ( p i * maximum frequency ) ;
t 0 = 4.5 * tau ;
t i m e a r r a y = [ 1 : 1 0 0 0 ] * 1 e 11;
g = exp ( ( ( t i m e a r r a y t 0 ) / t a u ) . 2 ) ;
figure ( 1 ) ;
p l o t ( t i m e a r r a y * 1 e9 , g , b , l i n e w i d t h , 1 . 5 ) ;
t i t l e ( g ( t )= e { ( ( t t 0 ) / \ t a u ) 2 } , f o n t s i z e , 1 4 ) ;
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 ) ;
s e t ( gca , f o n t s i z e , 1 2 ) ;
g r i d on ;
% 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 ;
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

23

25

27

29

31

33

35

figure ( 2 ) ;
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 ) ;
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 ) ;
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 ) ;
g r i d on ;
subplot ( 2 , 1 , 2 ) ;
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 ) ;
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 ) ;
g r i d on ;
drawnow ;

37

39

% 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
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

43

45

47

figure ( 3 ) ;
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 ) ;
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 ) ;
s e t ( gca , f o n t s i z e , 1 2 ) ;
g r i d on ;

14:16

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation Examples

161

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).

5.4.2 An RLC Circuit Excited by a Cosine-Modulated Gaussian Waveform

The second example is a simulation of a 10 n H inductor and a 10 p F capacitor connected in series


and excited by a voltage source with 50 internal resistor. The geometry of the problem is shown
in Fig. 5.8(a) as it is simulated by the FDTD program. The equivalent circuit representation of
the problem is illustrated in 5.8(b). The size of a unit cell is set to 1 mm on each side. The number
of time steps to run the simulation is 2000. Two parallel PEC plates are dened 2 mm apart from
each other as shown in Listing 5.11. A voltage source is placed in between these plates at one end,
and an inductor and a capacitor are placed in series at the other end as shown in Listing 5.12.
A cosine-modulated Gaussian waveform with 2 GHz center frequency is assigned to the voltage
source. A sampled voltage is dened between the parallel PEC plates at the load end as shown in
Listing 5.13.

1
0.9
0.8
0.7
magnitude

fdtd_main

0.6
2

g(t)=e((tt0)/)

0.5
0.4
0.3
0.2
0.1
0
0

6
time (ns)

Figure 5.7 (a) A Gaussian waveform and its Fourier transform: g (t).

10

14:16

SPIB005-Elsherbeni & Demir

October 13, 2009

162

Source Waveforms

G() = F(g(t))

magnitude

x 10

0.5

0
0

0.5

1
frequency (GHz)

1.5

0.5

1
frequency (GHz)

1.5

phase (degrees)

200
100
0
100
200
0

Figure 5.7 (b) A Gaussian waveform and its Fourier transform: G ().

1
0.9
0.8
0.7
magnitude

fdtd_main

0.6
g(t)= F1(G())

0.5
0.4
0.3
0.2
0.1
0
0

time (ns)
Figure 5.7 (c) A Gaussian waveform and its Fourier transform: g (t) recovered from G ().

10

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation Examples

14:16

163

Rs=50
Vs
(a) Circuit simulated in FDTD

C=10pF
L=10nH

Vo

(b) Lumped element equivalent circuit

Figure 5.8 An RLC circuit.

Listing 5.11 define geometry.m


1

d i s p ( d e f i n i n g t h e problem g e o m e t r y ) ;
bricks = [ ] ;
spheres = [ ] ;

11

13

15

17

19

21

% d e f i n e a PEC p l a t e
b r i c k s ( 1 ) . min x = 0 ;
b r i c k s ( 1 ) . min y = 0 ;
b r i c k s ( 1 ) . min z = 0 ;
b r i c k s ( 1 ) . max x = 1e 3;
b r i c k s ( 1 ) . max y = 1e 3;
b r i c k s ( 1 ) . max z = 0 ;
bricks ( 1 ) . material type = 2;
% d e f i n e a PEC p l a t e
b r i c k s ( 2 ) . min x = 0 ;
b r i c k s ( 2 ) . mi n y = 0 ;
b r i c k s ( 2 ) . m i n z = 2e 3;
b r i c k s ( 2 ) . max x = 1e 3;
b r i c k s ( 2 ) . max y = 1e 3;
b r i c k s ( 2 ) . max z = 2e 3;
bricks ( 2 ) . material type = 2;

Listing 5.12 define sources and lumped elements.m


1

d i s p ( d e f i n i n g s o u r c e s and lumped e l e m e n t components ) ;


voltage sources = [ ] ;
current sources = [ ] ;
diodes = [ ] ;
resistors = [];
inductors = [ ] ;

fdtd_main

SPIB005-Elsherbeni & Demir

164

October 13, 2009

Source Waveforms

capacitors = [ ] ;
9

11

13

15

17

% 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 ;
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;
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;
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 = 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

21

23

25

27

29

31

33

35

37

39

41

43

45

47

49

51

53

55

57

% voltage sources
% 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
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 ;
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 ;
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;
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;
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 ;
v o l t a g e s o u r c e s ( 1 ) . waveform index = 1;
% inductors
% direction :
% inductance
inductors ( 1 ) .
inductors ( 1 ) .
inductors ( 1 ) .
inductors ( 1 ) .
inductors ( 1 ) .
inductors ( 1 ) .
inductors ( 1 ) .
inductors ( 1 ) .

x , y , or z
: henrys
m i n x = 1 . 0 e 3;
min y = 0 . 0 ;
min z = 0 . 0 ;
max x = 1 . 0 e 3;
max y = 1 . 0 e 3;
max z = 1 . 0 e 3;
direction = z ;
i n d u c t a n c e = 10 e 9;

% capacitors
% d i r e c t i o n : x , y , or z
% capacitance : farads
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 ;
c a p a c i t o r s ( 1 ) . m i n z = 1 . 0 e 3;
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;
c a p a c i t o r s ( 1 ) . max z = 2 . 0 e 3;
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;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation Examples

14:16

165

Listing 5.13 define output parameters.m



1

disp ( d e f i n i n g output parameters ) ;


sampled
sampled
sampled
sampled

electric fields = [];


magnetic fields = [ ] ;
voltages = [ ] ;
currents = [ ] ;

11

13

% figure refresh rate


p l o t t i n g s t e p = 10;
% mode o f o p e r a t i o n
run simulation = true ;
show material mesh = true ;
show problem space = true ;

15

17

19

21

23

25

27

29

% 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 e7 ;
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 = 2 e7 ;
% define
sampled
sampled
sampled
sampled
sampled
sampled
sampled
sampled

sampled
voltages
voltages
voltages
voltages
voltages
voltages
voltages
voltages

voltages
( 1 ) . m i n x = 1 . 0 e 3;
( 1 ) . min y = 0 . 0 ;
( 1 ) . min z = 0 . 0 ;
( 1 ) . max x = 1 . 0 e 3;
( 1 ) . max y = 1 . 0 e 3;
( 1 ) . max z = 2 . 0 e 3;
( 1 ) . d i r e c t i o n = zp ;
( 1 ) . display plot = true ;

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 nd the transfer function of this
circuit by normalizing the output voltage Vo to Vs . Furthermore, we can perform a circuit analysis
to nd the transfer function of the equivalent circuit in Fig. 5.8(b), which yields
T() =

s 2 LC + 1
Vo ()
= 2
,
Vs ()
s LC + s RC + 1

(5.19)

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.

SPIB005-Elsherbeni & Demir

October 13, 2009

166

Source Waveforms

1
voltage source
sampled voltage

0.8
0.6
(volt)

0.4
0.2
0
0.2
0.4
0.6
0

0.5

1.5
2
time (ns)

2.5

3.5

Figure 5.9 Time-domain response, V o , compared with source waveform, V s .

5.5 EXERCISES

5.1

Consider the stripline structure that you constructed in Exercise 4.2. Dene 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 eld of the parameters
sampled voltages(i) and sampled currents(i). Input impedance of this stripline can be

magnitude

10

x 10

2
0
0

phase (degrees)

fdtd_main

2
frequency (GHz)

2
frequency (GHz)

200
0
200
0

Figure 5.10 (a) Frequency-domain response of source waveform V s and output voltage V o : Fourier transform
of V s .

14:16

SPIB005-Elsherbeni & Demir

October 13, 2009

Exercises

167
10

magnitude

x 10
1.5
1
0.5
0
0

0.5

1.5
2
2.5
frequency (GHz)

3.5

0.5

1.5
2
2.5
frequency (GHz)

3.5

phase (degrees)

200
100
0
100
200
0

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
|Vo/Vs| exact

1.2
1
magnitude

fdtd_main

0.8
0.6
0.4
0.2
0
0

0.5

Figure 5.11 Transfer function T () =

V o ()
.
V s ()

1.5
2
2.5
frequency (GHz)

3.5

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

168

October 13, 2009

Source Waveforms

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 reections 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 reections 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 reections are captured and only the Gaussian waveform
would be observed as the sampled transient voltage. This way you would be simulating an
innitely 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 dene a sampled current to capture the current owing 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.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

6
Scattering Parameters
Scattering parameters (S-parameters) are used to characterize the response of radiofrequency
(RF) and microwave circuits, and they are more commonly used than other types of network
parameters (e.g., Y-parameters, Z-parameters) because they are easier to measure and work with
at high frequencies [12]. In this chapter we discuss the methods to obtain the S-parameters from
a nite-difference time-domain (FDTD) simulation of a single or multiport circuit.
6.1 S-PARAMETERS AND RETURN LOSS DEFINITIONS

S-parameters are based on the power waves concept. The incident and reected power waves a i
and b i associated with port i are dened as
ai =

Vi + Zi Ii
,

2 |Re{Zi }|

bi =

Vi Zi Ii
,

2 |Re{Zi }|

(6.1)

where Vi , and Ii are the voltage and the current owing 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

S11 S12
b1
b 2 S21 S22

.. = ..
..
. .
.
bN
SN1 SN2


a1
S1N
a2
S2N

. . .
..
. .. ..
SNN
aN

(6.2)

By denition, 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
Smn =

bm
.
an

(6.3)

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

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

170

Scattering Parameters

I2

I1
a1

+
b1 _V1
Z1

+
a2
V2 b
_ 2

N-port circuit

IN

Z2
+VN _
bN

ZN

aN
Figure 6.1 An N -port network.

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 reected 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 Sparameters are plotted by their magnitudes in decibels such that |Smn |d B = 20 log10 (|Smn |) and
by their phases.
6.2 S-PARAMETER CALCULATIONS

In this section, we illustrate the implementation of S-parameter calculations through an example.


S-parameters are associated with ports; therefore, ports are the necessary components for the Sparameter calculations. To dene a port we need a sampled voltage and a sampled current dened
at the same location and associated with the port. Consider the two-port circuit shown in Fig. 6.2,
which has been published in [14] as an example for the application of the FDTD method to
the analysis of planar microstrip circuits. The problem space is composed of cells having x =
0.4064 mm, y = 0.4233 mm, and z = 0.265 mm. An air gap of 5 cells is left between the circuit
and the outer boundary in the xn, xp, yn, and y p directions and of 10 cells in the zp direction. The
outer boundary is PEC and touches the ground of the circuit in the zn direction. The dimensions
of the microstrips are shown in Fig. 6.2(b) and are implemented in Listing 6.1. The substrate is
3 z thick and has a dielectric constant of 2.2. The microstrip lter is terminated by a voltage
source with 50 internal resistance on one end and by a 50 resistor on the other end. The
voltage source is excited by a Gaussian waveform with 20 cells per wavelength accuracy parameter.
Two sampled voltages and two sampled currents are dened 10 cells away from the ends of the
microstrip terminations as implemented in Listing 6.2.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

S-Parameter Calculations

October 13, 2009

171

Figure 6.2 (a) A microstrip low-pass filter terminated by a voltage source and a resistor on two ends: threedimensional 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 dened 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 subeld 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 subeld
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.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

172

October 13, 2009

Scattering Parameters

Listing 6.1 define geometry.m


1

d i s p ( d e f i n i n g t h e problem g e o m e t r y ) ;
bricks = [ ] ;
spheres = [ ] ;

11

13

15

17

19

21

% define a substrate
b r i c k s ( 1 ) . min x = 0 ;
b r i c k s ( 1 ) . mi n y = 0 ;
b r i c k s ( 1 ) . min z = 0 ;
b r i c k s ( 1 ) . max x = 50 * dx ;
b r i c k s ( 1 ) . max y = 46 * dy ;
b r i c k s ( 1 ) . max z = 3 * dz ;
bricks ( 1 ) . material type = 4;
% 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 ;
b r i c k s ( 2 ) . mi n y = 0 ;
b r i c k s ( 2 ) . m i n z = 3 * dz ;
b r i c k s ( 2 ) . max x = 20 * dx ;
b r i c k s ( 2 ) . max y = 20 * dy ;
b r i c k s ( 2 ) . max z = 3 * dz ;
bricks ( 2 ) . material type = 2;

23

25

27

29

31

33

35

37

39

% d e f i n e a PEC p l a t e
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 ;
b r i c k s ( 3 ) . m i n z = 3 * dz ;
b r i c k s ( 3 ) . max x = 36 * dx ;
b r i c k s ( 3 ) . max y = 46 * dy ;
b r i c k s ( 3 ) . max z = 3 * dz ;
bricks ( 3 ) . material type = 2;
% d e f i n e a PEC p l a t e
b r i c k s ( 4 ) . min x = 0 ;
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 ;
b r i c k s ( 4 ) . max x = 50 * dx ;
b r i c k s ( 4 ) . max y = 26 * dy ;
b r i c k s ( 4 ) . max z = 3 * dz ;
bricks ( 4 ) . material type = 2;

41

43

45

47

49

% d e f i n e a PEC p l a t e a s ground
b r i c k s ( 5 ) . min x = 0 ;
b r i c k s ( 5 ) . mi n y = 0 ;
b r i c k s ( 5 ) . min z = 0 ;
b r i c k s ( 5 ) . max x = 50 * dx ;
b r i c k s ( 5 ) . max y = 46 * dy ;
b r i c k s ( 5 ) . max z = 0 ;
bricks ( 5 ) . material type = 2;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

S-Parameter Calculations

173

Listing 6.2 define output parameters.m



1

disp ( d e f i n i n g output parameters ) ;


sampled electric fields = [];
sampled magnetic fields = [ ] ;
sampled voltages = [ ] ;
sampled currents = [ ] ;
ports = [ ] ;
% figure refresh rate
p l o t t i n g s t e p = 100;

11

13

15

17

19

% mode o f o p e r a t i o n
run simulation = true ;
show material mesh = true ;
show problem space = true ;
% 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 ;
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

23

25

27

29

% define
sampled
sampled
sampled
sampled
sampled
sampled
sampled
sampled

sampled
voltages
voltages
voltages
voltages
voltages
voltages
voltages
voltages

voltages
( 1 ) . m i n x = 14 * dx ;
( 1 ) . m i n y = 10 * dy ;
( 1 ) . min z = 0 ;
( 1 ) . max x = 20 * dx ;
( 1 ) . max y = 10 * dy ;
( 1 ) . max z = 3 * dz ;
( 1 ) . d i r e c t i o n = zp ;
(1). display plot = false ;

sampled
sampled
sampled
sampled
sampled
sampled
sampled
sampled

voltages
voltages
voltages
voltages
voltages
voltages
voltages
voltages

(2).
(2).
(2).
(2).
(2).
(2).
(2).
(2).

% define
sampled
sampled
sampled
sampled
sampled
sampled
sampled
sampled

sampled
currents
currents
currents
currents
currents
currents
currents
currents

currents
( 1 ) . m i n x = 14 * dx ;
( 1 ) . m i n y = 10 * dy ;
( 1 ) . m i n z = 3 * dz ;
( 1 ) . max x = 20 * dx ;
( 1 ) . max y = 10 * dy ;
( 1 ) . max z = 3 * dz ;
( 1 ) . d i r e c t i o n = yp ;
(1). display plot = false ;

31

33

35

37

39

41

43

45

47

49

m i n x = 30 * dx ;
m i n y = 36 * dy ;
min z = 0 . 0 ;
max x = 36 * dx ;
max y = 36 * dy ;
max z = 3 * dz ;
d i r e c t i o n = zp ;
display plot = false ;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

174

51

53

55

57

October 13, 2009

Scattering Parameters

sampled
sampled
sampled
sampled
sampled
sampled
sampled
sampled

currents
currents
currents
currents
currents
currents
currents
currents

(2).
(2).
(2).
(2).
(2).
(2).
(2).
(2).

m i n x = 30 * dx ;
m i n y = 36 * dy ;
m i n z = 3 * dz ;
max x = 36 * dx ;
max y = 36 * dy ;
max z = 3 * dz ;
d i r e c t i o n = yn ;
display plot = false ;

59

61

63

% define
ports ( 1 ) .
ports ( 1 ) .
ports ( 1 ) .
ports ( 1 ) .

ports
sampled voltage index = 1;
sampled current index = 1;
impedance = 5 0 ;
is source port = true ;

ports
ports
ports
ports

sampled voltage index = 2;


sampled current index = 2;
impedance = 5 0 ;
is source port = false ;

65

67

69

(2).
(2).
(2).
(2).

terminating the microstrip line. One additional subeld of ports is is source port, which indicates
whether the port is the source port or not. In this two ports example the rst 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 dened as owing 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 rst 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 dening a single source, sources can
be dened 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 dene 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 reected 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.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

S-Parameter Calculations

14:16

175

Listing 6.3 initialize output parameters.m


1

disp ( i n i t i a l i z i n g the output parameters ) ;


number
number
number
number
number

of
of
of
of
of

sampled electric fields


sampled magnetic fields
sampled voltages = size
sampled currents = size
ports = size ( ports , 2 ) ;

= size ( sampled electric fields , 2 ) ;


= size ( sampled magnetic fields , 2 ) ;
( sampled voltages , 2 ) ;
( sampled currents , 2 ) ;

Listing 6.4 calculate frequency domain outputs.m


59

61

63

65

67

69

% c a l c u l a t i o n o f Sp a r a m e t e r s
% c a l c u l a t e i n c i d e n t and r e f l e c t e d power w a ve s
f o r i n d =1: n u m b e r o f p o r t s
s v i = p o r t s ( ind ) . sampled voltage index ;
s c i = p o r t s ( ind ) . sampled current index ;
Z = p o r t s ( i n d ) . impedance ;
V = sampled voltages ( s v i ) . frequency domain value ;
I = sampled currents ( s c i ) . frequency domain value ;
p o r t s ( i n d ) . a = 0 . 5 * ( V+Z . * I ) . / s q r t ( r e a l ( Z ) ) ;
p o r t s ( i n d ) . b = 0 . 5 * ( Vc o n j ( Z ) . * I ) . / s q r t ( r e a l ( Z ) ) ;
p o r t 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

71

73

75

77

79

% c a l c u l a t e t h e Sp a r a m e t e r s
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
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 ;
end
end
end

Listing 6.5 display frequency domain outputs.m


117

119

121

123

125

127

129

131

% f i g u r e s f o r Sp a r a m e t e r s
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
f r e q u e n c i e s = p o r t s ( i n d ) . f r e q u e n c i e s * 1 e 9;
f o r o i n d =1: n u m b e r o f p o r t s
S = p o r t s ( ind ) . S ( oind ) . v a l u e s ;
Sdb = 20 * l o g 1 0 ( abs ( S ) ) ;
Sphase = angle ( S ) * 1 8 0 / pi ;
figure ;
subplot ( 2 , 1 , 1 ) ;
p l o t ( f r e q u e n c i e s , Sdb , b , l i n e w i d t h , 1 . 5 ) ;
t i t l e ( [ S num2str ( o i n d ) num2str ( i n d ) ] , 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 ) ;
y l a b e l ( m a g n i t u d e ( dB ) , f o n t s i z e , 1 2 ) ;
g r i d on ;

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

176

Scattering Parameters
subplot ( 2 , 1 , 2 ) ;
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 ) ;
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 ;
drawnow ;

133

135

137

end
end

139

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 dened.
Although the reference planes for the S-parameters are dened away from the terminations, it is
possible to dene the planes at the terminations. It is sufcient 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 lter 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
lter. One can notice that, although the simulation is performed in 20,000 time steps, which

10
S11

magnitude (dB)

10

20

30

40

50
0

10
frequency (GHz)

Figure 6.3 (a) S-parameters of the microstrip low-pass filter: S 11 .

15

20

14:16

SPIB005-Elsherbeni & Demir

October 13, 2009

S-Parameter Calculations

177

10
S21

magnitude (dB)

10

20

30

40

50
0

10
frequency (GHz)

15

20

Figure 6.3 (b) S-parameters of the microstrip low-pass filter: S 21 .

0.25
sampled voltage at port 2
0.2
0.15

(volt)

fdtd_main

0.1
0.05
0
0.05
0.1
0

6
time (ns)

Figure 6.4 Sampled voltage at the second port of the microstrip low-pass filter.

10

12

14:16

SPIB005-Elsherbeni & Demir

October 13, 2009

178

Scattering Parameters

0.25
sampled voltage at port 2
0.2
0.15

(volt)

fdtd_main

0.1
0.05
0
0.05
0.1
0

6
time (ns)

10

12

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 lter 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
lter lossy dielectric substrate. Therefore, the truncation at a diminishing time-domain waveform
will not cause signicant 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.

6.3 SIMULATION EXAMPLES


6.3.1 Quarter-Wave Transformer

In this example the simulation of a microstrip quarter-wave transformer is presented. The geometry and the dimensions of the circuit are shown in Fig. 6.7. The circuit is constructed on a substrate
having 1 mm thickness and 4.6 dielectric constant. The index of the material type of the microstrip
substrate is 4. A voltage source with internal resistance 50 is connected to a 50 microstrip
line having 1.8 mm width and 4 mm length. This line is matched to a 100 line through a 70.7
line having 1 mm width and 10 mm length at 4 GHz. The 100 line has 0.4 mm width and 4 mm
length and is terminated by a 100 resistor. The FDTD problem space is composed of cubic cells
with sides each measuring 0.2 mm. The boundaries of the problem space are PEC on all sides;
however, to suppress the cavity resonances another material type is dened as an absorber. The

14:16

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation Examples

179

10
S11

magnitude (dB)

10

20

30

40

50
0

10
frequency (GHz)

15

20

Figure 6.6 (a) S-parameters of the microstrip low-pass filter with e = 0.2: S 11 .

10
S21
0

magnitude (dB)

fdtd_main

10

20

30

40

50
0

10
frequency (GHz)

15

Figure 6.6 (b) S-parameters of the microstrip low-pass filter with e = 0.2: S 21 .

20

14:16

SPIB005-Elsherbeni & Demir

October 13, 2009

180

Scattering Parameters

RL=100
Sampled voltage 2
Sampled current 2

Absorber

z
y
x

Absorbers
Voltage source
Sampled voltage 1
Sampled current 1

4 mm
50 line

1.8 mm

10 mm

4 mm

70.7 line

1 mm

100 line

0.4 mm

10 mm

fdtd_main

thickness = 1 mm, dielectric constant = 4.6


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 ve sides are surrounded by the absorber material. The denition of the relevant problem
space parameters and geometry are shown in Listing 6.6. The denition of the voltage source and
the resistor are shown in Listing 6.7. In the previous example, the sampled voltages and sampled
currents are dened on the microstrip lines away from the voltage source and the terminating
resistor. In this example the sampled voltages and sampled currents are dened on the voltage
source and the terminating resistor. Then the sampled voltages and currents are assigned to ports.
The denition 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.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation Examples

181

magnitude (dB)

0
S11
20

40
0

3
4
5
frequency (GHz)

magnitude (dB)

0
S21
0.5
1
1.5
0

3
4
5
frequency (GHz)

Figure 6.8 The S 11 and S 21 of the microstrip quarter-wave transformer circuit.

Listing 6.6 define geometry.m



d i s p ( d e f i n i n g t h e problem g e o m e t r y ) ;
2

10

12

bricks = [ ] ;
spheres = [ ] ;
% define a b r i c k with material type 4
b r i c k s ( 1 ) . min x = 0 ;
b r i c k s ( 1 ) . min y = 0 ;
b r i c k s ( 1 ) . min z = 0 ;
b r i c k s ( 1 ) . max x = 10 e 3;
b r i c k s ( 1 ) . max y = 18 e 3;
b r i c k s ( 1 ) . max z = 1e 3;
bricks ( 1 ) . material type = 4;

14

16

18

20

22

24

% define a b r i c k with material type 2


b r i c k s ( 2 ) . m i n x = 4e 3;
b r i c k s ( 2 ) . min y = 0 ;
b r i c k s ( 2 ) . m i n z = 1e 3;
b r i c k s ( 2 ) . max x = 5 . 8 e 3;
b r i c k s ( 2 ) . max y = 4e 3;
b r i c k s ( 2 ) . max z = 1e 3;
bricks ( 2 ) . material type = 2;
% define a b r i c k with material type 2
b r i c k s ( 3 ) . m i n x = 4 . 4 e 3;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

182
26

28

30

bricks
bricks
bricks
bricks
bricks
bricks

Scattering Parameters
(3).
(3).
(3).
(3).
(3).
(3).

mi n y = 4e 3;
m i n z = 1e 3;
max x = 5 . 4 e 3;
max y = 14 e 3;
max z = 1e 3;
material type = 2;

32

34

36

38

40

42

44

46

48

% define a b r i c k with material type 2


b r i c k s ( 4 ) . m i n x = 4 . 8 e 3;
b r i c k s ( 4 ) . mi n y = 14 e 3;
b r i c k s ( 4 ) . m i n z = 1e 3;
b r i c k s ( 4 ) . max x = 5 . 2 e 3;
b r i c k s ( 4 ) . max y = 18 e 3;
b r i c k s ( 4 ) . max z = 1e 3;
bricks ( 4 ) . material type = 2;
% 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;
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;
b r i c k s ( 5 ) . max x = 11 e 3;
b r i c k s ( 5 ) . max y = 20 e 3;
b r i c k s ( 5 ) . max z = 4e 3;
bricks ( 5 ) . material type = 5;

50

52

54

56

58

60

62

64

66

% d e f i n e a b s o r b e r f o r xn s i d e
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;
b r i c k s ( 6 ) . min z = 0 ;
b r i c k s ( 6 ) . max x = 0 ;
b r i c k s ( 6 ) . max y = 20 e 3;
b r i c k s ( 6 ) . max z = 4e 3;
bricks ( 6 ) . material type = 5;
% 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;
b r i c k s ( 7 ) . mi n y = 2e 3;
b r i c k s ( 7 ) . min z = 0 ;
b r i c k s ( 7 ) . max x = 11 e 3;
b r i c k s ( 7 ) . max y = 20 e 3;
b r i c k s ( 7 ) . max z = 4e 3;
bricks ( 7 ) . material type = 5;

68

70

72

74

76

October 13, 2009

% d e f i n e a b s o r b e r f o r yn s i d e
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;
b r i c k s ( 8 ) . min z = 0 ;
b r i c k s ( 8 ) . max x = 11 e 3;
b r i c k s ( 8 ) . max y = 1e 3;
b r i c k s ( 8 ) . max z = 4e 3;
bricks ( 8 ) . material type = 5;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation Examples
78

80

82

84

14:16

183

% 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;
b r i c k s ( 9 ) . mi n y = 19 e 3;
b r i c k s ( 9 ) . min z = 0 ;
b r i c k s ( 9 ) . max x = 11 e 3;
b r i c k s ( 9 ) . max y = 20 e 3;
b r i c k s ( 9 ) . max z = 4e 3;
bricks ( 9 ) . material type = 5;

Listing 6.7 define sources and lumped elements.m


24

26

28

30

32

voltage
voltage
voltage
voltage
voltage
voltage
voltage
voltage
voltage
voltage
voltage

sources
sources
sources
sources
sources
sources
sources
sources
sources
sources
sources

(1).
(1).
(1).
(1).
(1).
(1).
(1).
(1).
(1).
(1).
(1).

m i n x = 4e 3;
min y = 0 ;
min z = 0 ;
max x = 5 . 8 e 3;
max y = 0 . 4 e 3;
max z = 1e 3;
d i r e c t i o n = zp ;
r e s i s t a n c e = 50;
magnitude = 1 ;
waveform type = gaussian ;
waveform index = 1;

34

36

38

40

42

resistors
resistors
resistors
resistors
resistors
resistors
resistors
resistors

(1).
(1).
(1).
(1).
(1).
(1).
(1).
(1).

m i n x = 4 . 8 e 3;
mi n y = 1 7 . 6 e 3;
min z = 0 ;
max x = 5 . 2 e 3;
max y = 18 e 3;
max z = 1e 3;
direction = z ;
r e s i s t a n c e = 100;

Listing 6.8 define output parameters.m


17

19

% 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 e7 ;
f r e q u e n c y d o m a i n . end
= 8 e9 ;
f r e q u e n c y d o m a i n . s t e p = 2 e7 ;

29

% define
sampled
sampled
sampled
sampled
sampled
sampled
sampled
sampled

31

% d e f i n e sampled v o l t a g e s

21

23

25

27

sampled
voltages
voltages
voltages
voltages
voltages
voltages
voltages
voltages

voltages
( 1 ) . m i n x = 4e 3;
( 1 ) . min y = 0 ;
( 1 ) . min z = 0 ;
( 1 ) . max x = 5 . 8 e 3;
( 1 ) . max y = 0 . 4 e 3;
( 1 ) . max z = 1e 3;
( 1 ) . d i r e c t i o n = zp ;
(1). display plot = false ;

fdtd_main

SPIB005-Elsherbeni & Demir

184

33

35

37

39

41

43

45

47

49

51

53

55

57

59

61

63

65

67

69

Scattering Parameters
m i n x = 4 . 8 e 3;
m i n y = 1 7 . 6 e 3;
min z = 0 ;
max x = 5 . 2 e 3;
max y = 18 e 3;
max z = 1e 3;
d i r e c t i o n = zp ;
display plot = false ;

sampled
sampled
sampled
sampled
sampled
sampled
sampled
sampled

voltages
voltages
voltages
voltages
voltages
voltages
voltages
voltages

(2).
(2).
(2).
(2).
(2).
(2).
(2).
(2).

% define
sampled
sampled
sampled
sampled
sampled
sampled
sampled
sampled

sampled
currents
currents
currents
currents
currents
currents
currents
currents

currents
( 1 ) . m i n x = 4e 3;
( 1 ) . min y = 0 ;
( 1 ) . m i n z = 0 . 4 e 3;
( 1 ) . max x = 5 . 8 e 3;
( 1 ) . max y = 0 . 4 e 3;
( 1 ) . max z = 0 . 6 e 3;
( 1 ) . d i r e c t i o n = zp ;
(1). display plot = false ;

% define
sampled
sampled
sampled
sampled
sampled
sampled
sampled
sampled

sampled
currents
currents
currents
currents
currents
currents
currents
currents

currents
( 2 ) . m i n x = 4 . 8 e 3;
( 2 ) . m i n y = 1 7 . 6 e 3;
( 2 ) . m i n z = 0 . 4 e 3;
( 2 ) . max x = 5 . 2 e 3;
( 2 ) . max y = 18 e 3;
( 2 ) . max z = 0 . 6 e 3;
( 2 ) . d i r e c t i o n = zp ;
(2). display plot = false ;

% define
ports ( 1 ) .
ports ( 1 ) .
ports ( 1 ) .
ports ( 1 ) .

ports
sampled voltage index = 1;
sampled current index = 1;
impedance = 5 0 ;
is source port = true ;

ports
ports
ports
ports

sampled voltage index = 2;


sampled current index = 2;
impedance = 1 0 0 ;
is source port = false ;

October 13, 2009

(2).
(2).
(2).
(2).

6.4 EXERCISES

6.1

Consider the low-pass lter 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 lter 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

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

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. Redene 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 gures plotting
S12 and S22 , and verify that they are similar to the S21 and S11 in Fig. 6.8, respectively.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

7
Perfectly Matched Layer Absorbing
Boundary
Because computational storage space is nite, the nite-difference time-domain (FDTD) problem space size is nite 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 problems, 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 reections, 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 nite-thickness special medium surrounding the computational
space based on ctitious 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.

7.1 THEORY OF PML

In this section we demonstrate analytically the reectionless characteristics of PML at the vacuum
PML and PMLPML interfaces [15] in detail.
7.1.1 Theory of PML at the Vacuum-PML Interface

We provide the analysis of reection at a vacuumPML interface in a two-dimensional case.


Consider the T E z polarized plane wave propagating in an arbitrary direction as shown in Fig. 7.1.
In the given T E z case E x , E y , and Hz are the only eld components that exist in the twodimensional space. These eld components can be expressed in the time-harmonic domain as
E x = E0 sin 0 e j (txy) ,
E y = E0 cos 0 e

j (txy)

Hz = H0 e j (txy) .
187

(7.1a)
(7.1b)
(7.1c)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

188

Perfectly Matched Layer

Ey

0
Ex

Hz

Figure 7.1 The field decomposition of a T E z polarized plane wave.

Maxwells equations for a TEz polarized wave are


0

Ex
Hz
+ e Ex =
,
t
y

Ey
Hz
+ e Ey =
,
t
x
Ey
Hz
Ex
+ m Hz =

.
0
t
y
x
0

(7.2a)
(7.2b)
(7.2c)

In a T E z PML medium, Hz can be broken into two articial components associated with the x
and y directions as
Hzx = Hzx0 e j y e j (tx) ,

(7.3a)

Hzy = Hzy0 e j x e j (ty) ,

(7.3b)

where Hz = Hzx + Hzy . Therefore, a modied set of Maxwells equations for a T E z polarized
PML medium can be expressed as
0

(Hzx + Hzy )
Ex
+ pe y E x =
,
t
y

Ey
(Hzx + Hzy )
+ pe x E y =
,
t
x
Ey
Hzx
+ pmx Hzx =
,
0
t
x
Hzy
Ex
0
+ pmy Hzy =
,
t
y
0

(7.4a)
(7.4b)
(7.4c)
(7.4d)

where pe x , pe y , pmx , and pmy are the introduced ctitious 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 eld components of E x and Hzy represent a
wave propagating in the y direction. Substituting the eld equations for the x and y propagating

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Theory of PML

189

waves in (7.1a), (7.1b), (7.3a), and (7.3b) into the modied Maxwells equations given, one can
obtain
pe y
E0 sin 0 = (Hzx0 + Hzy0 ),

pe x
E0 cos 0 = (Hzx0 + Hzy0 ),
0 E0 cos 0 j

pmx
0 Hzx0 j
Hzx0 = E0 cos 0 ,

pmy
Hzy0 = E0 sin 0 .
0 Hzy0 j

0 E0 sin 0 j

(7.5a)
(7.5b)
(7.5c)
(7.5d)

Using equations (7.5c) and (7.5d) to eliminate magnetic eld terms from equations (7.5a) and
(7.5b) yields



cos 0
sin 0


 + 
 ,
sin 0 = 
0 0
1 j pmx /0
1 j pmy /0




pe x
cos 0
sin 0


 + 
 .
cos 0 = 
0 0 1 j
0
1 j pmx /0
1 j pmy /0


pe y
1 j
0

(7.6a)

(7.6b)

The unknown constants and can be obtained from (7.6a) and (7.6b) as


pe x
1 j
cos 0 ,
0



0 0
pe y
sin 0 ,
1 j
=
G
0

0 0
G

(7.7a)
(7.7b)

where
G=

wx cos2 0 + w y sin2 0 ,

(7.8)

and
wx =

1 j pe x /0
,
1 j pmx /0

wy =

1 j pe y /0
,
1 j pmy /0

(7.9)

Therefore, the generalized eld component can be expressed as


= 0 e



x cos 0 +y sin 0

cos

sin
j t
pex c G 0 x pey c G 0 y
cG

(7.10)

where the rst exponential represents the phase of a plane wave and the second and third exponentials govern the decrease in the magnitude of the wave along the x axis and y axis, respectively.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

190

Perfectly Matched Layer

Once and are determined by (7.7), the split magnetic eld can be determined from (7.5c) and
(7.5d) as

Hzx0 = E0

Hzy0 = E0

0 wx cos2 0
,
0
G

(7.11a)

0 w y sin2 0
.
0
G

(7.11b)

The magnitude of the total magnetic eld Hz is then given as



H0 = Hzx0 + Hzy0 = E0

0
G.
0

(7.12)

The wave impedance in a T E z PML medium can be expressed as


Z=

E0
=
H0

0 1
.
0 G

(7.13)

It is important to note that if the conductivity parameters are chosen such that
pe x
pmx
=
0
0

and

pe y
pmy
=
,
0
0

(7.14)

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 satised, a T E z polarized wave can
propagate from free space into the PML medium without reection 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 eld updating equation (7.4) for the PML region
becomes that of a vacuum region.
7.1.2 Theory of PML at the PMLPML Interface

The reection of elds at the interface between two different PML media can be analyzed as
follows. A T E z polarized wave of arbitrary incidence traveling from PML layer 1 to PML layer
2 is depicted in Fig. 7.2, where the interface is normal to the x axis. The reection coefcient

pex1 , pmx1 pex 2 , pmx 2


pey1 , pmy1 pey 2 , pmy 2

1
y
x

Figure 7.2 The plane wave transition at the interface between two PML media.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Theory of PML

191

for an arbitrary incident wave between two lossy media can be expressed as
rp =

Z2 cos 2 Z1 cos 1
,
Z2 cos 2 + Z1 cos 1

(7.15)

where Z1 and Z2 are the intrinsic impedances of respective mediums. Applying (7.13), the reection
coefcient r p becomes
rp =

G1 cos 2 G2 cos 1
.
G1 cos 2 + G2 cos 1

(7.16)

The Snell-Descartes law at the interface normal to x of two lossy media can be described as




y1 sin 1
y2 sin 2
1i
= 1i
.
0
G1
0
G2

(7.17)

When the two media have the same conductivities pe y1 = pe y2 = pe y and pmy1 = pmy2 = pmy ,
(7.17) becomes
sin 2
sin 1
=
.
G1
G2

(7.18)

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
reections, 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 )
satises (7.14), the reection coefcient at this interface is also null, which agrees with the previous
vacuumPML analysis. However, if the two media have the same ( pe y , pmy ) but do not satisfy
(7.14), then the reection coefcient becomes
rp =

sin 1 cos 2 sin 2 cos 1


.
sin 1 cos 2 + sin 2 cos 1

(7.19)

Substituting (7.18) into equation (7.19), the reection coefcient of two unmatched PML media
becomes

wx1 wx2
.
(7.20)
rp =

wx1 + wx2
Equation (7.20) shows that the reection coefcient for two unmatched PML media is highly
dependent on frequency, regardless of the incident angle. When the two PML media follow the
reectionless condition in (7.14), wx1 = wx2 = 1, the reection coefcient 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
1i
= 1i
.
(7.21)
0
G1
0
G2

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

192

Perfectly Matched Layer

Figure 7.3 The loss distributions in two-dimensional PML regions.

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 reection coefcient at this interface is r p = 0. To match the vacuumPML interface normal
to the y axis, the reectionless condition can be achieved when ( pe y2 , pmy2 ) of the PML medium
satises (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 reections. 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 reection [21]. Using the same impedance matching condition
in (7.14), the modied Maxwells equations for two-dimensional T Mz PML updating equations
are obtained as

Hy
E zx
+ pe x E zx =
,
t
x

(7.22a)

E zy
Hx
+ pe y E zy =
,
t
y

(7.22b)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Three-Dimensional PML

193

(E zx + E zy )
Hx
+ pmy Hx =
,
t
y

(7.22c)

Hy
(E zx + E zy )
+ pmx Hy =
.
t
x

(7.22d)

The nite difference approximation schemes can be applied to the modied Maxwells equations
(7.4) and (7.22) to obtain the eld-updating equations for the PML regions in the two-dimensional
FDTD problem space.

7.2 PML EQUATIONS FOR THREE-DIMENSIONAL PROBLEM SPACE

For a three-dimensional problem space, each eld component of the electric and magnetic elds
is broken into two eld components similar to the two-dimensional case. Therefore, the modied
Maxwells equations have 12 eld components instead of the original six components. These
modied split electric eld equations presented in [16] are

E xy
(Hzx + Hzy )
+ pe y E xy =
,
t
y

(7.23a)

(Hy x + Hy z )
E xz
+ pe z E xz =
,
t
z

(7.23b)

Eyx
(Hzx + Hzy )
+ pe x E y x =
,
t
x
Eyz
(Hxy + Hxz )
+ pe z E y z =
,
0
t
z

(Hy x + Hy z )
E zx
+ pe x E zx =
,
t
x
E zy
(Hxy + Hxz )
0
+ pe y E zy =
,
t
y

(7.23c)
(7.23d)
(7.23e)
(7.23f)

whereas the modied Maxwells split magnetic eld equations are

(Ezx + Ezy )
Hxy
,
+ pmy Hxy =
t
y

(7.24a)

(E y x + E y z )
Hxz
+ pmz Hxz =
,
t
z

(7.24b)

Hy z
(E xy + E xz )
+ pmz Hy z =
,
t
z

(7.24c)

Hy x
(E zx + E zy )
+ pmx Hy x =
,
t
x

(7.24d)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

194

Perfectly Matched Layer

Hzy
(E xy + E xz )
+ pmy Hzy =
,
t
y

(7.24e)

(E y x + E y z )
Hzx
+ pmx Hzx =
.
t
x

(7.24f)

Then the matching condition for a three-dimensional PML is given by


pe x
pmx
=
,
0
0

pe y
pe y
=
,
0
0

and

pe z
pmz
=
.
0
0

(7.25)

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

(c) Nonzero pez and pmz

(d) Overlapping PML regions

Figure 7.4 Nonzero regions of PML conductivities for a three-dimensional FDTD simulation domain.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

PML Loss Functions

195

reections. 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 nite difference schemes to the modied Maxwells equations (7.23) and
(7.24), one can obtain the FDTD eld updating equations for the three-dimensional PML regions.
7.3 PML LOSS FUNCTIONS

As discussed in the previous sections, PML regions can be formed as the boundaries of an FDTD
problem space where specic conductivities are assigned such that the outgoing waves penetrate
without reection and attenuate while traveling in the PML medium. The PML medium is
governed by the modied Maxwells equations (7.4), (7.22), (7.23), and (7.24), which can be used
to obtain the updating equations for the eld components in the PML regions. Furthermore, the
outer boundaries of the PML regions are terminated by PEC walls. When a nite-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 reections to the interior domain from the PEC back wall may
occur. For a nite-width PML medium where the conductivity distribution is uniform, there is
an apparent reection coefcient, which is expressed as
R(0 ) = e

cos 0
0 c

(7.26)

where is the conductivity of the medium. Here the exponential term is the attenuation factor
of the eld 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 vacuumPML interface and the PEC backing. If 0 is 0, equation (7.26) is
the reection coefcient for a nite-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 nite-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
nite-width PML medium but also to compute the appropriate loss distribution based on the loss
proles described in the following paragraphs.
As presented in [15], signicant reections were observed when constant uniform losses are
assigned throughout the PML media, which is a result of the discrete approximation of elds and
material parameters at the domainPML interfaces and sharp variation of conductivity proles.
This mismatch problem can be tempered using a spatially gradually increasing conductivity distribution, which is zero at the domainPML 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 proles: power and geometrically increasing functions. The
power-increasing function is dened as
 n pml
,
() = max



n pml + 1 0 c ln(R(0))
,
max =
2s N

(7.27a)
(7.27b)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

196

Perfectly Matched Layer

where is the distance from the computational domainPML interface to the position of the eld
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 reection coefcient of the nite-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 prole using (7.27a) the parameters R(0) and n pml
must be predened. 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 108 for a satisfactory PML performance.
The geometrically increasing distribution for () is given by

() = 0 g s ,
0 =

0 c ln(g)
ln(R(0)),
2s g N 1

(7.28a)
(7.28b)

where the parameter g is a real number used for a geometrically increasing function.
7.4 FDTD UPDATING EQUATIONS FOR PML AND MATLAB IMPLEMENTATION
7.4.1 PML Updating EquationsTwo-Dimensional TE z Case

The PML updating equations can be obtained for the two-dimensional T E z case by applying the
central difference approximation to the derivatives in the modied Maxwells equations (7.4). After
some manipulations one can obtain the two-dimensional T E z PML updating equations based on
the eld positioning scheme given in Fig. 1.10 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) ,

(7.29)

where
Ce xe (i, j ) =

20 t pe y (i, j )
,
20 + t pe y (i, j )

2t

Ce xhz (i, j ) = 
.
e (i, j ) y
20 + t pe
y
 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
Ce ye (i, j ) =

20 t pe x (i, j )
,
20 + t pe x (i, j )

2t

Ce yhz (i, j ) = 
.
20 + t pe x (i, j ) x


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)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

PML Updating Equations

197

where
C hzxh (i, j ) =

20 t pmx (i, j )
,
20 + t pmx (i, j )

2t

C hzxe y (i, j ) = 
.
20 + 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
C hzyh (i, j ) =

20 t pmy (i, j )
,
20 + t pmy (i, j )

2t

C hzye x (i, j ) = 
.
20 + 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 dened 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 dened.
Figure 7.5 shows the PML regions where the conductivity parameters are nonzero and the
respective eld components that need to be updated at each region. Figure 7.5(a) shows the
regions where pe x is dened. 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 eld Hz is the sum of two split elds 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 eld 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 ) ,
where
C hzxh (i, j ) = 1,

C hzxe y (i, j ) =

t
.
0 x

(7.33)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

198

Perfectly Matched Layer

(a) Nonzero pex

(b) Nonzero pey

(c) Nonzero pmx

(d) Nonzero pmy

Figure 7.5 Nonzero TE z regions of PML conductivities.

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 ) ,
where
C hzyh (i, j ) = 1,

C hzye x (i, j ) =

t
.
0 y

(7.34)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

PML Updating Equations

199

After all the components of Hzx and Hzy are updated in the PML regions, they are added to
calculate Hz .
7.4.2 PML Updating EquationsTwo-Dimensional TM z Case

The PML updating equations can be obtained for the two-dimensional T Mz case by applying the
central difference approximation to the derivatives in the modied Maxwells equations (7.22).
After some manipulations one can obtain the two-dimensional T Mz PML updating equations
based on the eld positioning scheme given in Fig. 1.11 as
 n+ 1

n+ 1
n+1
n
E zx
(i, j ) = Ce zxe (i, j ) E zx
(i, j ) + Ce zxhy (i, j ) Hy 2 (i, j ) Hy 2 (i 1, j ) ,
(7.35)
where
Ce zxe (i, j ) =

20 t pe x (i, j )
,
20 + t pe x (i, j )

2t

Ce zxhy (i, j ) = 
.
20 + t pe x (i, j ) x
 n+ 1

n+ 1
n+1
(i, j ) = Ce zye (i, j ) E zn (i, j ) + Ce zyhx (i, j ) Hx 2 (i, j ) Hx 2 (i, j 1) ,
E zy

(7.36)

where
Ce zye (i, j ) =

20 (i, j ) t pe y (i, j )
,
20 (i, j ) + t pe y (i, j )

2t

Ce zyhx (i, j ) = 
.
20 + t pe y (i, j ) y
n+ 12

Hx

n 12

(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
C hxh (i, j ) =

20 t pmy (i, j )
,
20 + t pmy (i, j )

2t

C hxe z (i, j ) = 
.
20 + t pmy (i, j ) y
n+ 12

Hy

n 12

(i, j ) = C hyh (i, j ) Hy



(i, j ) + C hye z (i, j ) E zn (i + 1, j ) E zn (i, j ) ,

where
C hyh (i, j ) =

20 t pmx (i, j )
,
20 + t pmx (i, j )

2t

C hye z (i, j ) = 
.
20 + t pmx (i, j ) x

(7.38)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

200

October 13, 2009

Perfectly Matched Layer

(a) Nonzero pmx

(b) Nonzero pmy

(c) Nonzero pex

(d) Nonzero pey

Figure 7.6 Nonzero TM z regions of PML conductivities.

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 dened 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 elds 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

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

PML Updating Equations

201

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
n
E zx
(i, j ) = Ce zxe (i, j ) E zx
(i, j ) + Ce zxhy (i, j ) Hy 2 (i, j ) Hy 2 (i 1, j ) ,

(7.39)

where
Ce zxe (i, j ) = 1,

Ce zxhy (i, j ) =

t
.
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
(i, j ) = Ce zye (i, j ) E zn (i, j ) + Ce zyhx (i, j ) Hx 2 (i, j ) Hx 2 (i, j 1) ,
E zy

(7.40)

where
Ce zye (i, j ) = 1,

Ce zyhx (i, j ) =

t
.
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 MATLAB Implementation of the Two-Dimensional FDTD Method with PML

In this section we demonstrate the implementation of a two-dimensional FDTD MATLAB code


including PML boundaries. The main routine of the two-dimensional program is named fdtd solve 2d and is given in Listing 7.1. The general structure of the two-dimensional FDTD program
is the same as the three-dimensional FDTD program; it is composed of problem denition, initialization, and execution sections. Many of the routines and notations of the two-dimensional
FDTD program are similar to their three-dimensional FDTD counterparts; thus, the corresponding details are provided only when necessary.
7.4.3.1 Denition of the Two-Dimensional FDTD Problem The types of boundaries surrounding
the problem space are dened 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 dened 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 reection
coefcient (R(0)) and the order of PML (n pml ), as discussed in Section 7.3. These two parameters
are dened 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 dened by their coordinates, sizes, and material types.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

202

October 13, 2009

Perfectly Matched Layer

Listing 7.1 fdtd solve 2d.m



2

10

12

14

16

% i n i t i a l i z e the matlab workspace


clear all ; close all ; clc ;
% d e f i n e t h e problem
define problem space parameters 2d ;
define geometry 2d ;
define sources 2d ;
define output parameters 2d ;
% 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 ;
initialize fdtd parameters and arrays 2d ;
initialize sources 2d ;
initialize updating coefficients 2d ;
initialize boundary conditions 2d ;
initialize output parameters 2d ;
initialize display parameters 2d ;

18

20

22

% draw t h e o b j e c t s i n t h e problem s p a c e
draw objects 2d ;
% FDTD t i m e m a r c h i n g l o o p
run fdtd time marching loop 2d ;

24

26

% display simulation results


post process and display results 2d ;

The sources exciting the two-dimensional problem space are dened in the subroutine define sources 2d. Unlike the three-dimensional case, in this implementation the impressed current
sources are dened as sources explicitly as shown in Listing 7.3.
Outputs of the program are dened 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 rst 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 dened 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 elds in these regions. Furthermore, new parameters are
dened 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 dened to indicate whether the respective side of the

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

PML Updating Equations

October 13, 2009

14:16

203

Listing 7.2 define problem space parameters 2d.m



18

20

22

24

26

28

30

32

34

36

38

%
%
%
%

==<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
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
pml : p e r f e c t l y matched l a y e r

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;
boundary . p m l n u m b e r o f c e l l s x n = 5 ;
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;
boundary . p m l n u m b e r o f c e l l s x p = 5 ;
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;
boundary . p m l n u m b e r o f c e l l s y n = 5 ;
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;
boundary . p m l n u m b e r o f c e l l s y p = 5 ;
boundary . pml order = 2 ;
b o u n d a r y . p m l R 0 = 1e 8;

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.

Figure 7.7 A two-dimensional FDTD problem space with PML boundaries.

fdtd_main

SPIB005-Elsherbeni & Demir

204

October 13, 2009

Perfectly Matched Layer

Listing 7.3 define sources 2d.m



disp ( defining sources ) ;
2

10

12

14

16

18

impressed J = [ ] ;
impressed M = [ ] ;
% 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 ;
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;
% electric
% direction
impressed J
impressed J
impressed J
impressed J
impressed J
impressed J
impressed J
impressed J

current sources
: xp , xn , yp , yn , zp , o r zn
( 1 ) . m i n x = 0.1 e 3;
( 1 ) . m i n y = 0.1 e 3;
( 1 ) . max x = 0 . 1 e 3;
( 1 ) . max y = 0 . 1 e 3;
( 1 ) . d i r e c t i o n = zp ;
( 1 ) . magnitude = 1 ;
( 1 ) . waveform type = gaussian ;
( 1 ) . waveform index = 1;

20

22

24

26

28

30

%
%
%
%
%
%
%
%
%
%

% 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
i m p r e s s e d M ( 1 ) . m i n x = 0.1 e 3;
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;
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 ;
impressed M ( 1 ) . magnitude = 1 ;
impressed M ( 1 ) . waveform type = gaussian ;
impressed M ( 1 ) . waveform index = 1;

The subroutine initialize fdtd parameters and arrays 2d includes the denition of some parameters such as 0 , 0 , c , and t that are required for the FDTD calculation and denition and
initialization of eld arrays Ex, Ey, Ez, Hx, Hy, and Hz. The eld arrays are dened 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 subelds of the respective parameters 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 elds 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 dened to indicate that
the mode of operation is T E z , whereas another logical parameter is TMz is dened to indicate
that the mode of operation is T Mz .

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

PML Updating Equations

October 13, 2009

14:16

205

Listing 7.4 initialize sources 2d.m


60

62

64

66

68

70

72

74

76

78

80

% d e t e r m i n e i f T E z o r TMz
is TEz = false ;
is TMz = f a l s e ;
for ind = 1: number of impressed J
sw i t ch i m p r e s s e d J ( i n d ) . d i r e c t i o n ( 1 )
case x
is TEz = true ;
case y
is TEz = true ;
case z
is TMz = true ;
end
end
for ind = 1: number of impressed M
sw i t ch i m p r e s s e d M ( i n d ) . d i r e c t i o n ( 1 )
case x
is TMz = true ;
case y
is TMz = true ;
case z
is TEz = true ;
end
end

The regular updating coefcients 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 coefcients as well.
Some coefcients and eld arrays need to be dened and initialized for the application of
the PML boundary conditions. The PML initialization process is performed in the subroutine initialize boundary conditions 2d, which is shown in Listing 7.5. The indices of the nodes
Listing 7.5 initialize boundary conditions 2d.m
1

11

13

15

disp ( i n i t i a l i z i n g boundary c o n d i t i o n s ) ;
% 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 nonpml r e g i o n
p i s = n p m l x n +1;
p i e = nxn p m l x p +1;
p j s = n p m l y n +1;
p j e = nyn p m l y p +1;
if is any side pml
if is TEz
initialize pml boundary conditions 2d TEz ;
end
i f is TMz
initialize pml boundary conditions 2d TMz ;
end
end

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

206

Perfectly Matched Layer

Listing 7.6 initialize pml boundary conditions 2d TEz.m


2

10

% i n i t i a l i z i n g PML b o u n d a r y c o n d i t i o n s f o r T E z
d i s p ( i n i t i a l i z i n g PML b o u n d a r y c o n d i t i o n s f o r T E z ) ;
Hzx
Hzy
Hzx
Hzy
Hzx
Hzy
Hzx
Hzy

xn
xn
xp
xp
yn
yn
yp
yp

=
=
=
=
=
=
=
=

zeros
zeros
zeros
zeros
zeros
zeros
zeros
zeros

( n pml xn , ny ) ;
( n pml xn , nyn
( n pml xp , ny ) ;
( n pml xp , nyn
( nxn pml xn n
( nx , n p m l y n ) ;
( nxn pml xn n
( nx , n p m l y p ) ;

pml yn n p m l y p ) ;
pml yn n p m l y p ) ;
pml xp , n p m l y n ) ;
pml xp , n p m l y p ) ;

12

14

16

18

20

22

24

26

pml order = boundary . pml order ;


R 0 = boundary . pml R 0 ;
i f is pml xn
s i g m a p e x x n = z e r o s ( n pml xn , ny ) ;
s i g m a p m x x n = z e r o s ( n pml xn , ny ) ;
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 ;
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
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 , : ) = . . .
( mu 0 / e p s 0 ) * sigma max * rho m ( i n d ) p m l o r d e r ;
end

28

30

% C o e f f i e c i e n t s updating Ey
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

34

% C o e f f i e c i e n t s u p d a t i n g Hzx
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

38

40

95

% C o e f f i e c i e n t s u p d a t i n g Hzy
Chzyh xn = 1;
C h z y e x x n = d t / ( dy * mu 0 ) ;
end
i f is pml yp
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

99

101

103

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 ) ;
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 ;
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 ;
sigma pmy yp ( : , ind ) = . . .

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

PML Updating Equations

14:16

207

( mu 0 / e p s 0 ) * sigma max * rho m ( i n d ) p m l o r d e r ;


end

105

% 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 ) ;
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 ) ;

107

109

% 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;
C h z x e y y p = d t / ( dx * mu 0 ) ;

111

113

% 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 ) ;
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 ) ;

115

117

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 coefcients and elds required for the T E z PML boundaries are initialized in the subroutine initialize pml boundary conditions 2d TEz, and partial code for this case is shown in
Listing 7.6. Figure 7.8 shows the eld distribution for the T E z case. The eld components in
the shaded region are updated by the PML updating equations. The eld 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 eld components Hzx and Hzy are dened
in the four PML regions shown in Fig. 7.5; therefore, the corresponding eld arrays Hzx xn,
Hzx xp, Hzx yn, Hzx yp, Hzy xn, Hzy xp, Hzy yn, and Hzy yp are initialized in Listing 7.6.

Figure 7.8 TEz field components in the PML regions.

fdtd_main

SPIB005-Elsherbeni & Demir

208

October 13, 2009

Perfectly Matched Layer

Figure 7.9 Field components updated by PML equations.

Then for each region the corresponding conductivity parameters and PML updating coefcients
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 elds E x and E y , respectively, whereas pmx and pmy are
associated with the magnetic eld Hz . Therefore, the conductivity components are located in
different positions. As mentioned before, the conductivity () is zero at the PML interiordomain 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
eld components and N magnetic eld 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 eld components updated in the xn and xp regions. The distance of the electric eld
components E y from the interior boundary of the PML is denoted as e whereas for the magnetic
eld 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 coefcients in (7.29)(7.32).
The initialization of the auxiliary split elds and the PML updating coefcients for the twodimensional 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 eld positioning and PML regions are
shown in Fig. 7.10, while the positions of the eld 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 initialization 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.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

PML Updating Equations

209

Listing 7.7 initialize pml boundary conditions 2d TMz.m


2

10

% i n i t i a l i z i n g PML b o u n d a r y c o n d i t i o n s f o r TMz
d i s p ( i n i t i a l i z i n g PML b o u n d a r y c o n d i t i o n s f o r TMz ) ;
Ezx
Ezy
Ezx
Ezy
Ezx
Ezy
Ezx
Ezy

xn
xn
xp
xp
yn
yn
yp
yp

=
=
=
=
=
=
=
=

zeros
zeros
zeros
zeros
zeros
zeros
zeros
zeros

( n pml xn , nym1 ) ;
( n pml xn , nym1n
( n pml xp , nym1 ) ;
( n pml xp , nym1n
( nxm1n pml xn n
( nxm1 , n p m l y n ) ;
( nxm1n pml xn n
( nxm1 , n p m l y p ) ;

pml yn n p m l y p ) ;
pml yn n p m l y p ) ;
pml xp , n p m l y n ) ;
pml xp , n p m l y p ) ;

12

14

42

44

pml order = boundary . pml order ;


R 0 = boundary . pml R 0 ;
i f is pml xp
s i g m a p e x x p = z e r o s ( n pml xp , nym1 ) ;
s i g m a p m x x p = z e r o s ( n pml xp , nym1 ) ;
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 ;
rho m = ( [ 1 : n p m l x p ] 0 . 2 5 ) / n p m l x p ;
for ind = 1: n pml xp
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 , : ) = . . .
( mu 0 / e p s 0 ) * sigma max * rho m ( i n d ) p m l o r d e r ;
end

46

48

50

52

54

% 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 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 ) ;

56

58

% C o e f f i e c i e n t s updating Ezx
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 ) ;

60

62

% C o e f f i e c i e n t s updating Ezy
Cezye xp = 1;
C e z y h x x p = d t / ( dy * e p s 0 ) ;

64

66

68

70

72

74

76

end
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 ) ;
s i g m a p m y y n = z e r o s ( nxm1 , n p m l y n ) ;
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 ;
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
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 ;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

210

October 13, 2009

Perfectly Matched Layer


sigma pmy yn ( : , ind ) = . . .
( mu 0 / e p s 0 ) * sigma max * rho m ( i n d ) p m l o r d e r ;

78

end
80

% 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 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 ) ;

82

84

% C o e f f i e c i e n t s updating Ezx
Cezxe yn = 1;
C e z x h y y n = d t / ( dx * e p s 0 ) ;

86

88

% C o e f f i e c i e n t s updating Ezy
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 ) ;

90

92

end

During the time-marching loop the rst step at every iteration is the update of magnetic
eld 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 eld 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 eld components in the intermediate
region of Fig. 7.6(b) and Hy eld 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 eld terms Hz , Hx , and Hy .

Figure 7.10 TMz field components in the PML regions.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

PML Updating Equations

October 13, 2009

14:16

211

Figure 7.11 Field components updated by PML equations.

The subroutine update magnetic fields for PML 2d is used to update the magnetic eld components 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).
Listing 7.8 run fdtd time marching loop 2d.m
2

disp ( [ S t a r t i n g the time marching loop ] ) ;


d i s p ( [ T o t a l number o f t i m e s t e p s : . . .
num2str ( n u m b e r o f t i m e s t e p s ) ] ) ;

10

12

14

16

18

20

22

s t a r t t i m e = cputime ;
current time = 0;
for time step = 1: number of time steps
update magnetic fields 2d ;
update impressed M ;
update magnetic fields for PML 2d ;
capture sampled magnetic fields 2d ;
update electric fields 2d ;
update impressed J ;
update electric fields for PML 2d ;
capture sampled electric fields 2d ;
display sampled parameters 2d ;
end
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 ;
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

212

October 13, 2009

Perfectly Matched Layer

Listing 7.9 update magnetic fields 2d.m



1

11

13

15

17

% update magnetic f i e l d s
current time

= current time + dt / 2 ;

% TEz
if is TEz
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) . . .
+ 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 ) )
...
+ 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 ) ) ;
end
% TMz
i f is TMz
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 , : ) . . .
+ 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 , : ) ) ;

21

end

Listing 7.10 update impressed M.m



2

10

12

14

16

18

20

% u p d a t i n g m a g n e t i c f i e l d components
% a s s o c i a t e d with the impressed magnetic c u r r e n t s
for ind = 1: number of impressed M
i s = impressed M ( ind ) . i s ;
j s = impressed M ( ind ) . j s ;
i e = impressed M ( ind ) . i e ;
j e = impressed M ( ind ) . j e ;
sw i t ch ( i m p r e s s e d M ( i n d ) . d i r e c t i o n ( 1 ) )
case x
Hx ( i s : i e , j s : j e 1) = Hx ( i s : i e , j s : j e 1) . . .
+ i m p r e s s e d M ( i n d ) . Chxm * i m p r e s s e d M ( i n d
case y
Hy ( i s : i e 1 , j s : j e ) = Hy ( i s : i e 1 , j s : j e ) . . .
+ i m p r e s s e d M ( i n d ) . Chym * i m p r e s s e d M ( i n d
case z
Hz ( i s : i e 1 , j s : j e 1) = Hz ( i s : i e 1 , j s : j e 1)
+ i m p r e s s e d M ( i n d ) . Chzm * i m p r e s s e d M ( i n d
end
end

) . waveform ( t i m e s t e p ) ;

) . waveform ( t i m e s t e p ) ;
...
) . waveform ( t i m e s t e p ) ;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

PML Updating Equations

October 13, 2009

14:16

213

Listing 7.11 update magnetic fields for PML 2d.m


1

% u p d a t e m a g n e t i c f i e l d s a t t h e PML r e g i o n s
i f i s a n y s i d e p m l == f a l s e
return ;
end
if is TEz
update magnetic fields for PML 2d TEz ;
end
i f is TMz
update magnetic fields for PML 2d TMz ;
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 components of Hzx and Hzy , located at the same positions, are added to obtain Hz at the same
positions.
The update of the electric eld components using the regular updating equations is performed in update electric fields 2d as shown in Listing 7.14. In the T Mz case the E z eld components 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 eld components in the intermediate region of Fig. 7.5(b) and E y eld
components in the intermediate region of Fig. 7.5(a) are updated based on (1.33) and (1.34),
respectively.
Listing 7.12 update magnetic fields for PML 2d TMz.m
2

10

% u p d a t e m a g n e t i c f i e l d s a t t h e PML r e g i o n s
% TMz
i f is pml xn
Hy ( 1 : p i s 1 ,2: ny ) = C h y h x n . * Hy ( 1 : p i s 1 ,2: ny ) . . .
+ C h y e z x n . * ( E z ( 2 : p i s , 2 : ny ) E z ( 1 : p i s 1 ,2: ny ) ) ;
end
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 ) . . .
+ 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

14

16

18

20

i f is pml yn
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 ) ) ;
end
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 ) . . .
+ 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

214

October 13, 2009

Perfectly Matched Layer

Listing 7.13 update magnetic fields for PML 2d TEz.m


1

11

13

15

17

19

21

23

25

27

29

31

33

% u p d a t e m a g n e t i c f i e l d s a t t h e PML r e g i o n s
% TEz
i f is pml xn
H z x x n = C h z x h x n . * H z x x n+ C h z x e y x n . * ( E y ( 2 : p i s , : ) E y ( 1 : p i s 1 , : ) ) ;
Hzy xn = Chzyh xn . * Hzy xn . . .
+ C h z y e x x n . * ( E x ( 1 : p i s 1 , p j s +1: p j e ) E x ( 1 : p i s 1 , p j s : p j e 1 ) ) ;
end
i f is pml xp
Hzx xp = Chzxh xp . * Hzx xp . . .
+ C h z x e y x p . * ( E y ( p i e +1: nxp1 , : ) E y ( p i e : nx , : ) ) ;
Hzy xp = Chzyh xp . * Hzy xp . . .
+ C h z y e x x p . * ( E x ( p i e : nx , p j s +1: p j e ) E x ( p i e : nx , p j s : p j e 1 ) ) ;
end
i f is pml yn
Hzx yn = Chzxh yn . * Hzx yn . . .
+ C h z x e y y n . * ( E y ( p i s +1: p i e , 1 : p j s 1) E y ( p i s : p i e 1 ,1: p j s 1 ) ) ;
Hzy yn = Chzyh yn . * Hzy yn . . .
+ C h z y e x y n . * ( E x ( : , 2 : p j s ) E x ( : , 1 : p j s 1 ) ) ;
end
i f is pml yp
Hzx yp = Chzxh yp . * Hzx yp . . .
+ C h z x e y y p . * ( E y ( p i s +1: p i e , p j e : ny ) E y ( p i s : p i e 1 , p j e : ny ) ) ;
Hzy yp = Chzyh yp . * Hzy yp . . .
+ C h z y e x y p . * ( E x ( : , p j e +1: nyp1 ) E x ( : , p j e : ny ) ) ;
end
Hz ( 1 : p i s 1 ,1: p j s 1) = H z x x n ( : , 1 : p j s 1) + H z y y n ( 1 : p i s 1 , : ) ;
Hz ( 1 : p i s 1 , p j e : ny ) = H z x x n ( : , p j e : ny ) + H z y y p ( 1 : p i s 1 , : ) ;
Hz ( p i e : nx , 1 : p j s 1) = H z x x p ( : , 1 : p j s 1) + H z y y n ( p i e : nx , : ) ;
Hz ( p i e : nx , p j e : ny )
= H z x x p ( : , p j e : ny ) + H z y y p ( p i e : nx , : ) ;
Hz ( 1 : p i s 1 , p j s : p j e 1) = H z x x n ( : , p j s : p j e 1) + H z y x n ;
Hz ( p i e : nx , p j s : p j e 1) = H z x x p ( : , p j s : p j e 1) + H z y x p ;
Hz ( p i s : p i e 1 ,1: p j s 1) = H z x y n + H z y y n ( p i s : p i e 1 , : ) ;
Hz ( p i s : p i e 1 , p j e : ny ) = H z x y p + H z y y p ( p i s : p i e 1 , : ) ;

Then in update impressed J the impressed current terms appearing in (1.36), (1.33), and (1.34)
are added to their respective eld terms E z , E x , and E y .
The subroutine update electric fields for PML 2d is used to update the electric eld components 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 regions 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.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation Examples

14:16

215

Listing 7.14 update electric fields 2d.m


1

current time

= current time + dt / 2 ;

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) . . .
+ 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 ) ) ;

E y ( p i s +1: p i e 1 , : ) = C e y e ( p i s +1: p i e 1 , : ) . * E y ( p i s +1: p i e 1 , : ) . . .


+ C e y h z ( p i s +1: p i e 1 , : ) . *
...
( Hz ( p i s +1: p i e 1 ,:) Hz ( p i s : p i e 2 , : ) ) ;

11

13

15

17

19

end
i f is TMz
E z ( p i s +1: p i e 1 , p j s +1: p j e 1) = . . .
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) . . .
. * ( 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) . . .
. * ( 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

7.5 SIMULATION EXAMPLES


7.5.1 Validation of PML Performance

In this section we evaluate the performance of the two-dimensional PML for the T E z case. A
two-dimensional problem is constructed as shown in Fig. 7.12(a). The problem space is empty (all
free space) and is composed of 36 36 cells with cell size 1 mm on a side. There are eight cell
layers of PML on the four sides of the boundaries. The order of the PML parameter n pml is 2, and
the theoretical reection coefcient R(0) is 108 . The problem space is excited by a z-directed
impressed magnetic current as dened in Listing 7.18. The impressed magnetic current is centered
at the origin and has a Gaussian waveform. A sampled magnetic eld with z component is placed
at the position x = 8 mm and y = 8 mm, two cells away from the upper right corner of the PML
boundaries as dened in Listing 7.19. The problem is run for 1,800 time steps. The captured
sampled magnetic eld Hz is plotted in Fig. 7.12(b) as a function of time. The captured eld
includes the effect of the reected elds from the PML boundaries as well.
Listing 7.15 update electric fields for PML 2d.m
2

10

% u p d a t e e l e c t r i c f i e l d s a t t h e PML r e g i o n s
% u p d a t e m a g n e t i c f i e l d s a t t h e PML r e g i o n s
i f i s a n y s i d e p m l == f a l s e
return ;
end
if is TEz
update electric fields for PML 2d TEz ;
end
i f is TMz
update electric fields for PML 2d TMz ;
end

fdtd_main

SPIB005-Elsherbeni & Demir

216

October 13, 2009

Perfectly Matched Layer

Listing 7.16 update electric fields for PML 2d TEz.m


1

% u p d a t e e l e c t r i c f i e l d s a t t h e PML r e g i o n s
% TEz
i f is pml xn
Ey ( 2 : pis , : ) = Ceye xn . * Ey ( 2 : pis , : ) . . .
+ C e y h z x n . * ( Hz ( 2 : p i s , : ) Hz ( 1 : p i s 1 , : ) ) ;
end

11

13

15

i f is pml xp
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 , : ) ) ;
end
i f is pml yn
Ex ( : , 2 : p j s )
= Cexe yn . * Ex ( : , 2 : p j s ) . . .
+ C e x h z y n . * ( Hz ( : , 2 : p j s )Hz ( : , 1 : p j s 1 ) ) ;
end

17

19

21

i f is pml yp
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 ) ) ;
end

Listing 7.17 update electric fields for PML 2d TMz.m


2

10

12

14

16

18

20

22

24

26

% u p d a t e e l e c t r i c f i e l d s a t t h e PML r e g i o n s
% TMz
i f is pml xn
Ezx xn = Cezxe xn .* Ezx xn . . .
+ C e z x h y x n . * ( Hy ( 2 : p i s , 2 : ny )Hy ( 1 : p i s 1 ,2: ny ) ) ;
Ezy xn = Cezye xn .* Ezy xn . . .
+ C e z y h x x n . * ( Hx ( 2 : p i s , p j s +1: p j e 1)Hx ( 2 : p i s , p j s : p j e 2 ) ) ;
end
i f is pml xp
Ezx xp = Cezxe xp .* Ezx xp + Cezxhy xp .*
...
( Hy ( p i e : nx , 2 : ny )Hy ( p i e 1: nx 1 ,2: ny ) ) ;
Ezy xp = Cezye xp .* Ezy xp . . .
+ C e z y h x x p . * ( Hx ( p i e : nx , p j s +1: p j e 1)Hx ( p i e : nx , p j s : p j e 2 ) ) ;
end
i f is pml yn
Ezx yn = Cezxe yn .* Ezx yn . . .
+ C e z x h y y n . * ( Hy ( p i s +1: p i e 1 ,2: p i s )Hy ( p i s : p i e 2 ,2: p j s ) ) ;
Ezy yn = Cezye yn .* Ezy yn . . .
+ C e z y h x y n . * ( Hx ( 2 : nx , 2 : p j s )Hx ( 2 : nx , 1 : p j s 1 ) ) ;
end
i f is pml yp
Ezx yp = Cezxe yp .* Ezx yp . . .
+ C e z x h y y p . * ( Hy ( p i s +1: p i e 1 , p j e : ny )Hy ( p i s : p i e 2 , p j e : ny ) ) ;
Ezy yp = Cezye yp .* Ezy yp . . .
+ C e z y h x y p . * ( Hx ( 2 : nx , p j e : ny )Hx ( 2 : nx , p j e 1: ny 1 ) ) ;
end
Ez ( 2 : pis , 2 : p j s )
= E z x x n ( : , 1 : p j s 1) + E z y y n ( 1 : p i s 1 , : ) ;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation Examples
28

30

32

34

14:16

217

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 , : ) ;
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 , : ) ;
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 ;
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 elds 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 reected elds arrive at the sampling point. Therefore, the elds
captured at the sampling point before any reected elds arrive is the same as the elds that would
be observed if the boundaries are open space. In the given example no reection 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 eld 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 reection 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.

SPIB005-Elsherbeni & Demir

October 13, 2009

218

Perfectly Matched Layer

x 10

0.5
(ampere/meter)

fdtd_main

0.5

1.5
0

0.5

1.5

2
2.5
time (ns)

3.5

Figure 7.12 (b) A two-dimensional TEz FDTD problem terminated by PML boundaries and its simulation results:
sampled H z in time.

time and calculated by



errort = 20 log10

pml

|Hz

re f

Hz |

re f

max(|Hz |)

(7.41)

pml

re f

where Hz is the sampled magnetic eld in the PML problem case and Hz is the sampled
magnetic eld 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 elds from the PML and reference cases by

error f = 20 log10

pml

|F(Hz

re f

) F(Hz )|
re f

F(|Hz |)


,

(7.42)

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 using 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.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation Examples

14:16

219

Listing 7.18 define sources 2d.m


disp ( defining sources ) ;
2

10

12

14

16

18

impressed J = [ ] ;
impressed M = [ ] ;
% 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 ;
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;
% 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
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;
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;
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 ;
impressed M ( 1 ) . waveform type = gaussian ;
impressed M ( 1 ) . waveform index = 2;

7.5.2 Electric Field Distribution

Since the elds are calculated on a plane by the two-dimensional FDTD program, it is possible to
capture and display the electric and magnetic eld distributions as a runtime animation while the
simulation is running. Furthermore, it is possible to calculate the eld distribution as a response of
a time-harmonic excitation at predened frequencies. Then the time-harmonic eld distribution
can be compared with results obtained from simulation of the same problem using frequencydomain solvers. In this example the two-dimensional FDTD program is used to calculate the
Listing 7.19 define output parameters 2d.m
1

disp ( d e f i n i n g output parameters ) ;


sampled
sampled
sampled
sampled

electric fields =
magnetic fields =
transient E planes
frequency E planes

[];
[];
= [];
= [];

11

13

% figure refresh rate


p l o t t i n g s t e p = 10;
% 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 ;
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

17

19

% define
sampled
sampled
sampled

sampled
magnetic
magnetic
magnetic

magnetic f i e l d s
f i e l d s ( 1 ) . x = 8e 3;
f i e l d s ( 1 ) . y = 8e 3;
f i e l d s ( 1 ) . component = z ;

SPIB005-Elsherbeni & Demir

October 13, 2009

220

Perfectly Matched Layer

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

0.5
(ampere/meter)

fdtd_main

0.5

1.5
0

0.5

1.5

2.5

3.5

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.

14:16

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation Examples

221

0
20
40

errort (dB)

60
80
100
120
140
160
180
200
0

0.5

1.5

2
2.5
time (ns)

3.5

(a) Error in time

0
10
20

errorf (dB)

fdtd_main

30
40
50
60
70
80
0

10
frequency (GHz)

(b) Error in frequency domain


Figure 7.14 Error in time and frequency domains.

15

20

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

222

October 13, 2009

Perfectly Matched Layer

Figure 7.15 A two-dimensional problem space including a cylinder and a line source.

electric eld 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 twodimensional 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 denition 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 dene two new output types: (1) transient electric eld distributions represented with a parameter named sampled transient E planes; and (2) electric eld distributions
calculated at certain frequencies represented with a parameter named sampled frequency E planes. The denition 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 elds 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.
Listing 7.20 define geometry 2d.m

6

10

% define a
circles (1).
circles (1).
circles (1).
circles (1).

circle
center x
center y
radius
material

= 0.4;
= 0.5;
= 0.2;
type = 4;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation Examples

14:16

223

Listing 7.21 define sources 2d.m


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 ;
10

12

14

16

18

20

% electric
% direction
impressed J
impressed J
impressed J
impressed J
impressed J
impressed J
impressed J
impressed J

current sources
: xp , xn , yp , yn , zp , o r zn
( 1 ) . min x = 0 . 8 ;
( 1 ) . min y = 0 . 5 ;
( 1 ) . max x = 0 . 8 ;
( 1 ) . max y = 0 . 5 ;
( 1 ) . d i r e c t i o n = zp ;
( 1 ) . magnitude = 1 ;
( 1 ) . waveform type = s i n u s o i d a l ;
( 1 ) . waveform index = 1;

Listing 7.22 define output parameters 2d.m


disp ( d e f i n i n g output parameters ) ;
2

23

25

27

29

sampled electric fields =


sampled magnetic fields =
sampled transient E planes
sampled frequency E planes
% d e f i n e sampled e l e c t r i c
% component can be x , y
% transient
sampled transient E planes

[];
[];
= [];
= [];
field distributions
, z , o r m ( m a g n i t u d e )
( 1 ) . component = z ;

% 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 ;
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 ;

Listing 7.23 initialize output parameters 2d.m


1

36

38

disp ( i n i t i a l i z i n g the output parameters ) ;


number of sampled electric fields = size ( sampled electric fields , 2 ) ;
number of sampled magnetic fields = size ( sampled magnetic fields , 2 ) ;
number of sampled transient E planes=s i z e ( s ampled t r a n s i e n t E p l a n e s , 2 ) ;
number of sampled frequency E planes=s i z e ( sampled frequency E planes , 2 ) ;
% i n i t i a l i z e sampled t r a n s i e n t e l e c t r i c f i e l d
f o r i n d =1: n u m b e r o f s a m p l e d t r a n s i e n t E p l a n e s
s a m p l e d t r a n s i e n t E p l a n e s ( ind ) . f i g u r e = f i g u r e ;
end

40

42

44

46

% 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
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 ) ;
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 ) ;
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

224

October 13, 2009

Perfectly Matched Layer

Listing 7.24 display sampled parameters 2d.m



37

39

41

43

45

47

49

51

53

55

57

% d i s p l a y sampled e l e c t r i c f i e l d d i s t r i b u t i o n
f o r i n d =1: n u m b e r o f s a m p l e d t r a n s i e n t E p l a n e s
f i g u r e ( s a m p l e d t r a n s i e n t E p l a n e s ( ind ) . f i g u r e ) ;
E s = z e r o s ( nxp1 , nyp1 ) ;
component = s a m p l e d t r a n s i e n t E p l a n e s ( i n d ) . component ;
sw i t ch ( component )
case x
E s ( 2 : nx , : ) = 0 . 5 * ( E x ( 1 : nx 1 , : ) + E x ( 2 : nx , : ) ) ;
case y
E s ( : , 2 : ny ) = 0 . 5 * ( E y ( : , 1 : ny 1) + E y ( : , 2 : ny ) ) ;
case z
Es = Ez ;
c a s e m
E x s ( 2 : nx , : ) = 0 . 5 * ( E x ( 1 : nx 1 , : ) + E x ( 2 : nx , : ) ) ;
E y s ( : , 2 : ny ) = 0 . 5 * ( E y ( : , 1 : ny 1) + E y ( : , 2 : ny ) ) ;
E z s = Ez ;
Es = sqrt ( Exs . 2 + Eys . 2 + Ezs . 2 ) ;
end
imagesc ( xcoor , ycoor , Es . ) ;
a x i s equal ; a x i s xy ; colorbar ;
t i t l e ( [ E l e c t r i c f i e l d < component >[ num2str ( i n d ) ] ] ) ;
drawnow ;
end

Listing 7.25 capture sampled electric fields 2d.m



24

26

28

30

32

34

36

38

40

42

44

% c a p t u r 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 s on a p l a n e
i f t i m e s t e p >6000
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
E s = z e r o s ( nxp1 , nyp1 ) ;
component = 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 ) . component ;
sw i t ch ( component )
case x
E s ( 2 : nx , : ) = 0 . 5 * ( E x ( 1 : nx 1 , : ) + E x ( 2 : nx , : ) ) ;
case y
E s ( : , 2 : ny ) = 0 . 5 * ( E y ( : , 1 : ny 1) + E y ( : , 2 : ny ) ) ;
case z
Es = Ez ;
c a s e m
E x s ( 2 : nx , : ) = 0 . 5 * ( E x ( 1 : nx 1 , : ) + E x ( 2 : nx , : ) ) ;
E y s ( : , 2 : ny ) = 0 . 5 * ( E y ( : , 1 : ny 1) + E y ( : , 2 : ny ) ) ;
E z s = Ez ;
Es = sqrt ( Exs . 2 + Eys . 2 + Ezs . 2 ) ;
end
I = find ( Es > sampled frequency E planes ( ind ) . s a m p l e d f i e l d ) ;
sampled frequency E planes ( ind ) . s a m p l e d f i e l d ( I ) = Es ( I ) ;
end
end

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation Examples

14:16

225

Listing 7.26 display frequency domain outputs 2d.m


42

44

46

48

50

52

% d i s p l a y 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 s on a p l a n e
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
figure ;
f = sampled frequency E planes ( ind ) . frequency ;
component = 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 ) . component ;
E s = abs ( 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 ) ;
E s = E s / max ( max ( E s ) ) ;
imagesc ( xcoor , ycoor , Es . ) ;
a x i s equal ; a x i s xy ; colorbar ;
t i t l e ( [ E l e c t r i c f i e l d at f = . . .
num2str ( f * 1 e 9) GHz , < component >[ num2str ( i n d )
drawnow ;
end

] ]);

The electric elds at node positions are captured and calculated as the frequency-domain response
at the given frequency in the subroutine capture sampled electric fields 2d as shown in Listing
7.25. One should notice in the given code that the elds are being captured after 6,000 time steps.
Here it is assumed that the time-domain response of the sinusoidal excitation has reached the
steady state after 6,000 time steps. Then the magnitude of the steady elds is captured. Therefore,
with the given code it is possible to capture the magnitude of the frequency-domain response
and only at the single excitation frequency. The given code cannot calculate the phase of the
response. The given algorithm can further be improved to calculate the phases as well; however,
in the following example, a more efcient method based on discrete fourier transform (DFT) is
presented, which can be used to calculate both the magnitude and phase responses concurrently.
After the simulation is completed, the calculated magnitude response can be plotted using the
code shown in Listing 7.26.
The two-dimensional FDTD program is excited for 8,000 time steps, and the transient electric
eld is sampled at a point between the cylinder and the line source as shown in Fig. 7.15. The
sampled electric eld is plotted in Fig. 7.16, which shows that the simulation has reached the
steady state after 50 ns. Furthermore, the magnitude of the electric eld distribution is captured
for 1 GHz as discussed already is shown in Fig. 7.17 as a surface plot. The same problem is solved
using boundary value solution (BVS) [22], and the result is shown in Fig. 7.18 for comparison. It
can be seen that the results agree very well. The levels of the magnitudes are different since these
gures are normalized to different values.
7.5.3 Electric Field Distribution Using DFT

The previous example demonstrated how the magnitude of electric eld distribution can be
calculated as a response of a time-harmonic excitation. As discussed before, it is only possible
to obtain results for a single frequency with the given technique. However, if the excitation is
a waveform including a spectrum of frequencies, then it should be possible to obtain results for
multiple frequencies using DFT. We modify the previous example to be able to calculate eld
distributions for multiple frequencies.
The output for the eld distribution is dened in the subroutine define output parameters as
shown in Listing 7.27. One can notice that it is possible to dene multiple eld distributions with
different frequencies. The excitation waveform as well shall include the desired frequencies in its
spectrum. An impressed current line source is dened as shown in Listing 7.28. To calculate eld
distributions for multiple frequencies we have to implement an on-the-y DFT. Therefore, the
subroutine capture sampled electric fields 2d is modied as shown in Listing 7.29.

SPIB005-Elsherbeni & Demir

October 13, 2009

226

Perfectly Matched Layer

0.05
sampled electric field
0.04
0.03
0.02
(volt/meter)

fdtd_main

0.01
0
0.01
0.02
0.03
0.04
0.05
0

10

20

30

40
50
time (ns)

60

70

Figure 7.16 Sampled electric field at a point between the cylinder and the line source.

Figure 7.17 Magnitude of electric field distribution calculated by FDTD.

80

90

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation Examples

14:16

227

Figure 7.18 Magnitude of electric field distribution calculated by BVS.

Listing 7.27 define output parameters 2d.m



27

29

31

% f r e q u e n c y domain
sampled frequency E
sampled frequency E
sampled frequency E
sampled frequency E

planes
planes
planes
planes

(1).
(1).
(2).
(2).

component
frequency
component
frequency

=
=
=
=

z ;
1 e9 ;
z ;
2 e9 ;

Listing 7.28 define sources 2d.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 ;
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 = 20;
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 ;

10

12

14

16

18

20

% magnetic
% direction
impressed J
impressed J
impressed J
impressed J
impressed J
impressed J
impressed J
impressed J

current sources
: xp , xn , yp , yn , zp , o r zn
( 1 ) . min x = 0 . 8 ;
( 1 ) . min y = 0 . 5 ;
( 1 ) . max x = 0 . 8 ;
( 1 ) . max y = 0 . 5 ;
( 1 ) . d i r e c t i o n = zp ;
( 1 ) . magnitude = 1 ;
( 1 ) . waveform type = gaussian ;
( 1 ) . waveform index = 2;

fdtd_main

SPIB005-Elsherbeni & Demir

228

October 13, 2009

Perfectly Matched Layer

Figure 7.19 Magnitude of electric field distribution calculated by FDTD using DFT at 1 GHz.

Listing 7.29 capture sampled electric fields 2d.m



24

26

28

30

32

34

36

38

40

42

44

% c a p t u r 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 s on a p l a n e
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
w = 2 * pi * sampled frequency E planes ( ind ) . frequency ;
E s = z e r o s ( nxp1 , nyp1 ) ;
component = 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 ) . component ;
sw i t ch ( component )
case x
E s ( 2 : nx , : ) = 0 . 5 * ( E x ( 1 : nx 1 , : ) + E x ( 2 : nx , : ) ) ;
case y
E s ( : , 2 : ny ) = 0 . 5 * ( E y ( : , 1 : ny 1) + E y ( : , 2 : ny ) ) ;
case z
Es = Ez ;
c a s e m
E x s ( 2 : nx , : ) = 0 . 5 * ( E x ( 1 : nx 1 , : ) + E x ( 2 : nx , : ) ) ;
E y s ( : , 2 : ny ) = 0 . 5 * ( E y ( : , 1 : ny 1) + E y ( : , 2 : ny ) ) ;
E z s = Ez ;
Es = sqrt ( Exs . 2 + Eys . 2 + Ezs . 2 ) ;
end
sampled frequency E planes ( ind ) . s a m p l e d f i e l d = . . .
sampled frequency E planes ( ind ) . s a m p l e d f i e l d . . .
+ d t * E s * exp ( j * w * d t * t i m e s t e p ) ;
end

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

Exercises

October 13, 2009

229

Figure 7.20 Magnitude of electric field distribution calculated by FDTD using DFT at 2 GHz.

The FDTD simulation is run, and electric eld 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-y 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 eld distributions. Follow the
same procedure, and add new code sections to the program such that the program will
display magnetic eld distributions as animations while the simulation is running and it will
display the magnitude of the magnetic eld distribution as the response of time-harmonic
excitations at a number of frequencies.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

8
The Convolutional Perfectly
Matched Layer
In the previous chapter we discussed the perfectly matched layers (PMLs) as a boundary to
terminate the nite-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 sufciently far from an obstacle such that the evanescent waves have sufciently
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 reections when terminating highly elongated lattices or
when simulating elds 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 CFSPML, 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 efcient 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.
8.1 FORMULATION OF CPML

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 innite length structures; these structures
penetrate into the PML, and the PML absorbs the waves traveling on them.
8.1.1 PML in Stretched Coordinates

Without loss of generality, the PML equations for a lossy medium are posed in the stretched
coordinate space [27] as
j x E x + xe E x =

1 Hy
1 Hz

,
Se y y
Se z z

231

(8.1a)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

232

The Convolutional Perfectly Matched Layer

j y E y + ye E y =

1 Hz
1 Hx

,
Se z z
Se x x

(8.1b)

j z E z + ze E z =

1 Hy
1 Hx

,
Se x x
Se y y

(8.1c)

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 Berengers PML in the case where
Se x = 1 +

pex
,
j 0

Se y = 1 +

pey
,
j 0

and

Se z = 1 +

pez
.
j 0

(8.2)

Here pex , pey , and pez are the PML conductivities.


It should be noted that equations 8.1a8.1c and 8.2 follow the form given in [23], but the
subscript notations have been modied to indicate the electric and magnetic parameters separately. This form of notation facilitates establishing the connection between the parameters in the
formulations and their counterparts in program implementation.
The other three scalar equations that are used to construct the magnetic eld update
equations are
j x Hx + xm Hx =

1 Ey
1 Ez
+
,
Smy y
Smz z

(8.3a)

j y Hy + ym Hy =

1 Ex
1 Ez
+
,
Smz z
Smx x

(8.3b)

j z Hz + zm Hz =

1 Ex
1 Ey
+
.
Smx x
Smy y

(8.3c)

Equations (8.3) reduce to the PML in the case where


Smx = 1 +

pmx
,
j 0

Smy = 1 +

pmy
,
j 0

and

Smz = 1 +

pmz
.
j 0

(8.4)

8.1.2 Complex Stretching Variables in CFS-PML

In the CPML method the choice of the complex stretching variables follows the new denition
proposed by Kuzuoglu and Mittra [25], such that
Se x = 1 +

pex
,
j 0

Se x = e x +

pex
.
e x + j 0

Then the complex stretching variables are given as


Sei = ei +

pei
,
ei + j 0

Smi = mi +

mi

pmi
,
+ j 0

i = x, y, or z,

where the parameters ei , mi , ei , and mi are the new parameters taking the values
ei 1, mi 1, ei 0,

and

mi 0.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Formulation of CPML

233

8.1.3 The Matching Conditions at the PMLPML Interface

For zero reection at the PMLPML interface, one should have


Sei = Smi .

(8.5)

ei = mi ,
pmi
pei
=
.
ei + j 0
mi + j 0

(8.6a)

This condition leads to

(8.6b)

To satisfy (8.6b), we must have


pmi
pei
=
,
0
0

ei
mi
=
.
0
0

and

(8.7)

8.1.4 Equations in the Time Domain

As mentioned before, equations (8.1) and (8.3) are in frequency domain. We need to have them
expressed in time to obtain the eld updating equations from them. For instance, (8.1a) is expressed
in the time domain as
x

Hy
Ex
Hz
+ xe E x = Se y
Se z
,
t
y
z

(8.8)

where Se y is a function of time that is the inverse Laplace transform of Se1


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.
are then given in open form as
The terms Sei and Smi


pei
(t)

e
Sei (t) =
ei
0 ei2

pei
0 ei

(t) = (t) pmi e


Smi
2
mi
0 mi

pmi
0 mi

pei
0


t

pmi
0

u(t) =

t

(t)
+ ei (t),
ei

u(t) =

(t)
+ mi (t),
mi

(8.9a)
(8.9b)

where (t) is the unit impulse function and u(t) is the unit step function. Inserting (8.9) in (8.8)
leads to
x

Hy
1 Hy
Ex
1 Hz
Hz
+ xe E x =

+ e y (t)
e z (t)
.
t
e y y
e z z
y
z

(8.10)

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 eld 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.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

234

The Convolutional Perfectly Matched Layer

8.1.5 Discrete Convolution

The convolution terms in (8.10) can be written in open form, for instance, as
Hz
=
y

e y

=t

=0

e y ( )

Hz (t )
d .
y

(8.11)

In the discrete domain, (8.11) takes the form


=t

=0

e y ( )

m=n1

 nm+ 12

Hz (t )
nm+ 12
d 
Z0e y (m) Hz
(i, j, k) Hz
(i, j 1, k) ,
y

(8.12)

m=0

where
Z0e y (m) =

1
y

=(m+1)t
=mt

pey
y0 e2y

= ae y e

=(m+1)t

=mt



pei + pei
ei

e y ( )d

mt
0



pei

pei
+
0 ei

(8.13)

and
ae y =

 pey


t
pey

+
 e e y pey 0 1 .

y pey e y + e y e2y

(8.14)

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


n+ 1
exy 2 (i,

j, k) =

m=n1



Z0e y (m)

nm+ 12
Hz
(i,

j, k)

nm+ 12
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 derivative of the magnetic eld term with respect to y. Then equation (8.10) can be written in
discrete form as
x (i, j, k)

E xn+1 (i, j, k) E xn (i, j, k)


E n+1 (i, j, k) + E xn (i, j, k)
+ xe (i, j, k) x
t
2
n+ 12

Hz
1
=
e y (i, j, k)

n+ 12

Hy
1

e z (i, j, k)
n+ 1

n+ 12

(i, j, k) Hz
y

(i, j 1, k)

n+ 12

(i, j, k) Hy
z
n+ 1

+ exy 2 (i, j, k) exz 2 (i, j, k).

(i, j, k 1)
(8.16)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Formulation of CPML

235

8.1.6 The Recursive Convolution Method

As can be followed from (8.16) the parameter exy has to be recalculated at every time step of the
FDTD time-marching loop. However, observing expression (8.15) one can see that the values of
the magnetic eld component Hz calculated at all previous time steps have to be readily available
to perform the discrete convolution. This implies that all the previous history of Hz must be
stored in the computer memory, which is not feasible with the current computer resources. The
recursive convolution technique, which is frequently used to overcome the same problem while
modeling dispersive media in the FDTD method, is employed to obtain a new expression for exy
that does not require all the previous history of Hz .
The general form of the discrete convolution (8.15) can be written as

(n) =

m=n1


Ae mT B(n m),

(8.17)

m=0

where, for instance,


A = ae y


pey
t
T=
+ e y
e y
0
nm+ 12

B = Hz

nm+ 12

(i, j, k) Hz

(i, j 1, k).

Equation (8.17) can be written in open form as


(n) = AB(n) + Ae T B(n 1) + Ae 2T B(n 2) + + Ae (n2)T B(2) + Ae (n1)T B(1).

(8.18)

We can write the same equation in open form for one previous time step value (n 1) as
(n 1) = AB(n 1) + Ae T B(n 2) + Ae 2T B(n 3) + + Ae (n2)T B(2) + Ae (n2)T B(1).
(8.19)
Comparing the right-hand side of (8.18) with (8.19), one can realize that the right-hand side of
(8.18), except the rst term, is nothing but a multiplication of e T by (n 1). Therefore, (8.18)
can be rewritten as
(n) = AB(n) + e T (n 1).

(8.20)

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)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

236

The Convolutional Perfectly Matched Layer

where
ae y =



pey

 bey 1 ,
2
y pey e y + e y e y

bey = e



pey
e y +pey t

(8.22)
(8.23)

8.2 THE CPML ALGORITHM

Examining the discrete domain equation (8.16), one can see that the form of the equation is the
same as the one for a lossy medium except that two new auxiliary terms are added to the expression.
This form of equation indicates that the CPML algorithm is independent of the material medium
and can be extended for dispersive media, anisotropic media, or nonlinear media. In each of these
cases, the left-hand side must be modied to treat the specic host medium. Yet the application
of the CPML remains unchanged [23].
The FDTD owchart can be modied to include the steps of the CPML as shown in
Fig. 8.1. The auxiliary parameters and coefcients required by the CPML are initialized before
the time-marching loop. During the time-marching loop, at every time step, rst the magnetic
eld components are updated in the problem space using the regular updating equation derived
for the host medium. Then the CPML terms (mxy , mxz , my x , my z , mzx , mzy ) are calculated
using their previous time step values and the new electric eld values. Afterward, these terms are
added to their respective magnetic eld components only at the CPML regions for which they
were dened. The next step is updating the electric eld components in the problem space using
the regular updating equation derived for the host medium. Then the CPML terms (exy , exz ,
e y x , e y z , e zx , e zy ) are calculated using their previous time step values and the new magnetic
eld values and are added to their respective electric eld components only at the CPML regions
for which they were dened. The details of the steps of this algorithm are discussed further in
subsequent sections of this chapter.
8.2.1 Updating Equations for CPML

The general form of the updating equation for a non-CPML lossy medium is given in Chapter 1
and is repeated here for the E x component for convenience as
E xn+1 (i, j, k) = Ce xe (i, j, k) E xn (i, j, k)
 n+ 1

n+ 1
+ Ce xhz (i, j, k) Hz 2 (i, j, k) Hz 2 (i, j 1, k)
 n+ 1

n+ 1
+ Ce xhy (i, j, k) Hy 2 (i, j, k) Hy 2 (i, j, k 1) .

(8.24)

Then the updating equation for the CPML region takes the form
E xn+1 (i, j, k) = Ce xe (i, j, k) E xn (i, j, k)
 n+ 1



n+ 1
+ 1/e y (i, j, k) Ce xhz (i, j, k) Hz 2 (i, j, k) Hz 2 (i, j 1, k)
 n+ 1

n+ 1
+ (1/e z (i, j, k)) Ce xhy (i, j, k) Hy 2 (i, j, k) Hy 2 (i, j, k 1)


n+ 1
n+ 1
+ (yCe xhz (i, j, k)) exy 2 (i, j, k) + zCe xhy (i, j, k) exz 2 (i, j, k).

(8.25)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

The CPML Algorithm

237

Start
Set problem space and define parameters
Compute field coefficients
Initialize CPML parameters and coefficients
Update magnetic field components
at time instant (n+0.5)t
Calculate the new values of CPML parameters m*,
and add them to the magnetic field components
Update electric field components
at time instant (n+1)t

Output data

Calculate the new values of CPML parameters e*,


and add them to the electric field components
Increment time step, n

n+1

No

Yes
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
coefcient Ce xhy (i, j, k) as can be followed from (1.26). Here two new coefcients can be
dened such that
Cexy (i, j, k) yCe xhz (i, j, k),

(8.26a)

Cexz (i, j, k) zCe xhy (i, j, k).

(8.26b)

Then (8.25) reduces to


E xn+1 (i, j, k) = Ce xe (i, j, k) E xn (i, j, k)
 n+ 1



n+ 1
+ 1/e y (i, j, k) Ce xhz (i, j, k) Hz 2 (i, j, k) Hz 2 (i, j 1, k)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

238

The Convolutional Perfectly Matched Layer

 n+ 1

n+ 1
+ (1/e z (i, j, k)) Ce xhy (i, j, k) Hy 2 (i, j, k) Hy 2 (i, j, k 1)
n+ 1

n+ 1

+ Cexy (i, j, k) exy 2 (i, j, k) + Cexz (i, j, k) exz 2 (i, j, k).

(8.27)



Furthermore, the 1/e y (i, j, k) and (1/e z (i, j, k)) terms can be embedded into Ce xhz (i, j, k) and
Ce xhy (i, j, k), respectively, such that


Ce xhz (i, j, k) 1/e y (i, j, k) Ce xhz (i, j, k),

(8.28a)

Ce xhy (i, j, k) (1/e z (i, j, k)) Ce xhy (i, j, k).

(8.28b)

These modications are applied to the coefcients only at the positions overlapping with the
respective CPML regions and further reduce (8.27) to
E xn+1 (i, j, k) = Ce xe (i, j, k) E xn (i, j, k)
 n+ 1

n+ 1
+ Ce xhz (i, j, k) Hz 2 (i, j, k) Hz 2 (i, j 1, k)
 n+ 1

n+ 1
+ Ce xhy (i, j, k) Hy 2 (i, j, k) Hy 2 (i, j, k 1)
n+ 1

n+ 1

+ Cexy (i, j, k) exy 2 (i, j, k) + Cexz (i, j, k) exz 2 (i, j, k).

(8.29)

With the given form of updating equation and coefcients, E xn+1 (i, j, k) is updated using the rst
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 eld components as well by using their
respective updating equations and CPML parameters.
8.2.2 Addition of Auxiliary CPML Terms at Respective Regions

While discussing the PML we showed in Fig. 7.4 that certain PML conductivity parameters take
nonzero value at certain respective regions. In the CPML case there are three types of parameters,
and the regions for which they are dened are shown in Fig. 8.2, which is similar to Fig. 7.4. In
the CPML case the parameters pei , pmi , ei , and mi are nonzero, whereas the parameters ei
and mi take values larger than one at their respective regions. These regions are named xn, xp,
yn, y p, zn, and zp. The CPML auxiliary terms are associated with these CPML parameters.
Therefore, each term is dened at the region where its associated parameters are dened. For
instance, exy is associated with pey , e y , and e y as can be observed in (8.21). Then the term exy
is dened for the yn and y p regions. Similarly, the term exz is dened for the zn and zp regions.
One should notice in (8.27) that both the exy and exz terms are added to E x as the requirement
of the CPML algorithm; however, exy and exz are dened in different regions. This implies that
the terms exy and exz should be added to E x only in their respective regions. Therefore, one
should take care while determining the regions where the CPML terms are added to the eld
components. For instance, exy should be added to E x in the yn and y p regions, whereas exz
should be added to E x in the zn and zp regions. A detailed list of the CPML updating equations
for all six electric and magnetic eld components and the regions at which these equations are
applied is given in Appendix B.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Parameter Distribution

239

(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

Figure 8.2 Regions where CPML parameters are defined.

8.3 CPML PARAMETER DISTRIBUTION

As described in the previous chapter, the PML conductivities are scaled along the PML region
starting from a zero value at the inner domainPML interface and increasing to a maximum value
at the outer boundary. In the CPML case there are two additional types of parameter scaling
proles, which are different from the conductivity scaling proles.
The maximum conductivity of the conductivity prole is computed in [23] using max =
factor opt , where
opt =

npml + 1
.

150 r i

(8.30)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

240

The Convolutional Perfectly Matched Layer

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
pei () = max

 npml

(8.31)

where is the distance from the computational domainPML interface to the position of the eld
component and is the thickness of the CPML layer. Similarly, pmi can be calculated by
pmi () =

 npml
0
max
,
0

(8.32)

which satises the reectionless condition (8.7).


The value of ei is unity at the inner domainCPML interface, and it increases to a maximum
value max such that
 npml
ei () = 1 + (max 1)
,
(8.33)

whereas mi is given by
mi () = 1 + (max 1)

 npml

(8.34)

In these equations indicates the distances of the respective eld components from the inner
domainCPML interface. It should be noted that the values that can take in (8.33) and (8.34)
are different since the electric and magnetic eld components are located at different positions.
The parameter ei takes a maximum value max at the inner domainCPML interface and is
linearly scaled to a minimum value, min , at the outer boundary such that


.
(8.35)
ei () = min + (max min ) 1

Similarly, mi is calculated as
mi () =

 
0 
.
min + (max min ) 1
0

(8.36)

This scaling of the CPML parameter prole is chosen as before specically to reduce the
reection 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.71.5, max in the range 511, max in the range 00.05, thickness of CPML as 8
cells, and npml as 2, 3, or 4.
8.4 MATLAB IMPLEMENTATION OF CPML IN THE THREE-DIMENSIONAL FDTD METHOD

In this section we demonstrate the implementation of the CPML in the three-dimensional FDTD
MATLAB code.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

MATLAB Implementation of CPML in the Three-Dimensional FDTD Method

October 13, 2009

14:16

241

8.4.1 Definition of CPML

In the previous chapters, the only type of boundary available in our three-dimensional program
was PEC. The type of the boundaries were dened as PEC by assigning pec to the parameter
boundary.type, and the air gap between the objects and the outer boundary was assigned to
boundary.air buffer number of cells in the define problem space parameters subroutine. To
dene the boundaries as CPML, we can update define problem space parameters as shown in
Listing 8.1. The type of a boundary is determined as CMPL by assigning cpml to boundary.type.
It should be noted that the PEC boundaries can be used together with CPML boundaries; that is,
some sides can be assigned PEC while the others are CPML. In Listing 8.1, the zn and zp sides
are PEC while other boundaries are CPML.
Listing 8.1 define problem space parameters

19

21

23

25

27

29

31

33

35

37

39

41

43

45

47

49

51

53

%
%
%
%
%
%

==<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
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
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

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 ;
boundary . c p m l n u m b e r o f c e l l s x n = 5 ;
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 ;
boundary . c p m l n u m b e r o f c e l l s x p = 5 ;
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 ;
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;
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 ;
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;
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 ;
boundary . c p m l n u m b e r o f c e l l s z n = 5 ;
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 ;
boundary . c p m l n u m b e r o f c e l l s z p = 5 ;
boundary . cpml
boundary . c p m l
boundary . cpml
boundary . cpml
boundary . cpml

order = 3;
sigma factor = 1.5;
kappa max = 7 ;
alpha min = 0;
alpha max = 0 . 0 5 ;

fdtd_main

SPIB005-Elsherbeni & Demir

242

October 13, 2009

The Convolutional Perfectly Matched Layer

Figure 8.3 A problem space with 20 20 4 cells brick.

Another parameter required for a boundary dened as CPML is the thickness of the CPML
layer in terms of number of cells. A new parameter cpml number of cells is dened as a subeld
of the parameter boundary, and the thicknesses of the CPML regions are assigned to this new parameter. 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 dened
as penetrating into CPML; thus, these objects resemble structures extending to innity. As a convention, if cpml number of cells is dened 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 dened 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 dened in define problem space parameters
as well. The order of the polynomial distribution npml is dened as boundary.cpml order as
shown in Listing 8.1. The factor is dened as boundary.cpml sigma factor, max is dened as
boundary.cpml kappa max, max is dened as boundary.cpml alpha max, and similarly, min is
dened as boundary.cpml alpha min.
8.4.2 Initialization of CPML

To employ the CPML algorithm in the time-marching loop, several coefcient and auxiliary
parameter arrays need to be dened and initialized for the respective CPML regions before the
time-marching loop starts. Before dening these arrays, the size of the FDTD problem space
should be determined by taking the thicknesses of the CPML regions into account. The size of
the problem space and the number of cells in the domain are determined in the subroutine
calculate domain size, which was called in initialize fdtd material grid. The implementation of
calculate domain size is given in Listing 3.5, where the boundaries are assumed to be PEC. As
discussed in the previous section, if the thickness of the CPML is negative on a side, the CPML
region extends into the problem space on this side; therefore, the position of the outer boundary
of the problem space remains the same, and the calculation given for determining the position of
the outer boundary in Listing 3.5 remains the same. However, if the thickness of the CPML is
positive on a side, the CPML adds to the problem space on that side, and the calculation of the

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

MATLAB Implementation of CPML in the Three-Dimensional FDTD Method

14:16

243

position of the outer boundary needs to be updated accordingly. The necessary modications are
implemented in calculate domain size, and the modied 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

36

38

40

42

44

46

% 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
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
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
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
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
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
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

including air buffers


cells xn ;
cells yn ;
cells zn ;
cells xp ;
cells yp ;
cells zp ;

48

50

52

54

56

58

60

62

64

66

68

70

72

74

76

78

% 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
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)
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 ;
end
i f s t r c m p ( b o u n d a r y . t y p e x p , 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 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 . . .
+ 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
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)
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 ;
end
i f s t r c m p ( b o u n d a r y . t y p e y p , 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 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 . . .
+ 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
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)
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 ;
end
i f s t r c m p ( b o u n d a r y . t y p e z p , 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 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 . . .
+ 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

244

October 13, 2009

The Convolutional Perfectly Matched Layer

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
eld 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
Listing 8.3 initialize boundary conditions
% i n i t i a l i z e boundary parameters
2

10

12

14

16

18

20

22

24

26

28

30

32

34

%
is
is
is
if

define l o g i c a l parameters f o r the c o n d i t i o n s that


w i l l be u s e d o f t e n
cpml xn = false ; is cpml xp = false ; is cpml yn = false ;
cpml yp = false ; is cpml zn = false ; is cpml zp = false ;
any side cpml = false ;
s t r c m p ( b o u n d a r y . t y p e x n , cpml )
is cpml xn = true ;
n c p m l x n = abs ( 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 ) ;
end
i f s t r c m p ( b o u n d a r y . t y p e x p , cpml )
is cpml xp = true ;
n c p m l x p = abs ( 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
i f s t r c m p ( b o u n d a r y . t y p e y n , cpml )
is cpml yn = true ;
n c p m l y n = abs ( 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 ) ;
end
i f s t r c m p ( b o u n d a r y . t y p e y p , cpml )
is cpml yp = true ;
n c p m l y p = abs ( 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
i f s t r c m p ( b o u n d a r y . t y p e z n , cpml )
is cpml zn = true ;
n c p m l z n = abs ( 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 ) ;
end
i f s t r c m p ( b o u n d a r y . t y p e z p , cpml )
is cpml zp = true ;
n c p m l z p = abs ( 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

if ( is cpml xn | | is cpml xp | | is cpml yn . . .


| | is cpml yp | | is cpml zn | | is cpml zp )
is any side cpml = true ;
end

36

38

40

% C a l l CPML i n i t i a l i z a t i o n r o u t i n e i f any s i d e i s CPML


if is any side cpml
initialize CPML ABC ;
end

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

MATLAB Implementation of CPML in the Three-Dimensional FDTD Method

245

frequently used parameters are dened 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 dened for other sides as
well. Then another subroutine, initialize CPML ABC, is called to continue the CPML specic
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. Lets 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 rst, with the respective names
Listing 8.4 initialize CPML ABC

% I n i t i a l i z e CPML b o u n d a r y c o n d i t i o n
2

p o r d e r = boundary . cpml order ; % o r d e r o f the polynomial d i s t r i b u t i o n


s i g m a r a t i o = boundary . c p m l s i g m a f a c t o r ;
kappa max = b o u n d a r y . c p m l kappa max ;
alpha min = boundary . cpml alpha min ;
alpha max = boundary . cpml alpha max ;

10

12

14

16

18

20

22

24

26

28

30

32

34

36

38

% I n i t i a l i z e cpml f o r xn r e g i o n
if is cpml xn
% d e f i n e oned 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 ) ;
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 ;
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 ;
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 ;
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 ;
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 ) ;
a l p h a m x x n = ( mu 0 / e p s 0 ) * a l p h a m x x n ;
% d e f i n e oned 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 ) . . .
* ( ( 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 . . .
. / ( 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 ) . . .
* ( ( 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 . . .
. / ( 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 ) ) ;
% C r e a t e and
Psi eyx xn =
Psi ezx xn =
Psi hyx xn =

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
z e r o s ( n c e l l s , ny , nzp1 ) ;
z e r o s ( n c e l l s , nyp1 , nz ) ;
z e r o s ( n c e l l s , nyp1 , nz ) ;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

246

October 13, 2009

The Convolutional Perfectly Matched Layer


P s i h z x x n = z e r o s ( n c e l l s , ny , nzp1 ) ;

40

% Create
% Notice
CPsi eyx
CPsi ezx
CPsi hyx
CPsi hzx

42

44

46

and i n i t i a l i z e 2D cpml c o n v o l u t i o n c o e f f i c i e n t s
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
x n = C e y h z ( 2 : n c e l l s + 1 , : , : ) * dx ;
x n = C e z h y ( 2 : n c e l l s + 1 , : , : ) * dx ;
x n = C h y e z ( 1 : n c e l l s , : , : ) * dx ;
x n = C h z e y ( 1 : n c e l l s , : , : ) * dx ;

48

% 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
% 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
Ceyhz ( i + 1 , : , : ) = Ceyhz ( i + 1 , : , : ) / kappa ex xn ( i ) ;
Cezhy ( i + 1 , : , : ) = Cezhy ( i + 1 , : , : ) / kappa ex xn ( i ) ;
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 ) ;
end

50

52

54

56

% 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 ;
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 ;

58

60

62

64

end
% 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

68

70

72

74

76

78

% d e f i n e oned 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 ) ;
n c e l l s = n cpml xp ;
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 ;
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 ;
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 ;
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 ) ;
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

82

84

86

88

% d e f i n e oned 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 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 ) ) ;
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 ) ) ;
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 ) ) ;
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

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

MATLAB Implementation of CPML in the Three-Dimensional FDTD Method


Psi
Psi
Psi
Psi

92

94

eyx
ezx
hyx
hzx

xp
xp
xp
xp

=
=
=
=

zeros
zeros
zeros
zeros

(
(
(
(

ncells
ncells
ncells
ncells

, ny , nzp1
, nyp1 , nz
, nyp1 , nz
, ny , nzp1

14:16

247

);
);
);
);

96

% Create
% Notice
CPsi eyx
CPsi ezx
CPsi hyx
CPsi hzx

98

100

102

and i n i t i a l i z e 2D cpml c o n v o l u t i o n c o e f f i c i e n t s
t h a t E y ( nxp1 , : , : ) and E z ( nxp1 , : , : ) a r e n o t u p d a t e d by cmpl
x p = C e y h z ( nxp1n c e l l s : nx , : , : ) * dx ;
x p = C e z h y ( nxp1n c e l l s : nx , : , : ) * dx ;
x p = C h y e z ( nxp1n c e l l s : nx , : , : ) * dx ;
x p = C h z e y ( nxp1n c e l l s : nx , : , : ) * dx ;

% A d j u s t FDTD c o e f f i c i e n t s
% N o t i c e t h a t E y ( nxp1 , : , : )
for i = 1: n c e l l s
C e y h z ( nxn c e l l s +i , : , : )
C e z h y ( nxn c e l l s +i , : , : )
C h y e z ( nxn c e l l s +i , : , : )
C h z e y ( nxn c e l l s +i , : , : )
end

104

106

108

110

i n t h e CPML r e g i o n
and E z ( nxp1 , : , : ) a r e n o t u p d a t e d by cmpl
=
=
=
=

C e y h z ( nxn c e l l s +i
C e z h y ( nxn c e l l s +i
C h y e z ( nxn c e l l s +i
C h z e y ( nxn c e l l s +i

,:
,:
,:
,:

,:)/
,:)/
,:)/
,:)/

kappa
kappa
kappa
kappa

ex
ex
mx
mx

xp (
xp (
xp (
xp (

i
i
i
i

);
);
);
);

112

% 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 xp sigma pmx xp ;
c l e a r kappa ex xp kappa mx xp ;
clear alpha ex xp alpha mx xp ;

114

116

end

sigma pex xp, sigma pmx xp, kappa ex xp, kappa mx xp, alpha ex xp, and alpha mx xp, using 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 eld components, and the distances of these eld 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 eld
components and the respective distances of the eld components from the CPML interface are
illustrated in Fig. 8.4. One can see that CPML interface is assumed to be offset from the rst
CPML cell by a quarter cell size. This is to ensure that the same number of electric and magnetic
eld components are updated by the CPML algorithm. Similarly, Fig. 8.5 illustrates the magnetic
eld components of Hy and Hz being updated using the CPML in the xp region. The distances
of these eld 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 dened 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 coefcients Ce y x , Ce zx , Chy x , and Chzx are calculated and stored as two-dimensional arrays with the respective names CPsi eyx xp, CPsi ezx xp, CPsi hyx xp, and CPsi hzx xp. Then
the FDTD updating coefcients 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 MATLABs workspace.

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

248

The Convolutional Perfectly Matched Layer

e(1)

e(2)

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(1)

h(2)

Hy and Hz components
updated by CPML
Figure 8.5 Positions of the magnetic field components updated by CPML in the x p region.

8.4.3 Application of CPML in the FDTD Time-Marching Loop

The necessary CPML arrays and parameters are initialized in initialize CPML ABC, and they
are ready to use for applying the CPML in the FDTD time-marching loop. Two new subroutines
are added to the subroutine run fdtd time marching loop as shown in Listing 8.5. The rst one
is update magnetic field CPML ABC, and it follows update magnetic fields. The second one is
update electric field CPML ABC, and it follows update electric fields.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

MATLAB Implementation of CPML in the Three-Dimensional FDTD Method

October 13, 2009

14:16

249

Listing 8.5 run fdtd time marching loop



2

disp ( [ S t a r t i n g the time marching loop ] ) ;


d i s p ( [ T o t a l number o f t i m e s t e p s : . . .
num2str ( n u m b e r o f t i m e s t e p s ) ] ) ;

10

12

14

16

18

20

22

24

26

s t a r t t i m e = cputime ;
current time = 0;
for time step = 1: number of time steps
update magnetic fields ;
update magnetic field CPML ABC ;
capture sampled magnetic fields ;
capture sampled currents ;
update electric fields ;
update electric field CPML ABC ;
update voltage sources ;
update current sources ;
update inductors ;
update diodes ;
capture sampled electric fields ;
capture sampled voltages ;
display sampled parameters ;
end
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 ;
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 magnetic eld 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, rst the auxiliary parameters are calculated using the current values of the electric eld components.
These terms are then added to the appropriate magnetic eld components in their respective
CPML regions.
Similarly, the implementation of update electric field CPML ABC is given in Listing 8.7.
The electric eld 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, rst the auxiliary parameters are calculated using the current values of the magnetic eld components.
These terms are then added to the appropriate electric eld 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 dened as twodimensional 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 coefcients representing Ce and Cm 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

250

The Convolutional Perfectly Matched Layer

Listing 8.6 update magnetic field CPML ABC



1

11

13

15

17

19

21

% a p p l y CPML t o m a g n e t i c f i e l d components
if is cpml xn
for i = 1: n cpml xn
P s i h y x x n ( i , : , : ) = cpml b mx xn ( i ) * P s i h y x x n ( i , : , : )
+ cpml a mx xn ( i ) * ( Ez ( i +1 ,: ,:) Ez ( i , : , : ) ) ;
P s i h z x x n ( i , : , : ) = cpml b mx xn ( i ) * P s i h z x x n ( i , : , : )
+ cpml a mx xn ( i ) * ( Ey ( i +1 ,: ,:) Ey ( i , : , : ) ) ;
end
Hy ( 1 : n c p m l x n , : , : ) = Hy ( 1 : n c p m l x n , : , : ) . . .
+ CPsi hyx xn ( : , : , : ) .* Psi hyx xn ( : , : , : ) ;
Hz ( 1 : n c p m l x n , : , : ) = Hz ( 1 : n c p m l x n , : , : ) . . .
+ CPsi hzx xn ( : , : , : ) .* Psi hzx xn ( : , : , : ) ;
end
if is cpml xp
n s t = nx n c p m l x p ;
for i = 1: n cpml xp
P s i h y x x p ( i , : , : ) = cpml b mx
+ cpml a mx xp ( i ) * ( Ez ( i+n
P s i h z x x p ( i , : , : ) = cpml b mx
+ cpml a mx xp ( i ) * ( Ey ( i + n
end

...
...

xp ( i ) * P s i h y x x p ( i , : , : ) . . .
s t +1 ,: ,:) Ez ( i+n st , : , : ) ) ;
xp ( i ) * P s i h z x x p ( i , : , : ) . . .
s t +1 ,: ,:) Ey ( i+n s t , : , : ) ) ;

23

Hy ( n s t +1: nx , :
+ CPsi hyx
Hz ( n s t +1: nx , :
+ CPsi hzx

25

27

,:)
xp
,:)
xp

= Hy ( n
(: ,: ,:)
= Hz ( n
(: ,: ,:)

s t +1: nx , : , : )
.* Psi hyx xp
s t +1: nx , : , : )
.* Psi hzx xp

...
(: ,: ,:);
...
(: ,: ,:);

end

8.5 SIMULATION EXAMPLES

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.
8.5.1 Microstrip Low-Pass Filter

In Section 6.2, we demonstrated a low-pass lter geometry, which is illustrated in Fig. 6.2. We
assumed that the boundaries of the problem space were PEC. In this section we repeat the same
example but assume that the boundaries are CPML. The section of the code that denes the
boundaries in define problem space parameters is shown in Listing 8.8. As can be followed in
the listing, an air gap of 5 cells thickness is surrounding the lter circuit, and the boundaries are
terminated by 8 cells thickness of the CPML.
The simulation of the circuit is performed for 3,000 time steps. The results of this simulation
are plotted in the Figs. 8.6, 8.7, 8.8, and 8.9. Figure 8.6 shows the source voltage and sampled
voltages observed at the ports of the low-pass lter, whereas Fig. 8.7 shows the sampled currents
observed at the ports of the low-pass lter. It can be seen that the signals are sufciently decayed
after 3,000 time steps. After the transient voltages and currents are obtained, they are used for

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation Examples

14:16

251

Listing 8.7 update electric field CPML ABC


2

10

12

% a p p l y CPML t o e l e c t r i c f i e l d components
if is cpml xn
for i = 1: n cpml xn
Psi eyx xn ( i , : , : ) = cpml b ex xn ( i ) * Psi
+ c p m l a e x x n ( i ) * ( Hz ( i + 1 , : , : ) Hz ( i , :
Psi ezx xn ( i , : , : ) = cpml b ex xn ( i ) * Psi
+ c p m l a e x x n ( i ) * ( Hy ( i + 1 , : , : ) Hy ( i , :
end
Ey ( 2 : n cpml xn + 1 , : , : ) = Ey ( 2 : n cpml xn + 1 , : , : )
+ CPsi eyx xn .* Psi eyx xn ;
Ez ( 2 : n cpml xn + 1 , : , : ) = Ez ( 2 : n cpml xn + 1 , : , : )
+ CPsi ezx xn .* Psi ezx xn ;
end

eyx xn ( i , : , : )
,:));
ezx xn ( i , : , : )
,:));

...
...

...
...

14

16

18

20

22

24

26

if is cpml xp
n s t = nx n c p m l x p ;
for i = 1: n cpml xp
Psi eyx xp ( i , : , : ) = cpml b ex xp ( i ) * Psi
+ c p m l a e x x p ( i ) * ( Hz ( i + n s t , : , : ) Hz (
Psi ezx xp ( i , : , : ) = cpml b ex xp ( i ) * Psi
+ c p m l a e x x p ( i ) * ( Hy ( i + n s t , : , : ) Hy (
end
E y ( n s t +1: nx , : , : ) = E y ( n s t +1: nx , : , : ) . . .
+ CPsi eyx xp .* Psi eyx xp ;
E z ( n s t +1: nx , : , : ) = E z ( n s t +1: nx , : , : ) . . .
+ CPsi ezx xp .* Psi ezx xp ;
end

eyx
i+n
ezx
i+n

xp ( i
st 1
xp ( i
st 1

Listing 8.8 define problem space parameters.m


19

21

23

25

27

29

31

33

35

37

%
%
%
%
%
%

==<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
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
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

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 ;
boundary . c p m l n u m b e r o f c e l l s x n = 8 ;
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 ;
boundary . c p m l n u m b e r o f c e l l s x p = 8 ;
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 ;
boundary . c p m l n u m b e r o f c e l l s y n = 8 ;
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

252

41

43

45

47

49

51

53

boundary . c p m l n u m b e r o f c e l l s y p = 8 ;
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 ;
boundary . c p m l n u m b e r o f c e l l s z n = 8 ;
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 ;
boundary . c p m l n u m b e r o f c e l l s z p = 8 ;
boundary . cpml
boundary . c p m l
boundary . cpml
boundary . cpml
boundary . cpml

order = 3;
sigma factor = 1.3;
kappa max = 7 ;
alpha min = 0;
alpha max = 0 . 0 5 ;

postprocessing and scattering parameter (S-parameter) calculations. Figure 8.8 shows S11 , whereas
Fig. 8.9 shows S21 of the circuit. Comparing these gures with the plots in Fig. 6.3 one can observe
that the S-parameters calculated for the case where the boundaries are CPML are smooth and do
not include glitches. This means that resonances due to the closed PEC boundaries are eliminated
and the circuit is simulated as if it is surrounded by open space.
8.5.2 Microstrip Branch Line Coupler

The second example is a microstrip branch line coupler, which was published in [14]. The
circuit discussed in this section is illustrated in Fig. 8.10. The cell sizes are x = 0.406 mm,

1.2
sampled voltage at port 1
sampled voltage at port 2
source voltage

1
0.8
0.6
(V)

39

The Convolutional Perfectly Matched Layer

0.4
0.2
0
0.2
0

0.5

1
time (ns)

1.5

Figure 8.6 Source voltage and sampled voltages observed at the ports of the low-pass filter.

14:16

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation Examples

253
3

12

x 10

sampled current at port 1


sampled current at port 2

10
8

(A)

6
4
2
0
2
4
6
0

0.5

1
time (ns)

1.5

Figure 8.7 Sampled currents observed at the ports of the low-pass filter.

magnitude (dB)

0
20
40
60
0

phase (degrees)

fdtd_main

10
frequency (GHz)

15

20

10
frequency (GHz)

15

20

200

200
0

Figure 8.8 S 11 of the low-pass filter.

14:16

SPIB005-Elsherbeni & Demir

October 13, 2009

254

The Convolutional Perfectly Matched Layer

magnitude (dB)

0
20
40
0

phase (degrees)

fdtd_main

10
frequency (GHz)

15

20

10
frequency (GHz)

15

20

200

200
0

Figure 8.9 S 21 of the low-pass filter.

y = 0.406 mm, and z = 0.265 mm. In this circuit the wide lines are 10 cells wide and the narrow 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
denition 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.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

Simulation Examples

Listing 8.9 define geometry.m


d i s p ( d e f i n i n g t h e problem g e o m e t r y ) ;
2

10

12

bricks = [ ] ;
spheres = [ ] ;
% define a substrate
b r i c k s ( 1 ) . m i n x = 20* dx ;
b r i c k s ( 1 ) . m i n y = 25* dy ;
b r i c k s ( 1 ) . min z = 0 ;
b r i c k s ( 1 ) . max x = 20 * dx ;
b r i c k s ( 1 ) . max y = 25 * dy ;
b r i c k s ( 1 ) . max z = 3 * dz ;
bricks ( 1 ) . material type = 4;

14

16

18

20

22

24

26

28

30

% d e f i n e a PEC p l a t e
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 ;
b r i c k s ( 2 ) . m i n z = 3 * dz ;
b r i c k s ( 2 ) . max x = 12 * dx ;
b r i c k s ( 2 ) . max y = 9* dy ;
b r i c k s ( 2 ) . max z = 3 * dz ;
bricks ( 2 ) . material type = 2;
% 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 ;
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 ;
b r i c k s ( 3 ) . max x = 12 * dx ;
b r i c k s ( 3 ) . max y = 15 * dy ;
b r i c k s ( 3 ) . max z = 3 * dz ;
bricks ( 3 ) . material type = 2;

32

34

36

38

40

42

44

46

48

50

% d e f i n e a PEC p l a t e
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 ;
b r i c k s ( 4 ) . m i n z = 3 * dz ;
b r i c k s ( 4 ) . max x = 7* dx ;
b r i c k s ( 4 ) . max y = 12 * dy ;
b r i c k s ( 4 ) . max z = 3 * dz ;
bricks ( 4 ) . material type = 2;
% 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 ;
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 ;
b r i c k s ( 5 ) . max x = 17 * dx ;
b r i c k s ( 5 ) . max y = 12 * dy ;
b r i c k s ( 5 ) . max z = 3 * dz ;
bricks ( 5 ) . material type = 2;

October 13, 2009

255

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

256

52

54

56

58

60

62

64

66

October 13, 2009

The Convolutional Perfectly Matched Layer

% d e f i n e a PEC p l a t e
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 ;
b r i c k s ( 6 ) . m i n z = 3 * dz ;
b r i c k s ( 6 ) . max x = 9* dx ;
b r i c k s ( 6 ) . max y = 12* dy ;
b r i c k s ( 6 ) . max z = 3 * dz ;
bricks ( 6 ) . material type = 2;
% 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 ;
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 ;
b r i c k s ( 7 ) . max x = 15 * dx ;
b r i c k s ( 7 ) . max y = 12* dy ;
b r i c k s ( 7 ) . max z = 3 * dz ;
bricks ( 7 ) . material type = 2;

68

70

72

74

76

78

80

82

84

% d e f i n e a PEC p l a t e
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 ;
b r i c k s ( 8 ) . m i n z = 3 * dz ;
b r i c k s ( 8 ) . max x = 9* dx ;
b r i c k s ( 8 ) . max y = 25 * dy ;
b r i c k s ( 8 ) . max z = 3 * dz ;
bricks ( 8 ) . material type = 2;
% 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 ;
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 ;
b r i c k s ( 9 ) . max x = 15 * dx ;
b r i c k s ( 9 ) . max y = 25 * dy ;
b r i c k s ( 9 ) . max z = 3 * dz ;
bricks ( 9 ) . material type = 2;

86

88

90

92

94

% d e f i n e a PEC p l a t e a s ground
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 ;
b r i c k s ( 1 0 ) . min z = 0 ;
b r i c k s ( 1 0 ) . max x = 20 * dx ;
b r i c k s ( 1 0 ) . max y = 25 * dy ;
b r i c k s ( 1 0 ) . max z = 0 ;
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
denition of the voltage source and resistors is shown in Listing 8.10.
Four sampled voltages and four sampled currents are dened as the outputs of the circuit as
shown in Listing 8.11. One should notice that the sampled voltages and currents are dened
directly on the voltage source and the termination resistors. Therefore, the reference planes for

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

Simulation Examples

Listing 8.10 define sources and lumped elements.m


1

d i s p ( d e f i n i n g s o u r c e s and lumped e l e m e n t components ) ;


voltage sources = [ ] ;
current sources = [ ] ;
diodes = [ ] ;
resistors = [];
inductors = [ ] ;
capacitors = [ ] ;

11

% 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 ;
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

15

17

19

21

23

25

27

29

31

33

35

37

39

41

43

45

47

49

% voltage sources
% 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
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 ;
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 ;
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 ;
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;
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 ;
v o l t a g e s o u r c e s ( 1 ) . waveform index = 1;
% resistors
% direction :
% resistance
resistors (1).
resistors (1).
resistors (1).
resistors (1).
resistors (1).
resistors (1).
resistors (1).
resistors (1).

x , y , or z
: ohms
m i n x = 9 * dx ;
mi n y = 25* dy ;
min z = 0 ;
max x = 15 * dx ;
max y = 25* dy ;
max z = 3 * dz ;
direction = z ;
r e s i s t a n c e = 50;

% resistors
% direction :
% resistance
resistors (2).
resistors (2).
resistors (2).
resistors (2).
resistors (2).
resistors (2).
resistors (2).

x , y , or z
: ohms
m i n x = 9 * dx ;
mi n y = 25 * dy ;
min z = 0 ;
max x = 15 * dx ;
max y = 25 * dy ;
max z = 3 * dz ;
direction = z ;

October 13, 2009

257

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

258
51

53

55

57

59

61

63

The Convolutional Perfectly Matched Layer

r e s i s t o r s ( 2 ) . r e s i s t a n c e = 50;
% resistors
% direction :
% resistance
resistors (3).
resistors (3).
resistors (3).
resistors (3).
resistors (3).
resistors (3).
resistors (3).
resistors (3).

x , y , or z
: ohms
m i n x = 15* dx ;
mi n y = 25 * dy ;
min z = 0 ;
max x = 9* dx ;
max y = 25 * dy ;
max z = 3 * dz ;
direction = z ;
r e s i s t a n c e = 50;

Listing 8.11 define output parameters.m


disp ( d e f i n i n g output parameters ) ;
2

sampled electric fields = [];


sampled magnetic fields = [ ] ;
sampled voltages = [ ] ;
sampled currents = [ ] ;
ports = [ ] ;

10

12

14

% figure refresh rate


p l o t t i n g s t e p = 5;
% mode o f o p e r a t i o n
run simulation = true ;
show material mesh = true ;
show problem space = true ;

16

18

20

22

24

26

28

30

32

34

October 13, 2009

% 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 ;
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 ;
% define
sampled
sampled
sampled
sampled
sampled
sampled
sampled
sampled

sampled
voltages
voltages
voltages
voltages
voltages
voltages
voltages
voltages

voltages
( 1 ) . m i n x = 15* dx ;
( 1 ) . m i n y = 25* dy ;
( 1 ) . min z = 0 ;
( 1 ) . max x = 9* dx ;
( 1 ) . max y = 25* dy ;
( 1 ) . max z = 3 * dz ;
( 1 ) . d i r e c t i o n = zp ;
(1). display plot = false ;

% define
sampled
sampled
sampled

sampled
voltages
voltages
voltages

voltages
( 2 ) . m i n x = 9 * dx ;
( 2 ) . m i n y = 25* dy ;
( 2 ) . min z = 0 ;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation Examples
36

38

40

42

44

46

48

50

52

54

56

58

60

62

64

66

68

70

72

74

76

78

80

82

84

86

259

sampled
sampled
sampled
sampled
sampled

voltages
voltages
voltages
voltages
voltages

(2).
(2).
(2).
(2).
(2).

max x = 15 * dx ;
max y = 25* dy ;
max z = 3 * dz ;
d i r e c t i o n = zp ;
display plot = false ;

% define
sampled
sampled
sampled
sampled
sampled
sampled
sampled
sampled

sampled
voltages
voltages
voltages
voltages
voltages
voltages
voltages
voltages

voltages
( 3 ) . m i n x = 9 * dx ;
( 3 ) . m i n y = 25 * dy ;
( 3 ) . min z = 0 ;
( 3 ) . max x = 15 * dx ;
( 3 ) . max y = 25 * dy ;
( 3 ) . max z = 3 * dz ;
( 3 ) . d i r e c t i o n = zp ;
(3). display plot = false ;

% define
sampled
sampled
sampled
sampled
sampled
sampled
sampled
sampled

sampled
voltages
voltages
voltages
voltages
voltages
voltages
voltages
voltages

voltages
( 4 ) . m i n x = 15* dx ;
( 4 ) . m i n y = 25 * dy ;
( 4 ) . min z = 0 ;
( 4 ) . max x = 9* dx ;
( 4 ) . max y = 25 * dy ;
( 4 ) . max z = 3 * dz ;
( 4 ) . d i r e c t i o n = zp ;
(4). display plot = false ;

% define
sampled
sampled
sampled
sampled
sampled
sampled
sampled
sampled

sampled
currents
currents
currents
currents
currents
currents
currents
currents

currents
( 1 ) . m i n x = 15* dx ;
( 1 ) . m i n y = 25* dy ;
( 1 ) . m i n z = 2 * dz ;
( 1 ) . max x = 9* dx ;
( 1 ) . max y = 25* dy ;
( 1 ) . max z = 2 * dz ;
( 1 ) . d i r e c t i o n = zp ;
(1). display plot = false ;

% define
sampled
sampled
sampled
sampled
sampled
sampled
sampled
sampled

sampled
currents
currents
currents
currents
currents
currents
currents
currents

currents
( 2 ) . m i n x = 9 * dx ;
( 2 ) . m i n y = 25* dy ;
( 2 ) . m i n z = 2 * dz ;
( 2 ) . max x = 15 * dx ;
( 2 ) . max y = 25* dy ;
( 2 ) . max z = 2 * dz ;
( 2 ) . d i r e c t i o n = zp ;
(2). display plot = false ;

% define
sampled
sampled
sampled
sampled
sampled

sampled
currents
currents
currents
currents
currents

currents
( 3 ) . min x
( 3 ) . min y
( 3 ) . min z
( 3 ) . max x
( 3 ) . max y

=
=
=
=
=

9 * dx ;
25 * dy ;
2 * dz ;
15 * dx ;
25 * dy ;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

260
88

90

92

94

96

98

100

102

104

106

108

110

October 13, 2009

The Convolutional Perfectly Matched Layer

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 ;
sampled currents ( 3 ) . display plot = false ;
% define
sampled
sampled
sampled
sampled
sampled
sampled
sampled
sampled

sampled
currents
currents
currents
currents
currents
currents
currents
currents

currents
( 4 ) . m i n x = 15* dx ;
( 4 ) . m i n y = 25 * dy ;
( 4 ) . m i n z = 2 * dz ;
( 4 ) . max x = 9* dx ;
( 4 ) . max y = 25 * dy ;
( 4 ) . max z = 2 * dz ;
( 4 ) . d i r e c t i o n = zp ;
(4). display plot = false ;

% define
ports ( 1 ) .
ports ( 1 ) .
ports ( 1 ) .
ports ( 1 ) .

ports
sampled voltage index = 1;
sampled current index = 1;
impedance = 5 0 ;
is source port = true ;

ports
ports
ports
ports

(2).
(2).
(2).
(2).

sampled voltage index = 2;


sampled current index = 2;
impedance = 5 0 ;
is source port = false ;

ports
ports
ports
ports

(3).
(3).
(3).
(3).

sampled voltage index = 3;


sampled current index = 3;
impedance = 5 0 ;
is source port = false ;

ports
ports
ports
ports

(4).
(4).
(4).
(4).

sampled voltage index = 4;


sampled current index = 4;
impedance = 5 0 ;
is source port = false ;

112

114

116

118

120

122

124

126

128

130

132

% define animation
% 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
% 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 ;
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 ;
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 ;
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

136

138

% d i s p l a y problem s p a c e p a r a m e t e r s
problem space display . labels = false ;
problem space display . a x i s a t o r i g i n = false ;
problem space display . axis outside domain = false ;
problem space display . grid xn = false ;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation Examples

142

144

146

problem
problem
problem
problem
problem
problem
problem

space
space
space
space
space
space
space

261
display
display
display
display
display
display
display

.
.
.
.
.
.
.

grid xp = false ;
grid yn = false ;
grid yp = false ;
grid zn = false ;
grid zp = false ;
outer boundaries = false ;
cpml boundaries = f a l s e ;

the S-parameter calculations are at the positions of the source and resistor terminations. Then
four 50 ports are dened by associating sampled voltagecurrent pairs with them. Then port 1
is set to be the excitation port for this FDTD simulation.
After the denition 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].
8.5.3 Characteristic Impedance of a Microstrip Line

We have demonstrated the use of CPML for two microstip circuits in the previous examples.
These circuits are fed using microstrip lines, the characteristic impedance of which is assumed to
be 50 . In this section we provide an example showing the calculation of characteristic impedance
of a microstrip line.
We use the same microstrip feeding line as the one used in previous example; the line is 2.4 mm
wide, and the dielectric substrate has 2.2 dielectric constant and 0.795 mm thickness. A single line

0
5
10
magnitude (dB)

140

14:16

15
20
25

S11
S21
S31
S41

30
35
40
0

4
6
frequency (GHz)

Figure 8.11 S-parameters of the branch line coupler.

10

fdtd_main

SPIB005-Elsherbeni & Demir

262

October 13, 2009

The Convolutional Perfectly Matched Layer

Figure 8.12 An FDTD problem space including a microstrip line.

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 innity in these directions. The denition of the
problem space including the cell sizes and boundaries is shown in Listing 8.12. The denition of
the geometry is given in Listing 8.13. The microstrip line is fed with voltage source as dened in
Listing 8.14. A sampled voltage and a sampled current are dened 10 cells away from the source,
and they are tied to form a port as shown in Listing 8.15.
Listing 8.12 define problem space parameters.m

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 ) ;
2

10

% maximum number o f t i m e s t e p s t o run FDTD s i m u l a t i o n


number of time steps = 1000;
% 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
courant factor = 0.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
number of cells per wavelength = 20;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

Simulation Examples

October 13, 2009

14:16

263

12

14

16

18

20

22

% 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 . 0 3 0 e 4;
dy = 2 . 0 3 0 e 4;
dz = 1 . 3 2 5 e 4;
%
%
%
%
%
%

==<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
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
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

26

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 = 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

30

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 = 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

34

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 = 8 ;
boundary . c p m l n u m b e r o f c e l l s y n = 8 ;

36

38

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 ;
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

42

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 ;
boundary . c p m l n u m b e r o f c e l l s z n = 8 ;

44

46

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 = 10;
boundary . c p m l n u m b e r o f c e l l s z p = 8 ;

48

50

52

boundary . cpml
boundary . c p m l
boundary . cpml
boundary . cpml
boundary . cpml

order = 3;
sigma factor = 1;
kappa max = 1 0 ;
alpha min = 0;
alpha max = 0 . 0 1 ;

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 reection observed from the

fdtd_main

SPIB005-Elsherbeni & Demir

264

October 13, 2009

The Convolutional Perfectly Matched Layer

Listing 8.13 define geometry.m


d i s p ( d e f i n i n g t h e problem g e o m e t r y ) ;
2

10

12

bricks = [ ] ;
spheres = [ ] ;
% define a substrate
b r i c k s ( 1 ) . min x = 0 ;
b r i c k s ( 1 ) . mi n y = 0 ;
b r i c k s ( 1 ) . min z = 0 ;
b r i c k s ( 1 ) . max x = 60 * dx ;
b r i c k s ( 1 ) . max y = 60 * dy ;
b r i c k s ( 1 ) . max z = 6 * dz ;
bricks ( 1 ) . material type = 4;

14

16

18

20

22

% d e f i n e a PEC p l a t e
b r i c k s ( 2 ) . m i n x = 24 * dx ;
b r i c k s ( 2 ) . mi n y = 0 ;
b r i c k s ( 2 ) . m i n z = 6 * dz ;
b r i c k s ( 2 ) . max x = 36 * dx ;
b r i c k s ( 2 ) . max y = 60 * dy ;
b r i c k s ( 2 ) . max z = 6 . 0 2 * dz ;
bricks ( 2 ) . material type = 2;

Listing 8.14 define sources and lumped elements.m


d i s p ( d e f i n i n g s o u r c e s and lumped e l e m e n t components ) ;
2

10

12

14

16

18

20

22

24

26

voltage sources = [ ] ;
current sources = [ ] ;
diodes = [ ] ;
resistors = [];
inductors = [ ] ;
capacitors = [ ] ;
% 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 ;
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;
% voltage sources
% 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
v o l t a g e s o u r c e s ( 1 ) . m i n x = 24 * dx ;
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 ;
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 ;
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 ;
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 ;
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;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

Simulation Examples

October 13, 2009

14:16

265

Listing 8.15 define output parameters.m


1

disp ( d e f i n i n g output parameters ) ;


sampled electric fields = [];
sampled magnetic fields = [ ] ;
sampled voltages = [ ] ;
sampled currents = [ ] ;
ports = [ ] ;
% figure refresh rate
p l o t t i n g s t e p = 20;

11

13

15

17

19

% mode o f o p e r a t i o n
run simulation = true ;
show material mesh = true ;
show problem space = true ;
% 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 ;
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

23

25

27

29

% define
sampled
sampled
sampled
sampled
sampled
sampled
sampled
sampled

sampled
voltages
voltages
voltages
voltages
voltages
voltages
voltages
voltages

voltages
( 1 ) . m i n x = 24 * dx ;
( 1 ) . m i n y = 40 * dy ;
( 1 ) . min z = 0 ;
( 1 ) . max x = 36 * dx ;
( 1 ) . max y = 40 * dy ;
( 1 ) . max z = 6 * dz ;
( 1 ) . d i r e c t i o n = zp ;
(1). display plot = false ;

% define
sampled
sampled
sampled
sampled
sampled
sampled
sampled
sampled

sampled
currents
currents
currents
currents
currents
currents
currents
currents

currents
( 1 ) . m i n x = 24 * dx ;
( 1 ) . m i n y = 40 * dy ;
( 1 ) . m i n z = 6 * dz ;
( 1 ) . max x = 36 * dx ;
( 1 ) . max y = 40 * dy ;
( 1 ) . max z = 6 * dz ;
( 1 ) . d i r e c t i o n = yp ;
(1). display plot = false ;

31

33

35

37

39

41

43

45

% define
ports ( 1 ) .
ports ( 1 ) .
ports ( 1 ) .
ports ( 1 ) .

ports
sampled voltage index = 1;
sampled current index = 1;
impedance = 5 0 ;
is source port = true ;

SPIB005-Elsherbeni & Demir

October 13, 2009

266

The Convolutional Perfectly Matched Layer

1.2
sampled voltage
source voltage

1
0.8

(volt)

0.6
0.4
0.2
0
0.2
0

0.05

0.1

0.15
time (ns)

0.2

0.25

0.3

Figure 8.13 Source voltage and sampled voltage of the microstrip line.

10

x 10

sampled current
8
6
(ampere)

fdtd_main

4
2
0
2
0

0.05

Figure 8.14 Current on the microstrip line.

0.1

0.15
time (ns)

0.2

0.25

0.3

14:16

SPIB005-Elsherbeni & Demir

October 13, 2009

267

magnitude (dB)

Exercises

30

40

50
0
phase (degrees)

fdtd_main

4
6
frequency (GHz)

10

4
6
frequency (GHz)

10

50
100
150
200
0

Figure 8.15 S 11 of the microstrip line.

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. Redene the CPML absorbing 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 reected pulse from the PEC termination will not be observed at

14:16

SPIB005-Elsherbeni & Demir

October 13, 2009

268

The Convolutional Perfectly Matched Layer

60
50
real{Z0}

40

imaginary{Z0}

30
()

fdtd_main

20
10
0
10
0

4
6
frequency (GHz)

10

Figure 8.16 Characteristic impedance of the microstrip line.

the sampled voltage. This simulation result serves as the reference case since it does not
include any reected signals as if the microstrip line is innitely 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 reection. Find the maximum
value of the reection.

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.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

Exercises

October 13, 2009

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 reected voltage as described
in Exercise 8.3. Examine whether the reection increases or decreases. Then repeat the

Figure 8.19 The microstrip line reference case.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

270

October 13, 2009

The Convolutional Perfectly Matched Layer

same exercise by increasing the CPML thickness to 10 cells. Examine whether the reection
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 reections 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.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

9
Near-Field to Far-Field
Transformation
In previous chapters, the nite-difference time-domain (FDTD) method is used to compute
electric and magnetic elds within a nite space around an electromagnetic object, (i.e., the
near-zone electromagnetic elds). In many applications such as antennas and radar cross-section
(RCS), it is necessary to nd the radiation or scattered elds in the region that is far away from
an antenna or scatterer. With the FDTD technique, the direct evaluation of the far eld calls
for an excessively large computational domain, which is not practical in applications. Instead, the
far-zone electromagnetic elds are computed from the near-eld FDTD data through a near-eld
to far-eld (NFFF) transformation technique [1].
A simple condition for the far eld is dened as follows:
kR  1

2 R
 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 reector, the aperture
size D is often used to determine the far-eld condition [28]:
r>

2D2
,

(9.2)

where r is the distance from the center of the antenna aperture to the observation point. In the
far-eld region, the electromagnetic eld at an observation point (r, , ) can be expressed as
j kr
 , ) = e
E(r,
F (, ),
4r

 = r E ,
H
0

(9.3a)
(9.3b)

where 0 is the wave impedance of free space, and F (, ) is a term determining the angular
variations of the far-eld pattern of the electric eld. 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-eld to far-eld 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.
 on the surface are determined by the computed E and H
 elds inside
The currents J and M
271

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

272

Near-Field to Far-Field Transformation

Equivalence principle
Surround the object by
an imaginary surface
Define fictitious electric
and magnetic currents
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 eld from the
 and
currents is equivalent to the radiation eld from the antenna. Next, the vector potentials A



F are used to compute the radiation elds from the equivalent currents J and M. The far-eld
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 efcient to use this near-eld to far-eld 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 elds at each angle of interest are stored while updating the eld components [29,30].
In contrast, when the far elds 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 elds (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 elds at all observation angles through the frequency-domain
transformation.
This chapter is organized as follows. First, the surface equivalence theorem is discussed, and
 are obtained from the near-eld FDTD data. Then the imthe equivalent currents J and M
portant radiation formulas are presented to calculate the far elds 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-eld technique.
9.1 IMPLEMENTATION OF THE SURFACE EQUIVALENCE THEOREM
9.1.1 Surface Equivalence Theorem

The surface equivalence theorem was introduced in 1936 by Sckelkunoff [31] and is now widely
used in electromagnetic and antenna problems [32]. The basic idea is to replace the actual sources
such as antennas or scatterers with ctitious surface currents on a surrounding closed surface.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Implementation of the Surface Equivalence Theorem

273

J
DFT

Currents (J,M) in
Frequency Domain at
a specific frequency

Currents (J,M) in
Time Domain

Transformation of
(E,H)
(J,M)

Transformation of
(E,H)
(J,M)

DFT

Far Field at all observation


angles for selected number of
frequencies

Far Field at a selected number


of observation points, but for
all valid frequencies

Figure 9.2 Two paths of the near-field to far-field transformation technique are implemented to achieve different
computation objectives.

Within a specic region, the elds generated by the ctitious currents represent the original
elds.
Figure 9.3 illustrates a typical implementation of the surface equivalent theorem. Assume that
 H).
 An imaginary surface S is selected to enclose
elds generated by an arbitrary source are ( E,
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 elds 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 elds satisfy Maxwells equations both inside and outside the surface S. To comply with the

E, H
E, H

S
S

E = 0,
scatterers
and sources

(a) original problem

Figure 9.3 Surface equivalence theorem.

H = 0.

J s = n H
Ms = n E

(b) Equivalent problem for region


outside S

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

274

Near-Field to Far-Field Transformation

boundary conditions on the surface, equivalent surface currents must be introduced on S:





 out H
 in = n H,
JS = n H


 S = n E out E in = n E.

M

(9.4a)
(9.4b)

It is worthwhile to emphasize that Figs. 9.3(a) and 9.3(b) have the same elds outside the surface
S but different elds inside the surface S.
If the eld 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 elds
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 elds 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 elds outside the surface S are also the solution for the original problem.
The implementation of the surface equivalence theorem simplies the far-eld calculation. In
the original Fig. 9.3(a) problem, materials with different permittivities and permeabilities may
exist inside the surface S. Thus, a complex Greens function needs to be derived to calculate
the radiating eld. In the problem in Fig. 9.3(b), the elds 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 Greens function is used to compute the radiating eld.

9.1.2 Equivalent Surface Currents in FDTD Simulation

From the previous discussion, it is clear that the key point of the equivalence theorem implementation is to accurately obtain the equivalent currents on the imaginary surface S. In the FDTD
simulation, the surface currents can be readily computed from the following procedure.
First, a closed surface is selected around the antennas or scatterers, as shown in Fig. 9.4. The
selected surface is usually a rectangular box that ts the FDTD grid. It is set between the analyzed
objects and the outside absorbing boundary. The location of the box can be dened by two corners:
lowest coordinate (li, l j, lk) corner and upper coordinate (ui, u j, uk) corner. It is critical that all
the antennas or scatterers must be enclosed by this rectangular box so that the equivalent theorem
can be implemented. It is also important to have this box in the air buffer area between all objects
and the rst interface of the absorbing boundary.
Once the imaginary closed surface is selected, the equivalent surface currents are computed
next. There are six surfaces of the rectangular box, and each surface has four scalar electric and
magnetic currents, as shown in Fig. 9.5. For the top surface, the normal direction is z . From (9.4),
the equivalent surface currents are calculated as


 = z x Hx + y Hy + z Hz = x Hy + y Hx ,
JS = z H


 S = z E = z x E x + y E y + z E z = x E y y E x .
M

(9.5a)
(9.5b)

Thus, the scalar surface currents can be obtained:


JS = x Jx + y Jy Jx = Hy ,
 S = x Mx + y My Mx = E y ,
M

Jy = Hx ,

(9.6a)

My = E x .

(9.6b)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Implementation of the Surface Equivalence Theorem

275

Imaginary closed surface

(ui,uj,uk)

z
y

(li,lj,lk)

x
FDTD computational domain

Scatterer or antenna

Figure 9.4 An imaginary surface is selected to enclose the antennas or scatterers.

Note that the E and H elds used in (9.6) are computed from the FDTD simulation. For a timedomain far-eld calculation, the time-domain data are used directly. For a frequency-domain
far-eld calculation, a DFT needs to be carried out to obtain the desired frequency components
of the elds.

Imaginary closed surface

face zp J x , J y , M x , M y

z
x

facexn J y , J z , M y , M z

face yn J x , J z , M x , M z

facexp J y , J z , M y , M z
Figure 9.5 Equivalent surface currents on the imaginary closed surface.

face yp J x , J z , M x , M z

face zn J x , J y , M x , M y

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

276

Near-Field to Far-Field Transformation

Similar methodology is used to obtain the surface currents on the other ve surfaces. On the
bottom surface,
JS = x Jx + y Jy Jx = Hy ,

Jy = Hx ,

 S = x Mx + y My Mx = E y ,
M

My = E x .

(9.7a)
(9.7b)

On the left surface,


JS = x Jx + z Jz Jx = Hz ,
 S = x Mx + z Mz Mx = E z ,
M

Jz = Hx ,

(9.8a)

Mz = E x .

(9.8b)

On the right surface,


JS = x Jx + z Jz Jx = Hz ,

Jz = Hx ,

 S = x Mx + z Mz Mx = E z ,
M

Mz = E x .

(9.9a)
(9.9b)

On the front surface,


JS = y Jy + z Jz Jy = Hz ,
 S = y My + z Mz My = E z ,
M

Jz = Hy ,

(9.10a)

Mz = E y .

(9.10b)

On the back surface,


JS = y Jy + z Jz Jy = Hz ,

Jz = Hy ,

 S = y My + z Mz My = E z ,
M

Mz = E y .

(9.11a)
(9.11b)

To obtain complete source currents for the far-eld 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 Yees cell
surface that touches the equivalent surface S. Because of the spatial offset between the components
of the E and H eld locations on Yees cell, averaging of the eld 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-eld pattern in the next section.
9.1.3 Antenna on Infinite Ground Plane

It was mentioned earlier that the imaginary surface must surround all the scatterers or antennas
so that the equivalent currents radiate in a homogeneous medium, usually free space. For many
antenna applications, the radiator is mounted on a large or innite ground plane. In this situation, it
is impractical to select a large surface to enclose the ground plane. Instead, the selected surface that
encloses the radiator lies on top of the ground plane, and the ground plane effect is considered using
image theory, as shown in Fig. 9.6. The image currents have the same direction for horizontal
magnetic current and vertical electric current. In contrast, the image currents ow along the
opposite direction for horizontal electric current and vertical magnetic currents. This arrangement
is valid for ground planes simulating innite perfect electric conductor (PEC).

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Frequency Domain Near-Field to Far-Field Transformation

277

Imaginary
closed surface

Imaginary
closed surface

Image

Ground plane

Figure 9.6 An imaginary closed surface on an infinite PEC ground plane using the image theory.

9.2 FREQUENCY DOMAIN NEAR-FIELD TO FAR-FIELD TRANSFORMATION

In this section, the obtained equivalent surface currents are used to calculate the far-eld radiation
patterns. Antenna polarization and radiation efciency are also discussed.
9.2.1 Time-Domain to Frequency-Domain Transformation

This section focuses on the frequency-domain far-eld calculation. For the time-domain analysis,
readers are suggested to study reference [29,30]. The rst thing in the frequency-domain calculation is to convert the time-domain FDTD data into frequency-domain data using the DFT. For
example, the surface current Jy in (9.6) can be calculated as follows:


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 nished. 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.
9.2.2 Vector Potential Approach

For radiation problems, a vector potential approach is well developed to compute the unknown
far elds from the known electric and magnetic currents [32]. A pair of vector potential functions
is dened as
jkR

 = 0 e
A
N,
4 R

(9.13a)

0 e j k R 
L,
F =
4 R

(9.13b)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

278

Near-Field to Far-Field Transformation


Observation
point
Equivalent surface

( x, y , z )

( x, y, z)

r
y
z

Figure 9.7 The equivalent surface current source and far field.

where
 =
N
=
L


JS e j kr cos() dS ,

(9.14a)

S e j kr  cos() dS .
M

(9.14b)

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-eld calculation, the distance R is approximated by


r r  cos() for the phase term
2

2

R = r + (r ) 2rr cos() =
r
for the amplitude term

(9.15)

The computation of the components of E and H in the far elds can then be obtained using the
vector potentials, which are expressed as
Er = 0,

(9.16a)


E =

j ke
4r


L + 0 N ,

(9.16b)

E = +


j ke j kr 
L 0 N ,
4r

(9.16c)

j kr

Hr = 0,
H = +

j kr

j ke
4r

j ke j kr
H =
4r


N


L
0

L
N +
0

(9.16d)


,

(9.16e)

(9.16f)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Frequency Domain Near-Field to Far-Field Transformation

279

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 =

N =
L =
L =



Jx cos( )cos() + Jy cos( )sin() Jz sin( ) e j kr cos() dS ,




Jx sin() + Jy cos() e j kr cos() dS ,




Mx cos( )cos() + My cos( )sin() Mz sin( ) e j kr cos() dS ,




Mx sin() + My cos() e j kr cos() dS .

(9.17a)
(9.17b)
(9.17c)
(9.17d)

Substituting (9.17) into (9.16), the far-eld pattern can be obtained at any observation point
(r, , ).
9.2.3 Polarization of Radiation Field

The E and H elds calculated in (9.16) are linearly polarized (LP) components. In some antenna
applications such as satellite communications, it is desired to obtain circularly polarized (CP)
eld components. This can be done through unit vector transformations between LP and CP
components, such that
j
+ j
E R
E L
=
+
= + ,
2
2
2
2
+ j
E R
j
E L
=

= ,
2j
2j
j 2
j 2

(9.18a)
(9.18b)

where E R and E L are unit vectors for the right-hand circularly polarized (RHCP) eld and
left-hand circularly polarized (LHCP) eld. Substituting (9.18) into (9.16), we obtain





R
L
R
L
E
E
E
E
E = E + E = +
E
E +

2
2
j 2
j 2




E
E
E
E
+ E L +
= E R E R + E L E L ,
= E R
2
j 2
2
j 2
E
E
ER = ,
2
j 2

(9.19)

E
E
EL = + .
2
j 2

(9.20)

The magnitudes of the RHCP component (E R ) and the LHCP component (E L ) are then obtained.
The axial ratio is dened to describe the polarization purity of the propagating waves and is

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

280

Near-Field to Far-Field Transformation

calculated as follows [32]:


AR =

|E R | + |E L |
.
|E R | |E L |

(9.21)

For an LP wave, AR goes to innity. 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-eld components E and E are given in [33]

AR = 20 log10

1
2
1
2




E2

E2

E4

E4

2E2 E2

cos (2)

E2 + E2 + E4 + E4 2E2 E2 cos (2)

 12 ! 12

,
 12 ! 12

(9.22)

and in [34]

AR = 20 log10


|E |2 sin2 ( ) + |E |2 cos2 ( ) + |E ||E | cos()sin(2 )
,
|E |2 sin2 ( ) + |E |2 cos2 ( ) |E ||E | cos()sin(2 )

(9.23)

where
2 = tan


2|E ||E | cos()
,
|E |2 |E |2

and is the phase difference between E and E .


9.2.4 Radiation Efficiency

The radiation efciency is a very important indication for the effectiveness of an antenna, which
can also be obtained using the FDTD technique. First of all, the radiation power of an antenna is
obtained by applying the surface equivalence theorem to obtain
Prad =

1
Re
2

%
%

1
 ndS
 ndS
 = Re
 .
E H
J M
2
S
S

(9.24)

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
Pdel =

'
1 &
Re Vs ()Is () ,
2

(9.25)

where Vs () and Is () represent the Fourier transformed values of the source voltage and current.
The antennas radiation efciency a is then dened as [35]
a =

Prad
.
Pdel

(9.26)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

MATLAB Implementation of NF-FF Transformation

October 13, 2009

14:16

281

9.3 MATLAB IMPLEMENTATION OF NEAR-FIELD TO FAR-FIELD TRANSFORMATION

In this section we demonstrate the implementation of near-eld to far-eld transformation in the


three-dimensional FDTD MATLAB code.
9.3.1 Definition of NFFF Parameters

The implementation of the CPML boundary in the three-dimensional code is demonstrated in


Chapter 8. The availability of CPML makes it possible to simulate open boundary problems; the
electric and magnetic elds in a problem space can be calculated as if the boundaries are free space
extending to innity. Moreover, the near-eld to far-eld transformation technique described in
the previous section can be used to compute the far-eld patterns for a number of frequencies.
The desired frequencies as well as some other parameters for far-eld radiation are dened in
the denition section of the FDTD program. The denition of certain NFFF transformation
parameters is implemented in the subroutine define output parameters, partial implementation
of which is shown in Listing 9.1.
In Listing 9.1 a structure named farfield is dened with a eld frequencies, which is initialized
as an empty array. Then the frequencies for which the far-eld patterns are sought are assigned
to the array farfield.frequencies. Another variable for farfield that needs to be initialized is
number of cells from outer boundary, which indicates the position of the imaginary NFFF
transformation surface enclosing the radiators or scatterers existing in the problem space. This
imaginary surface must not coincide with any objects in the problem space or with the CPML
boundaries. Therefore, number of cells from outer boundary should be chosen such that it is
larger than the thickness of the CPML medium and less than the sum of the thicknesses of the
CPML medium and the air gap surrounding the objects as illustrated in Fig. 9.4. This parameter is
Listing 9.1 define output parameters
1

disp ( d e f i n i n g output parameters ) ;


sampled electric fields = [];
sampled magnetic fields = [ ] ;
sampled voltages = [ ] ;
sampled currents = [ ] ;
ports = [ ] ;
fa r fi e l d . frequencies = [ ] ;

11

13

15

% figure refresh rate


p l o t t i n g s t e p = 10;
% mode o f o p e r a t i o n
run simulation = true ;
show material mesh = true ;
show problem space = true ;

17

19

21

23

% 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 ) = 3 e9 ;
f a r f i e l d . f r e q u e n c i e s ( 2 ) = 5 e9 ;
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 ;
f a r f i e l d . number of cells from outer boundary = 10;

fdtd_main

SPIB005-Elsherbeni & Demir

282

October 13, 2009

Near-Field to Far-Field Transformation

Listing 9.2 fdtd solve


1

% i n i t i a l i z e the matlab workspace


clear all ; close all ; clc ;

% d e f i n e t h e problem
define problem space parameters ;
define geometry ;
define sources and lumped elements ;
define output parameters ;

11

13

15

17

19

21

% 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 ;
display problem space ;
display material mesh ;
if run simulation
initialize fdtd parameters and arrays ;
initialize sources and lumped elements ;
initialize updating coefficients ;
initialize boundary conditions ;
initialize output parameters ;
initialize farfield arrays ;
initialize display parameters ;
% FDTD t i m e m a r c h i n g l o o p
run fdtd time marching loop ;

23

25

% display simulation results


post process and display results ;

27

end

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.
9.3.2 Initialization of NFFF Parameters

A new subroutine, initialize farfield arrays, is added to the main FDTD program fdtd solve as
shown in Listing 9.2. Implementation of initialize farfield arrays is given in Listing 9.3.
The rst step in the NFFF initialization process is to determine the nodes indicating the
boundaries of the imaginary NFFF surface: (li, l j, lk) and (ui, u j, uk). Once the start and end
nodes are determined they are used to construct the NFFF auxiliary arrays. Two sets of arrays
are needed for the NFFF transformation: The rst set is used to capture and store the ctitious
electric and magnetic currents on the faces of the imaginary surface at every time step of the
FDTD time-marching loop, and the second set is used to store the on-the-y DFTs of these
currents. The naming conventions of these arrays are elaborated as follows.
There are six faces on the imaginary surface, and the ctitious electric and magnetic currents
are calculated for each face. Therefore, 12 two-dimensional arrays are needed. The names of
these arrays start with the letter t, which is followed by a letter j or m. Here j indicates the
electric current whereas m indicates the magnetic current being stored in the array. The third
character in the array name is a letter x, y, or z, which indicates the direction of the current
in consideration. The last two characters are xn, yn, zn, xp, yp, or zp indicating the face

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

MATLAB Implementation of NF-FF Transformation

283

Listing 9.3 initialize farfield arrays


2

10

12

% i n i t i a l i z e farfield arrays
number of farfield frequencies = size ( f a r f i e l d . frequencies , 2 ) ;
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 ;
end
nc farbuffer = f a r f i e l d . number of cells from outer boundary ;
l i = nc farbuffer + 1;
l j = nc farbuffer + 1;
lk = nc farbuffer + 1;
u i = nx n c f a r b u f f e r +1;
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

18

20

22

24

26

28

30

32

34

36

38

40

42

44

46

48

50

tjxyp
tjxzp
tjyxp
tjyzp
tjzxp
tjzyp
tjxyn
tjxzn
tjyxn
tjyzn
tjzxn
tjzyn
tmxyp
tmxzp
tmyxp
tmyzp
tmzxp
tmzyp
tmxyn
tmxzn
tmyxn
tmyzn
tmzxn
tmzyn

=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=

zeros (1
zeros (1
zeros (1
zeros (1
zeros (1
zeros (1
zeros (1
zeros (1
zeros (1
zeros (1
zeros (1
zeros (1
zeros (1
zeros (1
zeros (1
zeros (1
zeros (1
zeros (1
zeros (1
zeros (1
zeros (1
zeros (1
zeros (1
zeros (1

cjxyp
cjxzp
cjyxp
cjyzp
cjzxp
cjzyp
cjxyn
cjxzn
cjyxn

=
=
=
=
=
=
=
=
=

zeros
zeros
zeros
zeros
zeros
zeros
zeros
zeros
zeros

(
(
(
(
(
(
(
(
(

, u i l i , 1 , ukl k ) ;
, u i l i , uj l j , 1 ) ;
, 1 , uj l j , ukl k ) ;
, u i l i , uj l j , 1 ) ;
, 1 , uj l j , ukl k ) ;
, u i l i , 1 , ukl k ) ;
, u i l i , 1 , ukl k ) ;
, u i l i , uj l j , 1 ) ;
, 1 , uj l j , ukl k ) ;
, u i l i , uj l j , 1 ) ;
, 1 , uj l j , ukl k ) ;
, u i l i , 1 , ukl k ) ;
, u i l i , 1 , ukl k ) ;
, u i l i , uj l j , 1 ) ;
, 1 , uj l j , ukl k ) ;
, u i l i , uj l j , 1 ) ;
, 1 , uj l j , ukl k ) ;
, u i l i , 1 , ukl k ) ;
, u i l i , 1 , ukl k ) ;
, u i l i , uj l j , 1 ) ;
, 1 , uj l j , ukl k ) ;
, u i l i , uj l j , 1 ) ;
, 1 , uj l j , ukl k ) ;
, u i l i , 1 , ukl k ) ;

number
number
number
number
number
number
number
number
number

of
of
of
of
of
of
of
of
of

farfield
farfield
farfield
farfield
farfield
farfield
farfield
farfield
farfield

frequencies
frequencies
frequencies
frequencies
frequencies
frequencies
frequencies
frequencies
frequencies

, u i l i , 1 , ukl k ) ;
, u i l i , uj l j , 1 ) ;
, 1 , uj l j , ukl k ) ;
, u i l i , uj l j , 1 ) ;
, 1 , uj l j , ukl k ) ;
, u i l i , 1 , ukl k ) ;
, u i l i , 1 , ukl k ) ;
, u i l i , uj l j , 1 ) ;
, 1 , uj l j , ukl k ) ;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

284

52

54

56

58

60

62

64

cjyzn
cjzxn
cjzyn
cmxyp
cmxzp
cmyxp
cmyzp
cmzxp
cmzyp
cmxyn
cmxzn
cmyxn
cmyzn
cmzxn
cmzyn

Near-Field to Far-Field Transformation


=
=
=
=
=
=
=
=
=
=
=
=
=
=
=

zeros
zeros
zeros
zeros
zeros
zeros
zeros
zeros
zeros
zeros
zeros
zeros
zeros
zeros
zeros

(
(
(
(
(
(
(
(
(
(
(
(
(
(
(

number
number
number
number
number
number
number
number
number
number
number
number
number
number
number

of
of
of
of
of
of
of
of
of
of
of
of
of
of
of

farfield
farfield
farfield
farfield
farfield
farfield
farfield
farfield
farfield
farfield
farfield
farfield
farfield
farfield
farfield

frequencies
frequencies
frequencies
frequencies
frequencies
frequencies
frequencies
frequencies
frequencies
frequencies
frequencies
frequencies
frequencies
frequencies
frequencies

, u i l i , uj l j , 1 ) ;
, 1 , uj l j , ukl k ) ;
, u i l i , 1 , ukl k ) ;
, u i l i , 1 , ukl k ) ;
, u i l i , uj l j , 1 ) ;
, 1 , uj l j , ukl k ) ;
, u i l i , uj l j , 1 ) ;
, 1 , uj l j , ukl k ) ;
, u i l i , 1 , ukl k ) ;
, u i l i , 1 , ukl k ) ;
, u i l i , uj l j , 1 ) ;
, 1 , uj l j , ukl k ) ;
, u i l i , uj l j , 1 ) ;
, 1 , uj l j , ukl k ) ;
, u i l i , 1 , ukl k ) ;

of the imaginary surface with which the array is associated. These arrays are four-dimensional,
though they are effectively two-dimensional. The size of the rst dimension is 1; this dimension is
added to facilitate the on-the-y DFT calculations, as is illustrated later. The elds are calculated
in three-dimensional space and are stored in three-dimensional arrays. However, it is required
to capture the elds coinciding with the faces of the imaginary surface. Therefore, the sizes of
the other three dimensions of the ctitious current arrays are determined by the number of eld
components coinciding with imaginary surface faces.
The ctitious current arrays are used to calculate DFTs of these currents. Then the currents obtained in the frequency domain are stored in their respective arrays. Thus, each ctitious
current array is associated with another array in the frequency domain. Therefore, the naming
conventions of the frequency-domain arrays are the same as for the ones in time domain except
that they are preceded by a letter c. Furthermore, the sizes of the rst dimension of the frequency domain arrays is equal to the number of frequencies for which the far eld calculation is
sought.
One additional parameter dened in Listing 9.3 is farfield w. Since the far-eld frequencies
are used as angular frequencies, with the unit radians/second, during the calculations they are
calculated once and stored in farfield w for future use.
9.3.3 NFFF DFT during Time-Marching Loop

While the FDTD time-marching loop is running, the electric and magnetic elds are captured
and used to calculate ctitious magnetic and electric currents using equations (9.6)(9.11) on
the NFFF imaginary surface. A new subroutine called calculate JandM is added to run fdtd time marching loop as shown in Listing 9.4. The implementation of calculate JandM is given in
Listing 9.5.
One can notice in Listing 9.5 that an average of two electric eld components are used to
calculate the value of a ctitious magnetic current component. Here the purpose is to obtain the
values of electric eld components at the centers of the faces of the cells coinciding with the
NFFF surface. For instance, Fig. 9.8 illustrates the electric eld components E x on the yn face
of the imaginary NFFF surface. The E x components are located on the edges of the faces of cells
coinciding with the NFFF surface. To obtain an equivalent E x value at the centers of the faces
of the cells, the average of two E x components are calculated for each cell. Thus, the ctitious
magnetic current components Mz generated by the averaged E x components using (9.10b) are
located at the centers of the faces of the cells.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

MATLAB Implementation of NF-FF Transformation

14:16

285

Listing 9.4 run fdtd time marching loop


1

disp ( [ S t a r t i n g the time marching loop ] ) ;


d i s p ( [ T o t a l number o f t i m e s t e p s : . . .
num2str ( n u m b e r o f t i m e s t e p s ) ] ) ;
s t a r t t i m e = cputime ;
current time = 0;

11

13

15

17

19

21

23

25

27

for time step = 1: number of time steps


update magnetic fields ;
update magnetic field CPML ABC ;
capture sampled magnetic fields ;
capture sampled currents ;
update electric fields ;
update electric field CPML ABC ;
update voltage sources ;
update current sources ;
update inductors ;
update diodes ;
capture sampled electric fields ;
capture sampled voltages ;
calculate JandM ;
display sampled parameters ;
end
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 ;
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 . ] ) ;

Listing 9.5 calculate JandM


2

% C a l c u l a t e J and M on t h e i m a g i n a r y f a r f i l e d s u r f a c e
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 ;
end
j = sqrt ( 1);

10

12

14

tmyxp ( 1
tmzxp ( 1
tmxyp ( 1
tmzyp ( 1
tmxzp ( 1
tmyzp ( 1

,1 ,: ,:)
,1 ,: ,:)
,: ,1 ,:)
,: ,1 ,:)
,: ,: ,1)
,: ,: ,1)

= 0 . 5 * ( Ez ( ui
= 0.5*( Ey ( ui
= 0.5*( Ez ( l i
= 0 . 5 * ( Ex ( l i
= 0 . 5 * ( Ey ( l i
= 0.5*( Ex ( l i

, l j : uj 1 , l k : uk 1)+ E z ( u i , l j +1: uj , l k : uk 1 ) ) ;
, l j : uj 1 , l k : uk 1)+ E y ( u i , l j : uj 1 , l k +1: uk ) ) ;
: u i 1 , uj , l k : uk 1)+ E z ( l i +1: u i , uj , l k : uk 1 ) ) ;
: u i 1 , uj , l k : uk 1)+ E x ( l i : u i 1 , uj , l k +1: uk ) ) ;
: u i 1 , l j : uj 1 , uk )+ E y ( l i +1: u i , l j : uj 1 , uk ) ) ;
: u i 1 , l j : uj 1 , uk )+ E x ( l i : u i 1 , l j +1: uj , uk ) ) ;

t j y x p ( 1 , 1 , : , : ) = 0.25 * ( Hz ( u i , l j : uj 1 , l k : uk 1)+Hz ( u i , l j : uj 1 , l k +1: uk )


+ Hz ( u i 1 , l j : uj 1 , l k : uk 1) + Hz ( u i 1 , l j : uj 1 , l k +1: uk ) ) ;

...

16

18

t j z x p ( 1 , 1 , : , : ) = 0 . 2 5 * ( Hy ( u i , l j : uj 1 , l k : uk 1)+Hy ( u i , l j +1: uj , l k : uk 1) . . .
+ Hy ( u i 1 , l j : uj 1 , l k : uk 1) + Hy ( u i 1 , l j +1: uj , l k : uk 1 ) ) ;

20

t j z y p ( 1 , : , 1 , : ) = 0.25 * ( Hx ( l i : u i 1 , uj , l k : uk 1)+Hx ( l i +1: u i , uj , l k : uk 1) . . .

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

286

Near-Field to Far-Field Transformation

+ 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

24

26

t j x y p ( 1 , : , 1 , : ) = 0 . 2 5 * ( Hz ( l i : u i 1 , uj , l k : uk 1)+ Hz ( l i : u i 1 , uj , l k +1: uk )
+ Hz ( l i : u i 1 , uj 1 , l k : uk 1) + Hz ( l i : u i 1 , uj 1 , l k +1: uk ) ) ;

...

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 ) ) ;

...

t j x z p ( 1 , : , : , 1 ) = 0.25 * ( Hy ( l i : u i 1 , l j : uj 1 , uk )+ Hy ( l i : u i 1 , l j +1: uj , uk )
+ Hy ( l i : u i 1 , l j : uj 1 , uk 1) + Hy ( l i : u i 1 , l j +1: uj , uk 1 ) ) ;

...

28

30

32

tmyxn ( 1 , 1 , : , : ) = 0.5 * ( E z ( l i , l j : uj 1 , l k : uk 1)+ E z ( l i , l j +1: uj , l k : uk 1 ) ) ;


tmzxn ( 1 , 1 , : , : ) = 0 . 5 * ( E y ( l i , l j : uj 1 , l k : uk 1)+ E y ( l i , l j : uj 1 , l k +1: uk ) ) ;

34

36

38

tmxyn ( 1 , : , 1 , : ) = 0 . 5 * ( E z ( l i : u i 1 , l j , l k : uk 1)+ E z ( l i +1: u i , l j , l k : uk 1 ) ) ;


tmzyn ( 1 , : , 1 , : ) = 0.5 * ( E x ( l i : u i 1 , l j , l k : uk 1)+ E x ( l i : u i 1 , l j , l k +1: uk ) ) ;
tmxzn ( 1 , : , : , 1 ) = 0.5 * ( E y ( l i : u i 1 , l j : uj 1 , l k )+ E y ( l i +1: u i , l j : uj 1 , l k ) ) ;
tmyzn ( 1 , : , : , 1 ) = 0 . 5 * ( E x ( l i : u i 1 , l j : uj 1 , l k )+ E x ( l i : u i 1 , l j +1: uj , l k ) ) ;

40

42

44

t j y x n ( 1 , 1 , : , : ) = 0 . 2 5 * ( Hz ( l i , l j : uj 1 , l k : uk 1)+ Hz ( l i , l j : uj 1 , l k +1: uk )
+ Hz ( l i 1 , l j : uj 1 , l k : uk 1) + Hz ( l i 1 , l j : uj 1 , l k +1: uk ) ) ;

...

t j z x n ( 1 , 1 , : , : ) = 0.25 * ( Hy ( l i , l j : uj 1 , l k : uk 1)+Hy ( l i , l j +1: uj , l k : uk 1) . . .


+ Hy ( l i 1 , l j : uj 1 , l k : uk 1) + Hy ( l i 1 , l j +1: uj , l k : uk 1 ) ) ;

46

48

50

t j z y n ( 1 , : , 1 , : ) = 0 . 2 5 * ( Hx ( l i : u i 1 , l j , l k : uk 1)+Hx ( l i +1: u i , l j , l k : uk 1) . . .
+ Hx ( l i : u i 1 , l j 1 , l k : uk 1) + Hx ( l i +1: u i , l j 1 , l k : uk 1 ) ) ;
t j x y n ( 1 , : , 1 , : ) = 0.25 * ( Hz ( l i : u i 1 , l j , l k : uk 1)+ Hz ( l i : u i 1 , l j , l k +1: uk )
+ Hz ( l i : u i 1 , l j 1 , l k : uk 1) + Hz ( l i : u i 1 , l j 1 , l k +1: uk ) ) ;

...

t j y z n ( 1 , : , : , 1 ) = 0.25 * ( Hx ( l i : u i 1 , l j : uj 1 , l k )+ Hx ( l i +1: u i , l j : uj 1 , l k )
+ Hx ( l i : u i 1 , l j : uj 1 , l k 1)+Hx ( l i +1: u i , l j : uj 1 , l k 1 ) ) ;

...

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 ) ) ;

...

52

54

56

58

60

62

64

66

% fourier transform
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 ) * (
c j x y p ( mi , : , : , : ) = c j x y p ( mi , : , : , : ) +
c j x z p ( mi , : , : , : ) = c j x z p ( mi , : , : , : ) +
c j y x p ( mi , : , : , : ) = c j y x p ( mi , : , : , : ) +
c j y z p ( mi , : , : , : ) = c j y z p ( mi , : , : , : ) +
c j z x p ( mi , : , : , : ) = c j z x p ( mi , : , : , : ) +
c j z y p ( mi , : , : , : ) = c j z y p ( mi , : , : , : ) +

time step 0.5)* dt ) ;


exp h * t j x y p ( 1 , : , :
exp h * t j x z p ( 1 , : , :
exp h * t j y x p ( 1 , : , :
exp h * t j y z p ( 1 , : , :
exp h * t j z x p ( 1 , : , :
exp h * t j z y p ( 1 , : , :

,:);
,:);
,:);
,:);
,:);
,:);

exp
exp
exp
exp

,:);
,:);
,:);
,:);

68

70

72

cjxyn
cjxzn
cjyxn
cjyzn

( mi , :
( mi , :
( mi , :
( mi , :

,:
,:
,:
,:

,:)
,:)
,:)
,:)

=
=
=
=

cjxyn
cjxzn
cjyxn
cjyzn

( mi , :
( mi , :
( mi , :
( mi , :

,:
,:
,:
,:

,:)
,:)
,:)
,:)

+
+
+
+

h
h
h
h

*
*
*
*

tjxyn
tjxzn
tjyxn
tjyzn

(1
(1
(1
(1

,:
,:
,:
,:

,:
,:
,:
,:

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

MATLAB Implementation of NF-FF Transformation

287

74

c j z x n ( mi , : , : , : ) = c j z x n ( mi , : , : , : ) + e x p h * t j z x n ( 1 , : , : , : ) ;
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 ) ;

78

80

82

14:16

cmxyp ( mi , :
cmxzp ( mi , :
cmyxp ( mi , :
cmyzp ( mi , :
cmzxp ( mi , :
cmzyp ( mi , :

,:
,:
,:
,:
,:
,:

,:)
,:)
,:)
,:)
,:)
,:)

=
=
=
=
=
=

cmxyp ( mi , :
cmxzp ( mi , :
cmyxp ( mi , :
cmyzp ( mi , :
cmzxp ( mi , :
cmzyp ( mi , :

,:
,:
,:
,:
,:
,:

,:)
,:)
,:)
,:)
,:)
,:)

+
+
+
+
+
+

exp
exp
exp
exp
exp
exp

e
e
e
e
e
e

*
*
*
*
*
*

tmxyp
tmxzp
tmyxp
tmyzp
tmzxp
tmzyp

(1
(1
(1
(1
(1
(1

,:
,:
,:
,:
,:
,:

,:
,:
,:
,:
,:
,:

,:);
,:);
,:);
,:);
,:);
,:);

cmxyn ( mi , :
cmxzn ( mi , :
cmyxn ( mi , :
cmyzn ( mi , :
cmzxn ( mi , :
cmzyn ( mi , :

,:
,:
,:
,:
,:
,:

,:)
,:)
,:)
,:)
,:)
,:)

=
=
=
=
=
=

cmxyn ( mi , :
cmxzn ( mi , :
cmyxn ( mi , :
cmyzn ( mi , :
cmzxn ( mi , :
cmzyn ( mi , :

,:
,:
,:
,:
,:
,:

,:)
,:)
,:)
,:)
,:)
,:)

+
+
+
+
+
+

exp
exp
exp
exp
exp
exp

e
e
e
e
e
e

*
*
*
*
*
*

tmxyn
tmxzn
tmyxn
tmyzn
tmzxn
tmzyn

(1
(1
(1
(1
(1
(1

,:
,:
,:
,:
,:
,:

,:
,:
,:
,:
,:
,:

,:);
,:);
,:);
,:);
,:);
,:);

84

86

88

90

end

Similarly, every ctitious electric current component is calculated at the centers of the faces
of the cells by averaging four magnetic eld components. For example, Fig. 9.9 illustrates the
magnetic eld components Hx around the yn face of the imaginary NFFF surface. The Hx
components are located at the centers of the faces of cells, which are not coinciding with the
NFFF 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 ctitious 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 NFFF imaginary surface and the magnetic currents
generated by them.

fdtd_main

SPIB005-Elsherbeni & Demir

288

October 13, 2009

Near-Field to Far-Field Transformation

Figure 9.9 H x field components around the yn face of the NFFF imaginary surface and the electric currents
generated by them.

After the ctitious electric and magnetic currents are sampled on the NFFF surface at the
current time step, they are used to update the on-the-y DFTs for the far-eld frequencies dened
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.
9.3.4 Postprocessing for Far-Field Calculation

As the FDTD time-marching loop is completed, the frequency-domain values of ctitious currents
for the far-eld frequencies over the NFFF surface are available. Then they can be used at the
postprocessing stage of the FDTD simulation to calculate the far-eld auxiliary elds based on
(9.17). Then these elds can be used to calculate the desired far-eld patterns and to plot them.
A new subroutine named calculate and display farfields is added to the postprocessing routine
post process and display results as shown in Listing 9.6, which performs the tasks of far-eld
calculation and display.
Implementation of calculate and display farfields is given in Listing 9.7. This subroutine
initializes necessary arrays and parameters for calculation and display of far-eld patterns at three
principal planes: namely, the xy, xz, and y z planes. For instance, to calculate the far-elds in
the xy plane, two arrays, farfield theta and farfield phi, are constructed to store the angles that
represent the xy plane. For the xy plane is 90 and sweeps from 180 to 180 . Then a
Listing 9.6 post process and display results
1

d i s p ( p o s t p r o c e s s i n g and d i s p l a y i n g s i m u l a t i o n r e s u l t s ) ;
display transient parameters ;
calculate frequency domain outputs ;
display frequency domain outputs ;
calculate and display farfields ;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

MATLAB Implementation of NF-FF Transformation

Listing 9.7 calculate and display farfields


2

%
%
%
%
%

This f i l e c a l l s the r o u t i n e s necessary f o r c a l c u l a t i n g


f a r f i e l d p a t t e r n s i n xy , xz , and y z p l a n e c u t s , and d i s p l a y s them .
The d i s p l a y can be m o d i f i e d a s d e s i r e d .
You w i l l f i n d t h e i n s t r u c t i o n s t h e f o r m a t s f o r
r a d i a t i o n p a t t e r n p l o t s can be s e t by t h e u s e r .

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 ;
end

10

calculate radiated power ;


12

14

16

18

20

22

24

26

28

30

32

j = sqrt ( 1);
number of angles = 360;
% 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
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
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
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
% xy plane
% ===============================================
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 ) ;
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 ] . ;
c o n s t t h e t a = 90; % used f o r p l o t
% calculate farfields
calculate farfields per plane ;

34

36

38

% 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
f = figure ;
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

42

% 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 ) ;
p a t 2 = 10 * l o g 1 0 ( p a t 2 ) ;

44

46

48

50

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 ) ;
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 ] ;
l e g e n d s t r 2 = [ p l o t t y p e {\ p h i } , f = . . .

289

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

290

October 13, 2009

Near-Field to Far-Field Transformation


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 ] ;

52

54

56

58

60

62

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 , . . .
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 ) ;
end

...

% xz plane
% ===============================================
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 ) ;
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

66

68

70

72

74

76

78

% calculate farfields
calculate farfields per plane ;
% 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
f = figure ;
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 , : ) . ;
% 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 ) ;
p a t 2 = 10 * l o g 1 0 ( p a t 2 ) ;
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

82

84

86

88

90

legend str1 = . . .
[ 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 ] ;
legend str2 = . . .
[ p l o t t y p e {\ p h i } , 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 ] ;
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 , . . .
legend str1 , legend str2 , scale type ) ;
end

92

94

96

98

% yz plane
% ===============================================
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 ) ;
f a r f i e l d p h i = f a r f i e l d p h i + pi / 2 ;
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

102

% calculate farfields
calculate farfields per plane ;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

MATLAB Implementation of NF-FF Transformation

104

106

108

110

112

14:16

291

% 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
f = figure ;
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 , : ) . ;
% 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 ) ;
p a t 2 = 10 * l o g 1 0 ( p a t 2 ) ;
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 ) ;

114

116

legend str1 = . . .
[ 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 ] ;
legend str2 = . . .
[ p l o t t y p e {\ p h i } , 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 ] ;

118

120

122

124

126

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 , . . .
legend str1 , legend str2 , scale type ) ;
end

function calculate farfields per plane is called to calculate far-eld 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-eld to far-eld 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-eld data, the auxiliary elds 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
ctitious currents, which have already been calculated at the center points of the faces of the cells
coinciding with the NFFF surface for the given far-eld frequencies. The parameter k is the
wavenumber expressed by
k = 2 f

0 0 ,

(9.27)

where f is the far-eld frequency under consideration. Yet another term in (9.17) is r  cos(),
which needs to be further dened explicitly. As shown in Fig. 9.7, r is the position vector

fdtd_main

SPIB005-Elsherbeni & Demir

292

October 13, 2009

Near-Field to Far-Field Transformation

Listing 9.8 calculate radiated power


1

% C a l c u l a t e t o t a l r a d i a t e d power
radiated power = zeros ( number of farfield frequencies , 1 ) ;

11

13

15

17

19

21

23

25

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
powr = 0 ;
powr = dx * dy * sum ( sum ( sum ( cmyzp ( mi , : , : , : ) . *
c o n j ( c j x z p ( mi , : , : , : ) ) cmxzp ( mi , : , : , : )
. * c o n j ( c j y z p ( mi , : , : , : ) ) ) ) ) ;
powr = powr dx * dy * sum ( sum ( sum ( cmyzn ( mi , :
. * c o n j ( c j x z n ( mi , : , : , : ) ) cmxzn ( mi , : , :
. * c o n j ( c j y z n ( mi , : , : , : ) ) ) ) ) ;
powr = powr + dx * dz * sum ( sum ( sum ( cmxyp ( mi , :
. * c o n j ( c j z y p ( mi , : , : , : ) ) cmzyp ( mi , : , :
. * c o n j ( c j x y p ( mi , : , : , : ) ) ) ) ) ;
powr = powr dx * dz * sum ( sum ( sum ( cmxyn ( mi , :
. * c o n j ( c j z y n ( mi , : , : , : ) ) cmzyn ( mi , : , :
. * c o n j ( c j x y n ( mi , : , : , : ) ) ) ) ) ;
powr = powr + dy * dz * sum ( sum ( sum ( cmzxp ( mi , :
. * c o n j ( c j y x p ( mi , : , : , : ) ) cmyxp ( mi , : , :
. * c o n j ( c j z x p ( mi , : , : , : ) ) ) ) ) ;
powr = powr dy * dz * sum ( sum ( sum ( cmzxn ( mi , :
. * c o n j ( c j y x n ( mi , : , : , : ) ) cmyxn ( mi , : , :
. * 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 ) ;
end

...
...
,: ,:) ...
,:) ...
,: ,:) ...
,:) ...
,: ,:) ...
,:) ...
,: ,:) ...
,:) ...
,: ,:) ...
,:) ...

Listing 9.9 calculate farfields per plane


1

11

13

15

17

19

21

23

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 ;
end
c
= 2 . 9 9 7 9 2 4 5 8 e +8;
% speed of l i g h t in f r e e space
mu 0 = 4 * p i * 1e 7;
% permeability of f r e e space
e p s 0 = 1 . 0 / ( c * c * mu 0 ) ;
% p e r m i t t i v i t y of f r e e space
e t a 0 = s q r t ( mu 0 / e p s 0 ) ;
% i n t r i n s i c impedance o f f r e e s p a c e
e x p j k r p r = zeros ( number of angles , 1 ) ;
d x s i n t h c o s p h i = zeros ( number of angles , 1 ) ;
d y s i n t h s i n p h i = zeros ( number of angles , 1 ) ;
dz costh = zeros ( number of angles , 1 ) ;
d y d z c o s t h s i n p h i = zeros ( number of angles , 1 ) ;
d y d z s i n t h = zeros ( number of angles , 1 ) ;
dy dz cosphi = zeros ( number of angles , 1 ) ;
dx dz costh cosphi = zeros ( number of angles , 1 ) ;
d x d z s i n t h = zeros ( number of angles , 1 ) ;
dx dz sinphi = zeros ( number of angles , 1 ) ;
dx dy costh cosphi = zeros ( number of angles , 1 ) ;
d x d y c o s t h s i n p h i = zeros ( number of angles , 1 ) ;
dx dy sinphi = zeros ( number of angles , 1 ) ;
dx dy cosphi = zeros ( number of angles , 1 ) ;
farfield dirTheta = . . .

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

MATLAB Implementation of NF-FF Transformation

25

27

zeros ( number
farfield dir = ...
zeros ( number
farfield dirPhi =
zeros ( number

293

of farfield frequencies , number of angles ) ;


of farfield frequencies , number of angles ) ;
...
of farfield frequencies , number of angles ) ;

29

31

33

35

37

39

41

43

45

47

49

51

53

55

57

59

61

63

65

67

69

71

73

75

dx
dy
dz
dy
dy
dy
dx
dx
dx
dx
dx
dx
dx
ci
cj
ck

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 ) ;
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 ) ;
c o s t h = dz * c o s ( f a r f i e l d t h e t a ) ;
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
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 ) ;
d z c o s p h i = dy * dz * c o s ( f a r f i e l d p h i ) ;
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
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 ) ;
d z s i n p h i = dx * dz * s i n ( f a r f i e l d p h i ) ;
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
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
d y s i n p h i = dx * dy * s i n ( f a r f i e l d p h i ) ;
d y c o s p h i = dx * dy * c o s ( f a r f i e l d p h i ) ;
= 0 . 5 * ( u i+ l i ) ;
= 0 . 5 * ( u j+ l j ) ;
= 0 . 5 * ( uk+ l k ) ;

phi );

phi );

phi );
phi );

% 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
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 ] ) ;
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 ;
Ntheta = zeros ( number of angles , 1 ) ;
Ltheta = zeros ( number of angles , 1 ) ;
Nphi = z e r o s ( n u m b e r o f a n g l e s , 1 ) ;
Lphi = zeros ( number of angles , 1 ) ;
rpr = zeros ( number of angles , 1 ) ;
f o r n j = l j : uj 1
f o r nk = l k : uk1
% f o r +ax d i r e c t i o n
rpr = ( ui c i )* dx sinth cosphi . . .
+ ( nj c j + 0 . 5 ) * d y s i n t h s i n p h i . . .
+ ( nkc k + 0 . 5 ) * d z c o s t h ;
e x p j k r p r = exp ( j * k * r p r ) ;
Ntheta = Ntheta . . .
+ ( c j y x p ( mi , 1 , nj l j +1 , nkl k + 1 ) . * d y d z c o s t h s i n p h i . . .
c j z x p ( mi , 1 , nj l j +1 , nkl k + 1 ) . * d y d z s i n t h ) . * e x p j k r p r ;
Ltheta = Ltheta . . .
+ ( cmyxp ( mi , 1 , nj l j +1 , nkl k + 1 ) . * d y d z c o s t h s i n p h i . . .
cmzxp ( mi , 1 , nj l j +1 , nkl k + 1 ) . * d y d z s i n t h ) . * e x p j k r p r ;
Nphi = Nphi . . .
+ ( c j y x p ( mi , 1 , nj l j +1 , nkl k + 1 ) . * d y d z c o s p h i ) . * e x p j k r p r ;
Lphi = Lphi . . .

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

294

Near-Field to Far-Field Transformation


+ ( cmyxp ( mi , 1 , nj l j +1 , nkl k + 1 ) . * d y d z c o s p h i ) . * e x p j k r p r ;

77

79

81

83

85

87

89

91

93

95

97

99

101

% f o r ax d i r e c t i o n
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 . . .
+ ( nkc k + 0 . 5 ) * d z c o s t h ;
e x p j k r p r = exp ( j * k * r p r ) ;
Ntheta = Ntheta . . .
+ ( c j y x n ( mi , 1 , nj l j +1 , nkl k + 1 ) . * d y d z c o s t h s i n p h i . . .
c j z x n ( mi , 1 , nj l j +1 , nkl k + 1 ) . * d y d z s i n t h ) . * e x p j k r p r ;
Ltheta = Ltheta . . .
+ ( cmyxn ( mi , 1 , nj l j +1 , nkl k + 1 ) . * d y d z c o s t h s i n p h i . . .
cmzxn ( mi , 1 , nj l j +1 , nkl k + 1 ) . * d y d z s i n t h ) . * e x p j k r p r ;
Nphi = Nphi . . .
+ ( c j y x n ( mi , 1 , nj l j +1 , nkl k + 1 ) . * d y d z c o s p h i ) . * e x p j k r p r ;
Lphi = Lphi . . .
+ ( cmyxn ( mi , 1 , nj l j +1 , nkl k + 1 ) . * d y d z c o s p h i ) . * e x p j k r p r ;
end
end
f o r n i = l i : u i 1
f o r nk = l k : uk1
% f o r +ay d i r e c t i o n
rpr = ( ni c i + 0 . 5 ) * dx sinth cosphi
+ ( uj c j ) * d y s i n t h s i n p h i . . .
+ ( nkc k + 0 . 5 ) * d z c o s t h ;
e x p j k r p r = exp ( j * k * r p r ) ;

...

103

105

107

109

111

113

115

117

119

121

123

125

127

Ntheta = Ntheta . . .
+ ( c j x y p ( mi , ni l i + 1 , 1 , nkl 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 , nkl k + 1 ) . * d x d z s i n t h ) . * e x p j k r p r ;
Ltheta = Ltheta . . .
+ ( cmxyp ( mi , ni l i + 1 , 1 , nkl k + 1 ) . * d x d z c o s t h c o s p h i . . .
cmzyp ( mi , ni l i + 1 , 1 , nkl k + 1 ) . * d x d z s i n t h ) . * e x p j k r p r ;
Nphi = Nphi . . .
+ ( c j x y p ( mi , ni l i + 1 , 1 , nkl k + 1 ) . * d x d z s i n p h i ) . * e x p j k r p r ;
Lphi = Lphi . . .
+ ( cmxyp ( mi , ni l i + 1 , 1 , nkl k + 1 ) . * d x d z s i n p h i ) . * e x p j k r p r ;
% f o r ay d i r e c t i o n
rpr = ( ni c i + 0 . 5 ) * dx sinth cosphi
+ ( l j c j ) * d y s i n t h s i n p h i . . .
+ ( nkc k + 0 . 5 ) * d z c o s t h ;
e x p j k r p r = exp ( j * k * r p r ) ;

...

Ntheta = Ntheta . . .
+ ( c j x y n ( mi , ni l i + 1 , 1 , nkl k + 1 ) . * d x d z c o s t h c o s p h i
c j z y n ( mi , ni l i + 1 , 1 , nkl k + 1 ) . * d x d z s i n t h ) . * e x p j k
Ltheta = Ltheta . . .
+ ( cmxyn ( mi , ni l i + 1 , 1 , nkl k + 1 ) . * d x d z c o s t h c o s p h i
cmzyn ( mi , ni l i + 1 , 1 , nkl k + 1 ) . * d x d z s i n t h ) . * e x p j k
Nphi = Nphi . . .

...
rpr ;
...
rpr ;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

MATLAB Implementation of NF-FF Transformation

295

+ ( c j x y n ( mi , ni l i + 1 , 1 , nkl k + 1 ) . * d x d z s i n p h i ) . * e x p j k r p r ;
Lphi = Lphi . . .
+ ( cmxyn ( mi , ni l i + 1 , 1 , nkl k + 1 ) . * d x d z s i n p h i ) . * e x p j k r p r ;
end

129

131

end
133

135

f o r n i = l i : u i 1
f o r n j = l j : uj 1
% f o r +a z d i r e c t i o n

137

139

141

143

145

147

149

151

153

155

r p r = ( ni c i + 0 . 5 ) * d x s i n t h c o s p h i . . .
+ ( nj c j + 0 . 5 ) * d y s i n t h s i n p h i
+ ( ukc k ) * d z c o s t h ;
e x p j k r p r = exp ( j * k * r p r ) ;

...

Ntheta = Ntheta . . .
+ ( c j x z p ( mi , ni l i +1 , nj l j + 1 , 1 ) . * d x d y c o s t h c o s p h i . . .
+ c j y z p ( mi , ni l i +1 , nj l j + 1 , 1 ) . * d x d y c o s t h s i n p h i ) . . .
.* exp jk rpr ;
Ltheta = Ltheta . . .
+ ( cmxzp ( mi , ni l i +1 , nj l j + 1 , 1 ) . * d x d y c o s t h c o s p h i . . .
+ cmyzp ( mi , ni l i +1 , nj l j + 1 , 1 ) . * d x d y c o s t h s i n p h i ) . . .
.* exp jk rpr ;
Nphi = Nphi + ( c j x z p ( mi , ni l i +1 , nj l j + 1 , 1 ) . . .
. * d x d y s i n p h i + c j y z p ( mi , ni l i +1 , nj l j + 1 , 1 ) . * d x d y c o s p h i ) . . .
.* exp jk rpr ;
L p h i = L p h i + ( cmxzp ( mi , ni l i +1 , nj l j + 1 , 1 ) . . .
. * d x d y s i n p h i +cmyzp ( mi , ni l i +1 , nj l j + 1 , 1 ) . * d x d y c o s p h i ) . . .
.* exp jk rpr ;

157

% f o r a z d i r e c t i o n
159

161

163

165

167

169

171

173

175

177

179

r p r = ( ni c i + 0 . 5 ) * d x s i n t h c o s p h i . . .
+ ( 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 ;
e x p j k r p r = exp ( j * k * r p r ) ;

...

Ntheta = Ntheta . . .
+ ( c j x z n ( mi , ni l i +1 , nj l j + 1 , 1 ) . * d x d y c o s t h c o s p h i . . .
+ c j y z n ( mi , ni l i +1 , nj l j + 1 , 1 ) . * d x d y c o s t h s i n p h i ) . . .
.* exp jk rpr ;
Ltheta = Ltheta . . .
+ ( cmxzn ( mi , ni l i +1 , nj l j + 1 , 1 ) . * d x d y c o s t h c o s p h i . . .
+ cmyzn ( mi , ni l i +1 , nj l j + 1 , 1 ) . * d x d y c o s t h s i n p h i ) . . .
.* exp jk rpr ;
Nphi = Nphi + ( c j x z n ( mi , ni l i +1 , nj l j + 1 , 1 ) . . .
. * d x d y s i n p h i + c j y z n ( mi , ni l i +1 , nj l j + 1 , 1 ) . * d x d y c o s p h i ) . . .
.* exp jk rpr ;
L p h i = L p h i + ( cmxzn ( mi , ni l i +1 , nj l j + 1 , 1 ) . . .
. * d x d y s i n p h i +cmyzn ( mi , ni l i +1 , nj l j + 1 , 1 ) . * d x d y c o s p h i ) . . .
.* exp jk rpr ;
end

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

296

Near-Field to Far-Field Transformation


end
% 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 ) ) )
. * ( 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 ) ) )
. * ( abs ( L t h e t a e t a 0 * Nphi ) . 2 ) ;

181

183

185

...
...

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
r = sin( ) cos()x + sin( )sin() y + cos( )z.

(9.28)

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 NFFF surface can be expressed as
r  = (mi + 0.5 c i)x x + (mj + 0.5 c j )y y + (lk c k)zz,

(9.29)

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-eld 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
r  cos() = r  r = (mi + 0.5 c i)xsin( ) cos()
+ (mj + 0.5 c j )ysin( )sin() + (lk c k)z cos( ).

Figure 9.10 Position vectors for sources on the zn and zp faces.

(9.30)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

MATLAB Implementation of NF-FF Transformation

297

Similarly, r  cos() can be obtained for the zp face as


r  cos() = r  r = (mi + 0.5 c i)xsin( ) cos()
+ (mj + 0.5 c j )ysin( )sin() + (uk c k)z cos( ).

(9.31)

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
N =

j 1
ui1
 u




xy Jx cos( ) cos() + Jy cos( )sin() e j kr cos() ,

(9.32a)




xy Jx sin() + Jy cos() e j kr cos() ,

(9.32b)




xy Mx cos( ) cos() + My cos( )sin() e j kr cos() ,

(9.32c)




xy Mx sin() + My cos() e j kr cos() .

(9.32d)

mi=li mj =l j

N =

j 1
ui1
 u
mi=li mj =l j

L =

j 1
ui1
 u
mi=li mj =l j

L =

j 1
ui1
 u
mi=li mj =l j

Referring to Fig. 9.11 one can obtain r  cos() for the xn and xp faces, respectively, as
r  cos() = r  r = (li c i)xsin( ) cos()
+ (mj + 0.5 c j )ysin( )sin() + (mk + 0.5 c k)z cos( ),

Figure 9.11 Position vectors for sources on the x n and x p faces.

(9.33)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

298

Near-Field to Far-Field Transformation

Figure 9.12 Position vectors for sources on the yn and yp faces.

r  cos() = r  r = (ui c i)xsin( ) cos()


+ (mj + 0.5 c j )ysin( )sin() + (mk + 0.5 c k)z cos( ),

(9.34)

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
N =

u j 1 uk1
 




yz Jy cos( )sin() Jz sin( ) e j kr cos() ,

(9.35a)




yz Jy cos() e j kr cos() ,

(9.35b)




yz My cos( )sin() Mz sin( ) e j kr cos() ,

(9.35c)




yz My cos() e j kr cos() .

(9.35d)

mj =l j mk=lk

N =

u j 1 uk1
 
mj =l j mk=lk

L =

u j 1 uk1
 
mj =l j mk=lk

L =

u j 1 uk1
 
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
r  cos() = (mi + 0.5 c i)r  r = xsin( ) cos()
+ (l j c j )ysin( )sin() + (mk + 0.5 c k)z cos( ),

(9.36)

r  cos() = (mi + 0.5 c i)r  r = xsin( ) cos()


+ (u j c j )ysin( )sin() + (mk + 0.5 c k)z cos( ).

(9.37)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation Examples

299

Then the summations in (9.32) are expressed in terms of these indices mi and mk as
N =

ui1
 uk1


xz (Jx cos( ) cos() Jz sin( )) e j kr

cos()

(9.38a)

mi=li mk=lk

N =

ui1
 uk1


xz (Jx sin()) e j kr

cos()

(9.38b)

mi=li mk=lk

L =

ui1
 uk1


xz (Mx cos( ) cos() Mz sin( )) e j kr

cos()

(9.38c)

mi=li mk=lk

L =

ui1
 uk1


xz (Mx sin()) e j kr

cos()

(9.38d)

mi=li mk=lk

The implementation of the discrete summation just described can be followed in


Listing 9.9.
Finally, having obtained the auxiliary elds N , N , L , and L and the total radiated power,
the far-eld directivity data are calculated based on [1] as
D =

k2
|L + 0 N |2 ,
8 0 Prad

(9.39a)

D =

k2
|L 0 N |2 .
8 0 Prad

(9.39b)

9.4 SIMULATION EXAMPLES

In the previous sections we discussed the NFFF transformation algorithm and demonstrated its
implementation in MATLAB programs. In this section we provide examples of antennas and their
simulation results including the radiation patterns.
9.4.1 Inverted-F Antenna

In this section an inverted-F antenna is discussed, and its FDTD simulation results are presented
and compared with the published results in [36]. The antenna layout and dimensions are shown
in Fig. 9.13; the dimensions are slightly modied compared with the ones in [36] to have the
conductor patches snapped to a 0.4 mm 0.4 mm grid in the y z plane. The antenna substrate is
0.787 mm thick and has 2.2 dielectric constant.
The FDTD problem space is composed of cells with x = 0.262 mm, y = 0.4 mm, and
z = 0.4 mm. The boundaries are terminated by an 8 cells thickness convolutional perfectly
matched layer (CPML) and a 10 cells air gap is left between the objects in the problem space and
the CPML boundaries. The denition of the cell sizes, material types, and CPML parameters
are illustrated in Listing 9.10, and the denition of the geometry is given in Listing 9.11. The
antenna is excited using a voltage source, and a sampled voltage and a sampled current are dened
on and around the voltage source to form an input port. The denitions of the source as well as
the outputs are shown in Listings 9.12 and 9.13, respectively. One can notice in Listing 9.13 that

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

300

Near-Field to Far-Field Transformation

Dimensions are in mm.


Substrate thickness = 0.787 mm.
Strip widths = 2.4 mm.
40
40

12

24

.4

r = 2.2

16.4

5.
2
7.6

x
16

y
z

ground
13.6

voltage source

Figure 9.13 An inverted-F antenna.

the denition of the NFFF transformation is part of the define outputs parameters routine. In
this example the far-eld frequencies are 2.4 GHz and 5.8 GHz. One additional parameter for the
NFFF transform is the number of cells from outer boundary. The value of this parameter is
13, which means that the imaginary NFFF surface is 13 cells away from the outer boundaries,
thus 5 cells away from the CPML interface and residing in the air gap region.
Listing 9.10 define problem space parameters.m

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 ) ;
2

10

% maximum number o f t i m e s t e p s t o run FDTD s i m u l a t i o n


number of time steps = 7000;
% 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
courant factor = 0.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
number of cells per wavelength = 20;

12

14

16

18

% 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 = 0 . 2 6 2 e 3;
dy = 0 . 4 e 3;
dz = 0 . 4 e 3;
% ==<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

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

Simulation Examples
20

22

%
%
%
%

October 13, 2009

14:16

301

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
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

26

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 = 10;
boundary . c p m l n u m b e r o f c e l l s x n = 8 ;

28

30

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 = 10;
boundary . c p m l n u m b e r o f c e l l s x p = 8 ;

32

34

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 = 10;
boundary . c p m l n u m b e r o f c e l l s y n = 8 ;

36

38

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 = 10;
boundary . c p m l n u m b e r o f c e l l s y p = 8 ;

40

42

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 = 10;
boundary . c p m l n u m b e r o f c e l l s z n = 8 ;

44

46

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 = 10;
boundary . c p m l n u m b e r o f c e l l s z p = 8 ;

48

50

52

boundary . cpml
boundary . c p m l
boundary . cpml
boundary . cpml
boundary . cpml

order = 3;
sigma factor = 1.3;
kappa max = 7 ;
alpha min = 0;
alpha max = 0 . 0 5 ;

68

70

72

74

83

85

87

% 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;
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 ;
m a t e r i a l t y p e s ( 2 ) . sigma m = 0 ;
material types ( 2 ) . color
= [1 0 0];
% substrate
material types
material types
material types
material types
material types

(4).
(4).
(4).
(4).
(4).

eps r
= 2.2;
mu r
= 1;
sigma e = 0;
sigma m = 0 ;
color
= [0 0 1];

fdtd_main

SPIB005-Elsherbeni & Demir

302

Near-Field to Far-Field Transformation

Listing 9.11 define geometry.m


d i s p ( d e f i n i n g t h e problem g e o m e t r y ) ;
2

10

12

bricks = [ ] ;
spheres = [ ] ;
% define substrate
b r i c k s ( 1 ) . m i n x = 0.787 e 3;
b r i c k s ( 1 ) . mi n y = 0 ;
b r i c k s ( 1 ) . min z = 0 ;
b r i c k s ( 1 ) . max x = 0 ;
b r i c k s ( 1 ) . max y = 40 e 3;
b r i c k s ( 1 ) . max z = 40 e 3;
bricks ( 1 ) . material type = 4;

14

16

18

20

bricks
bricks
bricks
bricks
bricks
bricks
bricks

(2).
(2).
(2).
(2).
(2).
(2).
(2).

min x = 0 ;
mi n y = 0 ;
m i n z = 24 e 3;
max x = 0 ;
max y = 2 8 . 4 e 3;
max z = 2 6 . 4 e 3;
material type = 2;

bricks
bricks
bricks
bricks
bricks
bricks
bricks

(3).
(3).
(3).
(3).
(3).
(3).
(3).

min x = 0 ;
mi n y = 16 e 3;
m i n z = 30 e 3;
max x = 0 ;
max y = 2 8 . 4 e 3;
max z = 3 2 . 4 e 3;
material type = 2;

bricks
bricks
bricks
bricks
bricks
bricks
bricks

(4).
(4).
(4).
(4).
(4).
(4).
(4).

min x = 0 ;
mi n y = 26 e 3;
m i n z = 8 . 4 e 3;
max x = 0 ;
max y = 2 8 . 4 e 3;
max z = 3 2 . 4 e 3;
material type = 2;

bricks
bricks
bricks
bricks
bricks
bricks
bricks

(5).
(5).
(5).
(5).
(5).
(5).
(5).

min x = 0 ;
mi n y = 2 0 . 8 e 3;
m i n z = 16 e 3;
max x = 0 ;
max y = 2 3 . 2 e 3;
max z = 3 2 . 4 e 3;
material type = 2;

bricks
bricks
bricks
bricks

(6).
(6).
(6).
(6).

min
mi n
min
max

22

24

26

28

30

32

34

36

38

40

42

44

46

48

50

October 13, 2009

x
y
z
x

=
=
=
=

0.787 e 3;
16 e 3;
30 e 3;
0;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

Simulation Examples

52

October 13, 2009

14:16

303

b r i c k s ( 6 ) . max y = 16 e 3;
b r i c k s ( 6 ) . max z = 3 2 . 4 e 3;
bricks ( 6 ) . material type = 2;

54

56

58

60

bricks
bricks
bricks
bricks
bricks
bricks
bricks

(7).
(7).
(7).
(7).
(7).
(7).
(7).

m i n x = 0.787 e 3;
mi n y = 0 ;
min z = 0 ;
max x = 0.787 e 3;
max y = 16 e 3;
max z = 40 e 3;
material type = 2;

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].
Listing 9.12 define sources and lumped elements.m

1

d i s p ( d e f i n i n g s o u r c e s and lumped e l e m e n t components ) ;


voltage sources = [ ] ;
current sources = [ ] ;
diodes = [ ] ;
resistors = [];
inductors = [ ] ;
capacitors = [ ] ;

11

% 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 ;
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

15

17

19

21

23

25

27

% voltage sources
% 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
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 ;
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 ;
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;
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;
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 ;
v o l t a g e s o u r c e s ( 1 ) . waveform index = 1;

fdtd_main

SPIB005-Elsherbeni & Demir

304

October 13, 2009

Near-Field to Far-Field Transformation

Listing 9.13 define output parameters.m


1

disp ( d e f i n i n g output parameters ) ;


sampled electric fields = [];
sampled magnetic fields = [ ] ;
sampled voltages = [ ] ;
sampled currents = [ ] ;
ports = [ ] ;
fa r fi e ld . frequencies = [ ] ;

11

13

15

% figure refresh rate


p l o t t i n g s t e p = 100;
% mode o f o p e r a t i o n
run simulation = true ;
show material mesh = true ;
show problem space = true ;

17

19

21

23

25

% 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 ) = 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 ;
f a r f i e l d . number of cells from outer boundary = 13;
% 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 ;
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

29

31

33

35

% define
sampled
sampled
sampled
sampled
sampled
sampled
sampled
sampled

sampled
voltages
voltages
voltages
voltages
voltages
voltages
voltages
voltages

voltages
( 1 ) . m i n x = 0.787 e 3;
( 1 ) . min y = 0 ;
( 1 ) . m i n z = 2 4 . 4 e 3;
( 1 ) . max x = 0 ;
( 1 ) . max y = 0 ;
( 1 ) . max z = 2 6 . 4 e 3;
( 1 ) . d i r e c t i o n = xp ;
(1). display plot = false ;

% define
sampled
sampled
sampled
sampled
sampled
sampled
sampled
sampled

sampled
currents
currents
currents
currents
currents
currents
currents
currents

currents
( 1 ) . m i n x = 0.39 e 3;
( 1 ) . min y = 0 ;
( 1 ) . m i n z = 24 e 3;
( 1 ) . max x = 0.39 e 3;
( 1 ) . max y = 0 ;
( 1 ) . max z = 2 6 . 4 e 3;
( 1 ) . d i r e c t i o n = xp ;
(1). display plot = false ;

37

39

41

43

45

47

49

51

% define
ports ( 1 ) .
ports ( 1 ) .
ports ( 1 ) .
ports ( 1 ) .

ports
sampled voltage index = 1;
sampled current index = 1;
impedance = 5 0 ;
is source port = true ;

14:16

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation Examples

305

10
S11
5
0
magnitude (dB)

fdtd_main

5
10
15
20
25
30
0

4
6
frequency (GHz)

10

Figure 9.14 Return loss of the inverted-F antenna.

y
9010

y
9010
120

60
0
10

150

120
= 90o
xy plane

10

150

30

x
0

180

x
0

210

D, f=2.4 GHz

dB

330

240

300
270

30

180

330

210

240

= 90o
xy plane

20

20

dB

60
0

300
270

Figure 9.15 Radiation patterns in the x y plane cut.

D , f=5.8 GHz

D , f=2.4 GHz

(a) 2.4 GHz

D , f=5.8 GHz

(b) 5.8 GHz

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

306

Near-Field to Far-Field Transformation

30

z
0 10

30

0
10

60

30

= 0o
xz plane
60

10

60

x
90

120

60

x
90

90

120

120

D , f=2.4 GHz

dB

150
180

= 0o
xz plane

20

90

150

30

20

dB

z
0 10

120

150

150
180

D, f=2.4 GHz

D , f=5.8 GHz

D, f=5.8 GHz

(a) 2.4 GHz

(b) 5.8 GHz

Figure 9.16 Radiation patterns in the x z plane cut.

30

z
0 10

30

0
10

60

30
= 90o
yz plane

10

60

60

y
90

60

y
90

90

120

120

D, f=2.4 GHz

dB

120

120

150

150
180

= 90o
yz plane

20

90

150

30

20

dB

z
0 10

150
180

(a) 2.4 GHz


Figure 9.17 Radiation patterns in the yz plane cut.

D, f=5.8 GHz
D, f=5.8 GHz

D, f=2.4 GHz

(b) 5.8 GHz

14:16

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation Examples

307

Dimensions are in mm.

r =9.8
25.4
14

.3

26.1

10

Strip width 1 mm.

fdtd_main

ground
PEC boundary
Voltage source

PML interface

Figure 9.18 A strip-fed rectangular dielectric resonator antenna.

9.4.2 Strip-Fed Rectangular Dielectric Resonator Antenna

In this section the FDTD simulation of a strip-fed dielectric resonator antenna (DRA) is discussed
[37]. The example antenna is illustrated in Fig. 9.18 together with its dimensions. The rectangular
dielectric resonator has dimensions of 14.3 mm, 25.4 mm, and 26.1 mm in x, y, and z directions,
respectively, and dielectric constant of 9.8. The resonator stands on a ground plane and is fed
by a strip having 1 mm width and 10 mm height. The antenna is simulated by a probe feeding.
To simulate the probe feeding, a 1 mm gap is left between the ground plane and the strip, and
a voltage source is placed in this gap. Voltage and current are sampled across and around the
voltage source, and they are tied together to form a port. The boundaries are terminated by an 8
cells thickness CPML, and a 10 cells air gap is left between the objects in the problem space and
the CPML boundaries. The dimensions of a unit cell are x = 0.715 mm, y = 0.508 mm, and
z = 0.5 mm. The denition of the geometry is described in Listing 9.14, and the denition of
the voltage source is shown in Listing 9.15.
The denition of the output parameters is performed in define output parameters, the contents of which are shown in Listing 9.16. The output parameters to be dened are a sampled
voltage, a sampled current, and a port. Furthermore, far-eld frequencies are dened for the
NFFF transformation. The far-eld frequencies are 3.5 GHz and 4.3 GHz. Similar to the previous example, the value of number of cells from outer boundary is 13, which means that the
imaginary NFFF surface is 13 cells away from the outer boundaries.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

308

October 13, 2009

Near-Field to Far-Field Transformation

Listing 9.14 define geometry.m


1

d i s p ( d e f i n i n g t h e problem g e o m e t r y ) ;
bricks = [ ] ;
spheres = [ ] ;

11

13

15

17

19

21

23

25

27

29

% define d i e l e c t r i c
b r i c k s ( 1 ) . min x = 0 ;
b r i c k s ( 1 ) . mi n y = 0 ;
b r i c k s ( 1 ) . min z = 0 ;
b r i c k s ( 1 ) . max x = 1 4 . 3 e 3;
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;
bricks ( 1 ) . material type = 4;
bricks
bricks
bricks
bricks
bricks
bricks
bricks

(2).
(2).
(2).
(2).
(2).
(2).
(2).

m i n x = 8e 3;
mi n y = 6e 3;
min z = 0 ;
max x = 22 e 3;
max y = 31 e 3;
max z = 0 ;
material type = 2;

bricks
bricks
bricks
bricks
bricks
bricks
bricks

(3).
(3).
(3).
(3).
(3).
(3).
(3).

min x = 0 ;
mi n y = 1 2 . 2 e 3;
m i n z = 1e 3;
max x = 0 ;
max y = 1 3 . 2 e 3;
max z = 10 e 3;
material type = 2;

Listing 9.15 define sources and lumped elements.m


d i s p ( d e f i n i n g s o u r c e s and lumped e l e m e n t components ) ;
2

10

12

14

16

18

voltage sources = [ ] ;
current sources = [ ] ;
diodes = [ ] ;
resistors = [];
inductors = [ ] ;
capacitors = [ ] ;
% 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 ;
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;
% voltage sources
% 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
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 ) . 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 ;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation Examples
20

22

24

26

voltage
voltage
voltage
voltage
voltage
voltage
voltage
voltage

sources
sources
sources
sources
sources
sources
sources
sources

309
(1).
(1).
(1).
(1).
(1).
(1).
(1).
(1).

max x = 0 ;
max y = 1 3 . 2 e 3;
max z = 1e 3;
d i r e c t i o n = zp ;
r e s i s t a n c e = 50;
magnitude = 1 ;
waveform type = gaussian ;
waveform index = 1;

Listing 9.16 define output parameters.m


1

disp ( d e f i n i n g output parameters ) ;


sampled electric fields = [];
sampled magnetic fields = [ ] ;
sampled voltages = [ ] ;
sampled currents = [ ] ;
ports = [ ] ;
fa r fi e l d . frequencies = [ ] ;

11

13

15

% figure refresh rate


p l o t t i n g s t e p = 20;
% mode o f o p e r a t i o n
run simulation = true ;
show material mesh = true ;
show problem space = true ;

17

19

21

23

25

% 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 ) = 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 ;
f a r f i e l d . number of cells from outer boundary = 13;
% 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 ;
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

29

31

33

35

% define
sampled
sampled
sampled
sampled
sampled
sampled
sampled
sampled

sampled
voltages
voltages
voltages
voltages
voltages
voltages
voltages
voltages

voltages
( 1 ) . min x = 0 ;
( 1 ) . m i n y = 1 2 . 2 e 3;
( 1 ) . min z = 0 ;
( 1 ) . max x = 0 ;
( 1 ) . max y = 1 3 . 2 e 3;
( 1 ) . max z = 1e 3;
( 1 ) . d i r e c t i o n = zp ;
(1). display plot = false ;

% define
sampled
sampled
sampled

sampled
currents
currents
currents

currents
( 1 ) . min x = 0 ;
( 1 ) . m i n y = 1 2 . 2 e 3;
( 1 ) . m i n z = 0 . 5 e 3;

37

39

41

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

310

43

45

Near-Field to Far-Field Transformation

sampled
sampled
sampled
sampled
sampled

currents
currents
currents
currents
currents

(1).
(1).
(1).
(1).
(1).

max x = 0 ;
max y = 1 3 . 2 e 3;
max z = 0 . 5 e 3;
d i r e c t i o n = zp ;
display plot = false ;

47

51

% define
ports ( 1 ) .
ports ( 1 ) .
ports ( 1 ) .
ports ( 1 ) .

ports
sampled voltage index = 1;
sampled current index = 1;
impedance = 5 0 ;
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)

49

10

20

30

40
2

2.5

3.5
4
4.5
frequency (GHz)

Figure 9.19 Return loss of the strip-fed rectangular DRA.

5.5

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Exercises

311
y
9010
120

y
9010
60

0
10

150

120

= 90o
xy plane

60
0

30

10

150

20
180

210

x
0

180

330

240

210

300
270

30

20

x
0

dB

= 90o
xy plane

330

240

300

dB

D, f=3.5 GHz

270

D, f=3.5 GHz

D, f=4.3 GHz
D, f=4.3 GHz

(a) 3.5 GHz

(b) 4.3 GHz

Figure 9.20 Radiation patterns in the x y plane cut.

30

z
0 10

30

0
10

60

30

= 0o
xz plane
60

10

60

x
90

120

12 0

= 0o
xz plane
60

x
90

90

120

150
180

30

20

90

150

z
0
10

20

dB

D, f=3.5 GHz

12 0

150

dB

150
180

D, f=3.5 GHz

(a) 3.5 GHz


Figure 9.21 Radiation patterns in the x z plane cut.

D, f=4.3 GHz
D, f=4.3 GHz

(b) 4.3 GHz

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

312

Near-Field to Far-Field Transformation

30

z
010

z
30

0
10

60

30

= 90o
yz plane

60

10

60

20
y
90

120

150

= 90o
yz plane
60

y
90

90

12 0

120

D, f=3.5 GHz

dB

150
180

30

20

90

dB

010

1 20

150
180

D, f=4.3 GHz

D, f=3.5 GHz

(a) 3.5 GHz

150
D, f=4.3 GHz

(b) 4.3 GHz

Figure 9.22 Radiation patterns in the yz plane cut.

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 dene
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. Dene
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, dene a sampled voltage and a sampled current on the voltage

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

Exercises

October 13, 2009

313

Figure 9.23 A dipole antenna.

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.

Figure 9.24 A microstrip patch antenna.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

314

October 13, 2009

Near-Field to Far-Field Transformation

Figure 9.25 A microstrip patch antenna with a microstrip line feeding.

9.4

Consider the microstrip rectangular square patch antenna you constructed in Exercise 9.3.
In this conguration 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?

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

10
Thin-Wire Modeling
So far we have assumed that all of the objects in the nite-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 Faradays law contour-path formulation. This model is easy
to understand and to implement in the FDTD program.
10.1 THIN-WIRE FORMULATION

Figure 10.1 illustrates a thin wire of radius a with its axis coinciding with a eld component
E z (i, j, k) on the FDTD grid. In the given example the radius a is smaller than the x and y
cell dimensions. There are four magnetic eld components circulating around E z (i, j, k): namely,
Hy (i, j, k), Hx (i, j, k), Hy (i 1, j, k), and Hx (i, j 1, k) as shown in Fig. 10.2. The thin wire model
proposes special updating equations for these magnetic eld components. We now demonstrate
the derivation of the updating equation for the component Hy (i, j, k); the derivation of updating
equations for other eld components follows the same procedure.
Figure 10.1 shows the magnetic eld component Hy (i, j, k) and four electric eld components
circulating around Hy (i, j, k). Faradays law given in integral form as


H
d s =
t

E d l

(10.1)

can be applied on the enclosed surface shown in Fig. 10.1 to establish the relation between
Hy (i, j, k) and the electric eld components located on the boundaries of the enclosed surface.
Before utilizing (10.1) it should be noted that the variation of the elds around the thin wire is
assumed to be a function of 1/r, where r represents the distance to the eld position from the
thin-wire axis [38]. In more explicit form Hy can be expressed as
Hy (r) =
315

Hy0
,
r

(10.2)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

316

October 13, 2009

Thin-Wire Modeling

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).

Figure 10.2 Magnetic field components surrounding the thin wire.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Thin-Wire Formulation

317

and, similarly, E x can be expressed as


E x (r) =

E x0
,
r

(10.3)

where Hy0 and E x0 are constants. In Fig. 10.1 one can observe that the eld 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,

Hy

x
2

2Hy0
= Hy (i, j, k).
x

(10.4)

Hy (i, j, k)x
,
2

(10.5)

Then
Hy0 =
hence,
Hy (r) =

Hy (i, j, k)x
.
2r

(10.6)

Similarly,
E x (r)| j,k =

E x (i, j, k)x
,
2r

(10.7)

and
E x (r)| j,k+1 =

E x (i, j, k + 1)x
.
2r

(10.8)

Using (10.6), (10.7), and (10.8) in (10.1) one can obtain


z=z r=x

Hy (i, j, k)x
drd z
t
2r
z=0
r=a
z=z
z=0
=
E z (i, j, k)d z +
E z (i + 1, j, k)d z

z=0
r=x

r=a

z=z

E x (i, j, k + 1)x
dr +
2r

r=a

r=x

E x (i, j, k)x
dr.
2r

(10.9)
(10.10)
(10.11)

Notice that the electric eld 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).
a
2
a
2

(10.12)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

318

Thin-Wire Modeling

After applying the central difference approximation to the time derivative of magnetic eld component and re-arranging the terms, one can obtain the new value of Hy (i, j, k) in terms of other
components as
Hyn+1/2 (i, j, k) = Hyn1/2 (i, j, k) +

2t
  E zn (i + 1, j, k)
x ln x
a


t  n
E x (i, j, k + 1) E xn (i, j, k) .
z

(10.13)

Equation (10.13) can be written in the same form as the general updating equation for Hy (1.30),
such that
n+ 12

Hy

n 12

(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
C hyh (i, j, k) = 1, C hye z (i, j, k) =
C hye x (i, j, k) =

2t
 ,
y (i, j, k)x ln x
a

t
.
y (i, j, k)z

Then one only need to modify the updating coefcients 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 similarly by setting the updating coefcients 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 procedure begins.
As mentioned before, there are four magnetic eld components circulating around E zn (i, j, k) as
illustrated in Fig. 10.2; therefore, all these magnetic eld 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

Hy

n 12

(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) ,

where
C hyh (i 1, j, k) = 1, C hye z (i 1, j, k) =
C hye x (i 1, j, k) =

t
.
y (i 1, j, k)z

2t
 ,
y (i 1, j, k)x ln x
a

(10.15)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

MATLAB Implementation of the Thin-Wire Formulation


n+ 12

Hx

319
n 12

(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
C hxh (i, j, k) = 1, C hxe y (i, j, k) =
C hxe z (i, j, k) =

2t
x (i, j, k)y ln

t
,
x (i, j, k)z


y
a

.

and
n+ 12

Hx

n 12

(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
C hxh (i, j 1, k) = 1, C hxe y (i, j 1, k) =
C hxe z (i, j 1, k) =

2t
x (i, j 1, k)y ln

t
,
x (i, j 1, k)z


y
a

.

10.2 MATLAB IMPLEMENTATION OF THE THIN-WIRE FORMULATION

Having derived the updating equations for modeling thin wires, these equations can be implemented in the FDTD program. The rst step is the denition of the thin-wire parameters. The
thin wires are dened as a part of the geometry, and their denition implementation is provided
in the subroutine define geometry, as shown in Listing 10.1.
A new parameter called thin wires is dened and initialized as an empty structure array. This
parameter is used to hold the respective thin-wire parameter values. It is assumed that thin wires
are aligned parallel to either the x, y, or z axis; therefore, the direction eld of thin wires
is set accordingly. Then other parameters min x, min y, min z, max x, max y, and max z are
assigned values to indicate the position of the thin wire in three-dimensional space. Since a thin
wire is like a one-dimensional object, its length is determined by the given position parameters,
while its thickness is determined by its radius. Therefore, radius is another eld of thin wires
that holds the value of the radius. Although there are six position parameters, two of these are
actually redundant in the current implementation. For instance, if the thin wire is aligned in the x
direction, the parameters min x, min y, min z, and max x are sufcient to describe the location
of the thin wire. The other two parameters max y and max z are assigned the same values as
min y and min z as shown in Listing 10.1.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

320

Thin-Wire Modeling

Listing 10.1 define geometry


1

11

13

15

17

19

21

23

25

d i s p ( d e f i n i n g t h e problem g e o m e t r y ) ;
bricks = [ ] ;
spheres = [ ] ;
thin wires = [ ] ;
% define a thin wire
t h i n w i r e s ( 1 ) . min x = 0 ;
t h i n w i r e s ( 1 ) . min y = 0 ;
t h i n w i r e s ( 1 ) . m i n z = 1e 3;
t h i n w i r e s ( 1 ) . max x = 0 ;
t h i n w i r e s ( 1 ) . max y = 0 ;
t h i n w i r e s ( 1 ) . max z = 10 e 3;
t h i n w i r e s ( 1 ) . r a d i u s = 0 . 2 5 e 3;
thin wires ( 1 ) . direction = z ;
% define a thin wire
t h i n w i r e s ( 2 ) . min x = 0 ;
t h i n w i r e s ( 2 ) . min y = 0 ;
t h i n w i r e s ( 2 ) . m i n z = 10e 3;
t h i n w i r e s ( 2 ) . max x = 0 ;
t h i n w i r e s ( 2 ) . max y = 0 ;
t h i n w i r e s ( 2 ) . max z = 1e 3;
t h i n w i r e s ( 2 ) . r a d i u s = 0 . 2 5 e 3;
thin wires ( 2 ) . direction = z ;

After the denition 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.
Listing 10.2 calculate domain size
1

30

32

34

36

d i s p ( c a l c u l a t i n g t h e number o f c e l l s i n t h e problem s p a c e ) ;
number of spheres = size ( spheres , 2 ) ;
number of bricks = size ( bricks , 2 ) ;
number of thin wires = size ( thin wires , 2 ) ;
f o r i =1: n u m b e r o f t h i n w i r e s
min x ( n u m b e r o f o b j e c t s ) = t h i n w i r e s ( i ) . min
min y ( n u m b e r o f o b j e c t s ) = t h i n w i r e s ( i ) . min
min z ( n u m b e r o f o b j e c t s ) = t h i n w i r e s ( i ) . min
max x ( n u m b e r o f o b j e c t s ) = t h i n w i r e s ( i ) . max
max y ( n u m b e r o f o b j e c t s ) = t h i n w i r e s ( i ) . max
max z ( n u m b e r o f o b j e c t s ) = t h i n w i r e s ( i ) . max
number of objects = number of objects + 1;
end

x;
y;
z;
x;
y;
z;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

MATLAB Implementation of the Thin-Wire Formulation

321

The next step in the thin-wire implementation is the initialization of the thin-wire parameters through the updating coefcients. A new subroutine named initialize thin wire updating coefficients is implemented for initialization of the thin-wire updating coefcients. This subroutine is named initialize updating coefficients and is called after the initialization subroutines
for the updating coefcients of other types of objects are called. The implementation of initialize thin wire updating coefficients is shown in Listing 10.3. In this subroutine, the electric and
magnetic eld coefcients 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

10

12

14

16

18

20

22

24

26

28

30

32

34

36

38

40

42

for ind = 1: number of thin wires


i s = round ( ( t h i n w i r e s ( i n d ) . m i n
j s = round ( ( t h i n w i r e s ( i n d ) . m i n
k s = round ( ( t h i n w i r e s ( i n d ) . m i n
i e = round ( ( t h i n w i r e s ( i n d ) . max
j e = round ( ( t h i n w i r e s ( i n d ) . max
ke = round ( ( t h i n w i r e s ( i n d ) . max
r o = t h i n w i r e s ( ind ) . r a d i u s ;

x
y
z
x
y
z

fdtd
fdtd
fdtd
fdtd
fdtd
fdtd

domain . min
domain . min
domain . min
domain . min
domain . min
domain . min

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
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 ;
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 ;
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 ) ;
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 *
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 . . .
. / ( m u r z ( i s : i e 1 , j s 1: j s , k s ) * dy *
C h z e y ( i s : i e 1 , j s 1: j s , k s ) = dtm . . .
. / ( m u r z ( i s : i e 1 , j s 1: j s , k s ) * dx ) ;
case y
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 ;
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 ;
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 ) ;
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 *
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 . . .
. / ( m u r x ( i s , j s : j e 1 , ks 1: k s ) * dz *
C h x e z ( i s , j s : j e 1 , ks 1: k s ) = dtm . . .
. / ( m u r x ( i s , j s : j e 1 , ks 1: k s ) * dy ) ;

x
y
z
x
y
z

) / dx ) + 1 ;
) / dy ) + 1 ;
) / dz ) + 1 ;
) / dx ) + 1 ;
) / dy ) + 1 ;
) / dz ) + 1 ;

l o g ( dz / r o ) ) ;

l o g ( dy / r o ) ) ;

l o g ( dx / r o ) ) ;

l o g ( dz / r o ) ) ;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

322

October 13, 2009

Thin-Wire Modeling
case z
Ceze (
Cezhx (
Cezhy (
Chxh (
Chxey (
./
Chxez (
./
Chyh (
Chyez (
./
Chyex (
./

44

46

48

50

52

54

56

i s , j s , k s : ke 1) = 0 ;
i s , j s , k s : ke 1) = 0 ;
i s , j s , k s : ke 1) = 0 ;
i s , j s 1: j s , k s : ke 1) = 1 ;
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 ) ;
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 ) ) ;
i s 1: i s , j s , k s : ke 1) = 1 ;
i s 1: i s , j s , k s : ke 1) = 2 * dtm . . .
( m u r y ( i s 1: i s , j s , k s : ke 1) * dx * l o g ( dx / r o ) ) ;
i s 1: i s , j s , k s : ke 1) = dtm . . .
( m u r y ( i s 1: i s , j s , k s : ke 1) * dz ) ;

end
58

end

As the updating coefcients 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
coefcients will manipulate the elds for modeling the thin-wire behavior.
10.3 SIMULATION EXAMPLES
10.3.1 Thin-Wire Dipole Antenna

Simulation of a thin-wire dipole antenna is presented in this section. The problem space is
composed of cells with x = 0.25 mm, y = 0.25 mm, and z = 0.25 mm. The boundaries are
CPML with 8 cells thickness and a 10 cells air gap on all sides. The dipole is composed of two
thin wires having 0.05 mm radius and 9.75 mm length. There is a 0.5 mm gap between the wires
where a voltage source is placed. Figure 10.3 illustrates the problem geometry. The denition of
the geometry is illustrated in Listing 10.4. The denition of the voltage source is given in Listing
10.5, and the denitions of the output parameters are given in Listing 10.6. One can notice in
Listing 10.6 that a far-eld frequency is dened as 7 GHz to obtain the far-eld radiation patterns
at this frequency.
The simulation of this problem is performed for 4,000 time steps. The same problem is simulated using WIPL-D [39], which is a three-dimensional EM simulation software. Figure 10.4
shows the return loss of the thin-wire antenna calculated by FDTD and WIPL-D. The magnitude and phase curves show a good agreement. The input impedance of a dipole antenna is
Listing 10.4 define geometry.m

d i s p ( d e f i n i n g t h e problem g e o m e t r y ) ;
2

bricks = [ ] ;
spheres = [ ] ;
thin wires = [ ] ;

10

% define a thin wire


t h i n w i r e s ( 1 ) . min x = 0 ;
t h i n w i r e s ( 1 ) . min y = 0 ;
t h i n w i r e s ( 1 ) . m i n z = 0 . 2 5 e 3;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

Simulation Examples

12

14

thin
thin
thin
thin
thin

wires
wires
wires
wires
wires

(1).
(1).
(1).
(1).
(1).

October 13, 2009

14:16

323
max x = 0 ;
max y = 0 ;
max z = 10 e 3;
r a d i u s = 0 . 0 5 e 3;
direction = z ;

16

18

20

22

24

% define a thin wire


t h i n w i r e s ( 2 ) . min x = 0 ;
t h i n w i r e s ( 2 ) . min y = 0 ;
t h i n w i r e s ( 2 ) . m i n z = 10e 3;
t h i n w i r e s ( 2 ) . max x = 0 ;
t h i n w i r e s ( 2 ) . max y = 0 ;
t h i n w i r e s ( 2 ) . max z = 0.25 e 3;
t h i n w i r e s ( 2 ) . r a d i u s = 0 . 0 5 e 3;
thin wires ( 2 ) . direction = z ;

very much affected by the thickness of the dipole wires. The input impedances obtained from the
two simulations are compared in Fig. 10.5, and they show very good agreement over the simulated
frequency band from zero to 20 GHz.
Since this is a radiation problem the far-eld patterns are also calculated, as indicated before, at
7 GHz. The directivity patterns are plotted in Figs. 10.6, 10.7, and 10.8 for xy, xz, and y z planes,
respectively.
Listing 10.5 define sources and lumped elements.m
1

d i s p ( d e f i n i n g s o u r c e s and lumped e l e m e n t components ) ;


voltage sources = [ ] ;
current sources = [ ] ;
diodes = [ ] ;
resistors = [];
inductors = [ ] ;
capacitors = [ ] ;

11

% 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 ;
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

15

17

19

21

23

25

27

% voltage sources
% 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
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 ;
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 ;
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;
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;
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 ;
v o l t a g e s o u r c e s ( 1 ) . waveform index = 1;

fdtd_main

SPIB005-Elsherbeni & Demir

324

October 13, 2009

Thin-Wire Modeling

Listing 10.6 define output parameters.m



1

disp ( d e f i n i n g output parameters ) ;


sampled electric fields = [];
sampled magnetic fields = [ ] ;
sampled voltages = [ ] ;
sampled currents = [ ] ;
ports = [ ] ;
fa r fi e ld . frequencies = [ ] ;

11

13

15

% figure refresh rate


p l o t t i n g s t e p = 10;
% mode o f o p e r a t i o n
run simulation = true ;
show material mesh = true ;
show problem space = true ;

17

19

% 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 ) = 7 . 0 e9 ;
f a r f i e l d . number of cells from outer boundary = 13;

21

23

25

27

29

31

33

35

37

39

41

43

45

47

49

51

% 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 ;
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 ;
% define
sampled
sampled
sampled
sampled
sampled
sampled
sampled
sampled

sampled
voltages
voltages
voltages
voltages
voltages
voltages
voltages
voltages

voltages
( 1 ) . min x = 0 ;
( 1 ) . min y = 0 ;
( 1 ) . m i n z = 0.25 e 3;
( 1 ) . max x = 0 ;
( 1 ) . max y = 0 ;
( 1 ) . max z = 0 . 2 5 e 3;
( 1 ) . d i r e c t i o n = zp ;
(1). display plot = false ;

% define
sampled
sampled
sampled
sampled
sampled
sampled
sampled
sampled

sampled
currents
currents
currents
currents
currents
currents
currents
currents

currents
( 1 ) . min x = 0 ;
( 1 ) . min y = 0 ;
( 1 ) . min z = 0 ;
( 1 ) . max x = 0 ;
( 1 ) . max y = 0 ;
( 1 ) . max z = 0 ;
( 1 ) . d i r e c t i o n = zp ;
(1). display plot = false ;

% define
ports ( 1 ) .
ports ( 1 ) .
ports ( 1 ) .
ports ( 1 ) .

ports
sampled voltage index = 1;
sampled current index = 1;
impedance = 5 0 ;
is source port = true ;

14:16

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation Examples

325

CPML boundaries
outer boundaries

voltage source

z
y

Figure 10.3 A thin-wire dipole antenna.

magnitude (dB)

10
0
10
20
0

FDTD
WIPLD
5

10
frequency (GHz)

15

20

10
frequency (GHz)

15

20

50
phase (degrees)

fdtd_main

0
50
100
0

Figure 10.4 Return loss of the thin-wire dipole antenna.

14:16

SPIB005-Elsherbeni & Demir

October 13, 2009

326

Thin-Wire Modeling
2000
FDTD real[Z ]
in

FDTD imaginary[Zin]

1500

WIPLD real[Z ]
in

WIPLD imaginary[Zin]
input impedance ()

fdtd_main

1000

500

500

1000
0

8
10
12
frequency (GHz)

14

16

Figure 10.5 Input impedance of the thin-wire dipole antenna.

y
9010
120

60
0
10

150

= 90o
xy plane
30

20

x
0

180

210

330

240

dB

300
270

D , f=7 GHz

D , f=7 GHz

Figure 10.6 Radiation pattern in the x y plane cut.

18

20

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Exercises

327

30

z
0

10

30

0
10

60

= 0o
xz plane
60

20
x
90

90

120

120

150

dB

15 0
180

D , f=7 GHz

D , f=7 GHz

Figure 10.7 Radiation pattern in the x z plane cut.


10.4 EXERCISES

10.1

Construct a problem space composed of cells with size 1 mm on a side. Dene 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 conguration?

10.2

In this example we construct an antenna array composed of two thin-wire dipole antennas. 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 dene
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 rst antenna. Do not dene any ports, and if
there are already dened 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 congurations.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

328

Thin-Wire Modeling

30

z
0

10

30

0
10

60

= 90o
yz plane
60

20
y
90

90

1 20

120

1 50

dB

15 0
180

D , f=7 GHz

D , f=7 GHz

Figure 10.8 Radiation pattern in the yz plane cut.

Figure 10.9 An antenna array composed of two thin-wire dipole antennas.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

Exercises

October 13, 2009

329

Figure 10.10 A thin-wire loop.

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.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

11
Scattered Field Formulation
As discussed before, sources are the necessary components of a nite-difference time-domain
(FDTD) simulation, and their types vary depending on the type of the problem under consideration. Usually sources are of two types: (1) near-zone sources, such as the voltage and current sources
described in Chapter 4; and (2) far-zone sources, such as the incident elds in scattering problems.
In the previous chapters we demonstrated several examples utilizing near-zone sources. In this
chapter we present scattered eld formulation, one of the techniques that integrates far-zone sources
into the FDTD method.
11.1 SCATTERED FIELD BASIC EQUATIONS

Far-zone sources are the elds generated somewhere outside the FDTD problem space that
illuminate the objects in the problem space. Therefore, they are the incident elds exciting the
FDTD problem space. The incident eld exists in a problem space in which there are no scatterers.
Therefore, they are the elds that can be described by analytical expressions and would satisfy
Maxwells curl equations where the problem space medium is free space, such that

inc = 0 Einc ,
H
t
inc
H
Einc = 0
.
t

(11.1a)
(11.1b)

The most common type of incident eld is the plane wave. The expressions for the eld components generated by plane waves are discussed in a subsequent section.
When the incident eld illuminates the objects in an FDTD problem space, scattered elds are
generated and thus need to be calculated. The scattered eld formulation is one of the simplest
techniques that can be used for calculating scattered elds.
The elds in a problem space are referred to in general as total elds. The total elds satisfy
Maxwells curl equations for a general medium, such that

tot = Etot + e Etot ,
H
t
tot
H
tot .
Etot =
mH
t
331

(11.2a)
(11.2b)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

332

Scattered Field Formulation

Then the scattered elds are dened as the difference between the total elds and incident elds.
Therefore, one can write
Etot = Einc + Escat ,

and

Htot = Hinc + Hscat ,

(11.3)

where Escat and Hscat are the scattered electric and magnetic elds. In light of (11.3), equation
(11.2) can be rewritten in terms of incident and scattered eld terms as
Einc
Escat
+
+ e Escat + e Einc ,
t
t
scat
inc
H
H
scat m H
inc .
=

mH
t
t

inc =
scat + H
H

(11.4a)

Escat + Einc

(11.4b)

The curls of the incident elds in (11.4) can be replaced by the time-derivative terms from (11.1),
which yields
Escat
Einc
Einc
=
+
+ e Escat + e Einc ,
t
t
t
scat
inc
inc
H
H
H
scat m H
inc .
Escat 0
=

mH
t
t
t
scat + 0
H

(11.5a)
(11.5b)

After rearranging the terms in (11.5) one can obtain



Escat
scat + (0 ) Einc e Einc ,
+ e Escat = H
t
t


Hscat
scat = Escat + (0 ) Hinc m H
inc .

+ mH
t
t

(11.6a)
(11.6b)

At this point the derivatives in (11.6) can be represented by central nite difference approximations,
and updating equations can be obtained for the scattered eld formulation.
11.2 THE SCATTERED FIELD UPDATING EQUATIONS

After applying the central nite difference approximation, equation (11.6a) can be expressed for
the x component as
x (i, j, k)

n+1
n
n+1
n
(i, j, k) Escat,x
(i, j, k)
(i, j, k) + Escat,x
(i, j, k)
Escat,x
Escat,x
+ xe (i, j, k)
t
2
n+ 1

n+ 1

n+ 1

n+ 1

Hscat,y2 (i, j, k) Hscat,y2 (i, j, k 1)


Hscat,z2 (i, j, k) Hscat,z2 (i, j 1, k)

=
y
z
+ (0 x (i, j, k))
xe (i, j, k)

n+1
n
(i, j, k) Einc,x
(i, j, k)
Einc,x
t

n+1
n
(i, j, k) + Einc,x
(i, j, k)
Einc,x
,
2

(11.7)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

The Scattered Field Updating Equations

333

Equation (11.7) can be arranged such that the new value of the scattered electric eld component
n+1
(i, j, k) is calculated using other terms as
Escat,x
n+1
n
Escat,x
(i, j, k) = Cexe (i, j, k) Escat,x
(i, j, k)
n+ 1

n+ 1

n+ 1

n+ 1

+ Cexhz (i, j, k) Hscat,z2 (i, j, k) Hscat,z2 (i, j 1, k)

+ Cexhy (i, j, k) Hscat,y2 (i, j, k) Hscat,y2 (i, j, k 1)

n+1
n
+ Cexeic (i, j, k) Einc,x
(i, j, k) + Cexeip (i, j, k) Einc,x
(i, j, k),

(11.8)

where
Cexe (i, j, k) =
Cexhz (i, j, k) =

2x (i, j, k) xe (i, j, k)t


,
2x (i, j, k) + xe (i, j, k)t
2t

,
y 2x (i, j, k) + xe (i, j, k)t

Cexhy (i, j, k) =
Cexeic (i, j, k) =

2t

,
z 2x (i, j, k) + xe (i, j, k)t

2 (0 x (i, j, k)) xe (i, j, k)t


,
2x (i, j, k) + xe (i, j, k)t

Cexeip (i, j, k) =

2 (0 x (i, j, k)) + xe (i, j, k)t


.
2x (i, j, k) + xe (i, j, k)t

In this equation the ic term in the subscript of the coefcient Cexeic indicates that this coefcient
is multiplied with the current value of the incident eld component, whereas the ip term in the
subscript of the coefcient Cexeip indicates that this coefcient is multiplied with the previous value
of the incident eld component.
n+1
(i, j, k) as
Similarly the updating equation can be written for Escat,y
n+1
n
Escat,y
(i, j, k) = Ceye (i, j, k) Escat,y
(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)
n+1
n
(i, j, k) + Ceyeip (i, j, k) Einc,y
(i, j, k),
+ Ceyeic (i, j, k) Einc,y

where
Ceye (i, j, k) =
Ceyhx (i, j, k) =

2 y (i, j, k) ye (i, j, k)t


2 y (i, j, k) + ye (i, j, k)t

2t

,
z 2 y (i, j, k) + ye (i, j, k)t

(11.9)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

334

Scattered Field Formulation

2t

,
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
Ceyhz (i, j, k) =

n+1
The updating equation can be written for Escat,z
(i, j, k) as
n+1
n
(i, j, k) = Ceze (i, j, k) Escat,z
(i, j, k)
Escat,z


n+ 12
n+ 12
+ Cezhy (i, j, k) Hscat,y (i, j, k) Hscat,y (i, j, k 1)

+ Cezhx (i, j, k)

n+ 1
Hscat,x2 (i,

j, k)

n+ 1
Hscat,x2 (i


1, j, k)

n+1
n
(i, j, k) + Cezeip (i, j, k) Einc,z
(i, j, k),
+ Cezeic (i, j, k) Einc,z

(11.10)

where
Ceze (i, j, k) =
Cezhy (i, j, k) =

2z (i, j, k) ze (i, j, k)t


,
2z (i, j, k) + ze (i, j, k)t
2t

,
x 2z (i, j, k) + ze (i, j, k)t

Cezhx (i, j, k) =
Cezeic (i, j, k) =

2t

,
y 2z (i, j, k) + ze (i, j, k)t

2 (0 z (i, j, k)) ze (i, j, k)t


,
2z (i, j, k) + ze (i, j, k)t

Cezeip (i, j, k) =

2 (0 z (i, j, k)) + ze (i, j, k)t


.
2z (i, j, k) + ze (i, j, k)t

Following a similar procedure, the updating equations for the magnetic eld 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

n
+ Chxez (i, j, k) Escat,z
(i, j + 1, k) Escat,z
(i, j, k)
 n

n
(i, j, k + 1) Escat,y
(i, j, k)
+ Chxey (i, j, k) Escat,y
n+ 1

n 1

+ Chxhic (i, j, k) Hinc,x2 (i, j, k) + Chxhip (i, j, k) Hinc,x2 (i, j, k),

(11.11)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

The Scattered Field Updating Equations

335

where
Chxh (i, j, k) =

2x (i, j, k) xm (i, j, k)t


,
2x (i, j, k) + xm (i, j, k)t
2t

,
y 2x (i, j, k) + xm (i, j, k)t

Chxez (i, j, k) =
Chxey (i, j, k) =

2t

,
z 2x (i, j, k) + xm (i, j, k)t

Chxhic (i, j, k) =

2 (0 x (i, j, k)) xm (i, j, k)t


,
2x (i, j, k) + xm (i, j, k)t
2 (0 x (i, j, k)) + xm (i, j, k)t
.
2x (i, j, k) + xm (i, j, k)t

Chxhip (i, j, k) =

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

n
+ Chyex (i, j, k) Escat,x
(i, j + 1, k) Escat,x
(i, j, k)
 n

n
(i, j, k + 1) Escat,z
(i, j, k)
+ Chyez (i, j, k) Escat,z
n+ 1

n 1

+ Chyhic (i, j, k) Hinc,y2 (i, j, k) + Chyhip (i, j, k) Hinc,y2 (i, j, k),


where
Chyh (i, j, k) =

2 y (i, j, k) ym (i, j, k)t


2 y (i, j, k) + ym (i, j, k)t

Chyex (i, j, k) =
Chyez (i, j, k) =
Chyhic (i, j, k) =

2t

,
z 2 y (i, j, k) + ym (i, j, k)t

2t

,
x 2 y (i, j, k) + ym (i, j, k)t


2 0 y (i, j, k) ym (i, j, k)t

Chyhip (i, j, k) =

,
2 y (i, j, k) + ym (i, j, k)t


2 0 y (i, j, k) + ym (i, j, k)t
2 y (i, j, k) + ym (i, j, k)t

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

n
+ Chzey (i, j, k) Escat,y
(i, j + 1, k) Escat,y
(i, j, k)

(11.12)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

336

Scattered Field Formulation

 n

n
+ Chzex (i, j, k) Escat,x
(i, j, k + 1) Escat,x
(i, j, k)
n+ 1

n 1

+ Chzhic (i, j, k) Hinc,z2 (i, j, k) + Chzhip (i, j, k) Hinc,z2 (i, j, k),

(11.13)

where
Chzh (i, j, k) =

2z (i, j, k) zm (i, j, k)t


,
2z (i, j, k) + zm (i, j, k)t

Chzey (i, j, k) =

2t

,
x 2z (i, j, k) + zm (i, j, k)t

Chzex (i, j, k) =

2t

,
y 2z (i, j, k) + zm (i, j, k)t

Chzhic (i, j, k) =

2 (0 z (i, j, k)) zm (i, j, k)t


,
2z (i, j, k) + zm (i, j, k)t

Chzhip (i, j, k) =

2 (0 z (i, j, k)) + zm (i, j, k)t


.
2z (i, j, k) + zm (i, j, k)t

Equations (11.8)(11.13) are the updating equations with corresponding denitions for associated coefcients for the scattered eld 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 coefcients are the same except that (11.8)(11.13) include additional incident
eld terms.
11.3 EXPRESSIONS FOR THE INCIDENT PLANE WAVES

The aforementioned scattered eld updating equations are derived to calculate scattered electric
elds in a problem space in response to an incident eld. The incident eld 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 eld. This section discusses the incident plane
wave eld expressions.
Figure 11.1 illustrates an incident plane wave traveling in the direction denoted by a unit
vector 
k. The incident electric eld in general may have a component and a component when
expressed in a spherical coordinate system denoting its polarization. The incident electric eld
can be expressed for a given point denoted by a position vector r as


 f
+ E
Einc = E 



1
t 
k r ,
c

(11.14)

where f is a function determining the waveform of the incident electric eld. This equation can
be rewritten by allowing a time delay t0 and spatial shift l 0 as


 f
+ E
Einc = E 



1
(t t0 ) (k r l 0 ) .
c

(11.15)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Incident Plane Waves

337

inc

E
E

inc

x
Figure 11.1 An incident plane wave.

The vectors r and 


k can be written in Cartesian coordinates as
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 eld 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 eld for any point (x, y, z) in space as


Einc,x = E cos inc cos inc E sin inc fw f ,


Einc,y = E cos inc sin inc + E cos inc fw f ,

(11.17b)

Einc,z = (E sin inc ) fw f ,

(11.17c)

(11.17a)

where fw f is given by
fw f = f



1
(t t0 ) (x sin inc cos inc + y sin inc sin inc + z cos inc l 0 ) .
c

(11.18)

Once the expressions for the incident electric eld components are obtained, the expressions for
magnetic eld 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 eld components are

1 
E cos inc cos inc + E sin inc fw f ,
0

1 
E cos inc sin inc E cos inc fw f ,
=
0

1 
E sin inc fw f .
=
0

Hinc,x =

(11.19a)

Hinc,y

(11.19b)

Hinc,z

(11.19c)

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

338

Scattered Field Formulation


Leading edge of
the waveform

l0 = k r0

k r l0
f ( t t0 )

k r
f ( t t0 )

FDTD
problem
space

k r
f t

r0
y

Waveforms entry point


to the problem space

Figure 11.2 An incident plane wave delayed in time and shifted in space.

+
Equations (11.17)(11.19) express an incident eld with a polarization determined by (E 
), propagating in a direction determined by the angles inc and inc and having a waveform
E
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 eld in the problem space
is zero, and as time proceeds the incident eld 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
k r) ,
f t (
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
k r0 , where r0 is the position vector indicating the closest point of the problem space
as l 0 = 

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Incident Plane Waves

339

z
A plane wave traveling
away from origin

inc

A plane wave traveling


towards origin

E
E

inc

E
E

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
k r0 ]. After l 0 is
problem space, then the minimum distance for l 0 can be calculated by l 0 = min[
determined, the waveform equation can be modied as


1
f (t t0 ) (k r l 0 ) ,
c
which leads to (11.18).
In some scattering applications, a scatterer is placed at the origin and the scattered eld due
to an incident plane wave is calculated. The direction of propagation of the plane wave must
be dened appropriately in such applications. Consider Fig. 11.3, where two plane waves are
illustrated. Although these two plane waves are traveling in the same direction, one of them is
illustrated as traveling toward the origin while the other one is traveling away from the origin. The
equations given in this section are derived based on the wave traveling away from the origin; the
angles determining the propagation, inc and inc , and amplitudes of the incident eld components
E and E are as shown in this gure. If it is desired to dene the angles and eld components


, inc
, E , and E , then the following
based on the wave traveling toward the origin such as inc
conversions need to be employed to use the aforementioned equations as is:

inc = inc
,

(11.20a)


inc = + inc
,

(11.20b)

E =

E ,

E = E .

(11.20c)
(11.20d)

One of the types of results that can be obtained from the scattered eld due to an incident
plane wave is the radar cross-section (RCS) of a scatterer. The near-eld to far-eld NF-FF
transformation algorithm discussed in Chapter 9 is used for this purpose. In this case the scattered
near elds calculated in a problem space are captured on an imaginary surface enclosing the
scatterer to determine the equivalent ctitious surface currents. These currents are transformed
to the frequency domain while being captured. After the time-marching loop is completed, the
far-eld terms L , L , N , and N are calculated following the procedure described in Chapter 9.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

340

Scattered Field Formulation

At this point the components of the bistatic RCS can be calculated using
RCS =

k2
|L + 0 N |2
8 0 Pinc

(11.21a)

RCS =

k2
|L 0 N |2 ,
8 0 Pinc

(11.21b)

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
Pinc =

1
|Einc ()|2 ,
20

(11.22)

where Einc () is the discrete Fourier transform (DFT) of the incident electric eld waveform at
the frequency for which the RCS calculation is sought.
11.4 MATLAB IMPLEMENTATION OF THE SCATTERED FIELD FORMULATION

The scattered eld formulation is presented in the previous sections. In this section the implementation of the scattered eld formulation is discussed.
11.4.1 Definition of the Incident Plane Wave

For a scattering problem it is necessary to dene an incident eld as the source. In Section 11.3
the equations necessary to construct a plane wave are presented, and the plane wave is used as
the incident eld in this discussion. In the FDTD program an incident plane wave is dened
in the subroutine define sources and lumped elements as shown in Listing 11.1. In the given code
Listing 11.1 define sources and lumped elements

d i s p ( d e f i n i n g s o u r c e s and lumped e l e m e n t components ) ;
2

voltage sources = [ ] ;
current sources = [ ] ;
diodes = [ ] ;
resistors = [];
inductors = [ ] ;
capacitors = [ ] ;
incident plane wave = [ ] ;

10

12

% 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 ;
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

16

18

20

% Define
incident
incident
incident
incident
incident
incident

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
plane wave . E theta = 1;
plane wave . E phi = 0;
plane wave . theta incident = 0;
plane wave . phi incident = 0;
plane wave . waveform type = gaussian ;
plane wave . waveform index = 1;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

The Scattered Field Formulation

October 13, 2009

341

rst a new empty structure, incident plane wave, is dened. Then the parameters of the incident
plane wave are dened as elds 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 eld waveform. The elds 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 dened. The denition 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 dened as a
structure waveforms, and the elds waveform type and waveform index are dened under
incident plane wave, which point to a specic waveform dened under waveforms.
11.4.2 Initialization of the Incident Fields

The next step is the initialization of the incident elds and the updating coefcients. The initialization of the incident elds is performed in the subroutine initialize sources and lumped elements.
The section of the code listed in Listing 11.2 is added to this subroutine.
Listing 11.2 initialize sources and lumped elements
206

208

210

212

214

216

218

220

222

224

226

228

230

232

234

% i n i t i a l i z e i n c i d e n t p l a n e wave
i f i s f i e l d ( incident plane wave , E theta )
i n c i d e n t p l a n e w a v e . enabled = true ;
else
i n c i d e n t p l a n e w a v e . enabled = f a l s e ;
end
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
H x i c = z e r o s ( nxp1 , ny , nz ) ;
H y i c = z e r o s ( nx , nyp1 , nz ) ;
H z i c = z e r o s ( nx , ny , nzp1 ) ;
E x i c = z e r o s ( nx , nyp1 , nzp1 ) ;
E y i c = z e r o s ( nxp1 , ny , nzp1 ) ;
E z i c = z e r o s ( nxp1 , nyp1 , nz ) ;
% 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 ) ;
H y i p = z e r o s ( nx , nyp1 , nz ) ;
H z i p = z e r o s ( nx , ny , nzp1 ) ;
E x i p = z e r o s ( nx , nyp1 , nzp1 ) ;
E y i p = z e r o s ( nxp1 , ny , nzp1 ) ;
E z i p = z e r o s ( nxp1 , nyp1 , nz ) ;
% 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;
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 ;
E phi = incident plane wave . E phi ;
e t a 0 = s q r t ( mu 0 / e p s 0 ) ;
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 ) ;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

342
236

238

240

242

Scattered Field Formulation


E y i 0 = E t h e t a * cos ( t h e t a i n c i d e n t ) * sin ( p h i i n c i d e n t )
+ E phi * cos ( p h i i n c i d e n t ) ;
E z i 0 = E t h e t a * s i n ( t h e t a i n c i d e n t ) ;
H x i 0 = ( 1/ e t a 0 ) * ( E p h i * c o s ( 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 t h e t a * sin ( p h i i n c i d e n t ) ) ;
H y i 0 = ( 1/ e t a 0 ) * ( E p h i * c o s ( t h e t a i n c i d e n t ) . . .
* sin ( p h i i n c i d e n t ) E t h e t a * cos ( p h i i n c i d e n t ) ) ;
Hzi0 = ( 1 / eta 0 ) * ( E phi * sin ( t h e t a i n c i d e n t ) ) ;

...

244

246

248

250

252

254

256

% Create position
x p o s = z e r o s ( nxp1
y p o s = z e r o s ( nxp1
z p o s = z e r o s ( nxp1
f o r i n d = 1 : nxp1
x p o s ( ind , : , : )
end
f o r i n d = 1 : nyp1
y p o s ( : , ind , : )
end
f o r i n d = 1 : nzp1
z pos ( : , : , ind )
end

a r r a y s i n d i c a t i n g t h e c o o r d i n a t e s o f t h e nodes
, nyp1 , nzp1 ) ;
, nyp1 , nzp1 ) ;
, nyp1 , nzp1 ) ;
= ( i n d 1 ) * dx + f d t d d o m a i n . m i n x ;
= ( i n d 1 ) * dy + f d t d d o m a i n . m i n y ;
= ( i n d 1 ) * dz + f d t d d o m a i n . m i n z ;

258

260

262

264

266

% calculate s p a t i a l shift , l 0 , required


r 0 =[ f d t d d o m a i n . m i n x f d t d d o m a i n . m i n y
fdtd domain . min x fdtd domain . min y fdtd
f d t d d o m a i n . m i n x f d t d d o m a i n . max y f d t d
f d t d d o m a i n . m i n x f d t d d o m a i n . max y f d t d
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 y f d t d
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 y f d t d
f d t d d o m a i n . max x f d t d d o m a i n . max y f d t d
f d t d d o m a i n . max x f d t d d o m a i n . max y f d t d

f o r i n c i d e n t p l a n e wave
fdtd domain . min z ;
d o m a i n . max z ;
domain . min z ;
d o m a i n . max z ;
domain . min z ;
d o m a i n . max z ;
domain . min z ;
d o m a i n . max z ; ] ;

268

270

k vec x =
k vec y =
k vec z =

sin ( theta incident


sin ( theta incident
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 ) ;
)* sin ( phi incident ) ;
);

272

274

k dot r0 = k v e c x * r0 ( : , 1 )
+ 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

280

282

284

286

% 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
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 . . .
+ z p o s ( 1 : nx , 1 : nyp1 , 1 : nzp1 ) * k v e c z ) / c ;
k d o t r e y = ( x p o s ( 1 : nxp1 , 1 : ny , 1 : nzp1 ) * k v e c x . . .
+ ( y p o s ( 1 : nxp1 , 1 : ny , 1 : nzp1 )+ dy / 2 ) * k v e c y . . .
+ z p o s ( 1 : nxp1 , 1 : ny , 1 : nzp1 ) * k v e c z ) / c ;

...

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

The Scattered Field Formulation

14:16

343

k d o t r e z = ( x p o s ( 1 : nxp1 , 1 : nyp1 , 1 : nz ) * k v e c x . . .
+ y p o s ( 1 : nxp1 , 1 : nyp1 , 1 : nz ) * k v e c y . . .
+ ( z p o s ( 1 : nxp1 , 1 : nyp1 , 1 : nz )+ dz / 2 ) * k v e c z ) / c ;

288

290

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 . . .
+ ( z p o s ( 1 : nxp1 , 1 : ny , 1 : nz )+ dz / 2 ) * k v e c z ) / c ;

292

294

296

298

300

302

k d o t r h y = ( ( x p o s ( 1 : nx , 1 : nyp1 , 1 : nz )+ dx / 2 ) * k v e c x
+ y p o s ( 1 : nx , 1 : nyp1 , 1 : nz ) * k v e c y . . .
+ ( z p o s ( 1 : nx , 1 : nyp1 , 1 : nz )+ dz / 2 ) * k v e c z ) / c ;

...

k d o t r h z = ( ( x p o s ( 1 : nx , 1 : ny , 1 : nzp1 )+ dx / 2 ) * k v e c x
+ ( y p o s ( 1 : nx , 1 : ny , 1 : nzp1 )+ dy / 2 ) * k v e c y . . .
+ z p o s ( 1 : nx , 1 : ny , 1 : nzp1 ) * k v e c z ) / c ;

...

%
k
k
k
k
k
k

304

306

308

310

embed
dot r
dot r
dot r
dot r
dot r
dot r

spatial
ex = k
ey = k
ez = k
hx = k
hy = k
hz = k

s h i f t in k . r
dot r ex l 0
dot r ey l 0
dot r ez l 0
dot r hx l 0
dot r hy l 0
dot r hz l 0

;
;
;
;
;
;

% s t o r e t h e waveform
w t s t r = incident plane wave . waveform type ;
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 . . . .
w t s t r ( w i s t r ) . waveform ; ] ;
eval ( e v a l s t r ) ;
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 ;

312

314

316

318

clear x pos y pos z pos ;

320

end

In this code the rst step is to determine whether an incident plane wave is dened. If an
incident plane wave is dened, then it indicates that the FDTD simulation is running a scattering
problem and, therefore, the algorithm of the scattered eld 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 eld components using the scattered eld updating equation
is the same as the calculation of the total eld components using the general updating equation,
except for the additional incident eld terms. Therefore, the parameters corresponding to the
eld arrays Ex, Ey, Ez, Hx, Hy, and Hz can be assumed as scattered elds if the mode of the
simulation is scattering. Then the eld arrays corresponding to incident elds must be dened.
The new eld arrays are thus dened 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 eld arrays.

fdtd_main

SPIB005-Elsherbeni & Demir

344

October 13, 2009

Scattered Field Formulation

In the next step the amplitudes of the electric and magnetic eld 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 eld components are computed at different positions in a three-dimensional
space. The coordinates of these eld 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 eld 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 specic 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
 corners are stored in an array denoted as r0. The value of l 0 is calculated
 these
k is the propagation vector indicating the direction of propagation.
k r0 , where 
by l 0 = min 
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 eld 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 eld 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 eld
arrays for use in the scattered eld updating equations.
11.4.3 Initialization of the Updating Coefficients

The scattered eld formulation algorithm requires a new set of updating coefcients. As discussed in Section 11.2 the updating equations for the scattered eld formulation are the same as
the general updating equations except that the scattered eld updating equations have additional
terms. These terms consist of incident elds multiplied by incident eld coefcients. The incident eld coefcients are initialized in a subroutine initialize incident field updating coefficients,
the implementation of which is shown in Listing 11.3. This subroutine is called in initialize updating coefficients after all other updating coefcient subroutines are called. Here a set of
new three-dimensional arrays is constructed representing the updating coefcients related to the
incident eld components based on equations (11.8)(11.13).
11.4.4 Calculation of the Scattered Fields

As the iterations proceed in the FDTD time-marching algorithm, the incident plane wave enters
the FDTD problem space and propagates such that at every time instant the values of the incident

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

The Scattered Field Formulation

14:16

345

Listing 11.3 initialize incident field updating coefficients


1

11

13

15

17

19

21

23

25

27

29

31

33

35

% i n i t i a l i z e incident f i e l d updating c o e f f i c i e n t s
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 ;
end
% 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 )
. / ( 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 )
. / ( 2 * e p s r x * e p s 0+d t * s i g m a e x ) ;
% 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 )
. / ( 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 )
. / ( 2 * e p s r y * e p s 0+d t * s i g m a e y ) ;
% 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 )
. / ( 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 )
. / ( 2 * e p s r z * e p s 0+d t * s i g m a e z ) ;

...
...

...
...

...
...

% 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 0d t * s i g m a m x ) . / ( 2 * m u r x * mu 0+d t * s i g m a m x ) ;
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 ) ;
% 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 0d t * s i g m a m y ) . / ( 2 * m u r y * mu 0+d t * s i g m a m y ) ;
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 ) ;
% 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 0d t * s i g m a m z ) . / ( 2 * m u r z * mu 0+d t * s i g m a m z ) ;
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 ) ;

eld components change. Therefore, the values of the incident eld 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 eld 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
specic 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 eld arrays are recalculated. One should notice that the
electric and magnetic eld components are calculated at time instants a half time step off from
each other since the magnetic eld components are evaluated at half-integer time steps while the
electric eld components are evaluated at integer time steps.

fdtd_main

SPIB005-Elsherbeni & Demir

346

October 13, 2009

Scattered Field Formulation

Listing 11.4 update incident fields


1

% update i n c i d e n t f i e l d s f o r the c u r r e n t time s t e p


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 ;
end

11

13

tm = c u r r e n t t i m e + d t / 2 ;
te = current time + dt ;
% 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 ;
Exip = Exic ; Eyip = Eyic ; Ezip = Ezic ;
w t s t r = incident plane wave . waveform type ;
wi = 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 ;

15

17

19

21

23

25

% i f waveform i s G a u s s i a n w a v e f o r m s
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 ;
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 ) ;
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 ) ;
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 ) ;
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

29

31

33

35

37

39

41

43

% 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
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 ;
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 )
. * 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 )
. * 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 )
. * 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 )
. * 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 )
. * 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 )
. * exp ( ( ( tm t 0 k d o t r h z ) / t a u ) . 2 ) ;
end

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

45

47

49

% i f waveform i s c o s i n e modulated G a u s s i a n
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 )
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 ;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

The Scattered Field Formulation


t 0 = waveforms . c o s i n e m o d u l a t e d
E x i c = E x i 0 * cos ( 2 * pi * f * ( te t
. * exp ( ( ( t e t 0 k d o t
E y i c = E y i 0 * cos ( 2 * pi * f * ( te t
. * exp ( ( ( t e t 0 k d o t
E z i c = E z i 0 * cos ( 2 * pi * f * ( te t
. * exp ( ( ( t e t 0 k d o t
H x i c = H x i 0 * c o s ( 2 * p i * f * ( tm t
. * exp ( ( ( tm t 0 k d o t
H y i c = H y i 0 * c o s ( 2 * p i * f * ( tm t
. * exp ( ( ( tm t 0 k d o t
H z i c = H y i 0 * c o s ( 2 * p i * f * ( tm t
. * exp ( ( ( tm t 0 k d o t

51

53

55

57

59

61

63

14:16

347
g a u s s i a n ( wi ) . t 0 ;
0 k dot r ex ) ) . . .
r e x ) / tau ) . 2 ) ;
0 k dot r ey ) ) . . .
r e y ) / tau ) . 2 ) ;
0 k dot r ez ) ) . . .
r e z ) / tau ) . 2 ) ;
0 k dot r hx ) ) . . .
r h x ) / tau ) . 2 ) ;
0 k dot r hy ) ) . . .
r h y ) / tau ) . 2 ) ;
0 k dot r hz ) ) . . .
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 eld components are updated for the current
time step. The implementation of update magnetic fields is modied as shown in Listing 11.5
to accommodate the scattered eld 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 eld arrays are multiplied by the corresponding
coefcients and are added to the magnetic eld components, which in this case are assumed to
be scattered elds. Similarly, the implementation of update electric fields is modied as shown
in Listing 11.6 to accommodate the scattered eld formulation for updating the scattered electric
eld components.

Listing 11.5 update magnetic fields


% update magnetic f i e l d s
2

current time

= current time + dt / 2 ;

Hx = Chxh . * Hx+C h x e y . * ( E y ( 1 : nxp1 , 1 : ny , 2 : nzp1 ) E y ( 1 : nxp1 , 1 : ny , 1 : nz ) )


+ C h x e z . * ( E z ( 1 : nxp1 , 2 : nyp1 , 1 : nz ) E z ( 1 : nxp1 , 1 : ny , 1 : nz ) ) ;

...

Hy = Chyh . * Hy+C h y e z . * ( E z ( 2 : nxp1 , 1 : nyp1 , 1 : nz ) E z ( 1 : nx , 1 : nyp1 , 1 : nz ) )


+ C h y e x . * ( E x ( 1 : nx , 1 : nyp1 , 2 : nzp1 ) E x ( 1 : nx , 1 : nyp1 , 1 : nz ) ) ;

...

10

12

14

16

18

Hz = Chzh . * Hz+C h z e x . * ( E x ( 1 : nx , 2 : nyp1 , 1 : nzp1 ) E x ( 1 : nx , 1 : ny , 1 : nzp1 ) )


+ C h z e y . * ( E y ( 2 : nxp1 , 1 : ny , 1 : nzp1 ) E y ( 1 : nx , 1 : ny , 1 : nzp1 ) ) ;
if incident
Hx = Hx
Hy = Hy
Hz = Hz
end

...

p l a n e w a v e . enabled
+ Chxhic . * Hxic + Chxhip . * Hxip ;
+ Chyhic . * Hyic + Chyhip . * Hyip ;
+ Chzhic . * Hzic + Chzhip . * Hzip ;

fdtd_main

SPIB005-Elsherbeni & Demir

348

October 13, 2009

Scattered Field Formulation

Listing 11.6 update electric fields



2

10

12

14

16

18

20

22

24

26

28

% u p d a t e e l e c t r i c f i e l d s e x c e p t t h e t a n g e n t i a l components
% on t h e b o u n d a r i e s
current time

= current time + dt / 2 ;

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 ) . * . . .
( 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 ) . * . . .
( Hy ( 1 : nx , 2 : ny , 2 : nz )Hy ( 1 : nx , 2 : ny , 1 : nz 1 ) ) ;
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 ) . *
...
( 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 ) . *
...
( Hz ( 2 : nx , 1 : ny , 2 : nz )Hz ( 1 : nx 1 ,1: ny , 2 : nz ) ) ;
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 ) . *
...
( 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 ) . * . . .
( Hx ( 2 : nx , 2 : ny , 1 : nz )Hx ( 2 : nx , 1 : ny 1 ,1: nz ) ) ;
if incident
Ex = Ex
Ey = Ey
Ez = Ez
end

p l a n e w a v e . enabled
+ Cexeic .* Exic + Cexeip .* Exip ;
+ Ceyeic .* Eyic + Ceyeip .* Eyip ;
+ Cezeic .* Ezic + Cezeip .* Ezip ;

11.4.5 Postprocessing and Simulation Results

The scattered electric and magnetic eld components at desired locations can be captured as the
FDTD simulation is running by dening sampled electric fields and sampled magnetic fields
in the subroutine define output parameters before the FDTD simulation is started. Another type
of output from a scattering simulation is the RCS as discussed in Section 11.3. The calculation of
RCS follows the same procedure as the NFFF transformation. Only a slight modication of the
code is required at the last stage of the NFFF transformation. However, before discussing this
modication, it should be noted that if the calculation of the RCS is desired, the frequencies for
which the RCS calculation is sought must be dened in the subroutine define output parameters
as the parameter farfield.frequencies(i). Furthermore, the parameter farfield.number of cells from outer boundary must be dened as well.
The calculation of RCS from the captured NFFF ctitious currents and display of results are
performed in the subroutine calculate and display farfields. The initial lines of this subroutine are
modied as shown in Listing 11.7. In the last part of the given code section it can be seen that if the
mode of the simulation is scattering, then the plotted radiation patterns are RCS; otherwise, plots
show the directivity of the eld patterns. Another modication is that a new subroutine named
calculate incident plane wave power is called after the subroutine calculate radiated power. The
RCS calculation is based on (11.21), which requires the value of the incident eld power. Hence, the

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

The Scattered Field Formulation

14:16

349

Listing 11.7 calculate and display farfields


8

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 ;
end

10

12

14

calculate radiated power ;


calculate incident plane wave power ;
j = sqrt ( 1);
number of angles = 360;

16

18

20

22

24

26

28

% 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
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
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
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 ;
else
p l o t t y p e = RCS ;
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 modied 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.

Listing 11.8 calculate incident plane wave power


2

10

12

14

% C a l c u l a t e t o t a l r a d i a t e d power
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 ;
end
x = i n c i d e n t p l a n e w a v e . waveform ;
t i m e s h i f t = 0;
[ 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 a r f i e l d . f r e q u e n c i e s , t i m e s h i f t ) ;
incident plane wave . frequency domain value = X ;
incident plane wave . frequencies = frequency array ;
E t = incident plane wave . E theta ;
E p = incident plane wave . E phi ;
e t a 0 = s q r t ( mu 0 / e p s 0 ) ;
incident plane wave . incident power = . . .
( 0 . 5 / e t a 0 ) * ( E t 2 + E p 2 ) * abs ( X ) 2 ;

fdtd_main

SPIB005-Elsherbeni & Demir

350

October 13, 2009

Scattered Field Formulation

Listing 11.9 calculate farfields per plane


152

154

156

158

160

162

164

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
% 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 ) ) ) . . .
. * ( 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 ) ) ) . . .
. * ( abs ( L t h e t a e t a 0 * Nphi ) . 2 ) ;
else
% c a l c u l a t e r a d a r c r o s s s e c t i o n
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 * i n c i d e n t p l a n e w a v e . i n c i d e n t p o w e r ( mi ) ) ) . . .
. * ( 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 * i n c i d e n t p l a n e w a v e . i n c i d e n t p o w e r ( mi ) ) ) . . .
. * ( abs ( L t h e t a e t a 0 * Nphi ) . 2 ) ;
end

Finally, a section of code is added to subroutine display transient parameters, as shown in


Listing 11.10, to display the waveform of the incident plane wave that would be observed at the
origin. It should be noted that the displayed waveform includes the temporal shift t0 but not the
spatial shift l 0 .
11.5 SIMULATION EXAMPLES

In the previous sections we discussed scattered eld algorithm and demonstrated its implementation using MATLAB programs. In this section we provide examples of scattering problems.
11.5.1 Scattering from a Dielectric Sphere

In this section we present the calculation of the bistatic RCS of a dielectric sphere. Figure 11.4
shows an FDTD problem space including a dielectric sphere illuminated by an x polarized plane
wave traveling in the positive z direction. The problem space is composed of cells with size
x = 0.75 cm, y = 0.75 cm, and z = 0.75 cm. The dielectric sphere radius is 10 cm, relative
Listing 11.10 display transient parameters
101

103

105

107

109

111

113

115

% f i g u r e f o r i n c i d e n t p l a n e wave
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 == t r u e
figure ;
x l a b e l ( time ( ns ) , f o n t s i z e , 1 2 ) ;
y l a b e l ( ( v o l t / meter ) , f o n t s i z e , 1 2 ) ;
title ( Incident electric field , fontsize ,12);
g r i d on ; hold on ;
sampled value theta = incident plane wave . E theta * . . .
i n c i d e n t p l a n e w a v e . waveform ;
sampled value phi = incident plane wave . E phi * . . .
i n c i d e n t p l a n e w a v e . waveform ;
s a m p l e d t i m e = t i m e ( 1 : t i m e s t e p ) * 1 e9 ;
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 t h e t a , b , . . .
sampled time , sampled value phi , r : , l i n e w i d t h , 1 . 5 ) ;
l e g e n d ( E {\ t h e t a , i n c } , E {\ phi , i n c } ) ; drawnow ;
end

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation Examples

14:16

351

Einc
CPML inner boundaries
outer PEC boundaries
Figure 11.4 An FDTD problem space including a dielectric sphere.

permittivity is 3, and relative permeability is 2. The denition of the problem space is shown in
Listing 11.11. The incident plane wave source is dened as shown in Listing 11.12. The waveform
of the plane wave is Gaussian. The output of the FDTD simulation is dened as far eld at 1 GHz,
which indicates that the RCS will be calculated. Furthermore, the x component of the scattered
electric eld at the origin is dened as the output as shown in Listing 11.13.
Listing 11.11 define geometry.m
d i s p ( d e f i n i n g t h e problem g e o m e t r y ) ;
2

bricks = [ ] ;
spheres = [ ] ;
thin wires = [ ] ;

10

12

% define a
spheres ( 1 ) .
spheres ( 1 ) .
spheres ( 1 ) .
spheres ( 1 ) .
spheres ( 1 ) .

sphere
radius =
center x
center y
center z
material

100 e 3;
= 0;
= 0;
= 0;
type = 4;

fdtd_main

SPIB005-Elsherbeni & Demir

352

October 13, 2009

Scattered Field Formulation

Listing 11.12 define sources and lumped elements.m


d i s p ( d e f i n i n g s o u r c e s and lumped e l e m e n t components ) ;
2

voltage sources = [ ] ;
current sources = [ ] ;
diodes = [ ] ;
resistors = [];
inductors = [ ] ;
capacitors = [ ] ;
incident plane wave = [ ] ;

10

12

% 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 ;
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

16

18

20

% Define
incident
incident
incident
incident
incident
incident

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
plane wave . E theta = 1;
plane wave . E phi = 0;
plane wave . theta incident = 0;
plane wave . phi incident = 0;
plane wave . waveform type = gaussian ;
plane wave . waveform index = 1;

Listing 11.13 define output parameters.m


disp ( d e f i n i n g output parameters ) ;
2

10

sampled electric fields = [];


sampled magnetic fields = [ ] ;
sampled voltages = [ ] ;
sampled currents = [ ] ;
ports = [ ] ;
fa r fi e ld . frequencies = [ ] ;
% figure refresh rate
p l o t t i n g s t e p = 10;

12

14

16

18

20

22

24

26

% mode o f o p e r a t i o n
run simulation = true ;
show material mesh = true ;
show problem space = true ;
% 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 ;
f a r f i e l d . number of cells from outer boundary = 13;
% 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 ;
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 ;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation Examples
28

30

32

34

14:16

353

% 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
% 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;
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;
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

40

42

44

46

% define animation
% 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
% 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 ;
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 ;
animation ( 1 ) . plane cut ( 1 ) . p o s i t i o n = 0;
animation ( 1 ) . enable = true ;
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 eld at the origin and the
RCS plots are obtained. Figure 11.5 shows the sampled scattered electric eld 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

(volt/meter)

38

Ex,scat

0.5

0.5

1
0

time (ns)
Figure 11.5 Scattered electric field captured at the origin and the incident field waveform.

10

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

354

Scattered Field Formulation

y
9010
120

60

= 90o
xy plane

20
30

150

30

40

x
0

180

210

330

240

300

dB

270

RCS, f=1 GHz


RCS , f=1 GHz

Figure 11.6 Bistatic RCS at 1 GHz in the x y plane.

30

z
00

30

= 0o
xz plane

10
20

60

60

30
x
90

90

120

120

150

dB

150
180

RCS , f=1 GHz

RCS, f=1 GHz


Figure 11.7 Bistatic RCS at 1 GHz in the x z plane.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation Examples

355

30

z
0

30

= 90o
yz plane

10
20

60

60

30
y
90

90

120

1 20

1 50

dB

150
180

RCS , f=1 GHz

RCS, f=1 GHz


Figure 11.8 Bistatic RCS at 1 GHz in the yz plane.

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 dened as an output. The scattered electric eld 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.

11.5.2 Scattering from a Dielectric Cube

In the previous section calculation of the bistatic RCS of a dielectric sphere is presented. In this
section we present calculation of the RCS of a cube using the FDTD method and comparison with
results obtained by a method of moments (MoM) solver [42]. In Fig. 11.12 the FDTD problem
space including a dielectric cube is illustrated. In the same gure the triangular meshing of the
surface of the cube used by the MoM solver is shown as well.
The FDTD problem space is composed of cubic cells 0.5 cm on a side. The denition of
the problem geometry is shown in Listing 11.14. Each side of the cube is 16 cm. The relative
permittivity of the cube is 5, and the relative permeability is 1. The incident plane wave is dened
as shown in Listing 11.15. The incident plane wave illuminating the cube is polarized and

14:16

SPIB005-Elsherbeni & Demir

October 13, 2009

356

Scattered Field Formulation

0
exact
FDTD
5

[dB]

10

15

20

25

30
0

20

40

60

80
100
o
o
, [ =0]

120

140

160

180

Figure 11.9 Calculated RCS at 1 GHz in the x z plane compared with the analytical solution.

0
exact
FDTD
5

10
[dB]

fdtd_main

15

20

25

30
0

20

40

60

80
100
o
o
, [ =90]

120

140

160

180

Figure 11.10 Calculated RCS at 1 GHz in the yz plane compared with the analytical solution.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation Examples

357

(a) At time step 120

(b) At time step 140

(c) At time step 160

(d) At time step 180

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-eld output is dened at 1 GHz as shown in Listing 11.16. Finally, a
sampled electric eld is dened at the origin to observe whether the elds in the problem space
are sufciently decayed.
After the FDTD time-marching loop is completed, the far-eld 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.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

358

Scattered Field Formulation

Geometry simulated by MoM

Einc
Geometry simulated by FDTD

Figure 11.12 An FDTD problem space including a cube, and the surface mesh of the cube used by the MoM
solver.

11.5.3 Reflection and Transmission Coefficients of a Dielectric Slab

Chapter 8 demonstrated that the objects with innite length can be simulated by letting the objects
penetrate into the convolutional perfectly matched layer (CPML) boundaries. In this example
we show the simulation of a dielectric slab, which is essentially a one-dimensional problem. The
availability of incident plane wave allows us to calculate the reection and transmission coefcients
of the slab.
Listing 11.14 define geometry.m
1

11

13

d i s p ( d e f i n i n g t h e problem g e o m e t r y ) ;
bricks = [ ] ;
spheres = [ ] ;
thin wires = [ ] ;
% define d i e l e c t r i c
b r i c k s ( 1 ) . m i n x = 80e 3;
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;
b r i c k s ( 1 ) . max x = 80 e 3;
b r i c k s ( 1 ) . max y = 80 e 3;
b r i c k s ( 1 ) . max z = 80 e 3;
bricks ( 1 ) . material type = 4;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation Examples

14:16

359

y
900
120

60
10
20

150

= 90o
xy plane
30

30

x
0

180

210

330

240

dB

300
270

RCS, f=1 GHz


RCS, f=1 GHz

Figure 11.13 Bistatic RCS at 1 GHz in the x y plane.

Listing 11.15 define sources and lumped elements.m



d i s p ( d e f i n i n g s o u r c e s and lumped e l e m e n t components ) ;
2

voltage sources = [ ] ;
current sources = [ ] ;
diodes = [ ] ;
resistors = [];
inductors = [ ] ;
capacitors = [ ] ;
incident plane wave = [ ] ;

10

12

% 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 ;
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

16

18

20

% Define
incident
incident
incident
incident
incident
incident

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
plane wave . E theta = 1;
plane wave . E phi = 0;
plane wave . t h e t a i n c i d e n t = 45;
plane wave . phi incident = 30;
plane wave . waveform type = gaussian ;
plane wave . waveform index = 1;

fdtd_main

SPIB005-Elsherbeni & Demir

360

October 13, 2009

Scattered Field Formulation

Listing 11.16 define output parameters.m


disp ( d e f i n i n g output parameters ) ;
2

10

sampled electric fields = [];


sampled magnetic fields = [ ] ;
sampled voltages = [ ] ;
sampled currents = [ ] ;
ports = [ ] ;
fa r fi e ld . frequencies = [ ] ;
% figure refresh rate
p l o t t i n g s t e p = 10;

12

14

16

18

20

22

24

% mode o f o p e r a t i o n
run simulation = true ;
show material mesh = true ;
show problem space = true ;
% 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 ;
f a r f i e l d . number of cells from outer boundary = 13;
% 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 ;
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

30

32

34

% 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
% 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;
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;
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 eld traveling in the positive z direction. Two sampled
electric elds are dened to capture the x component of the electric eld at two points, each 5 cm
away from the slabone below the slab and the other above the slab as illustrated in Fig. 11.18.
The denition of the problem space boundary conditions, incident eld, the slab, and the sampled
electric elds are shown in Listings 11.17, 11.18, 11.19, and 11.20, respectively. Notice that the
CPML parameters has been modied for better performance.
In the previous sections scattered eld formulation has been demonstrated for calculating the
scattered eld when an incident eld is used to excite the problem space. The sampled electric eld
therefore is the one being captured while the simulation is running. The reected eld from the
slab is the scattered eld, and the ratio of the reected eld to incident eld is required to calculate

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation Examples

361

30

z
0

30

= 0o
xz plane

10
20

60

60

30
x
90

90

120

120

150

150

dB

180

RCS, f=1 GHz


RCS, f=1 GHz

Figure 11.14 Bistatic RCS at 1 GHz in the x z plane.

30

z
00

30

= 90
yz plane

10
20

60

60

30
y
90

90

120

120

150

dB

150
180

RCS, f=1 GHz


RCS , f=1 GHz

Figure 11.15 Bistatic RCS at 1 GHz in the yz plane.

14:16

SPIB005-Elsherbeni & Demir

October 13, 2009

362

Scattered Field Formulation

0
MoM
FDTD

2
4

RCS [dB]

6
8
10
12
14
16
18
20
0

20

40

60

80
100
o
o
, [ =0]

120

140

160

180

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]

fdtd_main

15

20

25

30
0

20

40

60

80
100
o , [o=90]

120

140

160

Figure 11.17 Calculated RCS at 1 GHz in the x z plane compared with the MoM solution.

180

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation Examples

363

Sample electric
field point 2
dielectric
slab

Sample electric
field point 1

z
y

outer PEC boundaries


CPML inner boundaries

Einc

Figure 11.18 An FDTD problem space including a dielectric slab.

the reection coefcient using


|| =

| Escat |
,
| Einc |

(11.23)

where  is the reection coefcient. Here the scattered eld is the one sampled at a point below
the slab, and the incident eld 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 eld as the time-marching loop proceeds.
The ratio of the transmitted eld to incident eld is required to calculate the transmission
coefcient, where the transmitted eld is the total eld that is the sum of the incident and scattered
elds. Then the transmission coefcient can be calculated using
|T| =

| Escat + Einc |
| Etot |
=
,
| Einc |
| Einc |

(11.24)

where T is the transmission coefcient. Here the scattered eld is the one sampled at a point
above the slab, and the incident eld is sampled at the same point as well.
Listing 11.17 define problem space parameters.m
18

20

22

%
%
%
%
%
%

==<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
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
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 ;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

364
26

October 13, 2009

Scattered Field Formulation

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

30

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 = 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

34

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 ;
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

38

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 ;
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

42

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 = 10;
boundary . c p m l n u m b e r o f c e l l s z n = 8 ;

44

46

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 = 10;
boundary . c p m l n u m b e r o f c e l l s z p = 8 ;

48

50

52

boundary . cpml
boundary . c p m l
boundary . cpml
boundary . cpml
boundary . cpml

order = 4;
sigma factor = 1;
kappa max = 1 ;
alpha min = 0;
alpha max = 0;

Listing 11.18 define geometry.m


8

10

12

14

% define d i e l e c t r i c
b r i c k s ( 1 ) . m i n x = 0.05;
b r i c k s ( 1 ) . mi n y = 0.05;
b r i c k s ( 1 ) . min z = 0 ;
b r i c k s ( 1 ) . max x = 0 . 0 5 ;
b r i c k s ( 1 ) . max y = 0 . 0 5 ;
b r i c k s ( 1 ) . max z = 0 . 2 ;
bricks ( 1 ) . material type = 4;

Listing 11.19 define sources and lumped elements.m


12

14

16

18

20

% 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 . 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;
% Define
incident
incident
incident
incident
incident
incident

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
plane wave . E theta = 1;
plane wave . E phi = 0;
plane wave . theta incident = 0;
plane wave . phi incident = 0;
plane wave . waveform type = d e r i v a t i v e g a u s s i a n ;
plane wave . waveform index = 1;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Simulation Examples

14:16

365

Listing 11.20 define output parameters.m


19

21

23

25

27

29

% 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 e6 ;
f r e q u e n c y d o m a i n . end
= 2 e9 ;
f r e q u e n c y d o m a i n . s t e p = 1 e6 ;
% 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
% 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;
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;
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

33

35

sampled
sampled
sampled
sampled
sampled

electric
electric
electric
electric
electric

fields
fields
fields
fields
fields

(2).
(2).
(2).
(2).
(2).

x = 0;
y = 0;
z = 0.225;
component = x ;
display plot = false ;

The simulation for this problem is executed, the incident and scattered elds are captured at
two points above and below the slab and transformed to frequency domain, and the reection and
transmission coefcients are calculated using (11.23) and (11.24), respectively. The calculation
results are plotted in Fig. 11.19 together with the exact solution of the same problem. The exact
Listing 11.21 capture sampled electric fields.m
25

27

29

% Capturing the i n c i d e n t e l e c t r i c f i e l d s
i f i n c i d e n t p l a n e w a v e . enabled
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 = s a m p l e d e l e c t r i c f i e l d s ( ind ) . i 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 ) . j s ;
ks = s a m p l e d e l e c t r i c f i e l d s ( ind ) . ks ;
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
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
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
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
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 ) ) ;
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 ) ;
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 ) . . .
= sampled value ;

31

33

35

37

39

41

43

45

end
47

end

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

366

Scattered Field Formulation

0.8

0.6

0.4
|| FDTD
|T| FDTD
|| exact
|T| exact

0.2

0
0

0.2

0.4
0.6
frequency (GHz)

0.8

Figure 11.19 Reflection and transmission coefficients of the dielectric slab.

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 eld traveling in the positive z direction. In the
given example the direction of incidence is dened 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 dielectric sphere is calculated due to an incident eld. The RCS calculations are based on
the scattered elds; the ctitious electric and magnetic current densities used for NFFF
transformation are calculated using the scattered eld electric and magnetic elds. The
total eld in the problem space is the sum of the incident eld and the scattered eld.
Modify the program such that the RCS calculations are performed based on the total elds
rather than on the scattered elds. 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
eld does not contribute to far-eld scattering at all.

11.3

Consider the dielectric slab problem demonstrated in Section 11.5.3. You can perform the
reection and transmission coefcient calculation for stacked slabs composed of multiple
layers with different dielectric constants. For instance, create two slabs in the problem

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

Exercises

October 13, 2009

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 reection
and transmission coefcients. 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 eld formulation to solve the same problem.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

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 specically 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

14:16

SPIB005-Elsherbeni & Demir

October 13, 2009

370

Graphics Processing Unit Acceleration of Finite-Difference Time-Domain

Table 12.1 CPU versus GPU feature comparison.


Feature
Clock Speed
Main Memory
Memory Bandwidth
Memory Width
Cache Type

CPU
Quad 3.4 GHz
4 GB
41 GB/s
64 Bit
FIFO (Non-Streaming)

GPU
600 MHz
768 MB
86 GB/s
384 Bit
FILO (Streaming)

at how to relate the various functions available in the graphics card to various computational
electromagnetic applications.
Solvers for electromagnetic simulations based on nite-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

500

CPU Theoretical Max Performance


GPU Theoretical Max Performance

400

GFlops

fdtd_main

300

200

100

0
2003

2004

2005

Year
Figure 12.1 Theoretical maximum processing power of CPUs and GPUs.

2006

2007

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

Graphics Processors and General Math

October 13, 2009

371

solving problems and more efcient 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 specically 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 scientic 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.
12.1 GRAPHICS PROCESSORS AND GENERAL MATH

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 signicant 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, reectivity, roughness). Geometry
objects may be composed of several texture maps combined (e.g., the ball may be red, highly
reective, 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

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

372

October 13, 2009

Graphics Processing Unit Acceleration of Finite-Difference Time-Domain

Streaming

Sequential

Non-streaming

Random Access

Figure 12.2 Streaming versus non-streaming operations.

high-quality graphics, the processing accompanying this must be able to provide high computational 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 parallel, 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 mathematics 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 efciently 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 program 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 multiplication 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

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

Introduction to Brook

October 13, 2009

373

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 t 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 81928192 (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
reected 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 dened 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 operations on the streams. These are usually cross-compiled into a shader language (depending
on the video card) to implement the function in the most efcient possible way.
It should be noted that the fragment processors programmed with the kernel are only capable of
straight mathematical operations. Logical- and program-ow-related operators (e.g., if/then/else,
bitwise operators) cannot be implemented inside a kernel.
To maximize efciency 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 ve 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 ve) 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 elds we can utilize the nature of the eld components (E and H having three
components x, y, and z) to better utilize more of the processing power of the GPU.
12.2 INTRODUCTION TO BROOK

The sample codes introduced in this chapter are implemented using the Brook programming system for GPUs. Brook has been introduced as an extension to the many high-level

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

374

Graphics Processing Unit Acceleration of Finite-Difference Time-Domain

Table 12.2 Brook program flow.


Step
1
2
3
4
5
6

Operation Performed
Constants are dened.
Arrays are created and initialized.
Arrays are passed to GPU streams.
Streams are processed through kernels.
Streams are passed back to arrays.
Data are passed to the output le.

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 ow 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 les and additional examples can also
be found.
Compiling programs under Brook is very simple once it has been installed. Cygwin is a command line shell similar to what is found on most UNIX systems. Setting up new programs to
compile is fairly simple if the Makele in each of the sample directories is examined. The Makele
tells the Cygwin shell in what directories to look for source code and what the names of the source
code les 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.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

Sample Two-Dimensional FDTD Implementation Using Brook

October 13, 2009

14:16

375

Listing 12.1 Example Brook code


kernel void t e s t ( f l o a t a [ ] , f l o a t b [ ] ,
i t e r f l o a t i t <>, o u t f l o a t c <>)
{
c=a [ i t ]+ b [ i t ] ;
}

11

f l o a t a <100>;
f l o a t b<100>;
f l o a t c <100>;
i t e r f l o a t i t <1,98>
test ( a ,b , it , c ) ;

Brook operates by taking a source le 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 identies this particular stream as one that will
be modied 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 identies 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 specied by the iter.
12.3 SAMPLE TWO-DIMENSIONAL FDTD IMPLEMENTATION USING BROOK

The implementation of two-dimensional FDTD simulations is quite straightforward since the


textures (representing the arrays) in the video card are already two-dimensional. It is simply
required to transfer the arrays into the video card and program the shaders to perform the
necessary eld updates. The major part of the program works exactly the same way as any standard C program might for this problem. Constants are initialized, and arrays are created and
lled, but when it comes time to iterate over the time steps the data are passed to the GPU.
This is rst accomplished by creating the appropriately sized streams using commands such as
oat Hy<insize,insize>. The iter is also created specifying the limits of the arrays that will
be operated on. The C arrays are then copied into the GPU streams using commands like
streamRead(Ez, aEz).
A source code for a sample implementation of a two-dimensional GPU FDTD code is provided
with this book. The sample implementation is written so that the domain size and number of
iterations may be entered at runtime. The code requires three runtime parameters to set the

fdtd_main

SPIB005-Elsherbeni & Demir

376

October 13, 2009

Graphics Processing Unit Acceleration of Finite-Difference Time-Domain

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 eld component 10 cells back from the point source for every iteration the code
is run. Ezdata.txt, Hxdata.txt, and Hydata.txt export the nal eld states for each of the three elds
calculated in the code. It is possible to run the simulation for several different number of iterations
and to examine the eld 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 eld. The derivitives
are calculated by the use of an offset term such as oat2 t0 = oat2(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 oat2 type to specify the x and
y location such as Ez[54][60]). By adding another constant that is also a oat2 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 les for use elsewhere.
In part 1 of the sample two-dimensional transverse magnetic (TM) FDTD code the custom
GPU kernels are dened for the eld computations needed to be performed. For this sample three
kernels are dened: one to do the calculations on the H elds, one for the E elds, and one to
facilitate the extraction of eld points for postprocessing. The rst part of each kernel denes the
variables that is passed to it and also the variables that are sent out of it. The dimensionality of
each variable is dened 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, rst the CPML portions are calculated and updated, and then the
actual eld components with the CPML are calculated and updated. The last kernel is used to
copy one stream to another and to extract eld 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 dened. 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 dened at runtime through command line arguments.
The values of many of the constants and variables are also written to a text le 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 coefcients as well. In addition, a perfect electric conductor (PEC) boundary is dened
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

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

Extension to Three-Dimensional

October 13, 2009

377

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 coefcients 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 dened 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 dened 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 elds 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 rst time step the old elds are dened 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 le. 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 le for later examination.
The last section transfers the nal values of the elds back to the CPU and then writes them to
les. 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 200200 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 10001000 domain for several different graphics cards. Listings 12.2 to 12.8 are
provided for the reader as one Brook program titled tm2d.br.
12.4 EXTENSION TO THREE-DIMENSIONAL

Efcient 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 higherorder absorbing boundaries. Furthermore, this problem becomes more complicated for threedimensional 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

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

378

October 13, 2009

Graphics Processing Unit Acceleration of Finite-Difference Time-Domain


100 time steps

150 time steps

1000 time steps


250 time steps

Figure 12.3 Sample TM2D with CPML E z data at various time steps.

axis. This is the simplest form of translation from three-dimensional to two-dimensional as it


only requires minor changes in programming to implement. In the two-dimensional example
presented previously the spatial offsets in x and y were simple to understand. For this translated
three-dimensional structure the same idea follows, but instead of having a third (z) offset, to move
up and down in the z direction one has to add or subtract the number of cells in the y direction
from the current value of y.
Once the CPML type absorbing boundaries are added, care must be taken in understanding
how the domain is laid out to ensure proper operation. Figure 12.7 shows where the boundaries
would be for a CPML boundary. This gure shows where the boundaries are located in each
of the x, y, and z directions. The x and z directional boundaries are quite self-explanatory, but
the y boundaries are more complex. Since the z layers are sliced and laid out edge to edge,
the y boundaries are located throughout the computational domain. It is due to this fact that the
CPML elds must be calculated for the entire computational domain since the boundaries are
scattered. While no CPML eld expressions normally exist within the internal portion of the
computational domain, they are still calculated to simplify the GPU implementation. Thus,
the CPML coefcients should be zero in the internal computational domain. This leads to no

14:16

SPIB005-Elsherbeni & Demir

October 13, 2009

Three-Dimensional Parameter Exploration

379

20

10

Ez Value

fdtd_main

-10

-20

-30

-40

100

200

300

400

500
time steps

600

700

800

900

1000

Figure 12.4 TM2D with CPML E z value at observation point.

signicant difculties while performing three-dimensional simulations of CPML type absorbing


boundaries on GPU cards. Details of this implementation can be found in [51].

12.5 THREE-DIMENSIONAL PARAMETER EXPLORATION

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 lters 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 nal design. However, until the design has been simulated, the nal 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 rst example of this application of the GPU-based FDTD method is the simulation of
the basic rectangular patch antenna. For this example, the conguration 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

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

380

Graphics Processing Unit Acceleration of Finite-Difference Time-Domain


70
DirectX 9.0c-ATI x1900
DirectX 9.0c-ATI x800
DirectX 9.0c-ATI 9550

60

speedup factor

50

40

30

20

10

500

1000

1500

2000
Iterations

2500

3000

3500

4000

Figure 12.5 TM2D with CPML speedup factors.

Listing 12.2 Brook code for two-dimensional TM simulationpart 1.



1

/ / GPU F u n c t i o n F o r H F i e l d s
k e r n e l v o i d p r o c e s s f i e l d H ( f l o a t Hx [ ] [ ] , f l o a t Chxh [ ] [ ] ,
f l o a t Chxe [ ] [ ] , f l o a t Hy [ ] [ ] ,
f l o a t Chyh [ ] [ ] ,
f l o a t Chye [ ] [ ] , f l o a t E z [ ] [ ] ,
f l o a t Khx [ ] , f l o a t Khy [ ] ,
f l o a t Bhx [ ] , f l o a t Bhy [ ] , f l o a t Chx [ ] , f l o a t Chy [ ] ,
f l o a t psiHxy [ ] [ ] , f l o a t psiHyx [ ] [ ] ,
f l o a t dx , f l o a t dy ,
i t e r f l o a t 2 i t <>,
o u t f l o a t o Hx <>, o u t f l o a t o Hy <>,
o u t f l o a t o p s i H x y <>, o u t f l o a t o p s i H y x <> )

11

{
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

19

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 ] ) ) ;
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 ] ) ) ;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Three-Dimensional Parameter Exploration

14:16

381

o p s i H x y =p x y ;
o p s i H y x =p y x ;

21

23

o Hx
25

o Hy
27

29

= ( Chxh [ i t ] * Hx [ i t ]
( E z [ i t +t 0 ] E z [ i t ] ) )
= ( Chyh [ i t ] * Hy [ i t ]
( E z [ i t +t 1 ] E z [ i t ] ) )

) + ( Khy [
+ ( Chxe [
) + ( Khx [
+ ( Chye [

it
it
it
it

.y]
] *
.x]
] *

* Chxe [ i t ] / dy *
pxy ) ;
* Chye [ i t ] / dx *
pyx ) ;

31

33

35

37

39

41

/ / GPU F u n c t i o n F o r E F i e l d s
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 [ ] [ ] ,
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 [ ] ,
f l o a t Cex [ ] , f l o a t Cey [ ] ,
float psiEzx [ ] [ ] , float psiEzy [ ] [ ] ,
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 <>,
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 ] ) ) ;
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 ] ) ) ;

51

o p s i E z x =p z x ;
o p s i E z y =p z y ;

53

55

o Ez
57

59

61

= ( Ceze [ i t ] * Ez [ i t ] )
( Hy [ i t ]Hy [ i t +t 1 ] ) )
( Hx [ i t ]Hx [ i t +t 0 ] ) )
( Cezh [ i t ] * pzx ) +

+ ( Kex [ i t . x ] * ( C e z h [ i t ] / dx ) *
+ ( Key [ i t . y ] * ( C e z h [ i t ] / dy ) *
( Cs [ i t ]* gauss ) +
( Cezh [ i t ] * pzy ) ;

63

65

/ / 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
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

69

output = input ;

fdtd_main

SPIB005-Elsherbeni & Demir

382

October 13, 2009

Graphics Processing Unit Acceleration of Finite-Difference Time-Domain

Listing 12.3 Brook code for two-dimensional TM simulationpart 2.


i n t main ( i n t a r g c , c h a r * a r g v [ ] ) {

10

12

14

16

18

20

22

// I n i t i a l i z e Variables
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;
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 ;
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 ;
f l o a t * t =NULL ;
f l o a t * g a u s s=NULL ;
f l o a t * o u t p u t P o r t =NULL ;
float *
float *
float *
float *
float *
float *
float *
float *
float *
float *

aHx=NULL ;
aHy=NULL ;
a E z=NULL ;
a C e z e=NULL ;
aChxh=NULL ;
aChyh=NULL ;
a C e z h=NULL ;
a C h x e=NULL ;
a C h y e=NULL ;
a C s=NULL ;

24

26

f l o a t * o u t p u t E z = NULL ;
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 *
float *
float *
float *

aKex=NULL ;
aKey=NULL ;
aKhx=NULL ;
aKhy=NULL ;

float *
float *
float *
float *

a b e x=NULL ;
abey=NULL ;
a c e x=NULL ;
a c e y=NULL ;

42

float *
float *
float *
float *

abhx=NULL ;
abhy=NULL ;
a c h x=NULL ;
a c h y=NULL ;

44

f l o a t * a p s i =NULL ;

30

32

34

36

38

40

46

48

50

FILE * pFile ;
FILE * pFile2 ;
FILE * pFile3 ;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

Three-Dimensional Parameter Exploration

52

/ / Define Constants
pi =3.14159265;
c = 2 . 9 9 8 e8 ;

54

56

58

60

62

64

66

68

70

72

74

76

78

80

82

84

86

88

90

92

94

/ / 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
/ / problems with c e r t a i n c o m p l i e r s
eps0 =8.854;
e p s 0=e p s 0 * 1 e 6;
e p s 0=e p s 0 * 1 e 6;
mu0= 4 * p i ;
mu0= mu0 * 1 e 4;
mu0= mu0 * 1 e 3;
/ / D e f i n e dx & dy
dx=1e 3;
dy=1e 3;
dx2 = ( 1 / dx ) * ( 1 / dx ) ;
dy2 = ( 1 / dy ) * ( 1 / dy ) ;
/ / 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
/ / By r u n t i m e a r g u m e n t s
N = atoi ( argv [ 1 ] ) ;
x s i z e = atoi ( argv [ 2 ] ) ;
y s i z e = atoi ( argv [ 3 ] ) ;
nx =( i n t ) x s i z e ;
ny =( i n t ) y s i z e ;
dfactor =.9;
d t = ( 1 / ( c * s q r t ( dx2 + dy2 ) ) ) * d f a c t o r ;
c e=d t / ( 2 * e p s 0 ) ;
/ / D e f i n e s o u r c e waveform c o n s t a n t s
Nc =25;
t a u =( Nc * d t ) / ( 2 * s q r t ( 2 . 0 ) ) ;
t0 =4.5* tau ;
fmax = 1 / ( t a u ) ;
/ / D e f i n e PML C o n s t a n t s
iPML =10;
kappa =8;
m=4;
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 ) ;
amax = ( fmax / 2 . 1 ) * 2 * p i * ( e p s 0 / 1 0 ) ;

100

/ / P r i n t out C o n s t a n t s for Checking


p F i l e = fopen ( " I n p u t D a t a . t x t " , " wt " ) ;
f p r i n t f ( p F i l e , " p i=% f e p s 0=%e mu0=%e c=% f \n " , p i , eps0 , mu0 , c ) ;
f p r i n t f ( p F i l e , " dx=%e dy=%e dx2=%e dy2=%e \n " , dx , dy , dx2 , dy2 ) ;
f p r i n t f ( p F i l e , " d t=%e t a u=%e t 0 =%e \n " , dt , tau , t 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

96

98

October 13, 2009

383

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

384

Graphics Processing Unit Acceleration of Finite-Difference Time-Domain


/ / S e t a t Runtime
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 ) ) ;
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 ) ) ;

104

106

aHx=
aHy=
a E z=
a C e z e=
aChxh=
aChyh=
a C e z h=
a C h x e=
a C h y e=
a C s=
o u t p u t E z=
o u t p u t H x=
o u t p u t H y=

108

110

112

114

116

118

120

122

124

126

128

130

(
(
(
(
(
(
(
(
(
(
(
(
(

float
float
float
float
float
float
float
float
float
float
float
float
float

* ) malloc
* ) malloc
* ) malloc
* ) malloc
* ) malloc
* ) malloc
* ) malloc
* ) malloc
* ) malloc
* ) malloc
* ) malloc
* ) malloc
* ) malloc

(
(
(
(
(
(
(
(
(
(
(
(
(

xsize * ysize * sizeof


xsize * ysize * sizeof
xsize * ysize * sizeof
xsize * ysize * sizeof
xsize * ysize * sizeof
xsize * ysize * sizeof
xsize * ysize * sizeof
xsize * ysize * sizeof
xsize * ysize * sizeof
xsize * ysize * sizeof
xsize * ysize * sizeof
xsize * ysize * sizeof
xsize * ysize * sizeof

/ / PML
aKex =
aKhx =
aKey =
aKhy =

Arrays
( float
( float
( float
( float

* ) malloc
* ) malloc
* ) malloc
* ) malloc

(
(
(
(

xsize * sizeof
xsize * sizeof
ysize * sizeof
ysize * sizeof

(
(
(
(

float
float
float
float

));
));
));
));

abex
abhx
abey
abhy

=
=
=
=

(
(
(
(

float
float
float
float

* ) malloc
* ) malloc
* ) malloc
* ) malloc

(
(
(
(

xsize * sizeof
xsize * sizeof
ysize * sizeof
ysize * sizeof

(
(
(
(

float
float
float
float

));
));
));
));

acex
achx
acey
achy

=
=
=
=

(
(
(
(

float
float
float
float

* ) malloc
* ) malloc
* ) malloc
* ) malloc

(
(
(
(

xsize * sizeof
xsize * sizeof
ysize * sizeof
ysize * sizeof

(
(
(
(

float
float
float
float

));
));
));
));

(
(
(
(
(
(
(
(
(
(
(
(
(

float
float
float
float
float
float
float
float
float
float
float
float
float

));
));
));
));
));
));
));
));
));
));
));
));
));

132

134

136

138

apsi = ( f l o a t * ) malloc ( x s i z e * y s i z e * 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

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Three-Dimensional Parameter Exploration

Listing 12.4 Brook code for two-dimensional TM simulationpart 3.


1

/ / P r e c a l c u t e input pulse
t [0]= dt ;
gauss [0]=0;

f o r ( i =1; i <N ; i ++) {


t [ i ]= t [ i 1]+ d t ;
g a u s s [ i ]= exp ( ( ( ( t [ i ] t 0 ) * ( t [ i ] t 0 ) ) / ( t a u * t a u ) ) ) ;
}

11

13

/ / Define E x t e r i o r Size
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

19

21

23

25

/ / 1D X A r r a y s
f o r ( i =0; i <nx ; i ++) {
aKex [ i ] = 1 ;
aKhx [ i ] = 1 ;
abex [ i ] = 0 ;
abhx [ i ] = 0 ;
acex [ i ]=0;
achx [ i ]=0;
}

27

29

31

33

35

/ / 1D Y A r r a y s
f o r ( i =0; i <ny ; i ++) {
aKey [ i ] = 1 ;
aKhy [ i ] = 1 ;
abey [ i ] = 0 ;
abhy [ i ] = 0 ;
acey [ i ]=0;
achy [ i ]=0;
}

37

39

41

43

45

47

49

/ / 2D A r r a y s
f o r ( j =0; j <ny ; j ++) {
f o r ( i =0; i <nx ; i ++) {
aHy [ nx * j + i ] = 0 ;
aHx [ nx * j + i ] = 0 ;
a E z [ nx * j + i ] = 0 ;
a C s [ nx * j + i ] = 0 ;
a C e z e [ nx * j + i ] = 1 . 0 ;
aChxh [ nx * j + i ] = 1 . 0 ;
aChyh [ nx * j + i ] = 1 . 0 ;
a C e z h [ nx * j + i ] = ( d t / e p s 0 ) ;
a C h x e [ nx * j + i ] = ( d t / mu0 ) ;
a C h y e [ nx * j + i ] = ( d t / mu0 ) ;

385

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

386

Graphics Processing Unit Acceleration of Finite-Difference Time-Domain

51

53

55

a p s i [ nx * j + i ] = 0 ;

/ / 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

f o r ( j =0; j <ny ; j ++) {


f o r ( i =0; i <nx ; i ++) {
a C e z e [ nx * j + i ] = ( 1 ( c e * 1 e30 ) ) / ( 1 + ( c e * 1 e30 ) ) ;
a C e z h [ nx * j + i ] = ( ( 2 * c e ) / ( 1 + ( c e * 1 e30 ) ) ) ;
}
}

59

61

63

65

67

69

f o r ( j =2; j <ny 2; j ++) {


f o r ( i =2; i <nx 2; i ++) {
a C e z e [ nx * j + i ] = 1 . 0 ;
a C e z h [ nx * j + i ] = ( d t / e p s 0 ) ;
}
}

Listing 12.5 Brook code for two-dimensional TM simulationpart 4.


2

/ / I n i t i a l i z e PML B o u n d a r i e s
f o r ( i =1; i <1+iPML ; i ++) {
i i =( f l o a t ) i ;
i i =(1+ iPML ) i i ;

10

s i g 1 =pow ( ( ( i i 0 . 5 ) / iPML ) ,m) * s i g m a x ;


s i g 2 =(mu0 / e p s 0 ) * pow ( ( ( i i ) / iPML ) ,m) * s i g m a x ;
a1=pow ( ( ( iPML ( i i 1 + . 5 ) ) / iPML ) ,m) * amax ;
a2 =(mu0 / e p s 0 ) * pow ( ( ( iPML ( i i 1 ) ) / iPML ) ,m) * amax ;

12

14

16

k1 =1+( kappa 1) * pow ( ( ( i i 0 . 5 ) / iPML ) ,m ) ;


k2 =1+( kappa 1) * pow ( ( ( i i ) / iPML ) ,m ) ;
aKex [ i +1]=1/ k1 ;
aKhx [ i ] = 1 / k2 ;

18

20

22

24

aKex [ nxi 1]=1/ k1 ;


aKhx [ nxi 1]=1/ k2 ;
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 ) ) ) *
( exp ( ( d t / e p s 0 ) * ( ( s i g 1 / k1 )+ a1 ) ) 1 ) ;

26

28

30

a b e x [ nxi 1]= exp ( ( d t / e p s 0 ) * ( ( s i g 1 / k1 )+ a1 ) ) ;


a c e x [ nxi 1 ] = ( ( s i g 1 / dx ) / ( ( s i g 1 * k1 ) + ( a1 * k1 * k1 ) ) ) *
( exp ( ( d t / e p s 0 ) * ( ( s i g 1 / k1 )+ a1 ) ) 1 ) ;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Three-Dimensional Parameter Exploration

14:16

387

abhx [ i ]= exp ( ( d t / mu0 ) * ( ( s i g 2 / k2 )+ a2 ) ) ;


a c h x [ i ] = ( ( s i g 2 / dx ) / ( ( s i g 2 * k2 ) + ( a2 * k2 * k2 ) ) ) *
( exp ( ( d t / mu0 ) * ( ( s i g 2 / k2 )+ a2 ) ) 1 ) ;

32

34

abhx [ nxi 1]= exp ( ( d t / mu0 ) * ( ( s i g 2 / k2 )+ a2 ) ) ;


a c h x [ nxi 1 ] = ( ( s i g 2 / dx ) / ( ( s i g 2 * k2 ) + ( a2 * k2 * k2 ) ) ) *
( exp ( ( d t / mu0 ) * ( ( s i g 2 / k2 )+ a2 ) ) 1 ) ;

36

38

aKey [ i +1]=1/ k1 ;
aKhy [ i ] = 1 / k2 ;

40

aKey [ nyi 1]=1/ k1 ;


aKhy [ nyi 1]=1/ k2 ;

42

44

abey [ i +1]= exp ( ( d t / e p s 0 ) * ( ( s i g 1 / k1 )+ a1 ) ) ;


a c e y [ i + 1 ] = ( ( s i g 1 / dx ) / ( ( s i g 1 * k1 ) + ( a1 * k1 * k1 ) ) ) *
( exp ( ( d t / e p s 0 ) * ( ( s i g 1 / k1 )+ a1 ) ) 1 ) ;

46

48

abey [ nyi 1]= exp ( ( d t / e p s 0 ) * ( ( s i g 1 / k1 )+ a1 ) ) ;


a c e y [ nyi 1 ] = ( ( s i g 1 / dx ) / ( ( s i g 1 * k1 ) + ( a1 * k1 * k1 ) ) ) *
( exp ( ( d t / e p s 0 ) * ( ( s i g 1 / k1 )+ a1 ) ) 1 ) ;

50

52

abhy [ i ]= exp ( ( d t / mu0 ) * ( ( s i g 2 / k2 )+ a2 ) ) ;


a c h y [ i ] = ( ( s i g 2 / dx ) / ( ( s i g 2 * k2 ) + ( a2 * k2 * k2 ) ) ) *
( exp ( ( d t / mu0 ) * ( ( s i g 2 / k2 )+ a2 ) ) 1 ) ;

54

56

58

60

abhy [ nyi 1]= exp ( ( d t / mu0 ) * ( ( s i g 2 / k2 )+ a2 ) ) ;


a c h y [ nyi 1 ] = ( ( s i g 2 / dx ) / ( ( s i g 2 * k2 ) + ( a2 * k2 * k2 ) ) ) *
( exp ( ( d t / mu0 ) * ( ( s i g 2 / k2 )+ a2 ) ) 1 ) ;

62

64

66

/ / 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 )
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
// This places a rectangular scattering
/ / D i e l e c t r i c box 10 c e l l s from t h e p o i n t s o u r c e
/ / T h a t i s 16 c e l l s wide and 10 C e l l s Deep

70

72

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 ++) {
a C e z e [ nx * j + i ] = 1 ;
a C e z h [ nx * j + i ] = ( 2 * c e ) / ( 1 0 . 2 ) ;
}
}

74

76

78

80

f p r i n t f ( p F i l e , " C e z h=%e Chxe=%e \n " , a C e z h [ 1 0 ] , a C h x e [ 1 0 ] ) ;

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

388

Graphics Processing Unit Acceleration of Finite-Difference Time-Domain

Listing 12.6 Brook code for two-dimensional TM simulationpart 5.


2

/ / B e g i n Code t o I n i t i a l i z e and Use GPU


{
/ / Set the l i m i t s of the c a l c u l a t i o n s to the i n t e r i o r points
i t e r f l o a t 2 i t <i n s i z e y , i n s i z e x > = i t e r ( f l o a t 2 ( 0 . 0 f , 0 . 0 f ) ,
float2 ( ( float ) insizex , ( float ) insizey ) ) ;

10

12

14

16

18

20

22

24

26

/ / I n i t i a l i z e the streams
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 >;
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 >;
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 >;
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 >;
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 >;
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 >;
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 >;
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
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
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

30

32

34

36

38

40

42

/ / 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
/ / can p r o c e s s them
s t r e a m R e a d ( Ez , a E z ) ;
s t r e a m R e a d ( Hy , aHy ) ;
s t r e a m R e a d ( Hx , aHx ) ;
streamRead ( o Ez , aEz ) ;
s t r e a m R e a d ( o Hy , aHy ) ;
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 ) ;
s t r e a m R e a d ( Chxh , aChxh ) ;
s t r e a m R e a d ( Chyh , aChyh ) ;
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 ) ;
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

46

48

50

s t r e a m R e a d ( Kex ,
s t r e a m R e a d ( Khx ,
s t r e a m R e a d ( Bex ,
s t r e a m R e a d ( Bhx ,
s t r e a m R e a d ( Cex ,
s t r e a m R e a d ( Chx ,

aKex
aKhx
abex
abhx
acex
achx

);
);
);
);
);
);

>;
>;
>;
>;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Three-Dimensional Parameter Exploration

s t r e a m R e a d ( Key ,
s t r e a m R e a d ( Khy ,
s t r e a m R e a d ( Bey ,
s t r e a m R e a d ( Bhy ,
s t r e a m R e a d ( Cey ,
s t r e a m R e a d ( Chy ,

52

54

56

14:16

389

aKey ) ;
aKhy ) ;
abey ) ;
abhy ) ;
acey ) ;
achy ) ;

58

60

62

64

66

streamRead (
streamRead (
streamRead (
streamRead (
streamRead (
streamRead (
streamRead (
streamRead (

psiEzx ,
o psiEzx
psiEzy ,
o psiEzy
psiHxy ,
o psiHxy
psiHyx ,
o psiHyx

apsi ) ;
, apsi
apsi ) ;
, apsi
apsi ) ;
, apsi
apsi ) ;
, apsi

);
);
);
);

Listing 12.7 Brook code for two-dimensional TM simulationpart 6.


1

/ / Open D a t a f i l e F o r O b s e r v a t i o n P o r t
p F i l e 2 = fopen ( " P o r t . t x t " , " wt " ) ;

11

13

15

17

19

21

/ / 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
f o r ( i =0; i <N ; i ++){
/ / 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
i f ( i %2==0) {
p r o c e s s f i e l d H ( Hx , Chxh , Chxe , Hy , Chyh , Chye ,
Ez , Khx , Khy , Bhx , Bhy , Chx , Chy , p s i H x y , p s i H y x ,
dx , dy , i t , o Hx , o Hy , o p s i H x y , o p s i H y x ) ;
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 ,
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 ) ;
/ / Save a s i n g l e Ez point f o r use l a t e r
/ / E z p o i n t i s h e r e i s 10 c e l l s from c e n t e r
Copy ( o E z . domain ( i n t 2 ( ( x s i z e /2) 10 , y s i z e / 2 ) ,
i n t 2 ( ( x s i z e /2) 10 , y s i z e / 2 ) ) , Obs ) ;

23

25

27

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 ] ) ;
} else {

31

p r o c e s s f i e l d H ( o Hx , Chxh , Chxe , o Hy , Chyh , Chye ,


o E z , Khx , Khy , Bhx , Bhy , Chx , Chy , o p s i H x y ,
o p s i H y x , dx , dy , i t , Hx , Hy , p s i H x y , p s i H y x ) ;

33

p r o c e s s f i e l d E z ( o E z , Ceze , Cezh , Hx , Hy , Cs , Kex ,

29

fdtd_main

SPIB005-Elsherbeni & Demir

390

October 13, 2009

Graphics Processing Unit Acceleration of Finite-Difference Time-Domain


Key , Bex , Bey , Cex , Cey , o p s i E z x , o p s i E z y , dx ,
dy , g a u s s [ i ] , i t , Ez , p s i E z x , p s i E z y ) ;

35

/ / Save a s i n g l e Ez point f o r use l a t e r


/ / E z p o i n t i s h e r e i s 10 c e l l s from c e n t e r

37

39

Copy ( E z . domain ( i n t 2 ( ( x s i z e /2) 10 , y s i z e / 2 ) ,


i n t 2 ( ( x s i z e /2) 10 , y s i z e / 2 ) ) , Obs ) ;

41

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 ] ) ;

43

45

}
47

49

f p r i n t f ( p F i l e , " %e %e \n " , g a u s s [ i ] , t [ i ] ) ;

Listing 12.8 Brook code for two-dimensional TM simulationPart 7.


2

/ / Copy t h e p r o p e r s t r e a m s b a c k i n t o C a r r a y s
/ / s o we can o u t p u t them

/ / 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

10

12

14

i f ( i %2==0) {
streamWrite
streamWrite
streamWrite
} else {
streamWrite
streamWrite
streamWrite
}

( Ez , o u t p u t E z ) ;
( Hx , o u t p u t H x ) ;
( Hy , o u t p u t H y ) ;
( o Ez , outputEz ) ;
( o Hx , o u t p u t H x ) ;
( o Hy , o u t p u t H y ) ;

16

18

/ / 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
fclose ( pFile ) ;
fclose ( pFile2 ) ;

20

22

24

26

28

30

32

/ / 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
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 " ) ;
p F i l e 3 = fopen ( " H y d a t a . t x t " , " wt " ) ;
f o r ( j =0; j <ny ; j ++) {
f o r ( i =0; i <nx ; i ++) {
f p r i n t f ( p F i l e , " %e " , o u t p u t E z [ nx * j + i ] ) ;
f p r i n t f ( p F i l e 2 , " %e " , o u t p u t H x [ nx * j + i ] ) ;
f p r i n t f ( p F i l e 3 , " %e " , o u t p u t H y [ nx * j + i ] ) ;
}
fprintf ( pFile ,"\ n " ) ;
fprintf ( pFile2 ,"\ n " ) ;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Three-Dimensional Parameter Exploration


34

36

391

fprintf ( pFile3 ,"\ n " ) ;

// Close Field F il e s
fclose ( pFile ) ;
fclose ( pFile2 ) ;
fclose ( pFile3 ) ;
p r i n t f ( " Program c o m p l e t e \n " ) ;
return 0;

38

40

42

44

14:16

calls the GPU FDTD program and runs the simulation for the requested parameters and time
steps. After the simulation has nished, the GUI performs the postprocessing on the data and
displays the return loss for the selected conguration. In addition to the return loss, the transient 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 interactively 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 postprocessing 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 lter was
chosen from [14]. This is a simple offset microstrip lter 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 lter bar width, spacing of the left feed

Figure 12.6 Simple tiling from three-dimensional structure to two-dimensional texture.

fdtd_main

SPIB005-Elsherbeni & Demir

392

October 13, 2009

Graphics Processing Unit Acceleration of Finite-Difference Time-Domain

Figure 12.7 PML boundaries of a three-dimensional simulation domain in a two-dimensional texture.

Figure 12.8 Example microstrip patch antenna.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

Three-Dimensional Parameter Exploration

Figure 12.9 MATLAB GUI for the microstrip patch antenna.

Figure 12.10 The transient voltage at the input port.

October 13, 2009

393

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

394

October 13, 2009

Graphics Processing Unit Acceleration of Finite-Difference Time-Domain

Figure 12.11 The transient current at the input port.

Figure 12.12 The input port impedance versus frequency.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

Three-Dimensional Parameter Exploration

Figure 12.13 Return loss results for default microstrip patch antenna.

Figure 12.14 Example microstrip filter.

October 13, 2009

395

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

396

October 13, 2009

Graphics Processing Unit Acceleration of Finite-Difference Time-Domain

Figure 12.15 MATLAB GUI for microstrip filter.

arm from the edge of the end of the lter bar, rst 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 lter 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 congurations, and the results
calculated show in seconds on personal computers with modest conguration. Figure 12.16 shows
the results for the default parameters of the microstrip lter. Both the microstrip patch antenna
and the microstrip lter examples executable codes and their corresponding MATLAB GUI are
provided on the CD for further experiments by the reader.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

Three-Dimensional Parameter Exploration

Figure 12.16 Return loss and transmission results for default microstrip filter.

October 13, 2009

397

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

A
One-Dimensional FDTD Code
Listing A.1 MATLAB code for one-dimensional FDTD

2

10

12

%
%
%
%
%
%
%
%

T h i s program d e m o n s t r a t e s a oned i m e n s i o n a l FDTD s i m u l a t i o n .


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
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
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 zd i r e c t e d c u r r e n t d e n s i t y J z ,
which h a s a G a u s s i a n waveform i n t i m e .

% 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;
mu 0 = 4 * p i * 1 e 7;
c
= 1 / s q r t ( mu 0 * e p s 0 ) ;

% p e r m i t t i v i t y of f r e e space
% permeability of f r e e space
% speed of l i g h t

14

16

18

20

% 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
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
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
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

24

26

28

30

32

34

36

38

% Initialize
Ceze
=
Cezhy
=
Cezj
=
Ez
=
Jz
=
eps r z
=
sigma e z =

f i e l d and m a t e r i a l a r r a y s
z e r o s ( nx + 1 , 1 ) ;
z e r o s ( nx + 1 , 1 ) ;
z e r o s ( nx + 1 , 1 ) ;
z e r o s ( nx + 1 , 1 ) ;
z e r o s ( nx + 1 , 1 ) ;
o n e s ( nx + 1 , 1 ) ; % f r e e s p a c e
z e r o s ( nx + 1 , 1 ) ; % f r e e s p a c e

Chyh
Chyez
Chym
Hy
My
mu r y
sigma m y

zeros
zeros
zeros
zeros
zeros
ones
zeros

=
=
=
=
=
=
=

( nx
( nx
( nx
( nx
( nx
( nx
( nx

,1);
,1);
,1);
,1);
,1);
, 1 ) ; % f r e e space
, 1 ) ; % f r e e space
399

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

400

40

42

44

Appendix A One-Dimensional FDTD Code

% 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 ) . . .
. / ( 2 * e p s r z * eps 0 + dt * sigma e z ) ;
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 ) . . .
. / ( 2 * e p s r z * eps 0 + dt * sigma e z ) ;

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 ) ;

48

50

...

52

54

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 ) ;

56

Chym

= ( 2 * d t ) . . .
. / ( 2 * m u r y * mu 0 + d t * s i g m a m y ) ;

58

60

62

64

% D e f i n e t h e G a u s s i a n s o u r c e waveform
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 ) ;
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 ;
% Subroutine to i n i t i a l i z e p l o t t i n g
initialize plotting parameters ;

66

68

% FDTD l o o p
for time step = 1: number of time steps
% 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 ) ;

70

72

% Update m a g n e t i c f i e l d
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 ) )
+ Chym ( 1 : nx ) . * My ( 1 : nx ) ;

74

76

% Update e l e c t r i c f i e l d
E z ( 2 : nx ) = C e z e ( 2 : nx )
+ C e z h y ( 2 : nx )
+ C e z j ( 2 : nx )

78

80

...

. * E z ( 2 : nx ) . . .
. * ( Hy ( 2 : nx ) Hy ( 1 : nx 1 ) )
.*
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
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

84

% Subroutine to p l o t the current s t a t e of the f i e l d s


plot fields ;

86

88

end

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Appendix A One-Dimensional FDTD Code

14:16

401

Listing A.2 initialize plotting parameters


% s u b r o u t i n e u s e d t o i n i t i a l i z e 1D p l o t
2

10

12

14

16

18

20

E z p o s i t i o n s = [ 0 : nx ] * dx ;
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; . . .
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 ] ;
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 ) ;
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 , . ) ;
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 ;
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] ) ;
y l a b e l ( [ A /m] ) ;
z l a b e l ( [ V /m] ) ;
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 ) ;
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 ) ;

Listing A.3 plot fields


1

11

% s u b r o u t i n e u s e d t o p l o t 1D t r a n s i e n t f i e l d s
delete ( lez ) ;
delete ( lhy ) ;
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 , . . .
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 ) ;
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 ] ) ;
drawnow ;

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

B
Convolutional Perfectly
Matched Layer Regions and
Associated Field Updates for a
Three-Dimensional Domain
B.1 UPDATING E X AT CONVOLUTIONAL PERFECTLY MATCHED LAYER (CPML) REGIONS
Initialization

Create new coefcient arrays for Ce xy and Ce xz :


Ce xy = yCe xhz

Ce xz = zCe xhy

Modify the coefcient arrays for Ce xhy and Ce xhz in the CPML regions:


Ce xhz = 1/e y Ce xhz ,

in the

yn

and

Ce xhy = (1/e z ) Ce xhy ,

in the

zn

and

yp
zp

regions.
regions.

Finite-Difference Time-Domain (FDTD) Time-Marching Loop

Update E x in the full domain using the regular updating equation


E xn+1 (i, j, k) = Ce xe (i, j, k) E xn (i, j, k)
 n+ 1

n+ 1
+ Ce xhz (i, j, k) Hz 2 (i, j, k) Hz 2 (i, j 1, k)
 n+ 1

n+ 1
+ Ce xhy (i, j, k) Hy 2 (i, j, k) Hy 2 (i, j, k 1) .
n+ 1

Calculate e xy 2 for the yn and y p regions:


n+ 1
e xy 2 (i,

j, k) =

n 1
b e y e xy 2 (i,


j, k) + a e y
403

n+ 1
Hz 2 (i,


j, k)

Hzn+ (i,

j 1, k) ,

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

404

Appendix B Convolutional Perfectly Matched Layer

(a) E x is updated in yn and yp using ex y

(b) E x is updated in zn and zp using ex z

Figure B.1 CPML regions where E x is updated.

where
ae y =



pe y
 bey 1 ,

2
y pe y e y + e y e y

bey = e



y
pe
+ pe y t

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
ae z =

pe z
 [b e z 1] ,

z pe z e z + e z e2z

bez = e



z
pe
+ pe z t

ez
0

Add the CPML auxiliary term to E x in the yn and y p regions:


n+ 1

E xn+1 = E xn+1 + Ce xy e xy 2 .
Add the CPML auxiliary term to E x in the zn and zp regions:
n+ 1

E xn+1 = E xn+1 + Ce xz e xz 2 .

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Appendix B Convolutional Perfectly Matched Layer

405

(a) E y is updated in zn and zp using eyz

(b) E y is updated in x n and x p using eyx

Figure B.2 CPML regions where E y is updated.

B.2 UPDATING E Y AT CPML REGIONS


Initialization

Create new coefcient arrays for Ce y z and Ce y x :


Ce y z = zCe yhx

Ce y x = xCe yhz

Modify the coefcient arrays for Ce yhz and Ce yhx in the CPML regions:
Ce yhx = (1/e z ) Ce yhx ,


Ce yhz = 1/e y Ce yhz ,

in the

zn

and

zp

in the

xn

and

xp

regions.
regions.

FDTD Time-Marching Loop

Update E y in the full domain using the regular updating equation


E yn+1 (i, j, k) = Ce ye (i, j, k) E yn (i, j, k)
 n+ 1

n+ 1
+ Ce yhx (i, j, k) Hx 2 (i, j, k) Hx 2 (i, j, k 1)
 n+ 1

n+ 1
+ Ce yhz (i, j, k) Hz 2 (i, j, k) Hz 2 (i 1, j, k) .
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) ,

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

406

Appendix B Convolutional Perfectly Matched Layer

where
ae z =

pe z
 [b e z 1] ,

z pe z e z + e z e2z

bez = e



z
pe
+ pe z t

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
ae x =

pe 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 .

Add the CPML auxiliary term to E y in the zn and zp regions:


n+ 1

E yn+1 = E yn+1 + Ce y z e y z 2 .
Add the CPML auxiliary term to E y in the xn and xp regions:
n+ 1

E yn+1 = E yn+1 + Ce y x e y x 2 .
B.3 UPDATING E Z AT CPML REGIONS
Initialization

Create new coefcient arrays for Ce zx and Ce zy :


Ce zx = xCe zhy

Ce zy = yCe zhx

Modify the coefcient arrays for Ce zhx and Ce zhy in the CPML regions:
Ce zhy = (1/e x ) Ce zhy ,

in the

xn

and

xp

regions.

Ce zhx = (1/e z ) Ce zhx ,

in the

yn

and

yp

regions.

FDTD Time-Marching Loop

Update E z in the full domain using the regular updating equation


 n+ 1

n+ 1
E zn+1 (i, j, k) = 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) .
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) ,

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Appendix B Convolutional Perfectly Matched Layer

407

(a) E z is updated in x n and x p using ezx

(b) E z is updated in yn and yp using ezy

Figure B.3 CPML regions where E z is updated.

where
ae x =

pe 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
e zy 2 (i,

j, k) =

n 1
b e y e zy 2 (i,


j, k) + a e y

n+ 1
Hx 2 (i,

j, k)

n+ 1
Hx 2 (i,

where
ae y =



pe y
 bey 1 ,

2
y pe y e y + e y e y

bey = e



y
pe
+ pe y t

ey
0

Add the CPML auxiliary term to E z in the xn and xp regions:


n+ 1

E zn+1 = E zn+1 + Ce zx e zx 2 .
Add the CPML auxiliary term to E z in the yn and y p regions:
n+ 1

E zn+1 = E zn+1 + Ce zy e zy 2 .


j 1, k) ,

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

408

Appendix B Convolutional Perfectly Matched Layer

(a) H x is updated in yn and yp using hx y

(b) H x is updated in zn and zp using hx z

Figure B.4 CPML regions where H x is updated.

B.4 UPDATING H X AT CPML REGIONS


Initialization

Create new coefcient arrays for Chxy and Chxz :


Chxy = yC hxe z

Chxz = zC hxe y

Modify the coefcient 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

C hxe y = (1/mz ) C hxe y ,

in the

zn

and

yp
zp

regions.
regions.

FDTD Time-Marching Loop

Update Hx in the full domain using the regular updatingequation


n+ 12

Hx

n 12

(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) .

n
Calculate hxy
for the yn and y p regions:



n1
n
hxy
(i, j, k) = b my hxy
(i, j, k) + a my E zn (i, j + 1, k) E zn (i, j, k) ,

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Appendix B Convolutional Perfectly Matched Layer

409

where
a my =



pmy
 b my 1 ,

2
y pmy my + my my

b my = e




pmy
+ pmy t
my

n
Calculate hxz
for the zn and zp regions:



n1
n
hxz
(i, j, k) = b mz hxz
(i, j, k) + a mz E yn (i, j, k + 1) E yn (i, j, k) ,
where
a mz =

pmz
 [b mz 1] ,

2
z pmz mz + mz mz

b mz = e




pmz
+ pmz t
mz

Add the CPML auxiliary term to Hx in the yn and y p regions:


n+ 12

Hx

n+ 12

= Hx

n
+ Chxy hxy
.

Add the CPML auxiliary term to Hx in the zn and zp regions:


n+ 12

Hx

n+ 12

= Hx

n
+ Chxz hxz
.

B.5 UPDATING H Y AT CPML REGIONS


Initialization

Create new coefcient arrays for Chy z and Chy x :


Chy z = zC hye x

Chy x = xC hye z

Modify the coefcient arrays for C hye z and C hye x in the CPML regions:
C hye x = (1/mz ) C hye x ,

in the

zn

and

zp

regions.

C hye z = (1/mx ) C hye z ,

in the

xn

and

xp

regions.

FDTD Time-Marching Loop

Update Hy in the full domain using the regular updating equation


n+ 12

Hy

n 12

(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) .

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

410

Appendix B Convolutional Perfectly Matched Layer

(a) H y is updated in zn and zp using hyz

(b) H y is updated in x n and x p using hyx

Figure B.5 CPML regions where H y is updated.


n
Calculate hy
z for the zn and zp regions:

 n

n1
n
n
hy
z (i, j, k) = b mz hy z (i, j, k) + a mz E x (i, j, k + 1) E x (i, j, k) ,
where
a mz =

pmz
 [b mz 1] ,

2
z pmz mz + mz mz

b mz = e




pmz
+ pmz t
mz

n
Calculate hy
x for the xn and xp regions:

 n

n1
n
n
hy
x (i, j, k) = b mx hy x (i, j, k) + a mx E z (i + 1, j, k) E z (i, j, k) ,
where
a mx =

pmx

 [b mx 1] ,
2
x pmx mx + mx mx

t
pmx +
b mx = e ( mx pmx ) 0 .

Add the CPML auxiliary term to Hy in the zn and zp regions:


n+ 12

Hy

n+ 12

= Hy

n
+ Chy z hy
z.

Add the CPML auxiliary term to Hy in the xn and xp regions:


n+ 12

Hy

n+ 12

= Hy

n
+ Chy x hy
x.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Appendix B Convolutional Perfectly Matched Layer

411

(a) H z is updated in x n and x p using hzx

(b) H z is updated in yn and yp using hzy

Figure B.6 CPML regions where H z is updated.

B.6 UPDATING H Z AT CPML REGIONS


Initialization

Create new coefcient arrays for Chzx and Chzy :


Chzy = xC hze y

Chzy = yC hze x

Modify the coefcient arrays for C hze x and C hze y in the CPML regions:
C hze y = (1/mx ) C hze y ,


C hze x = 1/my C hze x ,

in the

xn

and

xp

regions.

in the

yn

and

yp

regions.

FDTD Time-Marching Loop

Update Hz in the full domain using the regular updating equation


n+ 12

Hz

n 12

(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) .

n
Calculate hzx
for the xn and xp regions:



n1
n
hzx
(i, j, k) = b mx hzx
(i, j, k) + a mx E yn (i + 1, j, k) E yn (i, j, k) ,

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

412

Appendix B Convolutional Perfectly Matched Layer

where
a mx =

pmx
 [b mx 1] ,

2
x pmx mx + mx mx

t
pmx +
b mx = e ( mx pmx ) 0 .

n
Calculate hzy
for the yn and y p regions:



n1
n
hzy
(i, j, k) = b my hzy
(i, j, k) + a my E yn (i, j + 1, k) E yn (i, j, k) ,
where
a my =



pmy
 b my 1 ,

2
y pmy my + my my

b my = e




pmy
+ pmy t
my

Add the CPML auxiliary term to Hz in the xn and xp regions:


n+ 12

Hz

n+ 12

= Hz

n
+ Chzx hzx
.

Add the CPML auxiliary term to Hz in the yn and y p regions:


n+ 12

Hz

n+ 12

= Hz

n
+ Chzy hzy
.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

C
MATLAB Code for Plotting
Far-Field Patterns
Listing C.1 Code for plotting far-field patterns on a constant plane
1

f u n c t i o n p o l a r p l o t c o n s t a n t t h e t a ( phi , p a t t e r n 1 , p a t t e r n 2 ,
max val , s t e p s i z e , number of rings , . . .
line style 1 , line style 2 , constant theta , . . .
legend 1 , legend 2 , s c a l e t y p e )

...

% 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
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 ;

11

13

15

17

hold on ;
th = 0 : ( pi / 5 0 ) : 2 * pi ; c i r c l e x = cos ( th ) ; c i r c l e
f o r mi = 1 : n u m b e r o f r i n g s
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 ,
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
f o n t w e i g h t , demi , f o n t s i z e , 1 0 ) ;
end

y = sin ( th ) ;

linewidth ,1);
,...
,...

19

21

23

25

27

29

31

r =[0:0.1:1];
f o r mi = 0 : 1 1
t h=mi * p i / 6 ;
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 ) ] , . . .
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 ) ;
end
pattern
pattern
pattern
pattern

1
1
2
2

( find ( pattern
= ( pattern 1
( find ( pattern
= ( pattern 2

< min val ) ) =


min val ) / plot
< min val ) ) =
min val ) / plot

min val ;
range ;
min val ;
range ;

33

% transform data to C a r t e s i a n coordinates

413

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

414
35

October 13, 2009

Appendix C MATLAB Code for Plotting Far-Field Patterns

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

39

41

43

45

47

49

51

53

55

57

59

61

63

x2 = p a t t e r n 2 . * c o s ( p h i ) ;
y2 = p a t t e r n 2 . * s i n ( p h i ) ;
% 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 ) ;
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 ] , . . .
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 ) ;
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 , . . .
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 , . . .
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 ) ;
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 , . . .
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 , . . .
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 , . . .
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 , . . .
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 , . . .
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

67

69

a x i s ( [ 1 . 2 1 . 2 1.2 1 . 2 ] ) ;
a x i s ( equal ) ; a x i s ( o f f ) ;
hold o f f ;
s e t ( gcf , PaperPositionMode , auto ) ;
s e t ( gca , f o n t s i z e , 1 2 ) ;

Listing C.2 Code for plotting far-field patterns on a constant plane


1

function p o l a r p l o t c o n s t a n t p h i ( theta , pattern 1 , pattern 2 ,


max val , s t e p s i z e , number of rings , . . .
line style 1 , line style 2 , constant phi , . . .
legend 1 , legend 2 , s c a l e t y p e )

% 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
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 ;

11

13

hold on ;
th = 0 : ( pi / 5 0 ) : 2 * pi ; c i r c l e x = cos ( th ) ;
f o r mi = 1 : n u m b e r o f r i n g s
r = ( 1 / n u m b e r o f r i n g s ) * mi ;

c i r c l e y = sin ( th ) ;

...

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Appendix C MATLAB Code for Plotting Far-Field Patterns

415

plot ( r * c i r c l e x , r * c i r c l e y , : , color , k , linewidth , 1 ) ;


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 , . . .
f o n t w e i g h t , demi , f o n t s i z e , 1 0 ) ;

15

17

end
19

21

23

25

27

29

31

33

35

37

r =[ 1:0.1:1];
f o r mi = 3 : 8
t h=mi * p i / 6 ;
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 ) ) ] , . . .
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 ) ;
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 , . . .
f o n t w e i g h t , demi , f o n t s i z e , 1 0 ) ;
end
t e x t ( 0 , 1 . 1 , 180 , . . .
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 ) ;
pattern
pattern
pattern
pattern

1
1
2
2

( find ( pattern
= ( pattern 1
( find ( pattern
= ( pattern 2

< min val ) ) =


min val ) / plot
< min val ) ) =
min val ) / plot

min val ;
range ;
min val ;
range ;

39

41

% transform data to C a r t e s i a n coordinates


x1 = p a t t e r n 1 . * c o s ( t h e t a +p i / 2 ) ;
y1 = p a t t e r n 1 . * s i n ( t h e t a +p i / 2 ) ;

43

45

47

49

51

53

55

57

59

61

63

65

x2 = p a t t e r n 2 . * c o s ( t h e t a +p i / 2 ) ;
y2 = p a t t e r n 2 . * s i n ( t h e t a +p i / 2 ) ;
% 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 ) ;
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 ] , . . .
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 ) ;
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 ) ;
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 ) ;
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 , . . .
f o n t w e i g h t , demi , f o n t s i z e , 1 2 ) ;
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 ) ;
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 ) ;
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 ) ;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

416

67

69

71

73

75

October 13, 2009

Appendix C MATLAB Code for Plotting Far-Field Patterns

t e x t ( 1 . 2 * cos ( pi / 4 ) , 1 . 1 8 * sin ( pi /4) 0.12 , xz plane , . . .


c o l o r , b , f o n t w e i g h t , demi ) ;
end
i f c o n s t a n t p h i == 90
t e x t ( 1 . 2 , 0 . 0 6 , y , fontname , a r i a l , c o l o r , b , f o n t w e i g h t
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 ,
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
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 ,
t e x t ( 1 . 2 * cos ( pi / 4 ) , 1 . 1 8 * sin ( pi /4) 0.12 , yz plane , . . .
c o l o r , b , f o n t w e i g h t , demi ) ;
end

, demi ) ;
demi ) ;
, demi ) ;
demi ) ;

77

79

81

a x i s ( [ 1 . 2 1 . 2 1.2 1 . 2 ] ) ;
a x i s ( equal ) ; a x i s ( o f f ) ;
hold o f f ;
s e t ( gcf , PaperPositionMode , auto ) ;
s e t ( gca , f o n t s i z e , 1 2 ) ;

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

Bibliography
[1] A. Taove 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 Maxwells equations in
isotropic media, IEEE Transactions on Antennas and Propagation, vol. 14, pp. 302307, 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. 215234, 1967.
[4] J. A. Kong, Electromagnetic Wave Theory. Cambridge, MA: EMW Publishing, 2000.
[5] S. Dey and R. Mittra, Conformal nite-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 properties to improve accuracy of the FDTD method at interfaces, Applied Computational Electromagnetics
Society Journal, vol. 17, no. 3, pp. 198208, 2002.
[7] D. E. Aspnes, Bounds on allowed values of the effective dielectric function of two-component composites at nite frequencies, Physical Review B, vol. 25, no. 2, pp. 13581361, 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. 16451649, 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. 245249, 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. 68, 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. 194202, 1965.
[14] D. Sheen, S. Ali, M. Abouzahra, and J. Kong, Application of the three-dimensional nite-difference
time-domain method to the analysis of planar microstrip circuits, IEEE Transactions on Microwave
Theory, vol. 38, no. 7, pp. 849857, 1990.
[15] J.-P. Berenger, A perfectly matched layer for the absorption of electromagnetic waves, Journal of
Computational Physics, vol. 114, no. 2, pp. 185200, October 1994.
[16] , Three-dimensional perfectly matched layer for the absorption of electromagnetic waves, Journal
of Computational Physics, vol. 127, no. 2, pp. 363379, 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 ABCs for the FDTD method, IEEE Microwave and Guided Wave
Letters, vol. 5, no. 6, pp. 192194, 1995.
[18] J.-P. Berenger, Perfectly matched layer for the FDTD solution of wave-structure interaction problems, IEEE Transactions on Antennas and Propagation, vol. 44, no. 1, pp. 110117, 1996.
[19] J. C. Veihl and R. Mittra, Efcient implementation of Berengers perfectly matched layer (PML) for
nite-difference time-domain mesh truncation, IEEE Microwave and Guided Wave Letters, vol. 6, no. 2,
pp. 9496, 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. 16301639, 1996.
[21] A. Taove, Computational Electrodynamics: The Finite Difference Time Domain Method. Norwood, MA:
Artech House Publishers, 1995.

417

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

418

October 13, 2009

Bibliography

[22] A. Z. Elsherbeni, A comparative study of two-dimensional multiple scattering techniques, Radio


Science, vol. 29, no. 4, pp. 10231033, 1994.
[23] J. Roden and S. Gedney, Convolution PML (CPML): an efcient FDTD implementation of the
CFS-PML for arbitrary media, Microwave and Optical Technology Letters, vol. 27, no. 5, pp. 334339,
2000.
[24] F. Teixeira and W. Chew, On causality and dynamic stability of perfectly matched layers for FDTD
simulations, IEEE Transactions on Microwave Theory and Techniques, vol. 47, no. 6, pp. 775785, 1999.
[25] M. Kuzuoglu and R. Mittra, Frequency dependence of the constitutive parameters of causal perfectly
matched anisotropic absorbers, IEEE Microwave and Guided Wave Letters, vol. 6, no. 12, pp. 447449,
1996.
[26] J.-P. Berenger, Perfectly Matched Layer (PML) for Computational Electromagnetics. San Rafael, CA: Morgan & Claypool Publishers, 2007.
[27] W. C. Chew and W. H. Weedon, A 3D perfectly matched medium from modied Maxwells equations
with stretched coordinates, Microwave and Optical Technology Letters, vol. 7, no. 13, pp. 590604,
September 1994.
[28] W. L. Stutzman and G. A. Thiele, Antenna Theory and Design, 2nd ed. New York: John Wiley & Sons,
1998.
[29] R. J. Luebbers, K. S. Kunz, M. Schnizer, and F. Hunsberger, A nite-difference time-domain near
zone to far zone transformation, IEEE Transactions on Antennas and Propagation, vol. 39, no. 4, pp.
429433, 1991.
[30] R. J. Luebbers, D. Ryan, and J. Beggs, A two dimensional time domain near zone to far zone transformation, IEEE Transactions on Antennas and Propagation, vol. 40, no. 7, pp. 848851, 1992.
[31] S. A. Schelkunoff, Some equivalence theorem of electromagnetics and their application to radiation
problem, Bell System Technical Journal, vol. 15, pp. 92112, 1936.
[32] C. A. Balanis, Advanced Engineering Electromagnetics. New York: Wiley, 1989.
[33] , Antenna Theory: Analysis and Design, 3rd ed. Hoboken, NJ: John Wiley & Sons, 2005.
[34] H. Nakano, Helical and Spiral AntennasA Numerical Approach. Herts, UK: Research Studies Press Ltd.
[35] A. Z. Elsherbeni, C. G. Christodoulou, and J. Gomez-Tagle, Handbook of Antennas in Wireless Communications. Boca Raton, FL: CRC Press, 2001.
[36] V. Demir, C.-W. P. Huang, and A. Z. Elsherbeni, Novel dual-band WLAN antennas with integrated
band-select lter for 802.11 a/b/g WLAN radios in portable devices, Microwave and Optical Technology
Letters, vol. 49, no. 8, pp. 18681872, 2007.
[37] B. Li and K. W. Leung, Strip-fed rectangular dielectric resonator antennas with/without a parasitic
patch, IEEE Transactions on Antennas and Propagation, vol. 53, no. 7, pp. 22002207, 2005.
[38] K. Umashankar, A. Taove, and B. Beker, Calculation and experimental validation of induced currents
on coupled wires in an arbitrary shaped cavity, IEEE Transactions on Antennas and Propagation, [legacy,
pre-1988], vol. AP-35, no. 11, pp. 12481257, November 1987.
[39] B. M. Kolundzija, J. S. Ognjanovic, and T. Sarkar, WIPL-D Microwave: Circuit and 3D EM Simulation
for RF & Microwave Applications: Software and Users Manual. Norwood, MA: Artech House Publishers,
2006.
[40] F. E. Terman, Radio Engineers Handbook. London: McGraw-Hill, 1950.
[41] V. Demir, A. Z. Elsherbeni, D. Worasawate, and E. Arvas, A graphical user/interface (GUI) for
plane-wave scattering from a conducting, dielectric, or chiral sphere, IEEE Antennas and Propagation
Magazine, vol. 46, no. 5, pp. 9499, October 2004.
[42] D. Worasawate, J. R. Mautz, and E. Arvas, Electromagnetic scattering from an arbitrarily shaped
three-dimensional homogeneous chiral body, IEEE Transactions on Antennas and Propagation, vol. 51,
no. 5, pp. 10771084, May 2003.
[43] V. Demir and A. Z. Elsherbeni, A graphical user interface for calculation of the reection and
transmission coefcients of a layered medium, Antennas and Propagation Magazine, IEEE, February
2006.
[44] M. J. Inman, A. Z. Elsherbeni, and C. E. Smith, Gpu programming for FDTD calculations, Applied
Computational Electromagnetics Society (ACES) Conference, Honolulu, HI, 2005.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

Bibliography

October 13, 2009

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 Propagation Magazine, IEEE, vol. 47, no. 6, pp. 7178, 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 nite difference approximation of the time domain
electromagnetic eld equations, IEEE Transactions on Electromagnetic Compatibility, vol. 23, no. 4, pp.
377382, 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. 10631076, 1984.
[51] M. J. Inman and A. Z. Elsherbeni, Interactive GPU based FDTD simulations for teaching applications, Applied Computational Electromagnetics Society (ACES) Conference, Naigara Falls, Canada,
March 2008.

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

October 13, 2009

About the Authors


Atef Z. Elsherbeni received a B.Sc. with honors in electronics
and communications, a B.Sc. with honors in applied physics, and
an M.Eng. in electrical engineering, all from Cairo University,
Egypt, in 1976, 1979, and 1982, respectively, and a Ph.D. in electrical engineering from Manitoba University, Winnipeg, Canada,
in 1987. He was a part-time software and system design engineer
from March 1980 to December 1982 at the Automated Data System Center, Cairo, Egypt. From January to August 1987, he was a
postdoctoral fellow at Manitoba University. Dr. Elsherbeni joined
the faculty at the University of Mississippi in August 1987 as assistant professor of electrical engineering. He advanced to associate
professor in July 1991 and to professor in July 1997. In August 2002
he became the director of the School of Engineering CAD Lab
and associate director of the Center for Applied Electromagnetic
Systems Research (CAESR) at The University of Mississippi. He
was appointed as adjunct professor in the Department of Electrical
Engineering and Computer Science at the L.C. Smith College of
Engineering and Computer Science at Syracuse University in January 2004. He spent a sabbatical
term in 1996 in the Electrical Engineering Department at the University of California at Los
Angeles (UCLA) and was visiting professor at Magdeburg University during summer 2005.
Dr. Elsherbeni has received the 2006 School of Engineering Senior Faculty Research Award
for Outstanding Performance in research, the 2005 School of Engineering Faculty Service Award
for Outstanding Performance in Service, the 2004 Valued Service Award from the Applied Computational Electromagnetics Society (ACES) for Outstanding Service as 2003 ACES Symposium
Chair, the Mississippi Academy of Science 2003 Outstanding Contribution to Science Award, the
2002 IEEE Region 3 Outstanding Engineering Educator Award, the 2002 School of Engineering
Outstanding Engineering Faculty Member of the Year Award, the 2001 ACES Exemplary Service
Award for leadership and contributions as electronic publishing managing editor 19992001, the
2001 Researcher/Scholar of the Year Award in the Department of Electrical Engineering at the
University of Mississippi, and the 1996 Outstanding Engineering Educator of the IEEE Memphis
Section.
Dr. Elsherbeni has conducted research dealing with scattering and diffraction by dielectric
and metal objects, nite-difference time-domain analysis of passive and active microwave devices
including planar transmission lines, eld visualization and software development for electromagnetics (EM) education, interactions of electromagnetic waves with the human body, sensors
development for monitoring soil moisture, airports noise levels, air quality including haze and
humidity, reector and printed antennas and antenna arrays for radars, unmanned aerial vehicles
(UAVs), and personal communication systems, antennas for wideband applications, and antenna
and material properties measurements. He has coauthored 94 technical journal articles and 24
book chapters, has contributed to 266 professional presentations, and has offered 17 short courses
and 18 invited seminars. He is the coauthor of Antenna Design and Visualization Using MATLAB
(Scitech, 2006), MATLAB Simulations for Radar Systems Design (CRC Press, 2003), Electromagnetic
Scattering Using the Iterative Multiregion Technique (Morgan & Claypool, 2007), Electromagnetics
421

14:16

fdtd_main

SPIB005-Elsherbeni & Demir

422

October 13, 2009

About the Authors

and Antenna Optimization Using Taguchis Method (Morgan & Claypool, 2007), and is the main author 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.
Veysel Demir received his bachelor of science degree in electrical engineering from Middle East Technical University, Ankara,
Turkey, in 1997. He received a scholarship award from the Renaissance Scholarship Program for graduate study in the United States
(20002004). He studied at Syracuse University, New York, where
he received both a master of science and doctor of philosophy in
electrical engineering in 2002 and 2004, respectively. During his
graduate studies, he worked as research assistant for Sonnet Software, Inc., Liverpool, New York. He worked as a visiting research
scholar in the Department of Electrical Engineering at the University of Mississippi from 2004 to 2007. He joined the Department of
Electrical Engineering at Northern Illinois University as assistant
professor in August 2007. His research interests include numerical analysis techniquesnite-difference time-domain (FDTD),
nite-difference frequency-domain (FDFD), and method of moments (MoM)as well as microwave and radiofrequency (RF) circuit analysis and design. Dr. Demir is a member of IEEE and ACES and has coauthored more than
20 technical journal and conference papers. He is the coauthor of Electromagnetic Scattering Using
the Iterative Multiregion Technique (Morgan & Claypool, 2007). He currently serves as a reviewer
for both the Applied Computational Electromagnetics Society (ACES) Journal and the Transactions on
Microwave Theory and Techniques (MTT) Journal.

14:16

fdtd_ind

SPIB005-Elsherbeni & Demir

November 13, 2009

Index
A
absorbing boundary, 36, 187229, 274
absorbing boundary conditions (ABC), 36, 187, 371,
377, 419
air buffer number of cells, 47, 201, 241
Amperes law, 15, 52, 110
animation, 111, 114, 118, 128, 219, 222, 229, 355
anisotropic, 1, 43, 188, 236, 417, 418
axial ratio, 279

Courant-Friedrichs-Lewy (CFL), 33, 34, 36, 45


cputime, 119, 129, 249
create bricks, 58, 61
create PEC plates, 65
create spheres, 61
curl equation, 3, 13, 15, 23, 27, 71, 72, 331
current source, 7576, 81, 86, 90, 96, 101,
122

backward difference, 510


bandwidth, 151, 153, 164, 369
Berenger, 232
Berengers PML, 232
bistatic RCS, 340, 350, 354f, 355f, 359f, 361
Blackman-Harris window, 143144
Boltzmanns constant, 82
boundary conditions, 47, 118, 187
bricks, 48f, 5859, 69, 312
Brook, 371, 373374, 375377

dene geometry, 48, 49, 61, 67, 69, 133, 137, 138,
163, 172, 181, 201, 222, 255, 264, 302, 308,
320, 322, 351, 358, 364
derivative of Gaussian waveform, 149150, 151f
dielectric resonator antenna (DRA), 307
diode, 818588, 104, 123, 124
DirectX, 374, 380f
discrete convolution, 234, 235
discrete Fourier transformation (DFT), 225, 229f,
272, 273f, 277, 284, 340
dispersion relation, 3840
divergence equations, 3

capacitor, 77, 81, 86, 104, 138139, 139f, 141f, 161


central difference, 5f, 6, 7, 9f, 10, 12, 13, 16, 18, 23,
28, 38, 72, 78, 196, 233, 318
central processing unit (CPU), 369, 370, 376, 377
CFL condition, 3437
CFL limit, 36
characteristic impedance, 168, 261267, 268f
circularly polarized (CP), 279
complex frequency-shifted PML (CFS-PML), 231,
232, 240
constitutive relations, 2, 3
convolution, 233, 234, 235
convolutional PML (CPML), 231, 232, 236240,
242250, 269
cosine modulated Gaussian, 151
cosine modulated Gaussian pulse, 143, 151
cosine modulated Gaussian waveform, 151152,
152f, 153f, 161166
courant factor, 46

electric charge, 2
electric conductivity, 3, 15, 47, 55, 56, 57
electric current, 2, 71, 125, 204, 276, 287
electric displacement, 2, 53
electric eld, 2, 3, 15, 17, 31
evanescent modes, 240

F
Faradays law, 15, 315
far eld, 271, 272, 273, 275, 277280, 281, 307,
322, 339, 351, 357, 366, 413
far eld calculation, 274, 276, 277, 278, 288, 291,
296
far eld condition, 271, 272
far eld pattern, 271, 279, 281, 288, 357,
413416
far eld radiation, 277, 281, 322
423

19:43

fdtd_ind

SPIB005-Elsherbeni & Demir

November 13, 2009

424
far eld radiation pattern, 277, 322
far sources, 143
far zone sources, 271, 272, 331
fast Fourier transform (FFT), 157, 374
FDTD program, 43, 201, 219, 225, 282
eld distribution, 219, 225, 229
forward difference, 4f, 6, 7, 9f, 10
Fourier spectrum, 46
Fourier transform, 1, 108, 143, 144, 147, 150, 151,
152f, 154, 157, 160, 161, 218, 225, 272, 280,
286, 340
fragment processor, 372, 373
frequency dependent, 1
frequency domain, 1, 108,143, 147, 150, 151, 154,
156160, 225, 227, 232, 258, 277, 279, 284, 288

Index

L
Laplace transform, 233
late-time reections, 231
left hand circularly polarized (LHCP), 279, 280
linear indexing, 99
linearly polarized (LP), 279
local subcell models, 43
lumped circuit elements, 71
lumped element component, 71, 86, 87, 9097, 154,
163, 257, 264, 303, 308, 323, 340, 352,
359
lumped elements, 71139, 163f

M
G
Gaussian pulse, 41, 143, 147, 151
Gaussian waveform, 29, 146149, 149151,
151152, 153, 161166
graphical processing unit (GPU), 369, 370, 371,
373, 372, 376, 377, 379
Greens function, 1, 274

H
hard voltage source, 7475

I
image theory, 276, 277f
impedance matching condition, 187, 192
impressed current, 71, 90, 98, 122, 204, 225
impressed current density, 3, 71, 79, 222
impressed electric current, 122, 204
impressed magnetic current, 119, 204, 215
incident eld, 72, 143, 331, 333, 336, 338, 341344,
345, 346, 347, 353, 360, 363, 366
incident plane wave, 195, 336341, 343, 349, 351
inductor, 71, 77f, 7879, 90, 103, 122
ITERS, 373

K
Kernels, 373, 376

magnetic charge, 2
magnetic conductivity, 3, 15, 47, 62, 67
magnetic current, 2, 204, 276, 282, 284
magnetic eld, 3, 4, 15, 18, 73, 108, 110f, 111, 114,
119, 125, 126f, 190, 193, 197, 207, 208,
210215, 218, 234236, 237f, 238, 247, 248f,
249, 287, 315, 316f, 318, 337, 345,
347, 348
magnetic ux, 2, 54
magnitude, 31, 36, 40, 41, 74, 114, 125, 148f, 225,
226f, 227f, 228f, 229f
matching condition, 192, 194, 233
material arrays, 55, 58
material cell, 50, 52f, 53f
material type, 47, 48, 55, 56, 59, 67, 69
Maxwells equations, 2, 4, 188, 189, 192, 193, 195,
199, 273
method of moments (MoM), 355

N
near eld, 271310, 339
near sources, 143, 204
near zone sources, 331
negative direction, 47, 86
Newton-Raphson method, 83, 84, 124, 125
nonlinear, 1, 71, 82, 83, 85, 150
number of cells per wavelength, 46, 146, 147,
153
number of time steps, 44, 46, 89, 117, 131, 161
numerical dispersion, 3741
numerical dispersion relation, 38, 39
numerical stability, 3337, 40

19:43

fdtd_ind

SPIB005-Elsherbeni & Demir

November 13, 2009

Index

O
one-dimensional, 2631, 40, 41, 96, 117, 245, 376,
399
OpenGL, 374
output parameters, 111118, 130, 158, 219, 225,
281, 307, 322

P
parallel computation, 1
partial differential equation (PDE), 33
PEC boundaries, 31, 47, 118, 119, 121, 176, 187,
217, 363f, 376
perfect electric conductor (PEC) boundary, 31, 47,
118, 119, 121, 176, 187, 217, 363f, 376
perfectly matched layer (PML), 187229, 231,
376
perfectly matched layer (PML) absorbing boundary,
187229, 376
permeability, 2, 15, 47, 54, 66f, 67, 89, 274
permittivity, 2, 15, 47, 50, 53, 54, 55, 56, 66f, 67,
240
phase, 147, 161, 189, 225, 254, 278, 280
phase velocities, 37, 40
pixel shaders, 372
plane cuts, 66f, 114, 118, 128, 305f, 306f, 357
plane wave, 37, 38, 187, 188f, 190f, 195, 336341,
357
positive direction, 47, 86

R
radar cross section (RCS), 108, 271, 339
radiation efciency, 280
recursive convolution, 235236
resistor, 75f, 7677, 7981, 92, 104, 131134, 180,
256
right hand circularly polarized (RHCP), 279, 280

S
sampled current, 110, 125, 134, 135f, 170, 180,
253f, 262
sampled electric eld, 125, 131, 202, 225, 226f, 357,
360
sampled voltage, 108, 109f, 117, 128, 134, 135f,
136f, 138, 161, 170, 176, 177f, 178f, 180, 252,
256, 262

425
scattered eld, 331, 332336, 339, 340350, 357f,
360, 363
scattered eld formulation, 331336, 340350, 363,
364
scattered eld updating equation, 332336, 344
scattering cross-section, 1
sinusoidal, 40, 89, 131134, 144, 146
sinusoidal source, 131, 134
sinusoidal waveform, 89, 143146, 152, 153, 222
space increments, 34
space parameters, 4448, 67, 180, 203
S-parameters, 108, 169178, 179f, 180, 252, 261
spheres, 48, 59, 61, 350355, 357f
stair-cased grid, 43, 55
stair-cased gridding, 43, 55
streams, 373, 375, 376, 377
stretched coordinate, 231232
subcell modeling, 55, 56, 315
surface equivalence theorem, 272276

T
tangential components, 53
Taylor series, 6, 7, 12
texture maps, 371, 372, 373
texture processes, 372
thin sheet, 5657
thin wire, 57, 85, 315, 318, 319, 320, 321, 329
thin wire formulation, 315322
thin wire modelling, 57, 315, 318
three-dimensional, 3, 1322, 39, 55, 62, 99, 113,
193195, 240250, 344, 377379, 384, 391,
392
time domain, 2, 33, 34, 143, 147, 154158, 161,
165, 166f, 233, 277, 369
time increment, 34, 36
time shift, 149, 150, 157, 161
time step, 15, 17, 30f, 31, 36, 46, 88, 89, 108, 111,
122, 124, 125, 128, 156, 176, 225, 235, 236,
277, 345
total eld, 331, 332, 343, 363
transistors, 71, 369
two-dimensional, 2226, 27, 39, 192, 196, 199, 201,
202, 249, 375377, 380, 382, 388,
392f

U
updating coefcient, 97, 98, 100, 101, 102, 103,
104, 105, 106, 107, 121, 208, 321, 344

19:43

fdtd_ind

SPIB005-Elsherbeni & Demir

November 13, 2009

426
updating equation, 13, 22, 23, 25, 2631, 74, 76, 79,
86, 90, 96, 97, 98, 101, 103, 196, 197, 199201,
233, 236238, 249, 315, 318, 332336, 344,
403, 405, 406, 409, 411

V
voltage, 71, 7274, 80, 85, 86, 90, 95, 98, 101,
108111, 121, 128, 131, 134, 135f, 136f,
138139, 180, 252f
voltage source, 7275, 80, 86, 89, 96, 98, 101,
121122, 131, 161, 180, 307
voltage source updating equation, 101

Index

W
wave equation, 33, 37, 38
waveforms, 29, 40, 87, 143166, 338
wavelength, 146, 147, 153, 271
wavenumber, 271, 291

Y
Yee cell, 13, 14, 16, 23, 55, 56f, 59, 62, 110, 121,
125
Yee grid, 4367, 63f

19:43

Potrebbero piacerti anche