100% found this document useful (2 votes)
1K views

FDTD Method For em With MATLAB Simulations

Matlab code for FDTD

Uploaded by

aditi monga
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
1K views

FDTD Method For em With MATLAB Simulations

Matlab code for FDTD

Uploaded by

aditi monga
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 453

fdtd_fm SPIB005-Elsherbeni & Demir November 24, 2008 20:7

The Finite-Difference
Time-Domain Method for
Electromagnetics
 R
with MATLAB Simulations

Atef Z. Elsherbeni
and
Veysel Demir

SciTech Publishing, Inc


Raleigh, NC
scitechpublishing.com
fdtd_fm SPIB005-Elsherbeni & Demir November 24, 2008 20:7

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 [email protected].
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.
R
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 patterns–Computer simulation. 2. Electromag-
netic waves–Computer simulation. 3. Antennas (Electronics)–Computer simulation. 4. MATLAB. I. Demir, Veysel, 1974-
II. Title.
TK6565.A6E47 2008
621.382’4–dc22
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 01760-
2098 USA. http://www.mathworks.com.
Information provided in this book was developed with the authors’ and publisher’s 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
fdtd_fm SPIB005-Elsherbeni & Demir November 24, 2008 20:7

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
fdtd_fm SPIB005-Elsherbeni & Demir November 24, 2008 20:7
fdtd_fm SPIB005-Elsherbeni & Demir November 24, 2008 20:7

Contents
Preface xxi
Author Acknowledgements xxv
Acknowledgement of Reviewers xxvii

Chapter 1 Introduction to FDTD 1


1.1 The Finite-Difference Time-Domain Method Basic Equations 2
1.2 Approximation of Derivatives by Finite Differences 4
1.3 FDTD Updating Equations for Three-Dimensional Problems 13
1.4 FDTD Updating Equations for Two-Dimensional Problems 22
1.5 FDTD Updating Equations for One-Dimensional Problems 26
1.6 Exercises 32

Chapter 2 Numerical Stability and Dispersion 33


2.1 Numerical Stability 33
2.1.1 Stability in Time Domain Algorithm 33
2.1.2 CFL Condition for the FDTD Method 34
2.2 Numerical Dispersion 37
2.3 Exercises 41

Chapter 3 Building Objects in the Yee Grid 43


3.1 Definition of Objects 43
3.1.1 Defining the Problem Space Parameters 44
3.1.2 Defining the Objects in the Problem Space 48
3.2 Material Approximations 50
3.3 Subcell Averaging Schemes for Tangential and Normal Components 52
3.4 Defining Objects Snapped to the Yee Grid 55
3.5 Creation of the Material Grid 57
3.6 Improved Eight-Subcell Averaging 67
3.7 Exercises 67

Chapter 4 Active and Passive Lumped Elements 71


4.1 FDTD Updating Equations for Lumped Elements 71
4.1.1 Voltage Source 72
4.1.2 Hard Voltage Source 74
4.1.3 Current Source 75
4.1.4 Resistor 76
4.1.5 Capacitor 77
4.1.6 Inductor 78
4.1.7 Lumped Elements Distributed over a Surface or within
a Volume 79
4.1.8 Diode 81
4.1.9 Summary 85

vii
fdtd_fm SPIB005-Elsherbeni & Demir November 24, 2008 20:7

viii Contents

4.2 Definition, Initialization, and Simulation of Lumped Elements 86


4.2.1 Definition of Lumped Elements 86
4.2.2 Initialization of FDTD Parameters and Arrays 89
4.2.3 Initialization of Lumped Element Components 90
4.2.4 Initialization of Updating Coefficients 97
4.2.5 Sampling Electric and Magnetic Fields, Voltages and Currents 108
4.2.6 Definition and Initialization of Output Parameters 111
4.2.7 Running an FDTD Simulation: The Time-Marching
Loop 118
4.2.8 Displaying FDTD Simulation Results 130
4.3 Simulation Examples 131
4.3.1 A Resistor Excited by a Sinusoidal Voltage Source 131
4.3.2 A Diode Excited by a Sinusoidal Voltage Source 134
4.3.3 A Capacitor Excited by a Unit-Step Voltage Source 138
4.4 Exercises 139

Chapter 5 Source Waveforms and Transformation from Time Domain to


Frequency Domain 143
5.1 Common Source Waveforms for FDTD Simulations 143
5.1.1 Sinusoidal Waveform 143
5.1.2 Gaussian Waveform 146
5.1.3 Normalized Derivative of a Gaussian Waveform 149
5.1.4 Cosine-Modulated Gaussian Waveform 151
5.2 Definition and Initialization of Source Waveforms for FDTD
Simulations 152
5.3 Transformation from Time Domain to Frequency Domain 154
5.4 Simulation Examples 158
5.4.1 Recovering a Time Waveform from Its Fourier
Transform 160
5.4.2 An RLC Circuit Excited by a Cosine-Modulated Gaussian
Waveform 161
5.5 Exercises 166

Chapter 6 Scattering Parameters 169


6.1 S-Parameters and Return Loss Definitions 169
6.2 S-Parameter Calculations 170
6.3 Simulation Examples 178
6.3.1 Quarter-Wave Transformer 178
6.4 Exercises 184

Chapter 7 Perfectly Matched Layer Absorbing Boundary 187


7.1 Theory of PML 187
7.1.1 Theory of PML at the Vacuum–PML Interface 187
7.1.2 Theory of PML at the PML–PML Interface 190
7.2 PML Equations for Three-Dimensional Problem Space 193
7.3 PML Loss Functions 195
fdtd_fm SPIB005-Elsherbeni & Demir November 24, 2008 20:7

Contents ix

7.4 FDTD Updating Equations for PML and MATLAB Implementation 196
7.4.1 PML Updating Equations—Two-Dimensional TEz
Case 196
7.4.2 PML Updating Equations—Two-Dimensional TMz
Case 199
7.4.3 MATLAB Implementation of the Two-Dimensional FDTD
Method with PML 201
7.5 Simulation Examples 215
7.5.1 Validation of PML Performance 215
7.5.2 Electric Field Distribution 219
7.5.3 Electric Field Distribution Using DFT 225
7.6 Exercises 229

Chapter 8 The Convolutional Perfectly Matched Layer 231


8.1 Formulation of CPML 231
8.1.1 PML in Stretched Coordinates 231
8.1.2 Complex Stretching Variables in CFS-PML 232
8.1.3 The Matching Conditions at the PML–PML Interface 233
8.1.4 Equations in the Time Domain 233
8.1.5 Discrete Convolution 234
8.1.6 The Recursive Convolution Method 235
8.2 The CPML Algorithm 236
8.2.1 Updating Equations for CPML 236
8.2.2 Addition of Auxiliary CPML Terms at Respective
Regions 238
8.3 CPML Parameter Distribution 239
8.4 MATLAB Implementation of CPML in the Three-Dimensional
FDTD Method 240
8.4.1 Definition of CPML 241
8.4.2 Initialization of CPML 242
8.4.3 Application of CPML in the FDTD Time-Marching
Loop 248
8.5 Simulation Examples 250
8.5.1 Microstrip Low-Pass Filter 250
8.5.2 Microstrip Branch Line Coupler 252
8.5.3 Characteristic Impedance of a Microstrip Line 261
8.6 Exercises 267

Chapter 9 Near-Field to Far-Field Transformation 271


9.1 Implementation of the Surface Equivalence Theorem 272
9.1.1 Surface Equivalence Theorem 272
9.1.2 Equivalent Surface Currents in FDTD Simulation 274
9.1.3 Antenna on Infinite Ground Plane 276
9.2 Frequency Domain Near-Field to Far-Field Transformation 277
9.2.1 Time-Domain to Frequency-Domain Transformation 277
9.2.2 Vector Potential Approach 277
fdtd_fm SPIB005-Elsherbeni & Demir November 24, 2008 20:7

x Contents

9.2.3 Polarization of Radiation Field 279


9.2.4 Radiation Efficiency 280
9.3 MATLAB Implementation of Near-Field to Far-Field Transformation 281
9.3.1 Definition of NF–FF Parameters 281
9.3.2 Initialization of NF–FF Parameters 282
9.3.3 NF–FF DFT during Time-Marching Loop 284
9.3.4 Postprocessing for Far-Field Calculation 288
9.4 Simulation Examples 299
9.4.1 Inverted-F Antenna 299
9.4.2 Strip-Fed Rectangular Dielectric Resonator Antenna 307
9.5 Exercises 310

Chapter 10 Thin-Wire Modeling 315


10.1 Thin-Wire Formulation 315
10.2 MATLAB Implementation of the Thin-Wire Formulation 319
10.3 Simulation Examples 322
10.3.1 Thin-Wire Dipole Antenna 322
10.4 Exercises 327

Chapter 11 Scattered Field Formulation 331


11.1 Scattered Field Basic Equations 331
11.2 The Scattered Field Updating Equations 332
11.3 Expressions for the Incident Plane Waves 336
11.4 MATLAB Implementation of the Scattered Field Formulation 340
11.4.1 Definition of the Incident Plane Wave 340
11.4.2 Initialization of the Incident Fields 341
11.4.3 Initialization of the Updating Coefficients 344
11.4.4 Calculation of the Scattered Fields 344
11.4.5 Postprocessing and Simulation Results 348
11.5 Simulation Examples 350
11.5.1 Scattering from a Dielectric Sphere 350
11.5.2 Scattering from a Dielectric Cube 355
11.5.3 Reflection and Transmission Coefficients of a Dielectric
Slab 358
11.6 Exercises 366

Chapter 12 Graphics Processing Unit Acceleration of Finite-Difference


Time-Domain 369
12.1 Graphics Processors and General Math 371
12.2 Introduction to Brook 373
12.3 Sample Two-Dimensional FDTD Implementation Using Brook 375
12.4 Extension to Three-Dimensional 377
12.5 Three-Dimensional Parameter Exploration 379

Appendix A One-Dimensional FDTD Code 399


fdtd_fm SPIB005-Elsherbeni & Demir November 24, 2008 20:7

Contents xi

Appendix B Convolutional Perfectly Matched Layer Regions and Associated Field


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

Appendix C MATLAB Code for Plotting 413


Bibliography 417
About the Authors 421
Index 423
fdtd_fm SPIB005-Elsherbeni & Demir November 24, 2008 20:7
fdtd_fm SPIB005-Elsherbeni & Demir November 24, 2008 20:7

List of Figures
1.1(a). Approximation of the derivative of f (x) at x by finite differences: forward
difference. 4
1.1(b). Approximation of the derivative of f (x) at x by finite differences: backward
difference. 5
1.1(c). Approximation of the derivative of f (x) at x by finite differences: central
difference. 5
1.2(a). f (x), f  (x), and differences between f  (x) and finite difference approximations
of f  (x) for x = π/5 and x = π/10. f (x) = sin(x)e −0.3x 8
1.2(b). f (x), f  (x), and differences between f  (x) and finite difference approximations
of f  (x) for x = π/5 and x = π/10: f  (x) = cos(x)e −0.3x − 0.3 sin(x)e −0.3x
and finite difference approximations of f  (x) for x = π/5. 8
1.2(c). f (x), f  (x), and differences between f  (x) and finite difference approximations
of f  (x) for x = π/5 and x = π/10: error( f  (x)) for x = π/5. 9
1.2(d). f (x), f  (x), and differences between f  (x) and finite difference approximations
of f  (x) for x = π/5 and x = π/10: error( f  (x)) for x = π/10. 9
1.3. Sample points of f (x). 13
1.4. A three-dimensional FDTD computational space composed of (Nx × Ny × Nz )
Yee cells. 14
1.5. Arrangement of field components on a Yee cell indexed as (i, j, k). 14
1.6. Material parameters indexed on a Yee cell. 16
1.7. Field components around E x (i, j, k). 16
1.8. Field components around Hx (i, j, k). 18
1.9. Explicit FDTD procedure. 22
1.10. Two-dimensional T E z FDTD field components. 24
1.11. Two-dimensional T Mz FDTD field components. 25
1.12. One-dimensional FDTD—positions of field components E y and Hz . 27
1.13. One-dimensional FDTD — positions of field components E z and Hy . 28
1.14(a). Snapshots of a one-dimensional FDTD simulation: fields observed after 100
time steps. 29
1.14(b). Snapshots of a one-dimensional FDTD simulation: fields observed after 300
time steps. 30
1.14(c). Snapshots of a one-dimensional FDTD simulation: fields observed after 615
time steps. 30
1.14(d). Snapshots of a one-dimensional FDTD simulation: fields observed after 700
time steps. 31
2.1. The time–space domain grid with error  propagating with λ = 1/2. 34
2.2. The time–space domain grid with error  propagating with λ = 1. 35
2.3. The time–space domain grid with error  propagating with λ = 2. 35
2.4. Maximum magnitude of E z in the one-dimensional problem space for
simulations with t = 3.3356 ps and t = 3.3357 ps. 37
2.5(a). Maximum magnitude of E z in the one-dimensional problem space for
simulations with x = 1 mm and x = 4 mm: simulation with x = 1 mm. 40

xiii
fdtd_fm SPIB005-Elsherbeni & Demir November 24, 2008 20:7

xiv List of Figures

2.5(b). Maximum magnitude of E z in the one-dimensional problem space: simulation


with x = 4 mm. 41
3.1. Parameters defining a brick and a sphere in Cartesian coordinates. 48
3.2. An FDTD problem space and the objects defined in it. 50
3.3. A cell around material component εz (i, j, k) partially filled with two media. 51
3.4. A cell around material component εz (i, j, k) divided into eight subcells. 51
3.5. Material component εz (i, j, k) parallel to the boundary of two different media
partially filling a material cell. 52
3.6. Material component εz (i, j, k) normal to the boundary of two different media
partially filling a material cell. 53
3.7. Material component εz (i, j, k) located between four Yee cells filled with four
different material types. 55
3.8. Material component µz (i, j, k) located between two Yee cells filled with two
different material types. 56
3.9. A PEC plate with zero thickness surrounded by four σ e material components. 57
3.10. An FDTD problem space and the objects approximated by snapping to cells. 62
3.11. Positions of the E x components on the Yee grid for a problem space composed
of (Nx × Ny × Nz) cells. 63
3.12. Positions of the Hx components on the Yee grid for a problem space composed
of (Nx × Ny × Nz) cells. 63
3.13. Material grid on three plane cuts. 66
3.14. The FDTD problem space of Exercise 3.1. 68
3.15. The FDTD problem space of Exercise 3.3. 68
4.1. Field components around E z (i, j, k). 72
4.2. Voltage sources placed between nodes (i, j, k) and (i, j, k + 1). 73
4.3. Lumped elements placed between nodes (i, j, k) and (i, j, k + 1). 75
4.4. Lumped elements placed between nodes (i, j, k) and (i, j, k + 1). 77
4.5. Parallel perfect electric conductor (PEC) plates excited by a voltage source at
one end and terminated by a resistor at the other end. 80
4.6. A voltage source distributed over a surface and a resistor distributed over a
volume. 80
4.7. Diodes placed between nodes (i, j, k) and (i, j, k + 1). 82
4.8. A function f (x) and the points approaching to the root of the function
iteratively calculated using the Newton-Raphson Method. 84
4.9. A diode defined between the nodes (is , j s , ks ) and (ie, j e, ke). 96
4.10. A z-directed voltage source defined between the nodes (is , j s , ks ) and
(ie, j e, ke). 99
4.11. A volume between PEC plates where a z-directed sampled voltage is required. 109
4.12. A surface enclosed by magnetic field components and z-directed current
flowing through it. 110
4.13. The y components of the magnetic and electric fields around the node
(is , j s , ks ). 126
4.14. A voltage source terminated by a resistor. 132
4.15. Sinusoidal voltage source waveform with 500 MHz frequency and sampled
voltage and current. 135
4.16. Sinusoidal voltage source waveform with 500 MHz frequency and sampled
voltage. 136
fdtd_fm SPIB005-Elsherbeni & Demir November 24, 2008 20:7

List of Figures xv

4.17. Unit step voltage source waveform and sampled voltage. 139
4.18. Dimensions of 50  stripline. 140
4.19. A 50  stripline terminated by a resistor. 141
4.20. A circuit composed of a voltage source, a capacitor, and a diode. 141
5.1(a). A sinusoidal waveform excited for 4 seconds: x(t). 144
5.1(b). A sinusoidal waveform excited for 4 seconds: X(ω) magnitude. 145
5.2(a). A sinusoidal waveform excited for 8 seconds: x(t). 145
5.2(b). A sinusoidal waveform excited for 8 seconds: X(ω) magnitude. 146
5.3(a). A Gaussian waveform and its Fourier transform: g(t). 147
5.3(b). A Gaussian waveform and its Fourier transform: G(ω) magnitude. 148
5.4. Gaussian waveform shifted by t0 = 4.5τ in time. 149
5.5(a). Normalized derivative of a Gaussian waveform and its Fourier transform: g(t). 150
5.5(b). Normalized derivative of a Gaussian waveform and its Fourier transform: G(ω)
magnitude. 151
5.6(a). Cosine Gaussian waveform and its Fourier transform: g(t). 152
5.6(b). Cosine Gaussian waveform and its Fourier transform: G(ω) magnitude. 153
5.7(a). A Gaussian waveform and its Fourier transform: g(t). 161
5.7(b). A Gaussian waveform and its Fourier transform: G(ω). 162
5.7. A Gaussian waveform and its Fourier transform: g(t) recovered from G(ω). 162
5.8. An RLC circuit. 163
5.9. Time-domain response, Vo , compared with source waveform, Vs . 166
5.10(a). Frequency-domain response of source waveform Vs and output voltage Vo :
Fourier transform of Vs . 166
5.10(b). Frequency-domain response of source waveform Vs and output voltage Vo :
Fourier transform of Vo . 167
(ω)
5.11. Transfer function T(ω) = VVos (ω) . 167
6.1. An N-port network. 170
6.2(a). A microstrip low-pass filter terminated by a voltage source and a resistor on
two ends: three-dimensional view. 171
6.2(b). A microstrip low-pass filter terminated by a voltage source and a resistor on
two ends: dimensions. 171
6.3(a). S-parameters of the microstrip low-pass filter: S11 . 176
6.3(b). S-parameters of the microstrip low-pass filter: S21 . 177
6.4. Sampled voltage at the second port of the microstrip low-pass filter. 177
6.5. Sampled voltage at the second port of the microstrip low-pass filter with
σ e = 0.2. 178
6.6(a). S-parameters of the microstrip low-pass filter with σ e = 0.2: S11 . 179
6.6(b). S-parameters of the microstrip low-pass filter with σ e = 0.2: S21 . 179
6.7. The geometry and dimensions of a microstrip quarter-wave transformer
matching a 100  line to 50  line. 180
6.8. The S11 and S21 of the microstrip quarter-wave transformer circuit. 181
6.9. The problem space for the low-pass filter with absorbers on the xn, xp, yn, y p,
and zp sides. 185
7.1. The field decomposition of a T E z polarized plane wave. 188
7.2. The plane wave transition at the interface between two PML media. 190
7.3. The loss distributions in two-dimensional PML regions. 192
fdtd_fm SPIB005-Elsherbeni & Demir November 24, 2008 20:7

xvi List of Figures

7.4. Nonzero regions of PML conductivities for a three-dimensional FDTD


simulation domain. 194
7.5. Nonzero T E z regions of PML conductivities. 198
7.6. Nonzero T Mz regions of PML conductivities. 200
7.7. A two-dimensional FDTD problem space with PML boundaries. 203
7.8. TEz field components in the PML regions. 207
7.9. Field components updated by PML equations. 208
7.10. TMz field components in the PML regions. 210
7.11. Field components updated by PML equations. 211
7.12(a). A two-dimensional TEz FDTD problem terminated by PML boundaries and
its simulation results: an empty two-dimensional problem space. 217
7.12(b). A two-dimensional TEz FDTD problem terminated by PML boundaries and
its simulation results: sampled Hz in time. 218
7.13(a). A two-dimensional TEz FDTD problem used as open boundary reference and
its simulation results: an empty two-dimensional problem space. 220
7.13(b). A two-dimensional TEz FDTD problem used as open boundary reference and
its simulation results: sampled Hz in time. 220
7.14. Error in time and frequency domains. 221
7.15. A two-dimensional problem space including a cylinder and a line source. 222
7.16. Sampled electric field at a point between the cylinder and the line source. 226
7.17. Magnitude of electric field distribution calculated by FDTD. 226
7.18. Magnitude of electric field distribution calculated by BVS. 227
7.19. Magnitude of electric field distribution calculated by FDTD using DFT at 1
GHz. 228
7.20. Magnitude of electric field distribution calculated by FDTD using DFT at 2
GHz. 229
8.1. The FDTD flowchart including the steps of CPML algorithm. 237
8.2. Regions where CPML parameters are defined. 239
8.3. A problem space with 20 × 20 × 4 cells brick. 242
8.4. Positions of the electric field components updated by CPML in the xp region. 248
8.5. Positions of the magnetic field components updated by CPML in the xp region. 248
8.6. Source voltage and sampled voltages observed at the ports of the low-pass filter. 252
8.7. Sampled currents observed at the ports of the low-pass filter. 253
8.8. S11 of the low-pass filter. 253
8.9. S21 of the low-pass filter. 254
8.10. An FDTD problem space including a microstrip branch line coupler. 254
8.11. S-parameters of the branch line coupler. 261
8.12. An FDTD problem space including a microstrip line. 262
8.13. Source voltage and sampled voltage of the microstrip line. 266
8.14. Current on the microstrip line. 266
8.15. S11 of the microstrip line. 267
8.16. Characteristic impedance of the microstrip line. 268
8.17. The problem space for the quarter-wave transformer with CPML boundaries
on the xn, xp, yn, y p, and zp sides. 268
8.18. The problem space for the quarter-wave transformer with the substrate
penetrating into the CPML boundaries on the xn and xp sides. 269
8.19. The microstrip line reference case. 269
fdtd_fm SPIB005-Elsherbeni & Demir November 24, 2008 20:7

List of Figures xvii

9.1. Near-field to far-field transformation technique: equivalent currents on an


imaginary surface. 272
9.2. Two paths of the near-field to far-field transformation technique are
implemented to achieve different computation objectives. 273
9.3. Surface equivalence theorem. 273
9.4. An imaginary surface is selected to enclose the antennas or scatterers. 275
9.5. Equivalent surface currents on the imaginary closed surface. 275
9.6. An imaginary closed surface on an infinite PEC ground plane using the image
theory. 277
9.7. The equivalent surface current source and far field. 278
9.8. E x field components on the yn face of the NF–FF imaginary surface and the
magnetic currents generated by them. 287
9.9. Hx field components around the yn face of the NF–FF imaginary surface and
the electric currents generated by them. 288
9.10. Position vectors for sources on the zn and zp faces. 296
9.11. Position vectors for sources on the xn and xp faces. 297
9.12. Position vectors for sources on the yn and y p faces. 298
9.13. An inverted-F antenna. 300
9.14. Return loss of the inverted-F antenna. 305
9.15. Radiation patterns in the xy plane cut. 305
9.16. Radiation patterns in the xz plane cut. 306
9.17. Radiation patterns in the y z plane cut. 306
9.18. A strip-fed rectangular dielectric resonator antenna. 307
9.19. Return loss of the strip-fed rectangular DRA. 310
9.20. Radiation patterns in the xy plane cut. 311
9.21. Radiation patterns in the xz plane cut. 311
9.22. Radiation patterns in the y z plane cut. 312
9.23. A dipole antenna. 313
9.24. A microstrip patch antenna. 313
9.25. A microstrip patch antenna with a microstrip line feeding. 314
10.1. A thin wire with its axis coinciding with Ez (i, j, k) and field components
surrounding Hy (i, j, k). 316
10.2. Magnetic field components surrounding the thin wire. 316
10.3. A thin-wire dipole antenna. 325
10.4. Return loss of the thin-wire dipole antenna. 325
10.5. Input impedance of the thin-wire dipole antenna. 326
10.6. Radiation pattern in the xy plane cut. 326
10.7. Radiation pattern in the xz plane cut. 327
10.8. Radiation pattern in the y z plane cut. 328
10.9. An antenna array composed of two thin-wire dipole antennas. 328
10.10. A thin-wire loop. 329
11.1. An incident plane wave. 337
11.2. An incident plane wave delayed in time and shifted in space. 338
11.3. Two incident plane waves: one traveling toward the origin and the other
traveling away from the origin. 339
11.4. An FDTD problem space including a dielectric sphere. 351
11.5. Scattered electric field captured at the origin and the incident field waveform. 353
fdtd_fm SPIB005-Elsherbeni & Demir November 24, 2008 20:7

xviii List of Figures

11.6. Bistatic RCS at 1 GHz in the xy plane. 354


11.7. Bistatic RCS at 1 GHz in the xz plane. 354
11.8. Bistatic RCS at 1 GHz in the y z plane. 355
11.9. Calculated RCSθ at 1 GHz in the xz plane compared with the analytical
solution. 356
11.10. Calculated RCSφ at 1 GHz in the y z plane compared with the analytical
solution. 356
11.11. Scattered field due to a sphere captured on the xz plane cut. 357
11.12. An FDTD problem space including a cube, and the surface mesh of the cube
used by the MoM solver. 358
11.13. Bistatic RCS at 1 GHz in the xy plane. 359
11.14. Bistatic RCS at 1 GHz in the xz plane. 361
11.15. Bistatic RCS at 1 GHz in the y z plane. 361
11.16. Calculated RCSθ at 1 GHz in the xz plane compared with the MoM solution. 362
11.17. Calculated RCSφ at 1 GHz in the xz plane compared with the MoM solution. 362
11.18. An FDTD problem space including a dielectric slab. 363
11.19. Reflection and transmission coefficients of the dielectric slab. 366
12.1. Theoretical maximum processing power of CPUs and GPUs. 370
12.2. Streaming versus nonstreaming operations. 372
12.3. Sample TM2D with CPML E z data at various time steps. 378
12.4. TM2D with CPML E z value at observation point. 379
12.5. TM2D with CPML speedup factors. 380
12.6. Simple tiling from three-dimensional structure to two-dimensional texture. 391
12.7. PML boundaries of a three-dimensional simulation domain in a
two-dimensional texture. 392
12.8. Example microstrip patch antenna. 392
12.9. MATLAB GUI for the microstrip patch antenna. 393
12.10. The transient voltage at the input port. 393
12.11. The transient current at the input port. 394
12.12. The input port impedance versus frequency. 394
12.13. Return loss results for default microstrip patch antenna. 395
12.14. Example microstrip filter. 395
12.15. MATLAB GUI for microstrip filter. 396
12.16. Return loss and transmission results for default microstrip filter. 397
B.1. CPML regions where E x is updated. 404
B.2. CPML regions where E y is updated. 405
B.3. CPML regions where E z is updated. 407
B.4. CPML regions where Hx is updated. 408
B.5. CPML regions where Hy is updated. 410
B.6. CPML regions where Hz is updated. 411
fdtd_fm SPIB005-Elsherbeni & Demir November 24, 2008 20:7

List of Tables
1.1. Finite difference formulas for the first- and second-order derivatives where the
function f with the subscript i is an abbreviation of f (x). Similar notation can
be implemented for f (x + x), f (x + 2x), etc., as shown in Fig. 1.3. FD,
forward difference. BD, backward difference. CD, central difference. 13
12.1. CPU versus GPU feature comparison. 370
12.2. Brook program flow. 374

xix
fdtd_fm SPIB005-Elsherbeni & Demir November 24, 2008 20:7
fdtd_fm SPIB005-Elsherbeni & Demir November 24, 2008 20:7

Preface
The contents of this book have evolved gradually and carefully from many years of teaching gradu-
ate level courses in computational electromagnetics generally, and the FDTD method specifically,
at The University of Mississippi. Also, the first author, Atef Elsherbeni, has further refined and
developed the materials by teaching numerous short courses on the FDTD method at various
educational institutions and at a growing number of international conferences. The theoretical,
numerical, and programming experience of the second author, Veysel Demir, has been a crucial
factor in bringing the book to successful completion.

OBJECTIVE

The objective of the book is to introduce the powerful Finite-Difference Time-Domain method
to students and interested researchers and readers. An effective introduction is accomplished
using a step-by-step process that builds competence and confidence in developing complete
working codes for the design and analysis of various antennas and microwave devices. This book
will serve graduate students, researchers, and those in industry and government who are using
other electromagnetics tools and methods for the sake of performing independent numerical
confirmation. No previous experience with finite-difference methods is assumed of readers to use
this book.

IMPORTANT TOPICS

The main topics in the book include the following:


r the finite-difference approximation of the differential form of Maxwell’s equations
r the geometry construction in discrete space, including the treatment of the normal and
tangential electric and magnetic field components at the boundaries between different media
r the outer-boundary conditions treatment
r the procedures for the appropriate selection of time and spatial increments
r the proper selection of the source waveform
r the correct parameters for the time-to-frequency-domain transformation
r the simulation of thin wires
r the representation of lumped passive and active elements in the FDTD simulation
r the scattered versus total field formulations
r the definition and formulation of near and far zone sources
r 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 final expressions to be programmed, and also
includes sample MATLAB codes developed for these equations. MATLAB version 7.5 (R2007b)
is used for the development of the M-files provided with this book.

xxi
fdtd_fm SPIB005-Elsherbeni & Demir November 24, 2008 20:7

xxii Preface

The book includes a CD-ROM which contains the MATLAB M-files for all programming
examples shown in the text as well as all book figures in full-color. Readers may wish to check
the publisher’s web page for additional examples or other electronic files and figures that may be
added in the future: www.scitechpub.com/FDTDtext.htm

KEY STRENGTHS
The strengths of the book can be summarized in four points:
r First, the derivations of the FDTD equations are presented in an understandable, detailed,
and complete manner, which makes it easy for beginners to grasp the FDTD concepts.
Further to that point, regardless of the different treatments required for various objects,
such as dielectrics, conductors, lumped elements, active devices, or thin wires, the FDTD
updating equations are provided with a consistent and unified notation.
r Second, many three-dimensional figures are presented to accompany the derived equations.
This helps readers visualize, follow, and link the components of the equations with the
discrete FDTD spatial domain.
r Third, it is well known that readers usually face difficulties while developing numerical
tools for electromagnetics applications even though they understand the theory. Therefore,
we introduce in this book a top-down software design approach that links the theoretical
concepts with program development and helps in constructing an FDTD simulation tool as
the chapters proceed.
r Fourth, fully worked out practical examples showing how the MATLAB codes for each
example is developed to promote both the understanding and the visualization of the example
configuration, its FDTD parameters and setup procedure, and finally the frequency and/or
time domain corresponding solutions.
At the end of each chapter, readers will find a set of exercises that will emphasize the key
features presented in that chapter. Since most of these exercises require code developments and
the orientation of geometries and sources can be chosen arbitrarily, a suggested configuration of
each in almost all of these exercises is provided in a three dimensional figure.
The authors hope that with this coverage of the FDTD method, along with the supplied
MATLAB codes in a single book, readers will be able to learn the method, to develop their own
FDTD simulation tool, and to start enjoying, with confidence, the simulation of a variety of
electromagnetic problems.

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 configurations of personal computers, if the auto-run function does not
start, a double click on the file “index.html” will get it started. Links to all chapters and appendices
will show up in the first page. By clicking on any of these links the reader will be directed to the
appropriate chapter list of figures and code listings of the examples covered in that chapter.

INSTRUCTOR RESOURCES

Upon adopting this book as the required text, instructors are entitled to obtain the solutions of the
exercises located at the end of each chapter. Most of these solutions are in the form of MATLAB
M-files and can be obtained by contacting the publisher.
fdtd_fm SPIB005-Elsherbeni & Demir November 24, 2008 20:7

Preface xxiii

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
publisher’s web page for this book.
fdtd_fm SPIB005-Elsherbeni & Demir November 24, 2008 20:7
fdtd_fm SPIB005-Elsherbeni & Demir November 24, 2008 20:7

Author Acknowledgements
The authors would like to first thank God for giving us the endurance to initiate and complete this
book. Many thanks go to our family members for their support, patience, and sacrifice during the
preparation and completion of this book. The authors greatly acknowledge the contribution of
Matthew J. Inman to Chapter 12, “Graphical Processing Unit Acceleration of Finite-Difference
Time-Domain.” They would also like to thank Branko Kolundzija for providing a copy of WIPL-D
software package to use for verifications for some of the presented examples.
The first author acknowledges the support and advice over many years of the late Charles
E. Smith. Without his continuous encouragement and support this book would have not been
finalized. He also thanks many of his colleagues, postdoctoral fellows and visiting scholars who
worked with him in topics related to FDTD, the graduate students who participated in translating
ideas into reality, and the undergraduate students who participated in research projects with
this author, in particular, Allen Glisson, Fan Yang, Abdel-Fattah A. Elsohly, Joe LoVetri, Veysel
Demir, Matthew J. Inman, Chun-Wen Paul Huang, Clayborne D. Taylor, Mohamed Al Sharkawy,
Vicente Rodriguez-Pereyra, Jianbing (James) Chen, Adel M. Abdin, Bradford N. Baker, Asem
Mokaddem, Liang Xu, Nithya L. Iyer, Shixiong Dai, Xuexun Hu, Cuthbert Martindale Allen,
Khaled Elmahgoub, and Terry Gerald.
The authors thank Dudley Kay and Susan Manning of SciTech Publishing for their encour-
agement, patience, and useful suggestions during the course of the development of the manuscript
and production of the book.

xxv
fdtd_fm SPIB005-Elsherbeni & Demir November 24, 2008 20:7
fdtd_fm SPIB005-Elsherbeni & Demir November 24, 2008 20:7

Acknowledgement of Reviewers
SciTech Publishing and the authors gratefully acknowledge the time and expertise of the technical
reviewers who assisted in the development of this book. Their comments helped the authors to
enhance the presentations of the formulations and the MATLAB implementations. Close reading
of technical manuscripts in draft form is no small task, and the suggestions provided both from
academic and industry experts surely benefit all who will use this book to further their knowledge
of the Finite-Difference Time-Domain method in their studies and work.

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
fdtd_fm SPIB005-Elsherbeni & Demir November 24, 2008 20:7
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

1
Introduction to FDTD

Computational electromagnetics (CEM) has evolved rapidly during the past decade to a point
where now extremely accurate predictions can be given for a variety of electromagnetic problems,
including the scattering cross-section of radar targets and the precise design of antennas and
microwave devices. In general, commonly used CEM methods today can be classified into two
categories. The first is based on differential equation (DE) methods, whereas the second is based
on integral equation (IE) methods. Both IE and DE solution methods are based on the applications
of Maxwell’s equations and the appropriate boundary conditions associated with the problem to be
solved. The integral equation methods in general provide approximations for integral equations
in terms of finite sums, whereas the differential equation methods provide approximations for
differential equations as finite differences.
In previous years, most numerical electromagnetic analysis has taken place in the frequency
domain where time-harmonic behavior is assumed. Frequency domain was favored over time
domain because a frequency-domain approach is more suitable for obtaining analytical solutions
for canonical problems, which are used to verify the numerical results obtained as a first step
before depending on a newly developed numerical method for generating data for real-world
applications. Furthermore, the experimental hardware available for making measurements in past
years was largely confined to the frequency-domain approach.
The recent development of faster and more powerful computational resources allowed for more
advanced time-domain CEM models. More focus is directed toward differential equation time-
domain approaches as they are easier to formulate and to adapt in computer simulation models
without complex mathematics. They also provide more physical insight to the characteristics of
the problems.
Therefore, an in-depth analysis and implementation of the commonly used time-domain dif-
ferential equation approach, namely, the finite-difference time-domain (FDTD) method for CEM
applications, is covered in this book, along with applications related to antenna designs, microwave
filter designs, and radar cross-section analysis of three-dimensional targets.
The FDTD method has gained tremendous popularity in the past decade as a tool for solving
Maxwell’s equations. It is based on simple formulations that do not require complex asymptotic
or Green’s functions. Although it solves the problem in time, it can provide frequency-domain re-
sponses over a wide band using the Fourier transform. It can easily handle composite geometries
consisting of different types of materials including dielectric, magnetic, frequency-dependent,
nonlinear, and anisotropic materials. The FDTD technique is easy to implement using paral-
lel computation algorithms. These features of the FDTD method have made it the most at-
tractive technique of computational electromagnetics for many microwave devices and antenna
applications.

1
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

2 Introduction to FDTD

FDTD has been used to solve numerous types of problems arising while studying many appli-
cations, including the following:
r scattering, radar cross-section
r microwave circuits, waveguides, fiber optics
r antennas (radiation, impedance)
r propagation
r medical applications
r shielding, coupling, electromagnetic compatibility (EMC), electromagnetic pulse (EMP)
protection
r nonlinear and other special materials
r geological applications
r inverse scattering
r plasma

1.1 THE FINITE-DIFFERENCE TIME-DOMAIN METHOD BASIC EQUATIONS


The starting point for the construction of an FDTD algorithm is Maxwell’s time-domain
equations. The differential time-domain Maxwell’s equations needed to specify the field behavior
over time are

∂D 
 =
∇×H 
+ J, (1.1a)
∂t
∂ B
∇ × E = − 
− M, (1.1b)
∂t
∇·D  = ρe , (1.1c)
∇ · B = ρm , (1.1d)

where E is the electric field strength vector in volts per meter, D


 is the electric displacement vector
in coulombs per square meter, H  is the magnetic field strength vector in amperes per meter, B
is the magnetic flux density vector in webers per square meter, J is the electric current density
vector in amperes per square meter, M  is the magnetic current density vector in volts per square
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 Maxwell’s 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 × 10−12 farad/meter,


−7
µ = µ0 = 4π × 10 henry/meter.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

FDTD Basic Equations 3

We only need to consider curl equations (1.1a) and (1.1b) while deriving FDTD equations
because the divergence equations can be satisfied by the developed FDTD updating equations
[1]. The electric current density J is the sum of the conduction current density Jc = σ e E and
the impressed current density Ji as J = Jc + Ji . Similarly, for the magnetic current density,
M =M  i , where M
c + M  c = σ m H.
 Here σ e is the electric conductivity in siemens per meter, and
σ m is the magnetic conductivity in ohms per meter. Upon decomposing the current densities in
(1.1) to conduction and impressed components and by using the constitutive relations (1.2) we
can rewrite Maxwell’s curl equations as


∇×H  = ε ∂ E + σ e E + Ji , (1.3a)
∂t
∂H
∇ × E = −µ − σmH −M i. (1.3b)
∂t

This formulation treats only the electromagnetic fields E and H  and not the fluxes D  and B.

All four constitutive parameters ε, µ, σ e , and σ m are present so that any linear isotropic material
can be specified. Treatment of electric and magnetic sources are included through the impressed
currents. Although only the curl equations are used and the divergence equations are not part
of the FDTD formalism, the divergence equations can be used as a test on the predicted field
response, so that after forming D  = ε E and B = µ H  from the predicted E and H  fields, the
 
resulting D and B must satisfy the divergence equations.
Equation (1.3) is composed of two vector equations, and each vector equation can be de-
composed into three scalar equations for three-dimensional space. Therefore, Maxwell’s curl
equations can be represented with the following six scalar equations in a Cartesian coordinate
system (x, y, z):
 
∂ Ex 1 ∂ Hz ∂ Hy
= − − σx E x − Ji x ,
e
(1.4a)
∂t εx ∂y ∂z
 
∂ Ey 1 ∂ Hx ∂ Hz
= − − σ ye E y − Ji y , (1.4b)
∂t εy ∂z ∂x
 
∂ Ez 1 ∂ Hy ∂ Hx
= − − σze E z − Ji z , (1.4c)
∂t εz ∂ x ∂y
 
∂ Hx 1 ∂ Ey ∂ Ez
= − − σx Hx − Mi x ,
m
(1.4d)
∂t µx ∂z ∂y
 
∂ Hy 1 ∂ Ez ∂ Ex
= − − σ y Hy − Mi y ,
m
(1.4e)
∂t µy ∂ x ∂z
 
∂ Hz 1 ∂ Ex ∂ Ey
= − − σz Hz − Mi z .
m
(1.4f)
∂t µz ∂ y ∂x

The material parameters εx , ε y , and εz are associated with electric field components E x , E y , and
E z through constitutive relations Dx = εx E x , Dy = ε y E y , and Dz = εz E z , respectively. Similarly,
the material parameters µx , µ y , and µz are associated with magnetic field components Hx , Hy , and
Hz through constitutive relations Bx = µx Hx , B y = µ y Hy , and Bz = µz Hz , respectively. Similar
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

4 Introduction to FDTD

decompositions for other orthogonal coordinate systems are possible, but they are less attractive
from the applications point of view.
The FDTD algorithm divides the problem geometry into a spatial grid where electric and
magnetic field components are placed at certain discrete positions in space, and it solves Maxwell’s
equations in time at discrete time instances. This can be implemented by first approximating
the time and space derivatives appearing in Maxwell’s equations by finite differences and next
by constructing a set of equations that calculate the values of fields at a future time instant from
the values of fields at a past time instant, therefore constructing a time marching algorithm that
simulates the progression of the fields in time [2].

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 sufficient relative
to the function’s variation. Sampling rate determines the accuracy of operations performed on the
discrete function that approximates the operations on the continuous functions as well. However,
another factor that determines the accuracy of an operation on a discrete function is the choice of
the discrete operator. Most of the time it is possible to use more than one way of performing an
operation on a discrete function. Here we will consider the derivative operation.
Consider the continuous function given in Fig. 1.1(a–c), sampled at discrete points. The ex-
pression for the derivative of f (x) at point x can be written as

f (x + x) − f (x)
f  (x) = lim . (1.5)
x→0 x

f (x + ∆x)

f (x − ∆x)

f (x)

x − ∆x x x + ∆x

Figure 1.1 (a) Approximation of the derivative of f (x ) at x by finite differences: forward difference.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Approximation of Derivatives by Finite Differences 5

f (x + ∆x)

f (x − ∆x)

f (x)

x − ∆x x x + ∆x

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

f (x + ∆x)

f (x − ∆x)

f (x)

x − ∆x x x + ∆x

Figure 1.1 (c) Approximation of the derivative of f (x ) at x by finite differences: central difference.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

6 Introduction to FDTD

However, since x is a nonzero fixed number, the derivative of f (x) can be approximately
taken as
f (x + x) − f (x)
f  (x) ≈ . (1.6)
x
The derivative of f (x) is the slope of the dashed line as illustrated in Fig. 1.1(a). Equation (1.6) is
called the forward difference formula since one forward point f (x + x) is used to evaluate f  (x)
together with f (x).
It is evident that another formula for an approximate f  (x) can be obtained by using a backward
point f (x − x) rather than the forward point f (x + x) as illustrated in Fig. 1.1(b), which can
be written as
f (x) − f (x − x)
f  (x) ≈ . (1.7)
x
This equation is called the backward difference formula due to the use of the backward point
f (x − x).
The third way of obtaining a formula for an approximate f  (x) is by averaging the forward
difference and backward difference formulas, such that

f (x + x) − f (x − x)
f  (x) ≈ . (1.8)
2x
Equation (1.8) is called the central difference formula since both the forward and backward points
around the center one are used. The line representing the derivative of f (x) calculated using the
central difference formula is illustrated in 1.1(c). It should be noted that the value of the function
f (x) at x is not used in central difference formula.
Examination of Fig. 1.1 immediately reveals that the three different schemes yield different
values for f  (x), with an associated amount of error. The amount of error introduced by these
difference formulas can be evaluated analytically by using the Taylor series approach. For instance,
the Taylor series expansion of f (x + x) can be written as

(x)2  (x)3  (x)4 


f (x + x) = f (x) + x f  (x) + f (x) + f (x) + f (x) + . . . . (1.9)
2 6 24
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) satisfies certain conditions and infinite number of terms, theoretically, are being
used. Equation (1.9) can be rearranged to express f  (x) as

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


f  (x) = − f (x) − f (x) − f (x) − . . . . (1.10)
x 2 6 24
Here it can be seen that the first 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 + x) − f (x)
f  (x) = + O(x), (1.11)
x
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Approximation of Derivatives by Finite Differences 7

where O(x) represents the error term. The most significant term in O(x) is x/2, and the
order of x in this most significant term is one. Therefore, the forward difference formula is
first-order accurate. The interpretation of first-order accuracy is that the most significant term in
the error introduced by a first-order accurate formula is proportional to the sampling period. For
instance, if the sampling period is decreased by half, the error reduces by half.
A similar analysis can be performed for evaluation of the error of the backward formula starting
with the Taylor series expansion of f (x − x):

(x)2  (x)3  (x)4 


f (x − x) = f (x) − x f  (x) + f (x) − f (x) + f (x) + . . . . (1.12)
2 6 24

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

f (x) − f (x − x) x  (x)2  (x)3 


f  (x) = + f (x) − f (x) + f (x) − . . . . (1.13)
x 2 6 24

The first term on the right-hand side of (1.13) is the same as the backward difference formula
and the sum of the rest of the terms represents the error introduced by the backward difference
formula to the exact derivative of f (x), such that

f (x) − f (x − x)
f  (x) = + O(x). (1.14)
x

The order of x in the most significant term of O(x) is one; hence the backward difference
formula is first-order accurate.
The difference between the Taylor series expansions of f (x + x) and f (x − x) can be
expressed using (1.9) and (1.12) as

2(x)3 
f (x + x) − f (x − x) = 2x f  (x) + f (x) + . . . . (1.15)
6

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

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


f  (x) = − f (x) + . . . = + O((x)2 ),
2x 6 2x
(1.16)

where the first term on right-hand side is the same as the central difference formula given in (1.8)
and the order of x in the most significant term of the error O((x)2 ) is two; hence the central
difference formula is second-order accurate. The interpretation of second-order accuracy is that the
most significant term in the error introduced by a second-order accurate formula is proportional
to the square of sampling period. For instance, if the sampling period is decreased by half, the
error is reduced by a factor of four. Hence, a second-order accurate formula such as the central
difference formula is more accurate than a first-order accurate formula.
For an example, consider a function f (x) = sin(x)e −0.3x as displayed in Fig. 1.2(a). The exact
first-order derivative of this function is

f  (x) = cos(x)e −0.3x − 0.3 sin(x)e −0.3x .


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

8 Introduction to FDTD

0.8

0.6

0.4

0.2
f (x)

−0.2

−0.4

−0.6

−0.8

−1
0 5 10 15
x

Figure 1.2 (a) f (x ), f  (x ), and differences between f  (x ) and finite difference approximations of f  (x ) for x =
π/5 and x = π/10: f (x ) = sin(x )e −0.3x

1
exact
0.8 forward difference
backward difference
0.6 ∆x = π/5 central difference
0.4

0.2
f (x)

−0.2

−0.4

−0.6

−0.8

−1
0 5 10 15
x

Figure 1.2 (b) f (x ), f  (x ), and differences between f  (x ) and finite difference approximations of f  (x ) for x =
π/5 and x = π/10: f  (x ) = cos(x )e −0.3x − 0.3 sin(x )e −0.3x and finite difference approximations of
f  (x ) for x = π/5.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Approximation of Derivatives by Finite Differences 9

0.2
forward difference
0.15 ∆x = π/5 backward difference
central difference
0.1

error [f (x)] 0.05

−0.05

−0.1

−0.15

−0.2
0 5 10 15
x

Figure 1.2 (c) f (x ), f  (x ), and differences between f  (x ) and finite difference approximations of f  (x ) for x =
π/5 and x = π/10: error( f  (x )) for x = π/5.

0.2
forward difference
0.15 ∆x = π/10 backward difference
central difference
0.1
error [f (x)]

0.05

−0.05

−0.1

−0.15

−0.2
0 5 10 15
x

Figure 1.2 (d) f (x ), f  (x ), and differences between f  (x ) and finite difference approximations of f  (x ) for x =
π/5 and x = π/10: error( f  (x )) for x = π/10.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

10 Introduction to FDTD

This function f (x) is sampled with a sampling period x = π/5, and approximate derivatives
are calculated for f (x) using the forward difference, backward difference, and central difference
formulas. The derivative of the function f  (x) and its finite difference approximations are plotted
in Fig. 1.2(b). The errors introduced by the difference formulas, which are the differences between
f  (x) and its finite difference approximations, are plotted in Fig. 1.2(c) for the sampling interval
x = π/5. It is evident that the error introduced by the central difference formula is smaller than
the errors introduced by the forward difference and backward difference formulas. Furthermore,
the errors introduced by the difference formulas for the sampling period x = π/10 are plotted in
Fig. 1.2(d). It can be realized that as the sampling period is halved, the errors of the forward
difference and backward difference formulas are halved as well, and the error of the central
difference formula is reduced by a factor of four.
The MATLAB code calculating f (x) and its finite difference derivatives, and generating the
plots in Fig. 1.2 is shown in Listing 1.1.
Listing 1.1 MATLAB code generating Fig. 1.2(a–d)

1 % c r e a t e e x a c t f u n c t i o n and i t s d e r i v a t i v e
N e x a c t = 3 0 1 ; % number o f s ample p o i n t s f o r e x a c t f u n c t i o n
3 x e x a c t = l i n s p a c e ( 0 , 6 * pi , N e x a c t ) ;
f e x a c t = s i n ( x e x a c t ) . * exp ( − 0 . 3 * x e x a c t ) ;
5 f d e r i v a t i v e e x a c t = c o s ( x e x a c t ) . * exp ( − 0 . 3 * x e x a c t ) . . .
−0.3 * s i n ( x e x a c t ) . * exp ( − 0 . 3 * x e x a c t ) ;
7

% plot exact function


9 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 ) ;
11 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 ;
13 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

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


17 % and i t s f i n i t e d i f f e r e n c e d e r i v a t i v e s
N 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
19 x a = l i n s p a c e ( 0 , 6 * pi , N a ) ;
f a = s i n ( x a ) . * exp ( − 0 . 3 * x a ) ;
21 f 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

dx a = pi / 5 ;
25 f derivative f o r w a r d a = zeros (1 , N a ) ;
f derivative backward a = zeros (1 , N a ) ;
27 f derivative c e n t r a l a = zeros (1 , N a ) ;
f derivative f o r w a r d a ( 1 : N a −1) = . . .
29 (f a ( 2 : N a )− f a ( 1 : N a − 1 ) ) / d x a ;
f derivative backward a (2: N a ) = . . .
31 (f a ( 2 : N a )− f a ( 1 : N a − 1 ) ) / d x a ;
f derivative c e n t r a l a ( 2 : N a −1) = . . .
33 (f a ( 3 : N a )− f a ( 1 : N a − 2 ) ) / ( 2 * d x a ) ;

35

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


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Approximation of Derivatives by Finite Differences 11

37 % and i t s f i n i t e d i f f e r e n c e d e r i v a t i v e s
N b = 6 1 ; % number o f p o i n t s f o r p i / 1 0 s a m p l i n g p e r i o d
39 x b = l i n s p a c e ( 0 , 6 * pi , N b ) ;
f b = s i n ( x b ) . * exp ( − 0 . 3 * x b ) ;
41 f d e r i v a t i v e b = c o s ( x b ) . * exp ( − 0 . 3 * x b ) . . .
−0.3 * s i n ( x b ) . * exp ( − 0 . 3 * x b ) ;
43 dx b = pi / 1 0 ;
f d e r i v a t i v e f o r w a r d b = zeros (1 , N b ) ;
45 f derivative backward b = zeros (1 , N b ) ;
f d e r i v a t i v e c e n t r a l b = zeros (1 , N b ) ;
47 f d e r i v a t i v e f o r w a r d b ( 1 : N b −1) = . . .
( f b ( 2 : N b )− f b ( 1 : N b − 1 ) ) / d x b ;
49 f derivative backward b (2: N b ) = . . .
( f b ( 2 : N b )− f b ( 1 : N b − 1 ) ) / d x b ;
51 f d e r i v a t i v e c e n t r a l b ( 2 : N b −1) = . . .
( f b ( 3 : N b )− f b ( 1 : N b − 2 ) ) / ( 2 * d x b ) ;
53

% p l o t e x a c t d e r i v a t i v e o f t h e f u n c t i o n and i t s f i n i t e d i f f e r e n c e
55 % d e r i v a t i v e s using pi /5 sampling period
figure ( 2 ) ;
57 plot ( x exact , f d e r i v a t i v e e x a c t , ’ k ’ , . . .
x a ( 1 : N a − 1 ) , f d e r i v a t i v e f o r w a r d a ( 1 : N a − 1 ) , ’ b−− ’ , . . .
59 x a ( 2 : N a ) , f d e r i v a t i v e b a c k w a r d a ( 2 : N a ) , ’ r −. ’ , . . .
x a ( 2 : N a − 1 ) , f d e r i v a t i v e c e n t r a l a ( 2 : N a − 1 ) , ’ : ms ’ , . . .
61 ’ MarkerSize ’ ,4 , ’ linewidth ’ , 1 . 5 ) ;
s e t ( gca , ’ F o n t S i z e ’ , 1 2 , ’ f o n t w e i g h t ’ , ’ demi ’ ) ;
63 a x i s ( [ 0 6 * p i −1 1 ] ) ;
g r i d on ;
65 legend ( ’ e x a c t ’ , ’ forward d i f f e r e n c e ’ , . . .
’ backward d i f f e r e n c e ’ , ’ c e n t r a l d i f f e r e n c e ’ ) ;
67 x l a b e l ( ’ $x$ ’ , ’ I n t e r p r e t e r ’ , ’ l a t e x ’ , ’ F o n t S i z e ’ , 1 6 ) ;
ylabel ( ’ $f ’ ’ ( x ) $ ’ , ’ I n t e r p r e t e r ’ , ’ l a t ex ’ , ’ FontSize ’ ,16);
69 t e x t ( pi , 0 . 6 , ’ $ \ D e l t a x = \ p i / 5 $ ’ , ’ I n t e r p r e t e r ’ , . . .
’ l a t e x ’ , ’ f o n t s i z e ’ , 1 6 , ’ B a c k g r o u n d C o l o r ’ , ’w ’ , ’ E d g e C o l o r ’ , ’ k ’ ) ;
71

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


73 % using pi /5 sampling period
error forward a = f derivative a − f derivative forward a ;
75 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

figure ( 3 ) ;
79 p l o t ( x a ( 1 : N a − 1 ) , e r r o r f o r w a r d a ( 1 : N a − 1 ) , ’ b−− ’ , . . .
x a ( 2 : N a ) , e r r o r b a c k w a r d a ( 2 : N a ) , ’ r −. ’ , . . .
81 x a ( 2 : N a − 1 ) , e r r o r c e n t r a l a ( 2 : N a − 1 ) , ’ : ms ’ , . . .
’ MarkerSize ’ ,4 , ’ linewidth ’ , 1 . 5 ) ;
83

s e t ( gca , ’ F o n t S i z e ’ , 1 2 , ’ f o n t w e i g h t ’ , ’ demi ’ ) ;
85 a x i s ( [ 0 6 * p i −0.2 0 . 2 ] ) ;
g r i d on ;
87 l e g e n d ( ’ f o r w a r d d i f f e r e n c e ’ , ’ backward d i f f e r e n c e ’ , . . .
’ central difference ’ );
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

12 Introduction to FDTD

89 x l a b e l ( ’ $x$ ’ , ’ I n t e r p r e t e r ’ , ’ l a t e x ’ , ’ F o n t S i z e ’ , 1 6 ) ;
ylabel ( ’ error $ [ f ’ ’ ( x ) ] $ ’ , ’ Interpreter ’ , ’ latex ’ , ’ FontSize ’ ,16);
91 t e x t ( pi , 0 . 1 5 , ’ $ \ D e l t a x = \ p i / 5 $ ’ , ’ I n t e r p r e t e r ’ , . . .
’ l a t e x ’ , ’ f o n t s i z e ’ , 1 6 , ’ B a c k g r o u n d C o l o r ’ , ’w ’ , ’ E d g e C o l o r ’ , ’ k ’ ) ;
93

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


95 % using pi /10 sampling period
error forward b = f derivative b − f derivative forward b ;
97 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

figure ( 4 ) ;
101 p l o t ( x b ( 1 : N b − 1 ) , e r r o r f o r w a r d b ( 1 : N b − 1 ) , ’ b−− ’ , . . .
x b ( 2 : N b ) , e r r o r b a c k w a r d b ( 2 : N b ) , ’ r −. ’ , . . .
103 x b ( 2 : N b − 1 ) , e r r o r c e n t r a l b ( 2 : N b − 1 ) , ’ : ms ’ , . . .
’ MarkerSize ’ ,4 , ’ linewidth ’ , 1 . 5 ) ;
105

s e t ( gca , ’ F o n t S i z e ’ , 1 2 , ’ f o n t w e i g h t ’ , ’ demi ’ ) ;
107 a x i s ( [ 0 6 * p i −0.2 0 . 2 ] ) ;
g r i d on ;
109 l e g e n d ( ’ f o r w a r d d i f f e r e n c e ’ , ’ backward d i f f e r e n c e ’ , . . .
’ central difference ’ );
111 x l a b e l ( ’ $x$ ’ , ’ I n t e r p r e t e r ’ , ’ l a t e x ’ , ’ F o n t S i z e ’ , 1 6 ) ;
ylabel ( ’ error $ [ f ’ ’ ( x ) ] $ ’ , ’ Interpreter ’ , ’ latex ’ , ’ FontSize ’ ,16);
113 t e x t ( pi , 0 . 1 5 , ’ $ \ D e l t a x = \ p i / 1 0 $ ’ , ’ I n t e r p r e t e r ’ , . . .
’ l a t e x ’ , ’ f o n t s i z e ’ , 1 6 , ’ B a c k g r o u n d C o l o r ’ , ’w ’ , ’ E d g e C o l o r ’ , ’ k ’ ) ;
 

Values of the function f (x) at two neighboring points around x have been used to obtain a
second order accurate central difference formula to approximate f  (x). It is possible to obtain
formulas with higher orders of accuracy by including a larger number of neighboring points in
the derivation of a formula for f  (x). However, although there are FDTD formulations developed
based on higher-order accurate formulas, the conventional FDTD is based on the second-order
accurate central difference formula, which is found to be sufficiently accurate for most electro-
magnetics applications and simple in implementation and understanding.
It is possible to obtain finite-difference formulas for approximating higher-order derivatives as
well. For instance, if we take the sum of the Taylor series expansions of f (x + x) and f (x − x)
using (1.9) and (1.12), we obtain

(x)4 
f (x + x) + f (x − x) = 2 f (x) + (x)2 f  (x) + f (x) + . . . . (1.17)
12

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

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


f  (x) = − f (x) + . . .
(x)2 12
(1.18)
f (x + x) − 2 f (x) + f (x − x)
= + O((x)2 ).
(x)2
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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 fi+2 −2 fi+1 + fi


x
FD O(x) (x)2
FD O(x)
fi − fi−1 fi −2 fi−1 + fi−2
x
BD O(x) (x)2
BD O(x)
fi+1 − fi−1 fi+1 −2 fi + fi−1
2x
CD O((x)2 ) (x)2
CD O((x)2 )
− fi+2 +4 fi+1 −3 fi − fi+2 +16 fi+1 −30 fi +16 fi−1 − fi−2
2x
FD O((x)2 ) 12(x)2
CD O((x)4 )
3 fi −4 fi−1 + fi−2
2x
BD O((x)2 )

− fi+2 +8 fi+1 −8 fi−1 + fi−2


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


f  (x) ≈ , (1.19)
(x)2

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


Similarly, some other finite difference formulas can be obtained for the first- and second-order
derivatives with different orders of accuracy based on different sampling points. A list of finite
difference formulas is given for the first- 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 finite-difference equations for the time-dependent Maxwell’s curl
equations system [2]. These equations can be represented in discrete form, both in space and
time, employing the second-order accurate central difference formula. As mentioned before, the
electric and magnetic field components are sampled at discrete positions both in time and space.
The FDTD technique divides the three-dimensional problem geometry into cells to form a grid.
Figure 1.4 illustrates an FDTD grid composed of (Nx × Ny × Nz ) cells. A unit cell of this grid is
called a Yee cell. Using rectangular Yee cells, a stepped or “staircase” approximation of the surface

fi−2 fi−1 fi fi+1 fi+2

x − 2∆x x − ∆x x x + ∆x x + 2∆x

Figure 1.3 Sample points of f (x ).


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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

Figure 1.5 Arrangement of field components on a Yee cell indexed as (i, j, k).
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Three-Dimensional FDTD 15

to the respective faces. This provides a simple picture of three-dimensional space being filled
by an interlinked array of Faraday’s law and Ampere’s law contours. It can be easily noticed in
Fig. 1.5 that each magnetic field vector is surrounded by four electric field vectors that are curling
around the magnetic field vector, thus simulating Faraday’s law. Similarly, if the neighboring cells
are also added to the picture, it would be apparent that each electric field vector is surrounded
by four magnetic field vectors that are curling around the electric field vector, thus simulating
Ampere’s law.
Figure 1.5 shows the indices of the field components, which are indexed as (i, j, k), associated
with a cell indexed as (i, j, k). For a computational domain composed of uniform Yee cells having
dimension x in the x direction, y in the y direction, and z in the z direction, the actual
positions of the field components with respect to an origin coinciding with the position of the
node (1, 1, 1) can easily be calculated as

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 fields at discrete time instants; how-
ever, the electric and magnetic field components are not sampled at the same time instants.
For a time-sampling period t, the electric field components are sampled at time instants
0, t, 2t, . . . , nt, . . . ; however, the magnetic field components are sampled at time instants
1
2
t, (1 + 12 )t, . . . , (n + 12 )t, . . . . Therefore, the electric field components are calculated at in-
teger time steps, and magnetic field components are calculated at half-integer time steps, and they
are offset from each other by t/2. The field components need to be referred by not only their spa-
tial indices which indicate their positions in space, but also by their temporal indices, which indicate
their time instants. Therefore, a superscript notation is adopted to indicate the time instant. For
instance, the z component of an electric field vector positioned at ((i − 1)x, ( j − 1)y, (k −
0.5)z) and sampled at time instant nt is referred to as E zn (i, j, k). Similarly, the y component
of a magnetic field vector positioned at ((i − 0.5)x, ( j − 1)y, (k − 0.5)z) and sampled at time
n+ 1
instant (n + 12 )t is referred to as Hy 2 (i, j, k).
The material parameters (permittivity, permeability, electric, and magnetic conductivities) are
distributed over the FDTD grid and are associated with field components; therefore, they are
indexed the same as their respective field components. For instance, Fig. 1.6 illustrates the indices
for the permittivity and permeability parameters. The electric conductivity is distributed and
indexed the same as the permittivity, and the magnetic conductivity is distributed and indexed the
same as the permeability.
Having adopted an indexing scheme for the discrete samples of field components in both time
and space, Maxwell’s curl equations (1.4) that are given in scalar form can be expressed in terms
of finite differences. For instance, consider again (1.4a):
 
∂ Ex 1 ∂ Hz ∂ Hy
= − − σx E x − Ji x .
e
∂t εx ∂y ∂z
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

16 Introduction to FDTD

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

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


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Three-Dimensional FDTD 17

n+ 12 n+ 12
E xn+1 (i, j, k) − E xn (i, j, k) 1 Hz (i, j, k) − Hz (i, j − 1, k)
=
t εx (i, j, k) y
n+ 12 n+ 12
1 Hy (i, j, k) − Hy (i, j, k − 1)

εx (i, j, k) z
σxe (i, j, k) n+ 12 1 n+ 1
− E x (i, j, k) − Ji x 2 (i, j, k). (1.20)
εx (i, j, k) εx (i, j, k)

It has already been mentioned that the electric field components are defined at integer time steps;
however, the right-hand side of (1.20) includes an electric field term at time instant (n + 12 )t, that
n+ 1
is, E x 2 (i, j, k). This term can be written as the average of the terms at time instants (n + 1)t
and nt, such that

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


Ex (i, j, k) = . (1.21)
2

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

2εx (i, j, k) + tσxe (i, j, k) n+1 2εx (i, j, k) − tσxe (i, j, k) n


E x (i, j, k) = E x (i, j, k)
2εx (i, j, k) 2εx (i, j, k)
t  n+ 1 n+ 1

+ Hz 2 (i, j, k) − Hz 2 (i, j − 1, k)
εx (i, j, k)y
t  n+ 1 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). (1.22)
εx (i, j, k)

After some manipulations, we get

2εx (i, j, k) − tσxe (i, j, k) n


E xn+1 (i, j, k) = E (i, j, k)
2εx (i, j, k) + tσxe (i, j, k) x
2t  n+ 1 n+ 12

+  H z
2
(i, j, k) − Hz (i, j − 1, k)
2εx (i, j, k) + tσxe (i, j, k) y
2t  n+ 1 n+ 12

−  H y
2
(i, j, k) − Hy (i, j, k − 1)
2εx (i, j, k) + tσxe (i, j, k) z
2t n+ 1
− Ji x 2 (i, j, k). (1.23)
2εx (i, j, k) + tσx (i, j, k)
e

The form of (1.23) demonstrates how the future value of an electric field component can be
calculated by using the past values of the electric field component, the magnetic field com-
ponents, and the source components. This form of an equation is called an FDTD updating
equation. Updating equations can easily be obtained for calculating E yn+1 (i, j, k) starting from
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

18 Introduction to FDTD

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 field components following the
same methodology. However, while applying the central difference formula to the time derivative
of the magnetic field components, the central point in time shall be taken as nt. For instance,
(1.4c), which is
 
∂ Hx 1 ∂ Ey ∂ Ez
= − − σxm Hx − Mi x ,
∂t µx ∂z ∂y

can be approximated using finite differences based on the field positions (as shown in
Fig. 1.8) as
n+ 12 n− 12
Hx (i, j, k) − Hx (i, j, k) 1 E yn (i, j, k + 1) − E yn (i, j, k)
=
t µx (i, j, k) z
1 E zn (i, j + 1, k) − E zn (i, j, k)

µx (i, j, k) y
σxm (i, j, k) n 1
− H (i, j, k) − Mn (i, j, k). (1.24)
µx (i, j, k) x µx (i, j, k) i x

n+ 1
After some manipulations, the future term Hx 2 (i, j, k) in (1.24) can be moved to the left-hand
side and the other terms can be moved to the right-hand side such that

n+ 12 2µx (i, j, k) − tσxm (i, j, k) n− 12


Hx (i, j, k) = Hx (i, j, k)
2µx (i, j, k) + tσxm (i, j, k)
2t  n 
+  E y (i, j, k + 1) − E n
y (i, j, k)
2µx (i, j, k) + tσxm (i, j, k) z
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Three-Dimensional FDTD 19

2t  n 
−  E z (i, j + 1, k) − E zn (i, j, k)
2µx (i, j, k) + tσx (i, j, k) y
m

2t
− Mn (i, j, k). (1.25)
2µx (i, j, k) + tσxm (i, j, k) i x
n+ 1
This equation is the 1updating equation for Hx 2 (i, j, k). Similarly, updating equations can easily
n+ n+ 1
be obtained for Hy 2 (i, j, k) starting from (1.4e) and Hz 2 (i, j, k) starting from (1.4f ) following
the same methodology used to obtain (1.25).
Finally, equations (1.4a)–(1.4f ) can be expressed using finite differences and can be arranged to
construct the following six FDTD updating equations for the six components of electromagnetic
fields by introduction of respective coefficient terms:

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
2εx (i, j, k) − tσxe (i, j, k)
Ce xe (i, j, k) = ,
2εx (i, j, k) + tσxe (i, j, k)
2t
Ce xhz (i, j, k) =   ,
2εx (i, j, k) + tσxe (i, j, k) y
2t
Ce xhy (i, j, k) = −   ,
2εx (i, j, k) + tσxe (i, j, k) z
2t
Ce x j (i, j, k) = − .
2εx (i, j, k) + tσxe (i, j, k)

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
2ε y (i, j, k) − tσ ye (i, j, k)
Ce ye (i, j, k) = ,
2ε y (i, j, k) + tσ ye (i, j, k)
2t
Ce yhx (i, j, k) =   ,
2ε y (i, j, k) + tσ ye (i, j, k) z
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

20 Introduction to FDTD

2t
Ce yhz (i, j, k) = −   ,
2ε y (i, j, k) + tσ ye (i, j, k) x
2t
Ce y j (i, j, k) = − .
2ε y (i, j, k) + tσ ye (i, j, k)
E zn+1 (i, j, k) = Ce ze (i, j, k) × E zn (i, j, k)
 n+ 1 n+ 1

+ Ce zhy (i, j, k) × Hy 2 (i, j, k) − Hy 2 (i − 1, j, k)
 n+ 1 n+ 1

+ Ce zhx (i, j, k) × Hx 2 (i, j, k) − Hx 2 (i, j − 1, k)
n+ 12
+ Ce zj (i, j, k) × Ji z (i, j, k), (1.28)

where

2εz (i, j, k) − tσze (i, j, k)


Ce ze (i, j, k) =
2εz (i, j, k) + tσze (i, j, k),
2t
Ce zhy (i, j, k) =   ,
2εz (i, j, k) + tσze (i, j, k) x
2t
Ce zhx (i, j, k) = −   ,
2εz (i, j, k) + tσze (i, j, k) y
2t
Ce zj (i, j, k) = − .
2εz (i, j, k) + tσze (i, j, k)
n+ 12 n− 12
Hx (i, j, k) = C hxh (i, j, k) × Hx (i, j, k)
 
+ C hxe y (i, j, k) × E yn (i, j, k + 1) − E yn (i, j, k)
 
+ C hxe z (i, j, k) × E zn (i, j + 1, k) − E zn (i, j, k)
+ C hxm (i, j, k) × Minx (i, j, k), (1.29)

where

2µx (i, j, k) − tσxm (i, j, k)


C hxh (i, j, k) = ,
2µx (i, j, k) + tσxm (i, j, k)
2t
C hxe y (i, j, k) =   ,
2µx (i, j, k) + tσxm (i, j, k) z
2t
C hxe z (i, j, k) = −   ,
2µx (i, j, k) + tσxm (i, j, k) y
2t
C hxm (i, j, k) = − .
2µx (i, j, k) + tσxm (i, j, k)
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Three-Dimensional FDTD 21

n+ 12 n− 1
Hy (i, j, k) = C hyh (i, j, k) × Hy 2 (i, j, k) + C hye z (i, j, k)
 
× E zn (i + 1, j, k) − E zn (i, j, k) + C hye x (i, j, k)
 
× E xn (i, j, k + 1) − E xn (i, j, k) + C hym (i, j, k) × Miny (i, j, k), (1.30)

where
2µ y (i, j, k) − tσ ym (i, j, k)
C hyh (i, j, k) = ,
2µ y (i, j, k) + tσ ym (i, j, k)
2t
C hye z (i, j, k) =   ,
2µ y (i, j, k) + tσ ym (i, j, k) x
2t
C hye x (i, j, k) = −   ,
2µ y (i, j, k) + tσ ym (i, j, k) z
2t
C hym (i, j, k) = − .
2µ y (i, j, k) + tσ ym (i, j, k)
n+ 12 n− 12
Hz (i, j, k) = C hzh (i, j, k) × Hz (i, j, k)
 
+ C hze x (i, j, k) × E xn (i, j + 1, k) − E xn (i, j, k)
 
+ C hze y (i, j, k) × E yn (i + 1, j, k) − E yn (i, j, k)
+ C hzm (i, j, k) × Minz (i, j, k), (1.31)

where
2µz (i, j, k) − tσzm (i, j, k)
C hzh (i, j, k) = ,
2µz (i, j, k) + tσzm (i, j, k)
2t
C hze x (i, j, k) =   ,
2µz (i, j, k) + tσzm (i, j, k) y
2t
C hze y (i, j, k) = −   ,
2µz (i, j, k) + tσzm (i, j, k) x
2t
C hzm (i, j, k) = − .
2µz (i, j, k) + tσzm (i, j, k)

It should be noted that the first two subscripts in each coefficient refer to the corresponding
field component being updated. For three subscripts coefficients, the third subscript refers to
the type of the field or source (electric or magnetic) that this coefficient is multiplied by. For
four subscripts coefficients, the third and fourth subscripts refer to the type of the field that this
coefficient is multiplied by.
Having derived the FDTD updating equations, a time-marching algorithm can be constructed
as illustrated in Fig. 1.9. The first step in this algorithm is setting up the problem space—including
the objects, material types, and sources—and defining any other parameters that will be used during
the FDTD computation. Then the coefficient terms appearing in (1.26)–(1.31) can be calculated
and stored as arrays before the iteration is started. The field components need to be defined as
arrays as well and shall be initialized with zeros since the initial values of the fields in the problem
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

22 Introduction to FDTD

Start

Set problem space and define parameters

Compute field coefficients

Update magnetic field components


at time instant (n+0.5)∆t

Update electric field components


Output data at time instant (n+1)∆t

Apply boundary conditions

Increment time step, n n+1

Yes No
Stop Last iteration?

Figure 1.9 Explicit FDTD procedure.

space in most cases are zeros, and fields will be induced in the problem space due to sources as the
iteration proceeds. At every step of the time-marching iteration the magnetic field components
are updated for time instant (n + 0.5)t using (1.29)–(1.31); then the electric field components
are updated for time instant (n + 1)t using (1.26)–(1.28). The problem space has a finite size, and
specific boundary conditions can be enforced on the boundaries of the problem space. Therefore,
the field components on the boundaries of the problem space are treated according to the type of
boundary conditions during the iteration. The types of boundary conditions and the techniques
used to integrate them into the FDTD algorithm are discussed in detail in Chapters 7 and 8. After
the fields are updated and boundary conditions are enforced, the current values of any desired field
components can be captured and stored as output data, and these data can be used for real-time
processing or postprocessing to calculate some other desired parameters. The FDTD iterations
can be continued until some stopping criteria are achieved.

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
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Two-Dimensional FDTD 23

field distributions in one of the dimensions, a simplified set of updating equations can be obtained
starting from the Maxwell’s curl equations system (1.4). Since there is no variation in one of
the dimensions, the derivative terms with respect to that dimension vanish. For instance, if the
problem is z dimension independent, equations (1.4) reduce to
 
∂ Ex 1 ∂ Hz
= − σx E x − Ji x ,
e
(1.32a)
∂t εx ∂ y
 
∂ Ey 1 ∂ Hz
= − − σ ye E y − Ji y , (1.32b)
∂t εy ∂x
 
∂ Ez 1 ∂ Hy ∂ Hx
= − − σze E z − Ji z , (1.32c)
∂t εz ∂ x ∂y
 
∂ Hx 1 ∂ Ez
= − − σx Hx − Mi x ,
m
(1.32d)
∂t µx ∂y
 
∂ Hy 1 ∂ Ez
= − σ y Hy − Mi y ,
m
(1.32e)
∂t µy ∂ x
 
∂ Hz 1 ∂ Ex ∂ Ey
= − − σz Hz − Mi z .
m
(1.32f)
∂t µz ∂ y ∂x

One should notice that equations (1.32a), (1.32b), and (1.32f ) are dependent only on the terms E x ,
E y , and Hz , whereas equations (1.32c), (1.32d), and (1.32e) are dependent only on the terms E z ,
Hx , and Hy . Therefore, the six equations (1.32) can be treated as two separate sets of equations.
In the first set—(1.32a), (1.32b), and (1.32f )—all the electric field components are transverse to
the reference dimension z; therefore, this set of equations constitutes the transverse electric to z
case—T E z . In the second set—(1.32c), (1.32d), and (1.32e)—all the magnetic field components are
transverse to the reference dimension z; therefore, this set of equations constitutes the transverse
magnetic to z case—T Mz . Most two-dimensional problems can be decomposed into two separate
problems, each including separate field components that are T E z and T Mz for the case under
consideration. These two problems can be solved separately, and the solution for the main problem
can be achieved as the sum of the two solutions.
The FDTD updating equations for the T E z case can be obtained by applying the central
difference formula to the equations constituting the T E z case based on the field positions shown
in Fig. 1.10, which is obtained by projection of the Yee cells in Fig. 1.5 on the xy plane in the z
direction. The FDTD updating equations for the T E z case are therefore obtained as
 n+ 1 n+ 1

E xn+1 (i, j ) = Ce xe (i, j ) × E xn (i, j ) + Ce xhz (i, j ) × Hz 2 (i, j ) − Hz 2 (i, j − 1)
n+ 12
+ Ce x j (i, j ) × Ji x (i, j ), (1.33)

where
2εx (i, j ) − tσxe (i, j )
Ce xe (i, j ) = ,
2εx (i, j ) + tσxe (i, j )
2t
Ce xhz (i, j ) =   ,
2εx (i, j ) + tσxe (i, j ) y
2t
Ce x j (i, j ) = − .
2εx (i, j ) + tσxe (i, j )
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

24 Introduction to FDTD

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
2ε y (i, j ) − tσ ye (i, j )
Ce ye (i, j ) = ,
2ε y (i, j ) + tσ ye (i, j )
2t
Ce yhz (i, j ) = −   ,
2ε y (i, j ) + tσ ye (i, j ) x
2t
Ce y j (i, j ) = − .
2ε y (i, j ) + tσ ye (i, j )
n+ 1 n− 1  
Hz 2 (i, j ) = C hzh (i, j ) × Hz 2 (i, j ) + C hze x (i, j ) × E xn (i, j + 1) − E xn (i, j )
 
+ C hze y (i, j ) × E yn (i + 1, j ) − E yn (i, j ) + C hzm (i, j ) × Minz (i, j ), (1.35)

where
2µz (i, j ) − tσzm (i, j )
C hzh (i, j ) = ,
2µz (i, j ) + tσzm (i, j )
2t
C hze x (i, j ) =   ,
2µz (i, j ) + tσzm (i, j ) y
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Two-Dimensional FDTD 25

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

2t
C hze y (i, j ) = −   ,
2µz (i, j ) + tσzm (i, j ) x
2t
C hzm (i, j ) = − .
2µz (i, j ) + tσzm (i, j )

Since the FDTD updating equations for the three-dimensional case are readily available, they
can be used to derive (1.33), (1.34), and (1.35) by simply setting the coefficients including 1/z
to zero. Hence, the FDTD updating equations for the T Mz case can be obtained by eliminating
the term C hxe y (i, j, k) in (1.29) and eliminating the term C hye x (i, j, k) in (1.30) based on the field
positions shown in Fig. 1.11, such that

 n+ 1 n+ 1

E zn+1 (i, j ) = Ce ze (i, j ) × E zn (i, j ) + Ce zhy (i, j ) × Hy 2 (i, j ) − Hy 2 (i − 1, j )
 n+ 1 n+ 1
 n+ 1
+ Ce zhx (i, j ) × Hx 2 (i, j ) − Hx 2 (i, j − 1) + Ce zj (i, j ) × Ji z 2 (i, j ), (1.36)
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

26 Introduction to FDTD

where

2εz (i, j ) − tσze (i, j )


Ce ze (i, j ) = ,
2εz (i, j ) + tσze (i, j )
2t
Ce zhy (i, j ) =   ,
2εz (i, j ) + tσze (i, j ) x
2t
Ce zhx (i, j ) = −   ,
2εz (i, j ) + tσze (i, j ) y
2t
Ce zj (i, j ) = − .
2εz (i, j ) + tσze (i, j )
n+ 12 n− 12  
Hx (i, j ) = C hxh (i, j ) × Hx (i, j ) + C hxe z (i, j ) × E zn (i, j + 1) − E zn (i, j )
+ C hxm (i, j ) × Minx (i, j ), (1.37)

where

2µx (i, j ) − tσxm (i, j )


C hxh (i, j ) = ,
2µx (i, j ) + tσxm (i, j )
2t
C hxe z (i, j ) = −   ,
2µx (i, j ) + tσxm (i, j ) y
2t
C hxm (i, j ) = − .
2µx (i, j ) + tσxm (i, j )
n+ 12 n− 12  
Hy (i, j ) = C hyh (i, j ) × Hy (i, j ) + C hye z (i, j ) × E zn (i + 1, j ) − E zn (i, j )
+ C hym (i, j ) × Miny (i, j ), (1.38)

where

2µ y (i, j ) − tσ ym (i, j )


C hyh (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
2t
C hym (i, j ) = − .
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 field distributions
in two of the dimensions. For instance, if the y and z dimensions have no variation, the deriva-
tive with respect to the y and z dimensions vanish in Maxwell’s curl equations. Therefore, the
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

One-Dimensional FDTD 27

Figure 1.12 One-dimensional FDTD—positions 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 , (1.39a)
∂t εx
 
∂ Ey 1 ∂ Hz
= − − σ y E y − Ji y ,
e
(1.39b)
∂t εy ∂x
 
∂ Ez 1 ∂ Hy
= − σz E z − Ji z ,
e
(1.39c)
∂t εz ∂ x
∂ Hx 1  m 
= −σx Hx − Mi x , (1.39d)
∂t µx
 
∂ Hy 1 ∂ Ez
= − σ y Hy − Mi y ,
m
(1.39e)
∂t µy ∂ x
 
∂ Hz 1 ∂ Ey
= − − σz Hz − Mi z .
m
(1.39f)
∂t µz ∂x

It should be noted that (1.39a) and (1.39d) include time derivatives but not space derivatives.
Therefore, these equations do not represent propagating fields, hence the field components E x and
Hx , which only exist in these two equations, do not propagate. The other four equations represent
propagating fields, and both the electric and magnetic field components existing in these equations
are transverse to the x dimension. Therefore, transverse electric and magnetic to x (T E Mx ) fields
exist and propagate as plane waves in the one-dimensional case under consideration.
Similar to the two-dimensional case, the one-dimensional case as well can be decomposed
into two separate cases, since (1.39b) and (1.39f ), which include only the terms E y and Hz , are
decoupled from (1.39c) and (1.39e), which include only the terms E z and Hy . FDTD updating
equations can be obtained for (1.39b) and (1.39f ) using the central difference formula based on
the field positioning in one-dimensional space as illustrated in Fig. 1.12, such that
 n+ 1 n+ 1
 n+ 1
E yn+1 (i) = Ce ye (i) × E yn (i) + Ce yhz (i) × Hz 2 (i) − Hz 2 (i − 1) + Ce y j (i) × Ji y 2 (i), (1.40)
where
2ε y (i) − tσ ye (i)
Ce ye (i) = ,
2ε y (i) + tσ ye (i)
2t
Ce yhz (i) = −   ,
2ε y (i) + tσ ye (i) x
2t
Ce y j (i) = − ,
2ε y (i) + tσ ye (i)
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

28 Introduction to FDTD

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

and

n+ 12 n− 12  
Hz (i) = C hzh (i) × Hz (i) + C hze y (i) × E yn (i + 1) − E yn (i) + C hzm (i) × Minz (i), (1.41)

where

2µz (i) − tσzm (i)


C hzh (i) = ,
2µz (i) + tσzm (i)
2t
C hze y (i) = −   ,
2µz (i) + tσzm (i) x
2t
C hzm (i) = − .
2µz (i) + tσzm (i)

Similarly, FDTD updating equations can be obtained for (1.39c) and (1.39e) using the cen-
tral difference formula based on the field positioning in one-dimensional space as illustrated in
Fig. 1.13, such that

 n+ 1 n+ 1
 n+ 1
E zn+1 (i) = Ce ze (i) × E zn (i) + Ce zhy (i) × Hy 2 (i) − Hy 2 (i − 1) + Ce zj (i) × Ji z 2 (i), (1.42)

where

2εz (i) − tσze (i)


Ce ze (i) =
2εz (i) + tσze (i),
2t
Ce zhy (i) =   ,
2εz (i) + tσze (i) x
2t
Ce zj (i) = − ,
2εz (i) + tσze (i)

and

n+ 12 n− 12  
Hy (i) = C hyh (i) × Hy (i) + C hye z (i) × E zn (i + 1) − E zn (i) + C hym (i) × Miny (i), (1.43)
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

One-Dimensional FDTD 29

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

where

2µ y (i) − tσ ym (i)


C hyh (i) = ,
2µ y (i) + tσ ym (i)
2t
C hye z (i) =   ,
2µ y (i) + tσ ym (i) x
2t
C hym (i) = − .
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 field
components generated by a z-directed current sheet, Jz , placed at the center of a problem space
filled with air between two parallel, perfect electric conductor (PEC) plates extending to infinity 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 fields and their reflection 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
 
−10 2
− t−2×10−11
Jz (t) = e 5×10 .
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

30 Introduction to FDTD

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

Figure 1.14 (c) Snapshots of a one-dimensional FDTD simulation: fields observed after 615 time steps.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

One-Dimensional FDTD 31

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

The current sheet is excited over a one-cell cross-section (i.e., 1 mm wide), which translates
Jz into a surface current density K z of magnitude 1 × 10−3 A/m. The surface current density
causes a discontinuity in magnetic field and generates Hy , which satisfies the boundary condition

→ −

K = n × H . Therefore, two waves of Hy are generated on both sides of the current sheet, each of
which has magnitude 5 × 10−4 A/m. Since the fields are propagating in free space, the magnitude
of the generated electric field is η0 × 5 × 10−4 ≈ 0.1885 V/m, where η0 is the intrinsic impedance
of free space (η0 ≈ 377).
Examining the listing of the one-dimensional FDTD code in Appendix A, one immediately
notices that the sizes of the arrays associated with E z and Hy are not the same. The one-dimensional
problem space is divided into nx intervals; therefore, there are nx + 1 nodes in the problem space
including the left and right boundary nodes. This code is based on the field positioning scheme
given in Fig. 1.13, where the E z components are defined at node positions and the Hy components
are defined at the center positions of the intervals. Therefore, arrays associated with E z have the
size nx + 1, whereas those associated with Hy have the size nx.
Another point that deserves consideration is the application of the boundary conditions. In
this problem the boundaries are PEC; thus, the tangential electric field component (E z in this
case) vanishes on the PEC surface. Therefore, this condition can be enforced on the electric field
component on the boundaries, E z (1) and E z (nx + 1), as can be seen in the code listing. Observing
the changes in the fields from time step 650 to 700 in Fig. 1.14 reveals the correct behavior of
the incident and reflected waves for a PEC plate. This is evident by the reversal of the direction
of the peak value of E z after reflection from the PEC boundaries, which represents a reflection
coefficient equal to −1 while the behavior of the reflected Hy component represents the reflection
coefficient that is equal to +1 as expected.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

32 Introduction to FDTD

1.6 EXERCISES
1.1 Follow the steps presented in Section 1.2 to develop the appropriate approximations for the
first derivative of a function with second-order accuracy using the forward and backward
difference procedure and fourth-order accuracy using the central difference procedure.
Compare your derived expressions with those listed in Table 1.1.
1.2 Update the MATLAB program in Listing 1.1 to regenerate Fig. 1.2 using the second-order
accurate forward and backward differences and the fourth-order accurate central difference
approximations for the same function.
1.3 Update the MATLAB program in Listing 1.1 to generate the corresponding figures to
Fig. 1.2, but for the second derivatives of the function. Use the approximate expressions in
the right column of Table 1.1 while updating the program.
1.4 The steps of the development of the updating equation for the x component of the electric
field are demonstrated in Section 1.3. Follow the same procedure to show the steps required
to develop the updating equations for the y and z components for the electric field. Pay
sufficient attention to the selection of the indices of each individual field component in your
expressions. The Yee cell presented in Fig. 1.6 should help you in understanding the proper
use of these indices.
1.5 Repeat Exercise 1.4, but this time for developing the updating equations for the magnetic
field components.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

2
Numerical Stability and Dispersion

2.1 NUMERICAL STABILITY

The finite-difference time-domain (FDTD) algorithm samples the electric and magnetic fields at
discrete points both in time and space. The choice of the period of sampling (t in time, x, y,
and z in space) must comply with certain restrictions to guarantee the stability of the solution.
Furthermore, the choice of these parameters determines the accuracy of the solution. This section
focuses on the stability analysis. First, the stability concept is illustrated using a simple partial
differential equation (PDE) in space and time domain. Next, the Courant-Friedrichs-Lewy (CFL)
condition [3] for the FDTD method is discussed, accompanied by a one-dimensional FDTD
example.

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, let’s start with a simple wave equation:

∂u(x, t) ∂u(x, t)
+ = 0, u(x, t = 0) = u 0 (x), (2.1)
∂t ∂x

where u(x, t) is the unknown wave function and u 0 (x) is the initial condition at t = 0. Using the
PDE knowledge, the equation can be analytically solved:

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 finite-difference scheme is used to
compute the derivatives, and the following equation is obtained:

uin+1 − uin−1 u n − ui+1


n
+ i−1 = 0. (2.4)
2t 2x

33
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

34 Numerical Stability and Dispersion

5ε/8 -5ε/8
n+5
ε/2 ε/2 ε/2
n+4
ε/8 5ε/8 -5ε/8 -ε/8
n+3
ε/4 ε/2 ε/4
n+2
ε/2 -ε/2
n+1
ε
n

n-1 x
i-2 i-1 i i+1 i+2

Figure 2.1 The time–space domain grid with error ε propagating with λ = 1/2.

After a simple manipulation, a time-domain numerical scheme can be derived such that
 n  t
uin+1 = uin−1 + λ ui+1 − ui−1
n
, λ= . (2.5)
x
Figure 2.1 shows a time and space domain grid, where the horizontal axis represents the x axis
and the vertical axis denotes the t axis. The u values for time index denoted as n and n − 1 are all
assumed to be known. For simplicity we will assume that all these values are zeros. We will also
assume that at one x position denoted by the index i and at time denoted by the index n there is
a small error represented by the parameter . As the time evolves, a u value at n + 1 is computed
from two rows lower in accordance with equation (2.5).
Now let’s analyze the propagation of the assumed numerical error in this time domain
algorithm. Note that the error may result from a numerical truncation of a real number. When
λ = 1/2, the errors are shown in Fig. 2.1. The error will keep propagating in this time domain
algorithm; however, it can be observed that the errors are always bounded by the original error ,
whereas for the case when λ = 1, the maximum absolute value of the propagating error is of the
same value as the original error. This is clearly obvious from the errors propagating in Fig. 2.2.
On the contrary, when λ = 2, the propagation of error as shown in Fig. 2.3 will keep increasing
as time evolves. Finally, this error will be large enough and will destroy the actual u values. As a
result, the time-domain algorithm will not give an accurate result due to a very small initial error.
In summary, the numerical scheme in (2.5) is therefore considered conditionally stable. It is stable
for small λ values but unstable for large λ values, and the boundary of stability condition is λ = 1.

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 specific bound relative to the lattice space increments,
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Numerical Stability 35

ε -ε
n+5
-ε ε -ε
n+4
ε -ε ε -ε
n+3

ε -ε ε
n+2

n+1 ε -ε

n ε

n-1 x
i-2 i-1 i i+1 i+2

Figure 2.2 The time–space domain grid with error ε propagating with λ = 1.

66ε 50ε
n+5
4ε -25ε 4ε
n+4
8ε 8ε -8ε -8ε
n+3

4ε 7ε 4ε
n+2

n+1 2ε -2ε

n ε

n-1 x
i-2 i-1 i i+1 i+2

Figure 2.3 The time–space domain grid with error ε propagating with λ = 2.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

36 Numerical Stability and Dispersion

such that

1
t ≤  , (2.6)
2 + +
1 1 1
c (x) (y)2 (z)2

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

1 1 1
c t 2
+ 2
+ ≤ 1. (2.7)
(x) (y) (z)2

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

x
t ≤ √ . (2.8)
c 3

One can notice in (2.6) that the smallest value among x, y, and z is the dominant factor
controlling the maximum time step and that the maximum time step allowed is always smaller
than min(x, y, z)/c .
In the one-dimensional case where y → ∞ and z → ∞ in (2.6), the CFL condition
reduces to

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 fields in
the problem space as the FDTD iterations proceed. For instance, the one-dimensional FDTD
code presented in Chapter 1 simulates a problem space composed of cells having length x =
1 mm. Due to the one-dimensional CFL condition (2.9) the time increment must be chosen as
t ≤ 3.3356 ps. This code is run with the values of t = 3.3356 ps and t = 3.3357 ps, and the
maximum value of electric field magnitude is captured at every time step and plotted in Fig. 2.4.
The spikes of the electric field magnitude are due to the additive interference of the fields when
fields pass through the center of the problem space, and the nulls are due to the vanishing of
electric fields on PEC when the fields hit the PEC boundary walls. However, while the iterations
proceed, the electric field magnitude calculated by the simulation running with t = 3.3357 ps
starts to diverge. This examination demonstrates how a t value larger than the CFL limit gives
rise to instability in the FDTD computation.
The CFL stability condition applies to inhomogeneous media as well, since the velocity of
propagation in material media is smaller than c . However, numerical stability can be influenced
by other factors, such as absorbing boundary conditions, nonuniform spatial grids, and nonlinear
materials.
Even if the numerical solution is stable, satisfaction of the CFL condition does not guarantee
the numerical accuracy of the solution; it only provides a relationship between the spatial grid
size and the time step. One must still satisfy the sampling theory requirements with respect to the
highest frequency present in the excitation.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Numerical Dispersion 37

3
∆t = 3.3356 ps
∆t = 3.3357 ps
2.5
maximum Ez [V/m]
2

1.5

0.5

0
0 1 2 3 4 5 6
time [ns]

Figure 2.4 Maximum magnitude of E z in the one-dimensional problem space for simulations with t = 3.3356
ps and t = 3.3357 ps.

2.2 NUMERICAL DISPERSION

The FDTD method provides a solution for the behavior of fields that is usually a good approxima-
tion to the real physical behavior of the fields. The finite-difference approximation of derivatives
of continuous functions introduces an error to the solution. For instance, even in homogeneous
free space, the velocity of propagation of the numerical solution for a wave will generally differ
from c . Furthermore, it will vary with frequency, the spatial grid size, and direction of propagation
of the wave. The differing of phase velocities numerically obtained by the FDTD method from
the actual phase velocities is known as numerical dispersion.
For instance, consider a plane wave propagating in free space in the x direction, given by

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) satisfies the wave equation

∂2 ∂2
E z − µ0 ε0 E z = 0. (2.11)
∂ x2 ∂t 2

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


 ω 2
kx2 = ω2 µ0 ε0 = , (2.12)
c
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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 finite difference approximation of Maxwell’s curl equations as follows. For the one-
dimensional case previously discussed, the plane wave expressions E z (x, t) and Hy (x, t) satisfy the
Maxwell’s one-dimensional curl equations, which are given for the source-free region as

∂ Ez 1 ∂ Hy
= , (2.13a)
∂t ε0 ∂ x
∂ Hy 1 ∂ Ez
= . (2.13b)
∂t µ0 ∂ x

These equations can be rewritten using the central difference formula based on the field positioning
scheme in Fig. 1.13 as

n+ 12 n+ 12
E zn+1 (i) − E zn (i) 1 Hy (i) − Hy (i − 1)
= , (2.14a)
t ε0 x
n+ 12 n− 12
Hy (i) − Hy (i) 1 E zn (i + 1) − E zn (i)
= . (2.14b)
t µ0 x

The plane wave equations (2.10) are in continuous time and space, and they can be expressed in
discrete time and space with

E zn (i) = E0 cos(kx ix − ωnt), (2.15a)


E zn+1 (i) = E0 cos(kx ix − ω(n + 1)t), (2.15b)
E zn (i + 1) = E0 cos(kx (i + 1)x − ωnt), (2.15c)
n+ 12
Hy (i) = H0 cos(kx (i + 0.5)x − ω(n + 0.5)t), (2.15d)
n+ 12
Hy (i − 1) = H0 cos(kx (i − 0.5)x − ω(n + 0.5)t), (2.15e)
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)]. (2.16)
ε0 x

Using the trigonometric identity

cos(u − v) − cos(u + v) = 2 sin(u) sin(v)


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Numerical Dispersion 39

on the left-hand side of (2.16) with u = kx ix − ω(n + 0.5)t and v = 0.5t, and on the right-
hand side with u = kx ix − ω(n + 0.5)t and v = −0.5x, one can obtain
E0 −H0
sin(0.5ωt) = sin(0.5kx x). (2.17)
t ε0 x
Similarly, using the terms (2.15a), (2.15c), (2.15d), and (2.15f ) in (2.14b) leads to
H0 −E0
sin(0.5ωt) = sin(0.5kx x). (2.18)
t µ0 x
Combining (2.17) and (2.18) one can obtain the numerical dispersion relation for the one-
dimensional case as

 
 
1 ωt 2 1 kx x 2
sin = sin . (2.19)
c t 2 x 2
One should notice that the numerical dispersion relation (2.19) is different from the ideal dis-
persion relation (2.12). The difference means there is a deviation from the actual solution of a
problem and, hence, an error introduced by the finite-difference approximations to the numerical
solution of the problem. However, it is interesting to note that for the one-dimensional case,
if one sets t = x/c , (2.19) reduces to (2.12), which means that there is no dispersion error
for propagation in free space. However, this is of little practical use, since the introduction of a
material medium will again create dispersion.
So far, derivation of a numerical dispersion relation has been demonstrated for a one-
dimensional case. It is possible to obtain a numerical dispersion relation for the two-dimensional
case using a similar approach:

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

x = y = , t = √ , and kx = k y ,
c 2
the ideal dispersion relation for the two-dimensional case can be recovered as
 ω 2
kx2 + k2y = . (2.21)
c
The extension to the three-dimensional case is straightforward but tedious, yielding

 
 
 
 
1 ωt 2 1 kx x 2 1 ky y 2 1 kz z 2
sin = sin + sin + sin .
c t 2 x 2 y 2 z 2
(2.22)

Similar to the one- and two-dimensional cases, it is possible to recover the three-dimensional ideal
dispersion relation
 ω 2
kx2 + k2y + kz2 = (2.23)
c
for specific choices of t, x, y, z, and angle of propagation.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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.

Let’s rewrite (2.22) in the following form:


2
2
2
2
ω sin(ωt/2) kx sin(kx x/2) ky sin(ky y/2) kz sin(kz z/2)
= + + . (2.24)
2c (ωt/2) 2 (kx x/2) 2 (ky y/2) 2 (kz z/2)

Since limx→0 (sin(x)/x) = 1, (2.24) reduces to the ideal dispersion relation (2.23) when t → 0,
x → 0, y → 0, and z → 0. This is an expected result since when the sampling periods
approach zero, the discrete approximation turns into the continuous case. This also indicates that
if the temporal and spatial sampling periods t, x, y, and z are taken smaller, then the
numerical dispersion error reduces.
So far, we have discussed the numerical dispersion in the context of waves propagating in free
space. A more general discussion of numerical stability and dispersion, including the derivation of
two- and three-dimensional numerical dispersion relations, other factors affecting the numerical
dispersion, and strategies to reduce the associated errors, can be found in [1]. We conclude our
discussion with an example demonstrating the numerical dispersion.
Due to numerical dispersion, waves with different frequencies propagate with different phase
velocities. Any waveform is a sum of sinusoidal waves with different frequencies, and a waveform
does not maintain its shape while propagating since its sinusoidal components do not propagate
with the same velocity due to dispersion. Therefore, the existence of numerical dispersion exposes
itself as distortion of the waveform. For instance, Fig. 2.5 shows the electric and magnetic field
in the one-dimensional problem space calculated by the one-dimensional FDTD code presented
in Chapter 1. The problem space is 1 m wide, and t = 3 ps. Figure 2.5(a) shows the field
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Exercises 41

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

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 field 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 × 10−3 A/m; hence, the magnitudes of electric and magnetic fields
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 significant. 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 prop-
agates in a medium characterized with electric losses instead of free space. Observe the decay
of the amplitude of the propagating pulse and the effect of losses on the dispersion shown
in Fig. 2.5(b) at time = 3 ns.
2.3 Repeat Exercise 2.2, but with the introduction of magnetic losses in the medium, instead of
free space. Record your observations related to the pulse propagation at time = 3 ns.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

3
Building Objects in the Yee Grid

In Chapter 1 we discussed the derivation of the finite-difference time-domain (FDTD) updat-


ing equations based on the staircased grid composed of Yee cells in Cartesian coordinates. We
defined material components ε, µ, σ e , and σ m associated with the field components such that
they represent linear, anisotropic, nondispersive media. Due to the staircase gridding, the ob-
jects 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 repre-
sentation of the objects in the problem space. Some advanced modeling techniques called local
subcell models are available for defining objects with fine features, and some other FDTD for-
mulations 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 sufficiently accurate results for many practical problems. In this chap-
ter 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 con-
struction of an FDTD program as well. After completing this book, the reader should be able to
construct an FDTD program that can be used to solve three-dimensional electromagnetics prob-
lems of moderate difficulty. In this chapter, we start to provide the blocks of a three-dimensional
FDTD program.
We name the main MATLAB program file that runs an FDTD calculation as fdtd solve.
The MATLAB code in Listing 3.1 shows the contents of fdtd solve, in which the program
routines are named by their functions. Usually it is a good practice to divide a program into
functionally separable modules; this will facilitate the readability of the programs and will simplify
the debugging process. This file is not in the final form for a complete FDTD program; while
we proceed with the chapters we will add more routines with additional functions, will describe
the functions of the routines, and will provide partial code sections to illustrate the programming
of the respective concepts that have been described in the text. The program structures and
codes presented throughout this book are not necessarily samples of the most efficient ways of
programming the FDTD method; there are many ways of translating a concept into a program,
and readers can develop program structures or algorithms that they think are more efficient while
writing their own code. However, we tried to be as explicit as possible while linking the FDTD
concepts with the respective codes.

43
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

44 Building Objects in the Yee Grid

Listing 3.1 fdtd solve.m



% i n i t i a l i z e the matlab workspace
2 clear all ; close all ; clc ;

4 % d e f i n e t h e problem
define problem space parameters ;
6 define geometry ;
define sources and lumped elements ;
8 define output parameters ;

10 % i n i t i a l i z e t h e problem s p a c e and p a r a m e t e r s
initialize fdtd material grid ;
12 display problem space ;
display material mesh ;
14 if run simulation
initialize fdtd parameters and arrays ;
16 initialize sources and lumped elements ;
initialize updating coefficients ;
18 initialize boundary conditions ;
initialize output parameters ;
20 initialize display parameters ;

22 % FDTD t i m e m a r c h i n g l o o p
run fdtd time marching loop ;
24

% display simulation results


26 post process and display results ;
end
 

In the FDTD algorithm, before the time-marching iterations are performed the problem
should be set up as the first step as indicated in the concise flow chart in Fig. 1.9. Problem setup
can be performed in two sets of routines: (1) routines that define the problem; and (2) routines
that initialize the problem space and FDTD parameters. The problem definition process consists
of construction of data structures that store the necessary information about the electromagnetic
problem to be solved. This information would include the geometries of the objects in the problem
space, their material types, electromagnetic properties of these material types, types of sources
and waveforms, types of simulation results sought from the FDTD computation, and some other
simulation parameters specific to the FDTD algorithm, such as the number of time steps, and
types of boundaries of the problem space. The initialization process translates the data structures
into an FDTD material grid and constructs and initializes data structures and arrays representing
the FDTD updating coefficients, field components, and any other data structures that would be
used during and after the FDTD iterations. In other words, it prepares the structural framework
for the FDTD computation and postprocessing.

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
figures, and clc clears the command window. After the MATLAB workspace initialization, there
are four subroutines listed in Listing 3.1 for definition of the problem and other subroutines
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Definition of Objects 45

for initialization of the FDTD procedure. In this chapter, we implement the subroutines defi-
ne problem space parameters, define geometry, and initialize fdtd material grid.
The contents of the subroutine define problem space parameters are given in Listing 3.2.
Listing 3.2 starts with the MATLAB command disp, which displays the string in its argument on
MATLAB’s command window. Here the string argument of disp indicates that the program is
executing the routine in which the problem space parameters are defined. Displaying this kind of
informative statement at various stages of the program indicates the progress of the execution as
well as helps for debugging any sources of errors if they exist.
Listing 3.2 define problem space parameters.m
1 d i s p ( ’ d e f i n i n g t h e problem s p a c e p a r a m e t e r s ’ ) ;

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 = 700;
5

% A f a c t o r t h a t determines d u r a t i o n of a time s t e p
7 % wrt CFL l i m i t
courant factor = 0.9;
9

% A f a c t o r d e t e r m i n i n g t h e a c c u r a c y l i m i t o f FDTD r e s u l t s
11 number of cells per wavelength = 20;

13 % D i m e n s i o n s o f a u n i t c e l l i n x , y , and z d i r e c t i o n s ( m e t e r s )
dx = 2.4 e −3;
15 dy = 2.0 e −3;
dz = 2.2 e −3;
17

% ==<b o u n d a r y c o n d i t i o n s >========
19 % Here we d e f i n e t h e b o u n d a r y c o n d i t i o n s p a r a m e t e r s
% ’ pec ’ : p e r f e c t e l e c t r i c c o n d u c t o r
21 b o u n d a r y . t y p e x p = ’ pec ’ ;
boundary . a i r b u f f e r n u m b e r o f c e l l s x p = 5 ;
23

b o u n d a r y . t y p e x n = ’ pec ’ ;
25 boundary . a i r b u f f e r n u m b e r o f c e l l s x n = 5 ;

27 b o u n d a r y . t y p e y p = ’ pec ’ ;
boundary . a i r b u f f e r n u m b e r o f c e l l s y p = 10;
29

b o u n d a r y . t y p e y n = ’ pec ’ ;
31 boundary . a i r b u f f e r n u m b e r o f c e l l s y n = 5 ;

33 b o u n d a r y . t y p e z p = ’ pec ’ ;
boundary . a i r b u f f e r n u m b e r o f c e l l s z p = 5 ;
35

b o u n d a r y . t y p e z n = ’ pec ’ ;
37 boundary . a i r b u f f e r n u m b e r o f c e l l s z n = 0 ;

39 % ===< m a t e r i a l t y p e s >============
% Here we d e f i n e and i n i t i a l i z e t h e a r r a y s o f m a t e r i a l t y p e s
41 % eps r : relative permittivity
% mu r : relative permeability
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

46 Building Objects in the Yee Grid

43 % sigma e : e l e c t r i c c o n d u c t i v i t y
% sigma m : m a g n e t i c c o n d u c t i v i t y
45

% air
47 material types (1). eps r = 1;
material types (1). mu r = 1;
49 material types (1). sigma e = 0;
material types (1). sigma m = 0 ;
51 material types (1). color = [1 1 1];

53 % PEC : p e r f e c t e l e c t r i c c o n d u c t o r
material types ( 2 ) . eps r = 1;
55 m a t e r i a l t y p e s ( 2 ) . mu r = 1;
m a t e r i a l t y p e s ( 2 ) . s i g m a e = 1 e10 ;
57 m a t e r i a l t y p e s ( 2 ) . sigma m = 0 ;
material types ( 2 ) . color = [1 0 0];
59

% PMC : p e r f e c t m a g n e t i c c o n d u c t o r
61 material types ( 3 ) . eps r = 1;
m a t e r i a l t y p e s ( 3 ) . mu r = 1;
63 m a t e r i a l t y p e s ( 3 ) . sigma e = 0;
m a t e r i a l t y p e s ( 3 ) . sigma m = 1 e10 ;
65 material types ( 3 ) . color = [0 1 0];

67 % a dielectric
material types (4). eps r = 2.2;
69 material types (4). mu r = 1;
material types (4). sigma e = 0;
71 material types (4). sigma m = 0 . 2 ;
material types (4). color = [0 0 1];
73

% a dielectric
75 material types (5). eps r = 3.2;
material types (5). mu r = 1.4;
77 material types (5). sigma e = 0 . 5 ;
material types (5). sigma m = 0 . 3 ;
79 material types (5). color = [1 1 0];

81 % 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;
83 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 defined
in line 4 of Listing 3.2 with the parameter number of time steps. Line 8 defines a parameter
named courant factor: a factor by which the duration of a time step is determined with respect
to the CFL stability limit as described in Chapter 2. In line 11 another parameter is defined with
the name number of cells per wavelength. This is a parameter by which the highest frequency
in the Fourier spectrum of a source waveform is determined for a certain accuracy level. This
parameter is described in more detail in Chapter 5, where the source waveforms are discussed.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Definition of Objects 47

On lines 14, 15, and 16 the dimensions of a unit cell constructing the uniform FDTD problem
grid are defined as parameters dx, dy, and dz, respectively.
One of the important concepts in the FDTD technique is the treatment of boundaries of the
problem space. The treatment of perfect electric conductor (PEC) boundaries was demonstrated
in Chapter 1 through a one-dimensional FDTD code. However, some types of problems may
require other types of boundaries. For instance, an antenna problem requires that the boundaries
simulate radiated fields propagating outside the finite problem space to infinity. Unlike a PEC
boundary, this type of boundary requires advanced algorithms, which is the subject of a separate
chapter. However, for now, we limit our discussion to PEC boundaries. A conventional FDTD
problem space composed of uniform Yee cells is a rectangular box having six faces. On lines
21–37 of Listing 3.2 the boundary types of these six faces are defined using a data structure called
boundary. The structure boundary has two types of fields: type and air buffer number of cells.
These field names have extensions indicating the specific face of the domain under consideration.
For instance, the extension xn refers to the face of the problem space for which the normal
vector is directed in the negative x direction, where n stands for negative direction. Similarly, the
extension zp refers to the face of the problem space for which the normal vector is directed in the
positive z direction, where p stands for positive direction. The other four extensions refer to four
other faces. The field type defines the type of the boundary under consideration, and in this case
all boundaries are defined as PEC by the keyword pec. Other types of boundaries are identified
with other keywords.
Some types of boundary conditions require that the boundaries be placed at a distance from
the objects. Most of the time this space is filled with air, and the distance in between is given
in terms of the number of cells. Hence, the parameter air buffer number of cells defines the
distance of the respective boundary faces of the rectangular problem space from the objects placed
in the problem space. If the value of this parameter is zero, it implies that the boundary touches
the objects.
Finally, we define different types of materials that the objects in the problem space are made of.
Since more than one type of material may be used to construct the objects, an array structure with
name material types is used as shown in lines 47–79 of Listing 3.2. An index i in material types(i)
refers to the i th material type. Later on, every object will be assigned a material type through
the index of the material type. An isotropic and homogeneous material type can be defined by its
electromagnetic parameters: relative permittivity εr , relative permeability µr , electric conductivity
σ e , and magnetic conductivity σ m ; hence, fields eps r, mu r, sigma e, and sigma m are used with
parameter material types(i), respectively, to define the electromagnetic parameters of i th material
type. In the given example code a very high value is assigned to material types(2).sigma e to
construct a material type simulating a PEC, and a very high value is assigned to material -
types(3).sigma m to construct a material type simulating a perfect magnetic conductor (PMC).
A fifth field color in material types(i) is optional and is used to assign a color to each material
type, which will help in distinguishing different material types when displaying the objects in the
problem space on a MATLAB figure. The field color is a vector of three values corresponding to
red, green, and blue intensities of the red, green, and blue (RGB) color scheme, respectively, with
each color scaled between 0 and 1.
While defining the material types it is a good practice to reserve some indices for some
common material types. Some of these material types are air, PEC, and PMC, and these material
types are indexed as 1, 2, and 3 in the material types structure array, respectively. Then we can
define additional parameters material type index air, material type index pec, and material -
type index pmc, which store the indices of these materials and can be used to identify them in
the program.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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 definition 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 fields 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 field 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 defined
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 defined as a PEC.
A sphere can be defined by its center coordinates and radius as illustrated in Fig. 3.1(b). There-
fore, a structure array spheres is used in Listing 3.3 together with the fields center x, center y,
center z, and radius which correspond to the respective parameters in Cartesian coordinates.
Similar to the brick case, the field material type is used together with spheres(i) to define the
material type of the i th sphere. For example, in Listing 3.3 two spheres are defined 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 first 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 defining two arrays, bricks
and spheres, and initializes them by null. Even though we are not going to define an object
corresponding to some of these arrays, we still define them and initialize them as empty arrays.
Later, when the program executes, these arrays will be accessed by some routines of the program.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Definition of Objects 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

bricks = [ ] ;
4 spheres = [ ] ;

6 % define a b r i c k with material type 4


b r i c k s ( 1 ) . min x = 0 ;
8 b r i c k s ( 1 ) . min y = 0 ;
b r i c k s ( 1 ) . min z = 0 ;
10 b r i c k s ( 1 ) . max x = 24 e −3;
b r i c k s ( 1 ) . max y = 20 e −3;
12 b r i c k s ( 1 ) . max z = 11 e −3;
bricks ( 1 ) . material type = 4;
14

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


16 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;
18 b r i c k s ( 2 ) . m i n z = −11e −3;
b r i c k s ( 2 ) . max x = 0 ;
20 b r i c k s ( 2 ) . max y = 0 ;
b r i c k s ( 2 ) . max z = 0 ;
22 bricks ( 2 ) . material type = 2;

24 % define a sphere with material type 5


spheres ( 1 ) . radius = 20 e −3;
26 spheres ( 1 ) . center x = 0;
spheres ( 1 ) . center y = 0;
28 spheres ( 1 ) . c e n t e r z = 40 e −3;
spheres ( 1 ) . material type = 5;
30

% define a sphere with material type 1


32 spheres ( 2 ) . radius = 15 e −3;
spheres ( 2 ) . center x = 0;
34 spheres ( 2 ) . center y = 0;
spheres ( 2 ) . c e n t e r z = 40 e −3;
36 spheres ( 2 ) . material type = 1;
 

If MATLAB tries to access a parameter that does not exist in its workspace, it is going to fail and
stop the execution of the program. To prevent such a runtime error we define these arrays even
though they are empty.
So far we have defined an FDTD problem space and defined some objects existing in it.
Combining the definitions in Listings 3.2 and 3.3 we obtained a problem space, which is plotted
in Fig. 3.2. The dimensions of the cells in the grids in Fig. 3.2 are the same as the dimensions
of the unit cell making the FDTD grid. Therefore, it is evident that the boundaries are away
from the objects by the distances defined in Listing 3.2. Furthermore, the objects are placed in
the three-dimensional space with the positions and dimensions as defined in Listing 3.3, and their
colors are set as their corresponding material type colors.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

50 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 field components are defined at discrete loca-
tions, and the associated material components are defined at the same locations as illustrated in
Figs. 1.5 and 1.6. The material components need to be assigned appropriate values representing
the media existing at the respective positions. However, the medium around a material component
may not be homogeneous, and some approximation strategies need to be adopted.
One of the strategies is to assume that each material component is residing at the center of a
cell. These cells are offset from the Yee cells, and we refer to them as material cells. For instance,
consider the z-component of permittivity shown in Fig. 3.3, which can be imagined as being at
the center of a material cell partially filled with two different media denoted by subscripts 1 and 2,
with permittivity values ε1 and ε2 . The simplest approach is to assume that the cell is completely
filled with medium 1 since the material component εz (i, j, k) resides in the medium 1. Therefore,
εz (i, j, k) can be assigned ε1 ; εz (i, j, k) = ε1 .
A better approach would include the effect of ε2 by employing an averaging scheme. If it is
possible to obtain the volume of each medium filling the material cell, a simple weighted volume
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Material Approximations 51

Figure 3.3 A cell around material component εz (i, j, k) partially filled with two media.

averaging can be used as employed in [5]. In the example case shown in Fig. 3.3, εz (i, j, k) can
be calculated as εz (i, j, k) = (V1 × ε1 + V2 × ε2 )/(V1 + V2 ), where V1 and V2 are the volumes of
medium 1 and medium 2 in the material cell, respectively.
In many cases calculation of the volume of each media in a cell may require tedious calculations,
whereas it may be much simpler to determine the medium in which a point resides. A crude
approximation to the weighted volume averaging scheme is proposed in [6], which may be useful
for such cases. In this approach, every cell in the Yee grid is divided into eight subcells, and
each material component is located in between eight subcells, as illustrated in Fig. 3.4. For every

Figure 3.4 A cell around material component εz (i, j, k) divided into eight subcells.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

52 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
ε1 + ε2 + ε3 + ε4 + ε5 + ε6 + ε7 + ε8
εz (i, j, k) = . (3.1)
8
The advantage of this method is that objects may be modeled with eight times the geometrical
resolution (two times in each direction) without increasing the size of the staggered grid and
memory requirements.

3.3 SUBCELL AVERAGING SCHEMES FOR TANGENTIAL AND NORMAL COMPONENTS


The methods discussed thus far do not account for the orientation of the field component asso-
ciated 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 filled with two different types of media. In the first case the material component
is parallel to the boundary of the two media, whereas in the second case the material compo-
nent 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, Ampere’s law can be expressed in integral form based on the configuration 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.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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 field components in the two media are E z1 and E z2 . The total
electric flux through the cell cross-section can be expressed as

Dz × (A1 + A2 ) = ε1 E z1 A1 + ε2 E z2 A2 = εeff E z × (A1 + A2 ),

where E z is the electric field component (i, j, k), which is assumed to be uniform in the cross-
section of the cell and associated with the permittivity εeff that is equivalent to εz (i, j, k). On the
boundary of the media the tangential components of the electric field are continuous such that
E z1 = E z2 = E z ; therefore, one can write

ε1 A1 + ε2 A2
ε1 A1 + ε2 A2 = εeff × (A1 + A2 ) ⇒ εeff = εz (i, j, k) = . (3.2)
(A1 + A2 )

Hence, an equivalent permittivity can be calculated for a material component parallel to the
interface of two different material types of permittivity ε1 and ε2 using (3.2), by which the electric
flux conservation is maintained.
For the case where the material component is normal to the media boundary we can employ
Faradays’s law in integral form based on the configuration in Fig. 3.6, which reads

d
E · dl = − B · d s
dt
= −x E x (i, j, k) + x E x (i, j + 1, k) + zE z (i, j, k) − zE z (i + 1, j, k),
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

54 Building Objects in the Yee Grid

where E z is the equivalent electric field vector component in the z direction, which is assumed
to be uniform in the boundary cross-section. However, in reality there are two different electric
field values, E z1 and E z2 , due to the different material types. We want to obtain E z to represent
the equivalent effect of E z1 and E z2 and εeff to represent the equivalent effect of ε1 and ε2 . The
electric field terms shall satisfy

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

Dz (i, j, k) Dz (i, j, k) Dz (i, j, k)


E z1 = , E z2 = , E z (i, j, k) = . (3.5)
ε1 ε2 εeff

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) = . (3.6)
εeff ε1 ε2 (l 1 ε2 + l 2 ε1 )

Hence, an expression for the equivalent permittivity has been obtained in (3.6), by which the
magnetic flux conservation is maintained.
The averaging schemes given by (3.2) and (3.6) are specific cases of the more general approaches
introduced in [7], [8], and [9].
It can be shown that these schemes can be employed for other material parameters as well. For
instance, the equivalent permeability µ can be written as
µ1 A1 + µ2 A2
µeff = , µ parallel to media boundary, (3.7a)
(A1 + A2 )
µ1 µ2 × (l 1 + l 2 )
µeff = , µ normal to media boundary. (3.7b)
(l 1 µ2 + l 2 µ1 )

These schemes serve as good approximations for low values of σ e and σ m as well, where they can
be written as
σ1e A1 + σ2e A2
σeff
e
= , σe parallel to media boundary, (3.8a)
(A1 + A2 )
σ1e σ2e × (l 1 + l 2 )
σeff
e
= , σe normal to media boundary, (3.8b)
(l 1 σ2e + l 2 σ1e )

and
σ1m A1 + σ2m A2
σeff
m
= , σm parallel to media boundary, (3.9a)
(A1 + A2 )
σ1m σ2m × (l 1 + l 2 )
σeff
m
= , σm normal to media boundary. (3.9b)
(l 1 σ2m + l 2 σ1m )
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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 fine 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 filled with a sin-
gle 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 compli-
cated programming effort and since it is sufficient to obtain reliable results for many problems.
Furthermore, we still employ the aforementioned subcell averaging schemes for obtaining ef-
fective values for the material components lying on the boundaries of cells filled 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 filled with a material type. Every Yee cell is indexed by a respective
node. Since every cell is filled with a material type, three-dimensional material arrays can be
utilized, each element of which corresponds to the material type filling the respective cell. For
instance, ε(i − 1, j − 1, k) holds the permittivity value of the material filling 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

ε(i, j, k) + ε(i − 1, j, k) + ε(i, j − 1, k) + ε(i − 1, j − 1, k)


εz (i, j, k) = . (3.10)
4

Since the electric conductivity material components are defined at the same positions as the
permittivity components, the same averaging scheme can be employed to get the equivalent

Figure 3.7 Material component εz (i, j, k) located between four Yee cells filled with four different material types.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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

σ e (i, j, k) + σ e (i − 1, j, k) + σ e (i, j − 1, k) + σ e (i − 1, j − 1, k)
σze (i, j, k) = . (3.11)
4
Unlike the permittivity and electric conductivity components, the material components as-
sociated with magnetic field components, permeability and magnetic conductivity, are located
between two cells and are oriented normal to the cell boundaries as illustrated in Fig. 3.8. In this
case we can use the relation (3.7b) to get µz (i, j, k) as

2 × µ(i, j, k) × µ(i, j, k − 1)
µz (i, j, k) = . (3.12)
µ(i, j, k) + µ(i, j, k − 1)

Similarly, we can write σzm (i, j, k) as

2 × σ m (i, j, k) × σ m (i, j, k − 1)
σzm (i, j, k) = . (3.13)
σ m (i, j, k) + σ m (i, j, k − 1)

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
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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
the conductivity of PEC, σpec
e
, to these material components, such that

σxe (i, j, k) = σpec


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

Therefore, any electric conductivity components surrounding and coinciding with PEC plates can
be assigned the conductivity of PEC to model zero-thickness PEC plates in the FDTD method.
Similarly, if a PEC object with thickness smaller than a cell size in two dimensions, such as
a thin conductor wire, needs to be modeled in the FDTD method, it is sufficient to assign the
conductivity of PEC to the electric conductivity components coinciding with the object. This
approach gives a reasonable approximation to a thin wire in the FDTD method. However, since
the field variation around a thin wire is large, the sampling of the fields at the discrete points
around the wire may not be accurate. Therefore, it is more appropriate to use more advanced
thin-wire modeling techniques, which take into account the wire thickness, for better accuracy. A
thin-wire modeling technique is discussed in Chapter 10.

3.5 CREATION OF THE MATERIAL GRID

At the beginning of this chapter we discussed how we can define the objects using data structures in
MATLAB. We use these structures to initialize the FDTD material grid; we create and initialize
three-dimensional arrays representing the components of the material parameters ε, µ, σ e , and
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

58 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
coefficients.
The routine initialize fdtd material grid, which is used to initialize the material arrays, is
given in Listing 3.4. The material array initialization process is composed of multiple stages;
therefore, initialize fdtd material grid is divided into functional subroutines. We describe the
implementation of these subroutines and demonstrate how the concepts described in Section 3.4
are coded.

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
4 % l o c a t i o n s and b o u n d a r y c o n d i t i o n s
calculate domain size ;
6

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


8 % 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
10 m a t e r i a l 3 d s p a c e = o n e s ( nx , ny , nz ) ;

12 % C r e a t e t h e 3D o b j e c t s i n t h e problem s p a c e by
% a s s i g n i n g i n d i c e s of material types in the c e l l s
14 % to material 3d space

16 % create spheres
create spheres ;
18

% create bricks
20 create bricks ;

22 % M a t e r i a l component a r r a y s f o r a problem s p a c e
% composed o f ( nx , ny , nz ) c e l l s
24 eps r x = o n e s ( nx , nyp1 , nzp1 ) ;
eps r y = o n e s ( nxp1 , ny , nzp1 ) ;
26 eps r z = o n e s ( nxp1 , nyp1 , nz ) ;
mu r x = o n e s ( nxp1 , ny , nz ) ;
28 mu r y = o n e s ( nx , nyp1 , nz ) ;
mu r z = o n e s ( nx , ny , nzp1 ) ;
30 sigma e x = z e r o s ( nx , nyp1 , nzp1 ) ;
sigma e y = z e r o s ( nxp1 , ny , nzp1 ) ;
32 sigma e z = z e r o s ( nxp1 , nyp1 , nz ) ;
sigma m x = z e r o s ( nxp1 , ny , nz ) ;
34 sigma m y = z e r o s ( nx , nyp1 , nz ) ;
sigma m z = z e r o s ( nx , ny , nzp1 ) ;
36

% c a l c u l a t e m a t e r i a l component v a l u e s by a v e r a g i n g
38 calculate material component values ;

40 % c r e a t e z e r o t h i c k n e s s PEC p l a t e s
create PEC plates ;
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Creation of the Material Grid 59

The first subroutine in Listing 3.4 is calculate domain size, the implementation of which is
given in Listing 3.5. In this subroutine the dimensions of the FDTD problem space are determined,
including the number of cells (Nx, Ny, and Nz) making the problem space. Once the number
of cells in the x, y, and z dimensions are determined, they are assigned to parameters nx, ny,
and nz. Based on the discussion in Section 3.4, we assume that every Yee cell is filled with a
material type. Then in line 10 of Listing 3.4 a three-dimensional array material 3d space with
size (Nx × Ny × Nz) is initialized with ones. In this array each element will store the index of
the material type filling the corresponding cell in the problem space. Since material 3d space
is initialized by the MATLAB function ones, all of its elements have the value 1. Referring to
Listing 3.2 one can see that material types(1) is reserved for air; therefore, the problem space is
initially filled with air.

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

number of spheres = size ( spheres , 2 ) ;


4 number of bricks = size ( bricks , 2 ) ;

6 % 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
8 number of objects = 1;
f o r i =1: n u m b e r o f s p h e r e s
10 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 x − spheres ( i ). radius ;
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 y − spheres ( i ). radius ;
12 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 z − spheres ( i ). radius ;
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 x + spheres ( i ). radius ;
14 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 y + spheres ( i ). radius ;
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 z + spheres ( i ). radius ;
16 number of objects = number of objects + 1;
end
18 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 ;
20 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 ;
22 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 ;
24 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;
26 end

28 fdtd domain . min x = min ( m i n x );


fdtd domain . min y = min ( min y );
30 fdtd domain . min z = min ( m i n z );
fdtd d o m a i n . max x = max ( max x );
32 fdtd d o m a i n . max y = max ( max y );
fdtd d o m a i n . max z = max ( max z );
34

% D e t e r m i n e t h e problem s p a c e b o u n d a r i e s i n c l u d i n g a i r b u f f e r s
36 fdtd domain . min x = fdtd domain . min x . . .
− dx * b o u n d a r y . a i r b u f f e r n u m b e r o f c e l l s x n ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

60 Building Objects in the Yee Grid

38 fdtd domain . min y = fdtd domain . min y ...


− dy * b o u n d a r y . a i r b u f f e r n u m b e r of cells yn ;
40 fdtd domain . min z = fdtd domain . min z ...
− dz * b o u n d a r y . a i r b u f f e r n u m b e r of cells zn ;
42 f d t d d o m a i n . max x = f d t d d o m a i n . max x ...
+ dx * b o u n d a r y . a i r b u f f e r n u m b e r of cells xp ;
44 f d t d d o m a i n . max y = f d t d d o m a i n . max y ...
+ dy * b o u n d a r y . a i r b u f f e r n u m b e r of cells yp ;
46 f d t d d o m a i n . max z = f d t d d o m a i n . max z ...
+ dz * b o u n d a r y . a i r b u f f e r n u m b e r of cells zp ;
48

% D e t e r m i n i n g t h e problem space s i z e
50 fdtd domain . s i z e x = fdtd d o m a i n . max x − f d t d d o m a i n . m i n x ;
fdtd domain . s i z e y = fdtd d o m a i n . max y − f d t d d o m a i n . m i n y ;
52 fdtd domain . s i z e z = fdtd d o m a i n . max z − f d t d d o m a i n . m i n z ;

54 % number o f c e l l s i n x , y , and z directions


nx = round ( f d t d d o m a i n . s i z e x / dx );
56 ny = round ( f d t d d o m a i n . s i z e y / dy );
nz = round ( f d t d d o m a i n . s i z e z / dz );
58

% a d j u s t domain size by snapping to c e l l s


60 fdtd domain . s i z e x = nx * dx ;
fdtd domain . s i z e y = ny * dy ;
62 fdtd domain . s i z e x = nz * dz ;

64 f d t d d o m a i n . max x = f d t d d o m a i n . m i n x + f d t d d o m a i n . s i z e x ;
f d t d d o m a i n . max y = f d t d d o m a i n . m i n y + f d t d d o m a i n . s i z e y ;
66 f d t d d o m a i n . max z = f d t d d o m a i n . m i n z + f d t d d o m a i n . s i z e z ;

68 % some f r e q u e n t l y used a u x i l i a r y parameters


nxp1 = nx +1; nyp1 = ny +1; nzp1 = nz +1;
70 nxm1 = nx −1; nxm2 = nx −2; nym1 = ny −1;
nym2 = ny −2; nzm1 = nz −1; nzm2 = nz −2;
72

% 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


74 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 ) ;
76 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
78 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 ;
80 end
f o r i n d = 1 : ny
82 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 ;
84 end
f o r i n d = 1 : nz
86 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 ;
88 end
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Creation of the Material Grid 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 ;
4 cy = fdtd domain . c e l l c e n t e r c o o r d i n a t e s y ;
cz = fdtd domain . c e l l c e n t e r c o o r d i n a t e s z ;
6

f o r i n d =1: n u m b e r o f s p h e r e s
8 % d i s t a n c e o f t h e c e n t e r s o f t h e c e l l s from t h e c e n t e r o f t h e s p h e r e
d i s t a n c e = s q r t ( ( spheres ( ind ) . c e n t e r x − cx ) . ˆ 2 . . .
10 + ( spheres ( ind ) . c e n t e r y − cy ) . ˆ 2 . . .
+ ( spheres ( ind ) . c e n t e r z − cz ) . ˆ 2 ) ;
12 I = f i n d ( d i s t a n c e <=s p h e r e s ( i n d ) . r a d i u s ) ;
m a t e r i a l 3 d s p a c e ( I ) = spheres ( ind ) . m a t e r i a l t y p e ;
14 end
clear cx cy cz ;
 

After this point we find the cells overlapping with the objects defined in define geometry
and assign the indices of the material types of the objects to the corresponding elements of
the array material 3d space. This procedure is performed in the subroutines create spheres,
which is shown in Listing 3.6, and create bricks, which is shown in Listing 3.7. With the given
implementations, first the spheres are created in the problem space, and then the bricks are
created. Furthermore, the objects will be created in the sequence as they are defined in de-
fine geometry. This means that if more than one object overlaps in the same cell, the object de-
fined last will overwrite the objects defined before. So one should define the objects accordingly.
These two subroutines (create spheres and create bricks) can be replaced by a more advanced
algorithm in which the objects can be assigned priorities in case of overlapping, and chang-
ing the priorities would be sufficient to have the objects created in the desired sequence in the
problem space.

Listing 3.7 create bricks.m


1 disp ( ’ c r e a t i n g b r i c k s ’ ) ;

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

9 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 ;
11 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 % 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) . . .
15 = b r i c k s ( ind ) . m a t e r i a l t y p e ;
end
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

62 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 filled with the material parameter indices of
the objects that were defined in Listing 3.3 and displayed in Fig. 3.2. The cells represented by
material 3d space are plotted in Fig. 3.10, which clearly shows the staircased approximations of
the objects as generated by the subroutine display problem space, which is called in fdtd solve.
Then in initialize fdtd material grid we create three-dimensional arrays representing the
material parameter components εx , ε y , εz , µx , µ y , µz , σxe , σ ye , σze , σxm , σ ym , and σzm . Here the
parameters eps r x, eps r y, eps r z, mu r x, mu r y, and mu r z are relative permittivity and
relative permeability arrays, and they are initialized with 1. The electric and magnetic conductivity
arrays are initialized with 0. One can notice that the sizes of these arrays are not the same as they
correspond to the size of the associated field component. This is due to the specific positioning
scheme of the field components on the Yee cell as shown in Fig. 1.5. For instance, the distribution of
the x components of the electric field, E x , in a problem space composed of (Nx × Ny × Nz) cells is
illustrated in Fig. 3.11. It can be observed that there exist (Nx × Ny + 1 × Nz + 1) E x components
in the problem space. Therefore, in the program the three-dimensional arrays representing E x
and the material components associated with E x shall be constructed with size (Nx × Ny + 1 ×
Nz + 1). Hence, in Listing 3.4 the parameters eps r x and sigma e x are constructed with size
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Creation of the Material Grid 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.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

64 Building Objects in the Yee Grid

Since we have created and filled the array material 3d space as the staircased representation
of the FDTD problem space and have initialized material component arrays, we can proceed
with assigning appropriate parameter values to the material component array elements based
on the averaging schemes discussed in Section 3.4 to form the material grid. This is done in
the subroutine calculate material component values; partial implementation of this subroutine is
shown in Listing 3.8. In Listing 3.8 calculations for the x components of the material component
arrays are illustrated; implementation of other components is left to the reader. Here one can notice
that eps r x, sigma e x, mu r x, and sigma m x are calculated using the forms of equations (3.10),
(3.11), (3.12), and (3.13), respectively.

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

% c r e a t i n g t e m p o r a r y 1D a r r a y s f o r s t o r i n g
4 % parameter v a l u e s of m a t e r i a l types
for ind = 1: s i z e ( m a t e r i a l t y p e s , 2 )
6 t e p s r ( ind ) = m a t e r i a l t y p e s ( ind ) . e p s r ;
t mu r ( ind ) = m a t e r i a l t y p e s ( i n d ) . mu r ;
8 t s i g m a e ( ind ) = m a t e r i a l t y p e s ( ind ) . sigma e ;
t s i g m a m ( i n d ) = m a t e r i a l t y p e s ( i n d ) . sigma m ;
10 end

12 % a s s i g n n e g l i g i b l y s m a l l v a l u e s t o t m u r and t s i g m a m where t h e y a r e
% z e r o i n o r d e r t o p r e v e n t d i v i s i o n by z e r o e r r o r
14 t m u r ( f i n d ( t m u r = = 0 ) ) = 1e −20;
t s i g m a m ( f i n d ( t s i g m a m = = 0 ) ) = 1e −20;
16

disp ( ’ C a l c u l a t i n g e p s r x ’ ) ;
18 % eps r x ( i , j , k ) i s average of four c e l l s
% ( i , j , k ) , ( i , j −1 , k ) , ( i , j , k − 1 ) , ( i , j −1 ,k −1)
20 e p s r x ( 1 : nx , 2 : ny , 2 : nz ) = . . .
0 . 2 5 * ( t e p s r ( m a t e r i a l 3 d s p a c e ( 1 : nx , 2 : ny , 2 : nz ) ) . . .
22 + t e p s r ( m a t e r i a l 3 d s p a c e ( 1 : nx , 1 : ny −1 ,2: nz ) ) . . .
+ t e p s r ( m a t e r i a l 3 d s p a c e ( 1 : nx , 2 : ny , 1 : nz − 1 ) ) . . .
24 + t e p s r ( m a t e r i a l 3 d s p a c e ( 1 : nx , 1 : ny −1 ,1: nz − 1 ) ) ) ;
disp ( ’ C a l c u l a t i n g sigma e x ’ ) ;
45 % sigma e x ( i , j , k ) i s average of four c e l l s
% ( i , j , k ) , ( i , j −1 , k ) , ( i , j , k − 1 ) , ( i , j −1 ,k −1)
47 s i g m a e x ( 1 : nx , 2 : ny , 2 : nz ) = . . .
0 . 2 5 * ( t s i g m a e ( m a t e r i a l 3 d s p a c e ( 1 : nx , 2 : ny , 2 : nz ) ) . . .
49 + t s i g m a e ( m a t e r i a l 3 d s p a c e ( 1 : nx , 1 : ny −1 ,2: nz ) ) . . .
+ t s i g m a e ( m a t e r i a l 3 d s p a c e ( 1 : nx , 2 : ny , 1 : nz − 1 ) ) . . .
51 + t s i g m a e ( m a t e r i a l 3 d s p a c e ( 1 : nx , 1 : ny −1 ,1: nz − 1 ) ) ) ;
disp ( ’ C a l c u l a t i n g mu r x ’ ) ;
73 % m u r x ( i , j , k ) i s a v e r a g e o f two c e l l s ( i , j , k ) , ( i −1 , j , k )
m u r x ( 2 : nx , 1 : ny , 1 : nz ) = . . .
75 2 * ( t m u r ( m a t e r i a l 3 d s p a c e ( 2 : nx , 1 : ny , 1 : nz ) ) . . .
. * t m u r ( m a t e r i a l 3 d s p a c e ( 1 : nx −1 ,1: ny , 1 : nz ) ) ) . . .
77 . / ( t m u r ( m a t e r i a l 3 d s p a c e ( 2 : nx , 1 : ny , 1 : nz ) ) . . .
+ t m u r ( m a t e r i a l 3 d s p a c e ( 1 : nx −1 ,1: ny , 1 : nz ) ) ) ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Creation of the Material Grid 65

96 disp ( ’ C a l c u l a t i n g sigma m x ’ ) ;
% s i g m a m x ( i , j , k ) i s a v e r a g e o f two c e l l s ( i , j , k ) , ( i −1 , j , k )
98 s i g m a m x ( 2 : nx , 1 : ny , 1 : nz ) = . . .
2 * ( t s i g m a m ( m a t e r i a l 3 d s p a c e ( 2 : nx , 1 : ny , 1 : nz ) ) . . .
100 . * t s i g m a m ( m a t e r i a l 3 d s p a c e ( 1 : nx −1 ,1: ny , 1 : nz ) ) ) . . .
. / ( t s i g m a m ( m a t e r i a l 3 d s p a c e ( 2 : nx , 1 : ny , 1 : nz ) ) . . .
102 + t s i g m a m ( m a t e r i a l 3 d s p a c e ( 1 : nx −1 ,1: ny , 1 : nz ) ) ) ;
 

The last step in constructing the material grid is to create the zero-thickness PEC plates in
the material grid. The subroutine create PEC plates shown in Listing 3.9 is implemented for this
purpose. The code checks all of the defined bricks for zero thickness and assigns their material’s
conductivity values to the electric conductivity components overlapping with them.
Using the code sections described in this section, the material grid for the material cell distri-
bution in Fig. 3.10 is obtained and plotted on three plane cuts for relative permittivity distribution
in 3.13(a) and for relative permeability distribution in 3.13(b). The effects of averaging can be
clearly observed on the object boundaries.

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

3 for ind = 1: number of bricks

5 mtype = b r i c k s ( i n d ) . m a t e r i a l t y p e ;
s i g m a p e c = m a t e r i a l t y p e s ( mtype ) . s i g m a e ;
7

% convert coordinates to node i n d i c e s on t h e FDTD g r i d


9 b l x = round ( ( b r i c k s ( i n d ) . min x − fdtd 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 ) . min y − fdtd d o m a i n . m i n y ) / dy ) + 1 ;
11 b l z = round ( ( b r i c k s ( i n d ) . min z − fdtd d o m a i n . m i n z ) / dz ) + 1 ;

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

17 % f i n d the zero t h i c k n e s s b r i c k s
i f ( b l x == bux )
19 s i g m a e y ( b l x , b l y : buy −1 , b l z : buz ) = s i g m a p e c ;
s i g m a e z ( b l x , b l y : buy , b l z : buz −1) = s i g m a p e c ;
21 end
i f ( b l y == buy )
23 s i g m a e z ( b l x : bux , b l y , b l z : buz −1) = s i g m a p e c ;
s i g m a e x ( b l x : bux −1 , b l y , b l z : buz ) = s i g m a p e c ;
25 end
i f ( b l z == buz )
27 s i g m a e x ( b l x : bux −1 , b l y : buy , b l z ) = s i g m a p e c ;
s i g m a e y ( b l x : bux , b l y : buy −1 , b l z ) = s i g m a p e c ;
29 end
end
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

66 Building Objects in the Yee Grid

(a) Relative permittivity components

(b) Relative permeability components

Figure 3.13 Material grid on three plane cuts.


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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 find an equivalent value for a given material
component. We can combine the averaging schemes discussed in Section 3.3 with the eight-
subcell 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 filled 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 filled 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
2 × ε p × εn
εz (i, j, k) = . (3.14)
ε p + εn
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 file fdtd solve is the main program used to run FDTD simulations. Open this subrou-
tine and examine its contents. It calls several subroutines that are not implemented yet. In
the code disable the lines 7, 8, and 14–27 by “commenting” these lines. Simply insert “%”
sign in front of these lines. Now the code is ready to run with its current functionality.
Open the subroutine define problem space parameters, and define the problem space
parameters. Set the cell size as 1 mm on a side, boundaries as ‘pec’, and air gap between the
objects and boundaries as 5 cells on all sides. Define a material type with index 4 having the
relative permittivity as 4, relative permeability as 2, electric conductivity as 0.2, and magnetic
conductivity as 0.1. Define another material type with index 5 having relative permittivity
as 6, relative permeability as 3, electric conductivity as 0.4, and magnetic conductivity as
0.2. Open the subroutine define geometry, and define the problem geometry. Define a brick
with size 5 mm × 6 mm × 7 mm, and assign material type index 4 as its material type. Figure
3.14(a) shows the geometry of the problem in consideration.
In the directory including your code files there are some additional files prepared as plot-
ting routines that you can use together with your code. These routines are called in fdtd solve
after the definition routines. Insert the command ‘show problem space = true;’ in line 9 of
fdtd solve temporarily to enable three-dimensional geometry display. Run the program
fdtd solve. The program will open a figure including a three-dimensional view of the geom-
etry you have defined and another program named as “Display Material Mesh” that helps you
examine the material mesh created for the defined geometry. For instance, Fig. 3.14(b) shows
the relative permittivity distribution of the FDTD problem space in three plane cuts gener-
ated by the program “Display Material Mesh.” Examine the geometry and the material mesh,
and verify that the material parameter values are averaged on the boundaries as explained in
Chapter 3.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

68 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 (b) Electric conductivity distribution

Figure 3.15 The FDTD problem space of Exercise 3.3.


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Exercises 69

3.2 Consider the problem you constructed in Exercise 3.1. Now define another brick with size
3 mm × 4 mm × 5 mm, assign material type index 5 as its material type, and place it
at the center of the first brick. Run fdtd solve, and then examine the geometry and the
material mesh and verify that the material parameter values are averaged on the boundaries
as explained in Chapter 3.
Now change the definition sequence of these two bricks in define geometry; define the
second brick first with index 1 and the first brick as second with its index 2. Run fdtd -
solve, and examine the geometry and the material mesh. Verify that the smaller brick has
disappeared in the material mesh. With the given implementation of the program, the
sequence of defining the objects determines the way the FDTD material mesh is created.
3.3 Construct a problem space with the cell size as 1 mm on a side, boundaries as ‘pec’, and
air gap between the objects and boundaries as 5 cells on all sides. Define a brick as a PEC
plate with zero thickness placed between the coordinates given in millimeters as (0, 0, 0) and
(8, 8, 0). Define another brick as a plate with zero thickness, material type air, and placed
between the coordinates (3, 0, 0) and (5, 8, 0) as illustrated in Fig. 3.15(a), which shows the
geometry of the problem in consideration. Run fdtd solve, and then examine the geometry
and the material mesh. Examine the electric conductivity distribution, and verify that on the
boundary between the plates the material components are air as shown in Fig. 3.15(b).
3.4 Construct a problem space with the cell size as 1 mm on a side, boundaries as ‘pec’, and
air gap between the objects and boundaries as 5 cells on all sides. Define a brick as a PEC
plate with zero thickness placed between the coordinates given in millimeters as (0, 0, 0) and
(3, 8, 0). Define another brick as PEC plate and placed between the coordinates (5, 0, 0) and
(8, 8, 0). Run fdtd solve, and then examine the geometry and the material mesh. Examine
the electric conductivity distribution, and verify that on the boundaries of the plates facing
each other the material components are PEC.
Although the geometry constructed in this example is physically the same as the one in
Exercise 3.3, the material meshes are different since the ways the geometries are defined are
different.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

4
Active and Passive Lumped
Elements

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 flowing through these circuit elements can be represented
by the impressed current density term, Ji , in Maxwell’s curl equation


 = ε ∂ E + σ e E + Ji .
∇×H (4.1)
∂t

Impressed currents are used to represent sources or known quantities. In this sense, they are the
sources that cause the electric and magnetic fields in the computational domain [10]. A lumped
element component placed between two nodes is characterized by the relationship between the
voltage V across and the current I flowing between these two nodes. This relationship can be
incorporated into Maxwell’s curl equation (4.1) by expressing E in terms of V using

E = −∇V (4.2)

and by expressing J in terms of I using the relation


I= J · d s , (4.3)
S

where S is the cross-sectional area of a unit cell normal to the flow of the current I . These
equations can be implemented in discrete time and space and can be incorporated into (4.1), which
are expressed in terms of finite differences. Then, the finite-difference time-domain (FDTD)
updating equations can be obtained that simulate the respective lumped element characteristics.
In this chapter we discuss the construction of the FDTD updating equations for lumped
element components, and we demonstrate MATLAB implementation of definition, initialization,
and simulation of these elements.

71
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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 fields
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:
 
∂ Ez 1 ∂ Hy ∂ Hx
= − − σze E z − Ji z . (4.4)
∂t εz ∂ x ∂y
This equation constitutes the relation between the current density Ji z flowing in the z direction and
the electric and magnetic field vector components. Application of the central difference formula
to the time and space derivatives based on the field positioning scheme illustrated in Fig. 4.1 yields
n+ 12 n+ 12
E zn+1 (i, j, k) − E zn (i, j, k) 1 Hy (i, j, k) − Hy (i − 1, j, k)
=
t εz (i, j, k) x
n+ 12 n+ 12
1 Hx (i, j, k) − Hx (i, j − 1, k)

εz (i, j, k) y
σze (i, j, k)  n+1 
− E z (i, j, k) + E zn (i, j, k)
2εz (i, j, k)
1 n+ 1
− Ji z 2 (i, j, k). (4.5)
εz (i, j, k)
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

FDTD Updating Equations for Lumped Elements 73

(a) Voltage source with internal resistance (b) Voltage source without internal resis-
(soft source) tance (hard source)

Figure 4.2 Voltage sources placed between nodes (i, j, k) and (i, j, k + 1).

We want to place a voltage source with Vs volts magnitude and Rs ohms internal resistance between
nodes (i, j, k) and (i, j, k + 1) as illustrated in Fig. 4.2(a), where Vs is a time-varying function with
a predetermined waveform. The voltage–current relation for this circuit can be written as

V + Vs
I= , (4.6)
Rs

where V is the potential difference between nodes (i, j, k) and (i, j, k + 1). The term V can
be expressed in terms of E z using (4.2), which translates to

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


V = z × E z (i, j, k) = z × , (4.7)
2

in discrete form at time instant (n + 0.5)t. Current I is the current flowing through the surface
enclosed by the magnetic field components in Fig. 4.1, which can be expressed in terms of Ji z
using (4.3) as

1 n+ 12
I n+ 2 = xy Ji z (i, j, k). (4.8)

One should notice that V in (4.7) is evaluated at time instant (n + 0.5)t, which corresponds
to the required time instant of I and J dictated by (4.5). Inserting (4.7) and (4.8) in (4.6) one can
obtain

n+ 12 z   1 n+ 1
Ji z (i, j, k) = × E zn+1 (i, j, k) + E zn (i, j, k) + × Vs 2 . (4.9)
2xy Rs xy Rs
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

74 Active and Passive Lumped Elements

Equation (4.9) includes the voltage–current relation for a voltage source tying Vs and Rs to electric
field components in the discrete space and time. One can use (4.9) in (4.5) and rearrange the terms
such that the future value of the electric field component E zn+1 can be calculated using other terms,
which yields our standard form updating equations such that

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

tz
2εz (i, j, k) − tσze (i, j, k) − Rs xy
Ce ze (i, j, k) = tz
,
2εz (i, j, k) + tσze (i, j, k) + Rs xy

2t
Ce zhy (i, j, k) =   ,
tz
2εz (i, j, k) + tσze (i, j, k) + Rs xy
x

2t
Ce zhx (i, j, k) = −   ,
tz
2εz (i, j, k) + tσze (i, j, k) + Rs xy
y

2t
Ce zs (i, j, k) = −   .
tz
2εz (i, j, k) + tσze (i, j, k) + Rs xy
(Rs xy)

Equation (4.10) is the FDTD updating equation modeling a voltage source placed between the
nodes (i, j, k) and (i, j, k + 1), which is oriented in the z direction. The FDTD updating equations
for voltage sources oriented in other directions can easily be obtained following the same steps as
just illustrated.
The FDTD updating equation (4.10) is given for a voltage source with a polarity in the positive
z direction as indicated in Fig. 4.2(a). To model a voltage source with the opposite polarity, one
needs only to use the inverse of the voltage magnitude waveform by changing Vs to −Vs .

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

2 n+ 12
E zn+1 (i, j, k) = −E zn (i, j, k) − Vs (i, j, k). (4.11)
z
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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

2
Ce ze (i, j, k) = −1, Ce zhy (i, j, k) = 0, Ce zhx (i, j, k) = 0, Ce zs (i, j, k) = − .
z

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 voltage–current relation for the
current source can be written as

V
I = Is + . (4.13)
Rs

(a) Current source with internal resistance (b) Resistor

Figure 4.3 Lumped elements placed between nodes (i, j, k) and (i, j, k + 1).
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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 z   1 n+ 1
Ji z (i, j, k) = × E zn+1 (i, j, k) + E zn (i, j, k) + × Is 2 . (4.14)
2xy Rs xy

One can use (4.14) in (4.5) and rearrange the terms such that E zn+1 can be calculated using other
terms, which yields

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

tz
2εz (i, j, k) − tσze (i, j, k) − Rs xy
Ce ze (i, j, k) = tz
,
2εz (i, j, k) + tσze (i, j, k) + Rs xy

2t
Ce zhy (i, j, k) =   ,
tz
2εz (i, j, k) + tσze (i, j, k) + Rs xy
x

2t
Ce zhx (i, j, k) = −   ,
tz
2εz (i, j, k) + tσze (i, j, k) + Rs xy
y

2t
Ce zs (i, j, k) = −   .
tz
2εz (i, j, k) + tσze (i, j, k) + Rs xy
xy

Equation (4.15) is the updating equation modeling a current source. One should notice that
n+ 12
(4.15) is the same as (4.10) except for the source term; that is, replacing the Vs (i, j, k) term in
n+ 1
(4.10) by Rs × Is 2 (i, j, k) yields (4.15).
The FDTD updating equation (4.15) is given for a current source with a current flowing in
the positive z direction as indicated in Fig. 4.3(a). To model a current source with the opposite
flow direction, one needs only to use the inverse of the current magnitude waveform by changing
Is to −Is .

4.1.4 Resistor
Having derived the updating equations for a voltage source or a current source with internal
resistance, it is straightforward to derive updating equations for a resistor. For instance, eliminating
the current source in Fig. 4.3(a) yields the resistor in Fig. 4.3(b). Hence, setting the source term
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

FDTD Updating Equations for Lumped Elements 77

n+ 12
Is (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
tz
2εz (i, j, k) − tσze (i, j, k) − Rxy
Ce ze (i, j, k) = tz
,
2εz (i, j, k) + tσze (i, j, k) + Rxy

2t
Ce zhy (i, j, k) =   ,
tz
2εz (i, j, k) + tσze (i, j, k) + Rxy
x

2t
Ce zhx (i, j, k) = −   .
tz
2εz (i, j, k) + tσze (i, j, k) + Rxy
y

4.1.5 Capacitor
Figure 4.4(a) illustrates a capacitor with C farads capacitance. The voltage–current relation for
the capacitor can be written as

d V
I =C . (4.17)
dt

(a) Capacitor (b) Inductor

Figure 4.4 Lumped elements placed between nodes (i, j, k) and (i, j, k + 1).
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

78 Active and Passive Lumped Elements

This relation can be expressed in discrete time and space as

1 V n+1 − V n
I n+ 2 = C . (4.18)
t
1
Using V in (4.7) and I n+ 2 in (4.8) together with (4.18), one can obtain

n+ 12 Cz  
Ji z (i, j, k) = × E zn+1 (i, j, k) − E zn (i, j, k) . (4.19)
txy

One can use (4.19) in (4.5) and rearrange the terms such that E zn+1 can be calculated using other
terms, which yields the updating equation for a capacitor as

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

2εz (i, j, k) − tσze (i, j, k) + 2Cz


xy
Ce ze (i, j, k) = ,
2εz (i, j, k) + tσze (i, j, k) + 2Cz
xy

2t
Ce zhy (i, j, k) =   ,
2εz (i, j, k) + tσze (i, j, k) + 2Cz
xy
x

2t
Ce zhx (i, j, k) = −   .
2εz (i, j, k) + tσze (i, j, k) + 2Cz
xy
y

4.1.6 Inductor
Figure 4.4(b) illustrates an inductor with L henrys inductance. The inductor is characterized by
the voltage–current relation

dI
V=L . (4.21)
dt

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

L  n+ 1 1

V n = I 2 − I n− 2 . (4.22)
t

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

n+ 12 n− 12 tz n
Ji z (i, j, k) = Ji z (i, j, k) + E (i, j, k). (4.23)
Lxy z
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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 field1 component E zn (i, j, k) and the previous value of the impressed current density
n−
component Ji z 2 (i, j, k), we can use the general form of the FDTD updating equation (1.28)
without any modification, which is rewritten here for convenience as

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
2εz (i, j, k) − tσze (i, j, k)
Ce ze (i, j, k) = ,
2εz (i, j, k) + tσze (i, j, k)
2t
Ce zhy (i, j, k) =   ,
2εz (i, j, k) + tσze (i, j, k) x
2t
Ce zhx (i, j, k) = −   ,
2εz (i, j, k) + tσze (i, j, k) y
2t
Ce zj (i, j, k) = − .
2εz (i, j, k) + tσze (i, j, k)

One should notice that during the FDTD time-marching iteration, at every time step the new value
n+ 1 n− 1
of Ji z 2 (i, j, k) should be calculated by (4.23) using E zn (i, j, k) and Ji z 2 (i, j, k) before updating
E zn+1 (i, j, k) by (4.24).

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 modification of parameter values is required
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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 field components E z (vis : vie, v j s : v j e, vks :
vke − 1) need to be updated as shown in Fig. 4.6. Hence, the total number of field components
needing to be updated is (vie − vis + 1) × (v j e − v j s + 1) × (vke − vks ). Therefore, the main
voltage source can be replaced by multiple voltage sources, each of which is associated with a
respective field component. Each individual voltage source in Fig. 4.6 then should be assigned a
voltage value Vs ,

Vs
Vs = , (4.25)
(vke − vks )

since the potential difference between the ends of the main voltage source in the z direction shall
be kept the same. If the main voltage source has an internal resistance Rs , it should be maintained
as well. Then the main resistance Rs will be represented by a network of (vie − vis + 1) ×
(v j e − v j s + 1) resistors connected in parallel where each element in this parallel combination
is made of (vke − vks ) series resistors. Therefore, the resistance for each source component

Figure 4.6 A voltage source distributed over a surface and a resistor distributed over a volume.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

FDTD Updating Equations for Lumped Elements 81

Rs shall be set as

(vie − vis + 1) × (v j e − v j s + 1)
Rs = Rs × . (4.26)
(vke − vks )

Having applied these modifications to Vs and Rs , the electric field components E z (vis : vie, v j s :
v j e, vks : vke − 1) can be updated using (4.10).
The same procedure holds for each individual resistor R at the other end of the parallel PEC
plates. Thus, the resistance R can be given as

(rie − ris + 1) × (r j e − r j s + 1)
R = R × , (4.27)
(rke − rks )

and (4.16) can be used to update the electric field components E z (ris : rie, r j s : r j e, rks : rke − 1).
Similarly, for an inductor with inductance L extending between the nodes (is , j s , ks ) and
(ie, j e, ke), the individual inductance L can be defined as

(ie − is + 1) × ( j e − j s + 1)
L = L × , (4.28)
(ke − ks )

and (4.24) can be used to update the electric field components E z (is : ie, j s : j e, ks : ke − 1).
For a capacitor with capacitance C extending between the nodes (is , j s , ks ) and (ie, j e, ke),
each individual capacitance C  can be defined as

(ke − ks )
C = C × , (4.29)
(ie − is + 1) × ( j e − j s + 1)

and (4.19) can be used to update the electric field components E z (is : ie, j s : j e, ks : ke − 1).
A current source with magnitude Is and resistance Rs extending between the nodes (is , j s , ks )
and (ie, j e, ke) can be modeled by updating E z (is : ie, j s : j e, ks : ke − 1) using (4.15) after mod-
ifying Is and resistance Rs such that

Is
Is = , (4.30)
(ie − is + 1) × ( j e − j s + 1)

and
(vie − vis + 1) × (v j e − v j s + 1)
Rs = Rs × . (4.31)
(vke − vks )

One should notice that the equations given for modifying the lumped values are all for the
elements oriented in the z direction. The indexing scheme should be reflected appropriately to
obtain equations for lumped elements oriented in other directions.

4.1.8 Diode
Derivation of the FDTD updating equations of some lumped element circuit components have
been presented in previous sections. These circuit components are characterized by linear voltage–
current relations, and it is straightforward to model their behavior in FDTD by properly expressing
their voltage–current relations in discrete time and space. However, one of the strengths of the
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

82 Active and Passive Lumped Elements

(a) Diode oriented in the positive (b) Diode oriented in the nega-
z direction tive z direction

Figure 4.7 Diodes placed between nodes (i, j, k) and (i, j, k + 1).

FDTD method is that it is possible to model nonlinear components as well. In this section we
present the derivation of the updating equations for modeling a diode.
Figure 4.7(a) illustrates a diode placed between nodes (i, j, k) and (i, j, k + 1) in an FDTD
problem space. This diode allows currents flowing only in the positive z direction, as indicated by
direction of the current Id and characterized by the voltage–current relation

I = Id = I0 [e (q Vd /kT) − 1], (4.32)

where q is the absolute value of electron charge in coulombs, k is Boltzmann’s constant, and T is
the absolute temperature in kelvins. This equation can be expressed in discrete form as

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

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

n+ 12 n+ 12
E zn+1 (i, j, k) − E zn (i, j, k) 1 Hy (i, j, k) − Hy (i − 1, j, k)
=
t εz (i, j, k) x
n+ 12 n+ 12
1 Hx (i, j, k) − Hx (i, j − 1, k)

εz (i, j, k) y
σze (i, j, k)  n+1 
− E z (i, j, k) + E zn (i, j, k)
2εz (i, j, k)
I0
[e (q z/2kT)(Ez (i, j,k)+Ez (i, j,k)) − 1].
n+1 n
− (4.34)
εz (i, j, k)xy
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

FDTD Updating Equations for Lumped Elements 83

This equation can be expanded as

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


E zn+1 (i, j, k) + E z (i, j, k) = E zn (i, j, k) − z E (i, j, k)
2εz (i, j, k) 2εz (i, j, k) z
n+ 12 n+ 12
t Hy (i, j, k) − Hy (i − 1, j, k)
+
εz (i, j, k) x
n+ 12 n+ 12
t Hx (i, j, k) − Hx (i, j − 1, k)

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

εz (i, j, k)xy
I0 t
+ (4.35)
εz (i, j, k)xy

and can be arranged in the following form

Ae Bx + x + C = 0, (4.36)

where
n
x = E zn+1 (i, j, k), A = −Ce zd (i, j, k)e B×Ez (i, j,k) , B = (q z/2kT),
 n+ 1 n+ 1

C = Ce ze (i, j, k) × E zn (i, j, k) + Ce zhy (i, j, k) × Hy 2 (i, j, k) − Hy 2 (i − 1, j, k)
 n+ 1 n+ 1

+ Ce zhx (i, j, k) × Hx 2 (i, j, k) − Hx 2 (i, j − 1, k) + Ce zd (i, j, k),

2εz (i, j, k) − tσze (i, j, k)


Ce ze (i, j, k) = − ,
2εz (i, j, k) + tσze (i, j, k)
2t
Ce zhy (i, j, k) = −   ,
2εz (i, j, k) + tσze (i, j, k) x
2t
Ce zhx (i, j, k) =   ,
2εz (i, j, k) + tσze (i, j, k) y
2t I0
Ce zd (i, j, k) = − .
2εz (i, j, k)xy + tσze (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 field components,
and then (4.36) must be solved to obtain E zn+1 (i, j, k).
Equation (4.36) can easily be solved numerically by using the Newton-Raphson method, which
is one of the most widely used methods for finding roots of a nonlinear function. It is an iterative
process that starts from an initial point in the proximity of a root and approaches to the root by
the use of the derivative of the function. For instance, Fig. 4.8 shows a function for which we
want to find the value of x that satisfies f (x) = 0. We can start with an initial guess x0 as shown
in the figure. The derivative of the function f (x) at point x0 is the slope of the tangential line
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

84 Active and Passive Lumped Elements

60
f (x) = 2x − 10 + e0.4χ
50

40
f (x0 )
f (x0 )
f(x)

30

20
f (x1 )

10 f (x1 )
xn
0
x2 x1 x0

1 2 3 4 5 6 7 8 9 10
x

Figure 4.8 A function f (x ) and the points approaching to the root of the function iteratively calculated using the
Newton-Raphson Method.

passing through the point f (x0 ) and intersecting the x axis at point x1 . We can easily calculate
point x1 as

f (x0 )
x1 = x0 − . (4.37)
f  (x0 )

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

f (x1 )
x2 = x1 − . (4.38)
f  (x1 )

As can be followed from Fig. 4.8, the new calculated x leads to the target point where f (x)
intersects with the x axis. Due to the high convergence rate of this procedure a point xn can be
achieved after couple of iterations, which is in the very close proximity of the exact root of the
function f (x). This iterative procedure can be continued until a stopping criteria or a maximum
number of iterations is reached. Such a stopping criteria can be given by

| f (xn )| < , (4.39)

where is a very small positive number accepted as the error tolerance accepted for f (x) approx-
imately equals to zero.
It is very convenient to use the Newton-Raphson method to solve the diode equation (4.36),
since the nature of this equation does not allow local minima or maxima, which can be an obstacle
for the convergence of this method. Furthermore, the value of the electric field component
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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 voltage–current relation (4.32). A diode oriented in the negative z
direction, as shown in 4.7(b), can be characterized by the voltage–current relation

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
n
x = E zn+1 (i, j, k), A = −Ce zd (i, j, k)e B×Ez (i, j,k) , B = −(q z/2kT),
 n+ 1 n+ 1

C = Ce ze (i, j, k) × E zn (i, j, k) + Ce zhy (i, j, k) × Hy 2 (i, j, k) − Hy 2 (i − 1, j, k)
 n+ 1 n+ 1

+ Ce zhx (i, j, k) × Hx 2 (i, j, k) − Hx 2 (i, j − 1, k) + Ce zd (i, j, k),

2εz (i, j, k) − tσze (i, j, k)


Ce ze (i, j, k) = − ,
2εz (i, j, k) + tσze (i, j, k)
2t
Ce zhy (i, j, k) = −   ,
2εz (i, j, k) + tσze (i, j, k) x
2t
Ce zhx (i, j, k) =   ,
2εz (i, j, k) + tσze (i, j, k) y
2t I0
Ce zd (i, j, k) = .
2εz (i, j, k)xy + tσze (i, j, k)xy

Here, one should notice that only the coefficients B and Ce zd (i, j, k) are reversed when compared
with the respective coefficients of (4.36), and the rest of the terms are the same.
Due to the nonlinear nature of the diode voltage–current relation, it is not convenient to define
a diode extending over a number of cells in the FDTD problem grid. If a diode is going to be
placed between two nodes that are apart from each other more than one cell size, it is more
convenient to place the diode between two neighboring nodes and then to establish connection
between the other nodes by other means, (e.g., by thin wires). The thin-wires FDTD updating
procedure and equations are discussed in Chapter 10.

4.1.9 Summary
In this chapter we have provided the derivation of FDTD updating equations for model-
ing some common lumped element circuit components. We have shown the construction of
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

86 Active and Passive Lumped Elements

updating equations for components placed between two neighboring nodes and have illus-
trated how these components can be modeled if they extend over a number of cells on the
problem grid.
It is possible to obtain updating equations for the circuits composed of combinations of these
lumped elements; one only needs to obtain the appropriate voltage–current relations, express them
in discrete time and space, and establish the relation between the impressed current densities and
the field components. Then impressed current density terms can be used in the general form of
the updating equation to obtain the specific updating equations that model the lumped element
circuit under consideration.

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 con-
cepts in MATLAB. Furthermore, we show the implementation of other routines that initialize the
FDTD problem space, including some auxiliary parameters, field arrays, and updating coefficient
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 definition of the lumped element components. As
discussed before, these components can be defined as prism-like objects distributed over a volume
in the FDTD problem space. Any prism-like object can be defined with its lower and upper
coordinates in the Cartesian coordinate system. Therefore, we define 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 definition
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 defined 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 defining the coordinates of diodes; as discussed in Section 4.8, we assume diodes as
objects having zero thickness in two dimensions.
Besides the parameters defining 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 field components are updated due to the voltage–current
relations. These field components that need specific updates are determined by the functional
directions of these components. For voltage sources, current sources, and diodes there are six di-
rections in which they can be defined 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 defined with the directions ‘x’, ‘y’, or ‘z’. The
other parameters needed to specify the lumped components are magnitude, resistance, induc-
tance, and capacitance, which represent the characteristics of the lumped elements as shown in
Listing 4.1.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation of Lumped Elements 87

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

voltage sources = [ ] ;
4 current sources = [ ] ;
diodes = [ ] ;
6 resistors = [];
inductors = [ ] ;
8 capacitors = [ ] ;

10 % d e f i n e s o u r c e waveform t y p e s and p a r a m e t e r s
w a v e f o r m s . s i n u s o i d a l ( 1 ) . f r e q u e n c y = 1 e9 ;
12 w a v e f o r m s . s i n u s o i d a l ( 2 ) . f r e q u e n c y = 5 e8 ;
waveforms . u n i t s t e p ( 1 ) . s t a r t t i m e s t e p = 50;
14

% voltage sources
16 % d i r e c t i o n : ’ xp ’ , ’ xn ’ , ’ yp ’ , ’ yn ’ , ’ zp ’ , o r ’ zn ’
% r e s i s t a n c e : ohms , m a g i t u d e : volts
18 v o l t a g e s o u r c e s ( 1 ) . min x = 0 ;
v o l t a g e s o u r c e s ( 1 ) . min y = 0 ;
20 v o l t a g e s o u r c e s ( 1 ) . min z = 0 ;
v o l t a g e s o u r c e s ( 1 ) . max x = 1 . 0 e −3;
22 v o l t a g e s o u r c e s ( 1 ) . max y = 2 . 0 e −3;
v o l t a g e s o u r c e s ( 1 ) . max z = 4 . 0 e −3;
24 v o l t a g e s o u r c e s ( 1 ) . d i r e c t i o n = ’ zp ’ ;
v o l t a g e s o u r c e s ( 1 ) . r e s i s t a n c e = 50;
26 v o l t a g e s o u r c e s ( 1 ) . magnitude = 1 ;
v o l t a g e s o u r c e s ( 1 ) . waveform type = ’ s i n u s o i d a l ’ ;
28 v o l t a g e s o u r c e s ( 1 ) . waveform index = 2;

30 % current sources
% d i r e c t i o n : ’ xp ’ , ’ xn ’ , ’ yp ’ , ’ yn ’ , ’ zp ’ , o r ’ zn ’
32 % r e s i s t a n c e : ohms , m a g i t u d e : amperes
c u r r e n t s o u r c e s ( 1 ) . m i n x = 30 * dx ;
34 c u r r e n t s o u r c e s ( 1 ) . m in y = 10 * dy ;
c u r r e n t s o u r c e s ( 1 ) . m i n z = 10 * dz ;
36 c u r r e n t s o u r c e s ( 1 ) . max x = 36 * dx ;
c u r r e n t s o u r c e s ( 1 ) . max y = 10 * dy ;
38 c u r r e n t s o u r c e s ( 1 ) . max z = 13 * dz ;
c u r r e n t s o u r c e s ( 1 ) . d i r e c t i o n = ’ xp ’ ;
40 current sources ( 1 ) . r e s i s t a n c e = 50;
c u r r e n t s o u r c e s ( 1 ) . magnitude = 1 ;
42 c u r r e n t s o u r c e s ( 1 ) . waveform type = ’ u n i t s t e p ’ ;
c u r r e n t s o u r c e s ( 1 ) . waveform index = 1;
44

% resistors
46 % direction : ’x ’ , ’y ’ , or ’ z ’
% resistance : ohms
48 resistors (1). min x = 7 . 0 e −3;
resistors (1). mi n y = 0;
50 resistors (1). min z = 0;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

88 Active and Passive Lumped Elements

resistors (1). max x = 8 . 0 e −3;


52 resistors (1). max y = 2 . 0 e −3;
resistors (1). max z = 4 . 0 e −3;
54 resistors (1). direction = ’z ’ ;
resistors (1). r e s i s t a n c e = 50;
56

% inductors
58 % direction : ’ x ’ , ’ y ’ , or ’ z ’
% inductance : henrys
60 inductors ( 1 ) . m i n x = 30 * dx ;
inductors ( 1 ) . m i n y = 10 * dy ;
62 inductors ( 1 ) . m i n z = 10 * dz ;
inductors ( 1 ) . max x = 36 * dx ;
64 inductors ( 1 ) . max y = 10 * dy ;
inductors ( 1 ) . max z = 13 * dz ;
66 inductors ( 1 ) . direction = ’x ’ ;
inductors ( 1 ) . i n d u c t a n c e = 1e −9;
68

% capacitors
70 % d i r e c t i o n : ’ x ’ , ’ y ’ , or ’ z ’
% capacitance : farads
72 c a p a c i t o r s ( 1 ) . m i n x = 30 * dx ;
c a p a c i t o r s ( 1 ) . m i n y = 10 * dy ;
74 c a p a c i t o r s ( 1 ) . m i n z = 10 * dz ;
c a p a c i t o r s ( 1 ) . max x = 36 * dx ;
76 c a p a c i t o r s ( 1 ) . max y = 10 * dy ;
c a p a c i t o r s ( 1 ) . max z = 13 * dz ;
78 capacitors ( 1 ) . direction = ’x ’ ;
c a p a c i t o r s ( 1 ) . c a p a c i t a n c e = 1e −12;
80

% diodes
82 % d i r e c t i o n : ’ xp ’ , ’ xn ’ , ’ yp ’ , ’ yn ’ , ’ zp ’ , o r ’ zn ’
d i o d e s ( 1 ) . m i n x = 30 * dx ;
84 d i o d e s ( 1 ) . m i n y = 10 * dy ;
d i o d e s ( 1 ) . m i n z = 10 * dz ;
86 d i o d e s ( 1 ) . max x = 36 * dx ;
d i o d e s ( 1 ) . max y = 10 * dy ;
88 d i o d e s ( 1 ) . max z = 13 * dz ;
d i o d e s ( 1 ) . d i r e c t i o n = ’ xp ’ ;
 
Another type of parameter that is required for time-domain simulation of sources is the type
of waveforms that the voltages and current sources generate as a function of time. For each
source, the voltage or current value generated at every time step can be stored as the waveform
in a one-dimensional array with the size of number of time steps. However, before associating
a waveform to a source, we can define the parameters specific to various types of waveforms
in a structure named waveforms as illustrated in Listing 4.1. There are various options for
constructing a waveform in FDTD. Some of the most common types of waveforms are Gaussian,
sinusoidal, cosine modulated Gaussian, and unit step. The definition and construction of these
waveforms will be the subject of Chapter 5. However, we provide a template here showing how
the waveform parameters can be defined. In Listing 4.1 two fields are defined in the parameter
waveforms: sinusoidal and unit step. Later on we can add new parameters representing other
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation of Lumped Elements 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 specific characteristics. Here frequency is a parameter for
the sinusoidal waveform waveforms.sinusoidal(i), whereas start time step is a parameter for the
waveform waveforms.unit step(i).
Having defined the types of waveforms and their parameters, we can associate them to the
sources by referring to them with the waveform type and waveform index in the source pa-
rameters voltage sources(i) and current sources(i). In the example code we assign the type of
the waveform ‘sinusoidal’ to voltage sources(1).waveform type, and the index of the sinusoidal
waveform waveforms.sinusoidal(2), which is 2, to voltage sources(1).waveform index. Sim-
ilarly, the type of the waveform ‘unit step’ is assigned to current sources(1).waveform type
and the index of the waveform waveforms.unit step(1), which is 1, is assigned to current -
sources(1).waveform index.

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

3 % constant parameters
e p s 0 = 8 . 8 5 4 1 8 7 8 1 7 e −12; % p e r m i t t i v i t y o f f r e e s p a c e
5 mu 0 = 4 * p i * 1 e −7; % p e r m e a b i l i t y o f f r e e s p a c e
c = 1 / s q r t ( mu 0 * e p s 0 ) ; % s p e e d o f l i g h t i n f r e e s p a c e
7

% Duration of a time s t e p in seconds


9 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

% time a r r a y
13 time = ( [ 1 : n u m b e r o f t i m e s t e p s ] −0.5)* dt ;

15 % C r e a t e and i n i t i a l i z e f i e l d and c u r r e n t a r r a y s
disp ( ’ c r e a t i n g f i e l d arrays ’ ) ;
17

Hx = zeros ( nxp1 , ny , nz ) ;
19 Hy = zeros ( nx , nyp1 , nz ) ;
Hz = zeros ( nx , ny , nzp1 ) ;
21 Ex = zeros ( nx , nyp1 , nzp1 ) ;
Ey = zeros ( nxp1 , ny , nzp1 ) ;
23 Ez = zeros ( nxp1 , nyp1 , nz ) ;
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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 fields are zero. Therefore, the three-dimensional arrays representing
the vector components of the fields can be created and initialized using the MATLAB func-
tion zeros as illustrated in Listing 4.2. One can notice that the sizes of the arrays are not
the same due to the positioning scheme of field components on the Yee grid as discussed in
Section 3.5.
At this point one can ask if there are any arrays that need to be defined to represent impressed
currents. The answer is that we do not need to define any arrays representing the impressed
currents unless they are explicitly needed in an FDTD simulation. Throughout Chapter 4 we have
shown that the concept of impressed currents is used to establish the voltage–current relations for
the lumped element components and the final updating equations do not include the impressed
current terms except for the inductor. Therefore, we do not need to create three-dimensional
arrays expanded to the problem space to represent impressed current components. However,
for the case of the inductor, there exists an impressed electric current term. Since an inductor
would be expanding only over a couple of cells and only a small number of field components
need to be updated using the inductor updating equations, it is sufficient to create auxiliary arrays
representing these impressed currents that have the limited size based on the number of field
components associated with the respective inductors. The creation and initialization of these
arrays are performed in the subroutine where the updating coefficients of the lumped element
components are initialized.

4.2.3 Initialization of Lumped Element Components


We have shown templates for defining some types of source waveforms, voltage and current
sources, and other lumped element components. The initialization of these components is per-
formed 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 ’ ) ;

3 number of voltage sources = size ( voltage sources , 2 ) ;


number of current sources = size ( current sources , 2 ) ;
5 number of resistors = size ( resistors , 2 ) ;
number of inductors = size ( inductors , 2 ) ;
7 number of capacitors = size ( capacitors , 2 ) ;
number of diodes = s i z e ( diodes , 2 ) ;
9

% i n i t i a l i z e waveforms
11 initialize waveforms ;

13 % voltage sources
for ind = 1: n u m b e r o f v o l t a g e s o u r c e s
15 i s = round ( ( v o l t a g e s o u r c e s ( i n d ) . m i n x − fdtd domain . min x ) / dx ) + 1 ;
j s = round ( ( v o l t a g e s o u r c e s ( i n d ) . m i n y − fdtd domain . min y ) / dy ) + 1 ;
17 k s = round ( ( v o l t a g e s o u r c e s ( i n d ) . m i n z − fdtd domain . min z ) / dz ) + 1 ;
i e = round ( ( v o l t a g e s o u r c e s ( i n d ) . max x − fdtd domain . min x ) / dx ) + 1 ;
19 j e = round ( ( v o l t a g e s o u r c e s ( i n d ) . max y − fdtd domain . min y ) / dy ) + 1 ;
ke = round ( ( v o l t a g e s o u r c e s ( i n d ) . max z − fdtd domain . min z ) / dz ) + 1 ;
21 v o l t a g e s o u r c e s ( ind ) . i s = i s ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation of Lumped Elements 91

voltage sources ( ind ). js = js ;


23 voltage sources ( ind ). ks = ks ;
voltage sources ( ind ). ie = ie ;
25 voltage sources ( ind ). je = je ;
voltage sources ( ind ). ke = 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 ) )
29 case ’ x ’
n fields = ie − is ;
31 r m a g n i t u d e f a c t o r = ( 1 + j e − j s ) * ( 1 + ke − k s ) / ( i e − i s ) ;
case ’ y ’
33 n fields = je − js ;
r m a g n i t u d e f a c t o r = ( 1 + i e − i s ) * ( 1 + ke − k s ) / ( j e − j s ) ;
35 case ’ z ’
n f i e l d s = ke − k s ;
37 r m a g n i t u d e f a c t o r = ( 1 + i e − i s ) * ( 1 + j e − j s ) / ( ke − k s ) ;
end
39 i f strcmp ( v o l t a g e s o u r c e s ( ind ) . d i r e c t i o n ( 2 ) , ’ n ’ )
v magnitude factor = . . .
41 −1* v o l t a g e s o u r c e s ( i n d ) . m a g n i t u d e / n f i e l d s ;
else
43 v magnitude factor = . . .
1* v o l t a g e s o u r c e s ( i n d ) . magnitude / n f i e l d s ;
45 end
v o l t a g e s o u r c e s ( ind ) . resistance per component = . . .
47 r m a g n i t u d e f a c t o r * v o l t a g e s o u r c e s ( ind ) . r e s i s t a n c e ;

49 % 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 ;
51 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 . ’ . . .
53 w t s t r ’ ( ’ w i s t r ’ ) . waveform ; ’ ] ;
eval ( e v a l s t r ) ;
55 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 ;
57 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 ;
59 end

61 % current sources
for ind = 1: number of current sources
63 i s = round ( ( c u r r e n t s o u r c e s ( i n d ) . m i n x − fdtd domain . min x ) / dx ) + 1 ;
j s = round ( ( c u r r e n t s o u r c e s ( i n d ) . m i n y − fdtd domain . min y ) / dy ) + 1 ;
65 k s = round ( ( c u r r e n t s o u r c e s ( i n d ) . m i n z − fdtd domain . min z ) / dz ) + 1 ;
i e = round ( ( c u r r e n t s o u r c e s ( i n d ) . max x − fdtd domain . min x ) / dx ) + 1 ;
67 j e = round ( ( c u r r e n t s o u r c e s ( i n d ) . max y − fdtd domain . min y ) / dy ) + 1 ;
ke = round ( ( c u r r e n t s o u r c e s ( i n d ) . max z − fdtd domain . min z ) / dz ) + 1 ;
69 c u r r e n t s o u r c e s ( ind ) . i s = i s ;
c u r r e n t s o u r c e s ( ind ) . j s = j s ;
71 c u r r e n t s o u r c e s ( ind ) . ks = ks ;
c u r r e n t s o u r c e s ( ind ) . i e = i e ;
73 c u r r e n t s o u r c e s ( ind ) . j e = j e ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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 ) )
77 case ’ x ’
n f i e l d s = ( 1 + j e − j s ) * ( 1 + ke − k s ) ;
79 r m a g n i t u d e f a c t o r = ( 1 + j e − j s ) * ( 1 + ke − k s ) / ( i e − i s ) ;
case ’ y ’
81 n f i e l d s = ( 1 + i e − i s ) * ( 1 + ke − k s ) ;
r m a g n i t u d e f a c t o r = ( 1 + i e − i s ) * ( 1 + ke − k s ) / ( j e − j s ) ;
83 case ’ z ’
n fields = (1 + ie − is ) * (1 + je − js ) ;
85 r m a g n i t u d e f a c t o r = ( 1 + i e − i s ) * ( 1 + j e − j s ) / ( ke − k s ) ;
end
87 i f strcmp ( c u r r e n t s o u r c e s ( ind ) . d i r e c t i o n ( 2 ) , ’ n ’ )
i magnitude factor = . . .
89 −1* c u r r e n t s o u r c e s ( i n d ) . m a g n i t u d e / n f i e l d s ;
else
91 i magnitude factor = . . .
1* c u r r e n t s o u r c e s ( i n d ) . magnitude / n f i e l d s ;
93 end
c u r r e n t s o u r c e s ( ind ) . resistance per component = . . .
95 r m a g n i t u d e f a c t o r * c u r r e n t s o u r c e s ( ind ) . r e s i s t a n c e ;

97 % 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 ;
99 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 . ’ . . .
101 w t s t r ’ ( ’ w i s t r ’ ) . waveform ; ’ ] ;
eval ( e v a l s t r ) ;
103 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 ;
105 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 ;
107 end

109 % resistors
for ind = 1: n u m b e r o f r e s i s t o r s
111 i s = round ( ( r e s i s t o r s ( i n d ) . m i n x − fdtd domain . min x ) / dx ) + 1 ;
j s = round ( ( r e s i s t o r s ( i n d ) . min y − fdtd domain . min y ) / dy ) + 1 ;
113 k s = round ( ( r e s i s t o r s ( i n d ) . m i n z − fdtd domain . min z ) / dz ) + 1 ;
i e = round ( ( r e s i s t o r s ( i n d ) . max x − fdtd domain . min x ) / dx ) + 1 ;
115 j e = round ( ( r e s i s t o r s ( i n d ) . max y − fdtd domain . min y ) / dy ) + 1 ;
ke = round ( ( r e s i s t o r s ( i n d ) . max z − fdtd domain . min z ) / dz ) + 1 ;
117 r e s i s t o r s ( ind ) . i s = i s ;
r e s i s t o r s ( ind ) . j s = j s ;
119 r e s i s t o r s ( ind ) . ks = ks ;
r e s i s t o r s ( ind ) . i e = i e ;
121 r e s i s t o r s ( ind ) . j e = j e ;
r e s i s t o r s ( i n d ) . ke = ke ;
123 sw i t ch ( r e s i s t o r s ( i n d ) . d i r e c t i o n )
case ’ x ’
125 r magnitude factor = (1 + je − j s ) * ( 1 + ke − k s ) / ( i e − i s ) ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation of Lumped Elements 93

case ’ y ’
127 r magnitude factor = ( 1 + i e − i s ) * ( 1 + ke − k s ) / ( j e − j s ) ;
case ’ z ’
129 r magnitude factor = ( 1 + i e − i s ) * ( 1 + j e − j s ) / ( ke − k s ) ;
end
131 r e s i s t o r s ( ind ) . resistance per component = . . .
r magnitude factor * r e s i s t o r s ( ind ) . r e s i s t a n c e ;
133 end

135 % inductors
for ind = 1: number of inductors
137 i s = round ( ( i n d u c t o r s ( i n d ) . m i n x − f d t d d o m a i n . m i n x ) / dx ) + 1 ;
j s = round ( ( i n d u c t o r s ( i n d ) . m i n y − f d t d d o m a i n . m i n y ) / dy ) + 1 ;
139 k s = round ( ( i n d u c t o r s ( i n d ) . m i n z − f d t d d o m a i n . m i n z ) / dz ) + 1 ;
i e = round ( ( i n d u c t o r s ( i n d ) . max x − f d t d d o m a i n . m i n x ) / dx ) + 1 ;
141 j e = round ( ( i n d u c t o r s ( i n d ) . max y − f d t d d o m a i n . m i n y ) / dy ) + 1 ;
ke = round ( ( i n d u c t o r s ( i n d ) . max z − f d t d d o m a i n . m i n z ) / dz ) + 1 ;
143 i n d u c t o r s ( ind ) . i s = i s ;
i n d u c t o r s ( ind ) . j s = j s ;
145 i n d u c t o r s ( ind ) . ks = ks ;
i n d u c t o r s ( ind ) . i e = i e ;
147 i n d u c t o r s ( ind ) . j e = j e ;
i n d u c t o r s ( i n d ) . ke = ke ;
149 sw i t ch ( i n d u c t o r s ( i n d ) . d i r e c t i o n )
case ’ x ’
151 l m a g n i t u d e f a c t o r = ( 1 + j e − j s ) * ( 1 + ke − k s ) / ( i e − i s ) ;
case ’ y ’
153 l m a g n i t u d e f a c t o r = ( 1 + i e − i s ) * ( 1 + ke − k s ) / ( j e − j s ) ;
case ’ z ’
155 l m a g n i t u d e f a c t o r = ( 1 + i e − i s ) * ( 1 + j e − j s ) / ( ke − k s ) ;
end
157 i n d u c t o r s ( ind ) . inductance per component = . . .
l m a g n i t u d e f a c t o r * i n d u c t o r s ( ind ) . inductance ;
159 end

161 % capacitors
for ind = 1: number of capacitors
163 i s = round ( ( c a p a c i t o r s ( i n d ) . m i n x − f d t d domain . min x ) / dx ) + 1 ;
j s = round ( ( c a p a c i t o r s ( i n d ) . m i n y − f d t d domain . min y ) / dy ) + 1 ;
165 k s = round ( ( c a p a c i t o r s ( i n d ) . m i n z − f d t d domain . min z ) / dz ) + 1 ;
i e = round ( ( c a p a c i t o r s ( i n d ) . max x − f d t d domain . min x ) / dx ) + 1 ;
167 j e = round ( ( c a p a c i t o r s ( i n d ) . max y − f d t d domain . min y ) / dy ) + 1 ;
ke = round ( ( c a p a c i t o r s ( i n d ) . max z − f d t d domain . min z ) / dz ) + 1 ;
169 c a p a c i t o r s ( ind ) . i s = i s ;
c a p a c i t o r s ( ind ) . j s = j s ;
171 c a p a c i t o r s ( ind ) . ks = ks ;
c a p a c i t o r s ( ind ) . i e = i e ;
173 c a p a c i t o r s ( ind ) . j e = j e ;
c a p a c i t o r s ( i n d ) . ke = ke ;
175 sw i t ch ( c a p a c i t o r s ( i n d ) . d i r e c t i o n )
case ’ x ’
177 c magnitude factor = ( ie − is ) . . .
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

94 Active and Passive Lumped Elements

/ ((1 + j e − j s ) * ( 1 + ke − k s ) ) ;
179 case ’ y ’
c magnitude factor = ( je − js ) . . .
181 / ((1 + i e − i s ) * ( 1 + ke − k s ) ) ;
case ’ z ’
183 c magnitude f a c t o r = ( ke − k s ) . . .
/ ((1 + ie − is ) * (1 + je − js ) ) ;
185 end
c a p a c i t o r s ( ind ) . capacitance per component = . . .
187 c magnitude f a c t o r * c a p a c i t o r s ( ind ) . c a p a c i t a n c e ;
end
189

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

% diodes
193 for ind = 1: number of diodes
i s = round ( ( d i o d e s ( i n d ) . m i n x − fdtd domain . min x ) / dx ) + 1 ;
195 j s = round ( ( d i o d e s ( i n d ) . m i n y − fdtd domain . min y ) / dy ) + 1 ;
k s = round ( ( d i o d e s ( i n d ) . m i n z − fdtd domain . min z ) / dz ) + 1 ;
197 i e = round ( ( d i o d e s ( i n d ) . max x − fdtd domain . min x ) / dx ) + 1 ;
j e = round ( ( d i o d e s ( i n d ) . max y − fdtd domain . min y ) / dy ) + 1 ;
199 ke = round ( ( d i o d e s ( i n d ) . max z − fdtd domain . min z ) / dz ) + 1 ;
diodes ( ind ) . i s = i s ;
201 diodes ( ind ) . j s = j s ;
diodes ( ind ) . ks = ks ;
203 diodes ( ind ) . i e = i e ;
diodes ( ind ) . j e = j e ;
205 d i o d e s ( i n d ) . ke = ke ;

207 sw i t ch ( d i o d e s ( i n d ) . d i r e c t i o n ( 1 ) )
case ’ x ’
209 s i g m a e x ( i s +1: i e −1 , j s , k s ) = s i g m a p e c ;
case ’ y ’
211 s i g m a e y ( i s , j s +1: j e −1 , k s ) = s i g m a p e c ;
case ’ z ’
213 s i g m a e z ( i s , j s , k s +1: ke −1) = s i g m a p e c ;
end
215 end
 

Before initializing the sources, the source waveforms need to be initialized. Therefore, a
subroutine, initialize waveforms, is called in Listing 4.3 before initialization of lumped com-
ponents. The sample implementation of initialize waveforms is given in Listing 4.4, and this
subroutine will be expanded as new source waveform types are discussed in the following chap-
ter. In subroutine initialize waveforms for every waveform type the respective waveforms are
calculated as functions of time based on the waveform type specific parameters. Then the cal-
culated waveforms are stored in the arrays with the associated name waveform. For instance,
in Listing 4.4 the parameter waveforms.sinusoidal(i).waveform is constructed as a sinusoidal
waveform using sin(2π × f × t), where f is the frequency defined with the parameter wave-
forms.sinusoidal(i).frequency and t is the discrete time array time storing the time instants of the
time steps.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation of Lumped Elements 95

Listing 4.4 initialize waveforms.m


1 disp ( ’ i n i t i a l i z i n g s o u r c e waveforms ’ ) ;

3 % i n i t i a l i z e s i n u s o i d a l waveforms
f o r i n d =1: s i z e ( w a v e f o r m s . s i n u s o i d a l , 2 )
5 w a v e f o r m s . s i n u s o i d a l ( i n d ) . waveform = . . .
s i n ( 2 * pi * waveforms . s i n u s o i d a l ( ind ) . f r e q u e n c y * time ) ;
7 end

9 % i n i t i a l i z e u n i t s t e p waveforms
f o r i n d =1: s i z e ( w a v e f o r m s . u n i t s t e p , 2 )
11 s t a r t i n d e x = waveforms . u n i t s t e p ( ind ) . s t a r t t i m e s t e p ;
w a v e f o r m s . u n i t s t e p ( i n d ) . waveform ( 1 : n u m b e r o f t i m e s t e p s ) = 1 ;
13 w a v e f o r m s . u n i t s t e p ( i n d ) . waveform ( 1 : s t a r t i n d e x −1) = 0 ;
end
 
Once the waveform arrays are constructed for the defined waveform types they can be copied
to waveform fields of the structures of sources associated with them as demonstrated in Listing
4.3. For example, consider the code section in the loop initializing the voltage sources. The type
of source waveform is stored in voltage sources(ind).waveform type as a string, and the index
of the source waveform is stored in voltage sources(ind).waveform index as an integer number.
Here we employ the MATLAB function eval, which executes a string containing MATLAB
expression. We construct a string using the following expression:

w t s t r = v o l t a g e s o u r c e s ( ind ) . waveform type ;
w i s t r = num2str ( v o l t a g e s o u r c e s ( i n d ) . w a v e f o r m i n d e x ) ;
e v a l s t r = [ ’ a waveform = waveforms . ’ w t s t r ’ ( ’ w i s t r ’ ) . waveform ; ’ ] ;
 
which constructs the string eval str in the MATLAB workspace for the waveforms and the voltage
source voltage sources(1) defined in Listing 4.1 as
e v a l s t r = ’ a w a v e f o r m = w a v e f o r m s . s i n u s o i d a l ( 2 ) . waveform ; ’
Executing this string using eval as

eval ( e v a l s t r ) ;
 
creates a parameter a waveform in the MATLAB workspace, which has a copy of the waveform
that the voltage source voltage sources(1) is associated with. Then we can assign a waveform
to voltage sources(1).waveform after multiplying with a factor. This multiplication factor is
explained in the following paragraphs.
As discussed in Section 4.7 all the lumped element components except the diodes are assumed to
be distributed over surfaces or volumes extending over a number of cells. Therefore, a number of
field components require special updating due to the lumped elements associated with them. We
assume that the surfaces or volumes that the lumped elements are coinciding with are conforming
to the cells composing the FDTD problem space. Then we can identify the field components that
are associated with lumped components by the indices of the start node, (is , j s , ks ), coinciding
with the lower coordinates of the lumped component, and the indices of the end node, (ie, j e, ke),
coinciding with the upper coordinates of the lumped component, as illustrated in Fig. 4.6. There-
fore, for every lumped element, the start and end node indices are calculated and stored in the
parameters is, js, ks, ie, je, and ke as shown in Listing 4.3.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

96 Active and Passive Lumped Elements

Based on the discussion in Section 4.7, if a lumped element is associated with more than one
field component, the value of the lumped element should be assigned to the field components
after a modification. Therefore, new parameters are defined in the structures representing the
lumped elements, which store the value of the lumped element per field component. For instance,
resistance per component is defined in voltage sources(i), which stores the resistance of the
voltage source per field component as calculated using the form of (4.26) by taking into account the
direction of the component. Similarly, for a resistor resistance per component is defined and
calculated by (4.27). For a current source resistance per component is defined and calculated
by (4.31). The parameter inductance per component is calculated by (4.28) for an inductor, and
capacitance per component is calculated by (4.29) for a capacitor.
Similarly, the voltage sources(i).voltage per e field is scaled using (4.25), and current -
sources(i).current per e field is scaled using (4.30). Furthermore, directions of these compo-
nents as well are taken into account in the scaling factors; if the direction is negative the scaling
factor is multiplied by −1. Meanwhile, parameters voltage sources(i).waveform, and current -
sources(i).waveform are constructed to store the main voltages and currents of the lumped
sources rather than the values used to update the associated field components.
We assume that a diode is defined as a one-dimensional object, such as a line section, extending
over a number of electric field components on the cell edges as illustrated in Fig. 4.9. Here
the diode is extending between the nodes (is , j s , ks ) and (ie, j e, ke)—hence the field components
E z (is , j s , ks : ke − 1), where ie = is and j e = j s . However, as discussed in Section 4.8, we update
only one of these field components, in this case E z (is , j s , ks ), using the diode updating equations,
and we establish an electrical connection between other nodes (is , j s , ks + 1) and (ie, j e, ke).
The easiest way of establishing the electrical connection is considering a PEC line between these
nodes. Therefore, we can assign conductivity of PEC to the material components associated

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


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation of Lumped Elements 97

with the electric field components E z (is , j s , ks + 1 : ke − 1), which are σze (is , j s , ks + 1 : ke − 1).
Therefore, the necessary material components are assigned the conductivity of PEC in Listing
4.3 while initializing the diodes. A more accurate representation for a PEC line is presented
Chapter 10 where thin PEC wire updating equations will be developed.

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 coefficients. We calculate and store
updating coefficients in three-dimensional arrays before the FDTD time-marching loop begins
and use them while updating the fields during the time-marching loop. The initialization of the
updating coefficients 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 ’ ) ;

3 % General e l e c t r i c f i e l d updating c o e f f i c i e n t s
% C o e f f i e c i e n t s updating Ex
5 Cexe = ( 2 * e p s r x * eps 0 − dt * sigma e x ) . . .
. / ( 2 * e p s r x * eps 0 + dt * sigma e x ) ;
7 C e x h z = ( 2 * d t / dy ) . / ( 2 * e p s r x * e p s 0 + d t * s i g m a e x ) ;
C e x h y = −(2 * d t / dz ) . / ( 2 * e p s r x * e p s 0 + d t * s i g m a e x ) ;
9

% C o e f f i e c i e n t s updating Ey
11 Ceye = ( 2 * e p s r y * eps 0 − dt * sigma e y ) . . .
. / ( 2 * e p s r y * eps 0 + dt * sigma e y ) ;
13 C e y h x = ( 2 * d t / dz ) . / ( 2 * e p s r y * e p s 0 + d t * s i g m a e y ) ;
C e y h z = −(2 * d t / dx ) . / ( 2 * e p s r y * e p s 0 + d t * s i g m a e y ) ;
15

% C o e f f i e c i e n t s updating Ez
17 Ceze = ( 2 * e p s r z * eps 0 − dt * sigma e z ) . . .
. / ( 2 * e p s r z * eps 0 + dt * sigma e z ) ;
19 C e z h y = ( 2 * d t / dx ) . / ( 2 * e p s r z * e p s 0 + d t * s i g m a e z ) ;
C e z h x = −(2 * d t / dy ) . / ( 2 * e p s r z * e p s 0 + d t * s i g m a e z ) ;
21

% General magnetic f i e l d updating c o e f f i c i e n t s


23 % 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 ) . . .
25 . / ( 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 ) ;
27 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 ) ;

29 % C o e f f i e c i e n t s u p d a t i n g Hy
Chyh = ( 2 * m u r y * mu 0 − d t * s i g m a m y ) . . .
31 . / ( 2 * m u r y * mu 0 + d t * s i g m a m y ) ;
C h y e x = −(2 * d t / dz ) . / ( 2 * m u r y * mu 0 + d t * s i g m a m y ) ;
33 C h y e z = ( 2 * d t / dx ) . / ( 2 * m u r y * mu 0 + d t * s i g m a m y ) ;

35 % C o e f f i e c i e n t s u p d a t i n g Hz
Chzh = ( 2 * m u r z * mu 0 − d t * s i g m a m z ) ...
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

98 Active and Passive Lumped Elements

37 . / ( 2 * m u r z * mu 0 + d t * s i g m a m z ) ;
C h z e y = −(2 * d t / dx ) . / ( 2 * m u r z * mu 0 + d t * s i g m a m z ) ;
39 C h z e x = ( 2 * d t / dy ) . / ( 2 * m u r z * mu 0 + d t * s i g m a m z ) ;

41 % I n i t i a l i z e c o e f f i e c i e n t s f o r lumped e l e m e n t components
initialize voltage source updating coefficients ;
43 initialize current source updating coefficients ;
initialize resistor updating coefficients ;
45 initialize capacitor updating coefficients ;
initialize inductor updating coefficients ;
47 initialize diode updating coefficients ;
 

In Chapter 1 we obtained the set of equations (1.26)–(1.31) as the general form of the updating
equations. One can notice that the form of the updating equations obtained for the lumped
elements is the same as the general form. The only difference is that for some types of lumped
elements the terms associated with the impressed currents are replaced by some other terms; for
instance, for a voltage source the impressed current term is replaced by a voltage source term in
the updating equation. Furthermore, as discussed in Section 4.2.2, the impressed current terms in
(1.26)–(1.31) are used to establish the voltage–current relations for the lumped elements, and they
vanish in updating equations modeling media that does not include any lumped components.
Therefore, in an FDTD simulation before the time-marching iteration starts the updating
coefficients can be calculated for the whole problem space using the general updating equation
coefficients appearing in (1.26)–(1.31) and excluding the impressed current terms. Then the up-
dating coefficients can be recalculated only for the position indices where the lumped components
exist. The additional coefficients required for the lumped elements (e.g., voltage sources, current
sources, and inductors), can be calculated and stored in separate arrays associated with these com-
ponents. Then during the FDTD time-marching iterations, at every time step, the electric field
components can be updated using the general updating equations (1.26)–(1.31) excluding the im-
pressed current terms, and then the additional terms can be added to the electric field components
at the respective position indices where the lumped elements exist. In this section we illustrate the
implementation of the previous discussion in the MATLAB program. The vector type operation
in MATLAB is being used to efficiently generate these arrays.
In Listing 4.5 the updating coefficients, except for the impressed current terms, defined in the
general updating equations (1.26)–(1.31) are constructed using the material component arrays that
have been initialized in the subroutine initialize fdtd material grid. The sizes of the coefficient
arrays are the same as the sizes of the material component arrays that have been used to construct
them. Then the updating coefficients related to the lumped element components are constructed
in respective subroutines as shown in Listing 4.5.

4.2.4.1 Initialization of Voltage Source Updating Coefficients The updating coefficients related to the
voltage sources are constructed in the subroutine initialize voltage source updating coefficients
as implemented in Listing 4.6. The indices of the nodes identifying the positions of the voltage
sources, is, js, ks, ie, je, and ke, were determined while initializing the voltage sources as shown
in Listing 4.3. For instance, consider the z-directed voltage source defined between the nodes
(is , j s , ks ) and (ie, j e, ke) and the associated electric field components as illustrated in Fig. 4.10.
These indices of the nodes are used to identify the indices of the field components that need the
special updates due to the voltage sources. The indices of the field components are determined
by taking into account the directions of the voltage sources. Since these field components will be
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation of Lumped Elements 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 field components under consideration are usually accessed using
three index values, such as
C e z e ( i s : i e , j s : j e , k s : ke −1)
since the field arrays are three-dimensional. An alternative way of accessing an element of a
multidimensional array is to use the nice feature of MATLAB called linear indexing. Using linear
indexing the three indices of a three-dimensional array can be mapped to a single index. Therefore,
a single index would be sufficient. For the case where a number of elements need to be indexed,
a vector can be constructed in which each value holds the index of the respective element in the
three-dimensional array. Therefore, as shown in Listing 4.6, a temporary array of indices, fi, is
constructed using

f i = c r e a t e l i n e a r i n d e x l i s t ( e p s r z , i s : i e , j s : j e , k s : ke − 1 ) ;
 
Here create linear index list is a function that takes three parameters indicating the range of
indices of a subsection of a three-dimensional array and converts it to a one-dimensional linear
index array. While doing this conversion, it uses the MATLAB function sub2ind, which needs the
size of the three-dimensional array. Therefore, the first argument of create linear index list is the
three-dimensional array under consideration. The implementation of create linear index list is
given in Listing 4.7. After the linear indices array is constructed, instead of accessing a subsection
of an array by
C e z e ( i s : i e , j s : j e , k s : ke −1)
one can simply implement
Ceze ( f i )
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

100 Active and Passive Lumped Elements

Listing 4.6 initialize voltage source updating coefficients.m


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

3 for ind = 1: n u m b e r o f v o l t a g e s o u r c e s
i s = v o l t a g e s o u r c e s ( ind ) . i s ;
5 j s = v o l t a g e s o u r c e s ( ind ) . j s ;
ks = v o l t a g e s o u r c e s ( ind ) . ks ;
7 i e = v o l t a g e s o u r c e s ( ind ) . i e ;
j e = v o l t a g e s o u r c e s ( ind ) . j e ;
9 ke = v o l t a g e s o u r c e s ( i n d ) . ke ;
R = v o l t a g e s o u r c e s ( ind ) . resistance per component ;
11 i f ( R == 0 ) R = 1e −20; end

13 sw i t ch ( v o l t a g e s o u r c e s ( i n d ) . d i r e c t i o n ( 1 ) )
case ’ x ’
15 f i = c r e a t e l i n e a r i n d e x l i s t ( e p s r x , i s : i e −1 , j s : j e , k s : ke ) ;
a t e r m = ( d t * dx ) / ( R * dy * dz ) ;
17 Cexe ( f i ) = . . .
( 2 * e p s 0 * e p s r x ( f i )− d t * s i g m a e x ( f i )− a t e r m ) . . .
19 . / ( 2 * e p s 0 * e p s r x ( f i )+ d t * s i g m a e x ( f i )+ a t e r m ) ;
C e x h z ( f i )= ( 2 * d t / dy ) . . .
21 . / ( 2 * e p s r x ( f i ) * e p s 0+d t * s i g m a e x ( f i )+ a t e r m ) ;
C e x h y ( f i )= −(2 * d t / dz ) . . .
23 . / ( 2 * e p s r x ( f i ) * e p s 0 + d t * s i g m a e x ( f i )+ a t e r m ) ;
v o l t a g e s o u r c e s ( i n d ) . C e x s = −(2 * d t / ( R * dy * dz ) ) . . .
25 . / ( 2 * e p s r x ( f i ) * e p s 0+d t * s i g m a e x ( f i )+ a t e r m ) ;
case ’ y ’
27 f i = c r e a t e l i n e a r i n d e x l i s t ( e p s r y , i s : i e , j s : j e −1 , k s : ke ) ;
a t e r m = ( d t * dy ) / ( R * dz * dx ) ;
29 Ceye ( f i ) = . . .
( 2 * e p s 0 * e p s r y ( f i )− d t * s i g m a e y ( f i )− a t e r m ) . . .
31 . / ( 2 * e p s 0 * e p s r y ( f i )+ d t * s i g m a e y ( f i )+ a t e r m ) ;
C e y h x ( f i )= ( 2 * d t / dz ) . . .
33 . / ( 2 * e p s r y ( f i ) * e p s 0+d t * s i g m a e y ( f i )+ a t e r m ) ;
C e y h z ( f i )= −(2 * d t / dx ) . . .
35 . / ( 2 * e p s r y ( f i ) * e p s 0 + d t * s i g m a e y ( f i )+ a t e r m ) ;
v o l t a g e s o u r c e s ( i n d ) . C e y s = −(2 * d t / ( R * dz * dx ) ) . . .
37 . / ( 2 * e p s r y ( f i ) * e p s 0+d t * s i g m a e y ( f i )+ a t e r m ) ;
case ’ z ’
39 f i = c r e a t e l i n e a r i n d e x l i s t ( e p s r z , i s : i e , j s : j e , k s : ke − 1 ) ;
a t e r m = ( d t * dz ) / ( R * dx * dy ) ;
41 Ceze ( f i ) = . . .
( 2 * e p s 0 * e p s r z ( f i )− d t * s i g m a e z ( f i )− a t e r m ) . . .
43 . / ( 2 * e p s 0 * e p s r z ( f i )+ d t * s i g m a e z ( f i )+ a t e r m ) ;
C e z h y ( f i )= ( 2 * d t / dx ) . . .
45 . / ( 2 * e p s r z ( f i ) * e p s 0+d t * s i g m a e z ( f i )+ a t e r m ) ;
C e z h x ( f i )= −(2 * d t / dy ) . . .
47 . / ( 2 * e p s r z ( f i ) * e p s 0+d t * s i g m a e z ( f i )+ a t e r m ) ;
v o l t a g e s o u r c e s ( i n d ) . C e z s = −(2 * d t / ( R * dx * dy ) ) . . .
49 . / ( 2 * e p s r z ( f i ) * e p s 0+d t * s i g m a e z ( f i )+ a t e r m ) ;
end
51 v o l t a g e s o u r c e s ( ind ) . f i e l d i n d i c e s = f i ;
end
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation of Lumped Elements 101

Listing 4.7 create linear index list.m



% a function that generates a l i s t of l i n e a r ind ices
2 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 )

4 i s i z e = size ( i l i s t , 2 ) ;
j s i z e = size ( j l i s t , 2 ) ;
6 k size = size ( k list , 2 ) ;
number of indices = i s i z e * j s i z e * k size ;
8 I = zeros ( number of indices , 1 ) ;
J = zeros ( number of indices , 1 ) ;
10 K = zeros ( number of indices , 1 ) ;
ind = 1;
12 f o r mk = k l i s t ( 1 ) : k l i s t ( k s i z e )
f o r mj = j l i s t ( 1 ) : j l i s t ( j s i z e )
14 f o r mi = i l i s t ( 1 ) : i l i s t ( i s i z e )
I ( i n d ) = mi ;
16 J ( i n d ) = mj ;
K ( i n d ) = mk ;
18 ind = ind + 1;
end
20 end
end
22 f i = sub2ind ( s i z e ( array 3d ) , I , J , K ) ;
 

Once the field component indices needing special updates are determined as fi in Listing 4.6,
the respective components of the general updating coefficients are recalculated based on the voltage
source updating equations as given in (4.10).
n+ 12
One can notice that there exists an additional term in (4.10), given by Ce zs (i, j, k) × Vs (i, j, k),
n+ 1
for updating E zn+1 (i, j, k). The term Vs 2 (i, j, k) is the value of the voltage source waveform at
time instant (n + 12 ) × t, and this value is stored in the parameter voltage sources(i).waveform.
The other term Ce zs is the additional coefficient term for the voltage source. This term is con-
structed based on (4.10) as the parameter Cezs and associated with the respective voltage source
as voltage sources(i).Cezs. Similarly, if the voltage source updates the electric field compo-
nents E x the parameter voltage sources(i).Cexs can be constructed, whereas if the voltage
source updates E y the parameter voltage sources(i).Ceys can be constructed, based on the
direction of the voltage sources as implemented in Listing 4.6. Finally, the parameter voltage -
sources(i).field indices is constructed from fi. Then the parameter field indices are used to
access the respective field components while updating the electric field components during the
time-marching loop.

4.2.4.2 Initialization of Current Source Updating Coefficients The initialization of current source
updating coefficients is performed in the subroutine initialize current source updating -
coefficients, which is shown in Listing 4.8. The initialization of current source coefficients is
the same as the initialization of voltage source coefficients and follows the updating equation
given in (4.15).
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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 sources


4 i s = c u r r e n t s o u r c e s ( ind ) . is ;
j s = c u r r e n t s o u r c e s ( ind ) . js ;
6 ks = c u r r e n t s o u r c e s ( ind ) . ks ;
i e = c u r r e n t s o u r c e s ( ind ) . ie ;
8 j e = c u r r e n t s o u r c e s ( ind ) . je ;
ke = c u r r e n t s o u r c e s ( i n d ) . 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 ) )
14 case ’ x ’
f i = c r e a t e l i n e a r i n d e x l i s t ( e p s r x , i s : i e −1 , j s : j e , k s : ke ) ;
16 a t e r m = ( d t * dx ) / ( R * dy * dz ) ;
Cexe ( f i ) = . . .
18 ( 2 * e p s 0 * e p s r x ( f i )− d t * s i g m a e x ( f i )− a t e r m ) . . .
. / ( 2 * e p s 0 * e p s r x ( f i )+ d t * s i g m a e x ( f i )+ a t e r m ) ;
20 C e x h z ( f i )= ( 2 * d t / dy ) . . .
. / ( 2 * e p s r x ( f i ) * e p s 0+d t * s i g m a e x ( f i )+ a t e r m ) ;
22 C e x h y ( f i )= −(2 * d t / dz ) . . .
. / ( 2 * e p s r x ( f i ) * e p s 0 + d t * s i g m a e x ( f i )+ a t e r m ) ;
24 c u r r e n t s o u r c e s ( i n d ) . C e x s = −(2 * d t / ( dy * dz ) ) . . .
. / ( 2 * e p s r x ( f i ) * e p s 0+d t * s i g m a e x ( f i )+ a t e r m ) ;
26 case ’ y ’
f i = c r e a t e l i n e a r i n d e x l i s t ( e p s r y , i s : i e , j s : j e −1 , k s : ke ) ;
28 a t e r m = ( d t * dy ) / ( R * dz * dx ) ;
Ceye ( f i ) = . . .
30 ( 2 * e p s 0 * e p s r y ( f i )− d t * s i g m a e y ( f i )− a t e r m ) . . .
. / ( 2 * e p s 0 * e p s r y ( f i )+ d t * s i g m a e y ( f i )+ a t e r m ) ;
32 C e y h x ( f i )= ( 2 * d t / dz ) . . .
. / ( 2 * e p s r y ( f i ) * e p s 0+d t * s i g m a e y ( f i )+ a t e r m ) ;
34 C e y h z ( f i )= −(2 * d t / dx ) . . .
. / ( 2 * e p s r y ( f i ) * e p s 0 + d t * s i g m a e y ( f i )+ a t e r m ) ;
36 c u r r e n t s o u r c e s ( i n d ) . C e y s = −(2 * d t / ( dz * dx ) ) . . .
. / ( 2 * e p s r y ( f i ) * e p s 0+d t * s i g m a e y ( f i )+ a t e r m ) ;
38 case ’ z ’
f i = c r e a t e l i n e a r i n d e x l i s t ( e p s r z , i s : i e , j s : j e , k s : ke − 1 ) ;
40 a t e r m = ( d t * dz ) / ( R * dx * dy ) ;
Ceze ( f i ) = . . .
42 ( 2 * e p s 0 * e p s r z ( f i )− d t * s i g m a e z ( f i )− a t e r m ) . . .
. / ( 2 * e p s 0 * e p s r z ( f i )+ d t * s i g m a e z ( f i )+ a t e r m ) ;
44 C e z h y ( f i )= ( 2 * d t / dx ) . . .
. / ( 2 * e p s r z ( f i ) * e p s 0+d t * s i g m a e z ( f i )+ a t e r m ) ;
46 C e z h x ( f i )= −(2 * d t / dy ) . . .
. / ( 2 * e p s r z ( f i ) * e p s 0+d t * s i g m a e z ( f i )+ a t e r m ) ;
48 c u r r e n t s o u r c e s ( i n d ) . C e z s = −(2 * d t / ( dx * dy ) ) . . .
. / ( 2 * e p s r z ( f i ) * e p s 0+d t * s i g m a e z ( f i )+ a t e r m ) ;
50 end
c u r r e n t s o u r c e s ( ind ) . f i e l d i n d i c e s = f i ;
52 end
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation of Lumped Elements 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 inductors


4 i s = i n d u c t o r s ( ind ). is ;
j s = i n d u c t o r s ( ind ). js ;
6 ks = i n d u c t o r s ( ind ) . ks ;
i e = i n d u c t o r s ( ind ) . ie ;
8 j e = i n d u c t o r s ( ind ) . je ;
ke = i n d u c t o r s ( i n d ) . 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 ) )
14 case ’ x ’
f i = c r e a t e l i n e a r i n d e x l i s t ( e p s r x , i s : i e −1 , j s : j e , k s : ke ) ;
16 i n d u c t o r s ( i n d ) . C e x j = −(2 * d t ) . . .
. / ( 2 * e p s r x ( f i ) * e p s 0+d t * s i g m a e x ( f i ) ) ;
18 i n d u c t o r s ( ind ) . J i x = zeros ( s i z e ( f i ) ) ;
i n d u c t o r s ( i n d ) . C j e x = ( d t * dx ) / ( L * dy * dz ) ;
20 case ’ y ’
f i = c r e a t e l i n e a r i n d e x l i s t ( e p s r y , i s : i e , j s : j e −1 , k s : ke ) ;
22 i n d u c t o r s ( i n d ) . C e y j = −(2 * d t ) . . .
. / ( 2 * e p s r y ( f i ) * e p s 0+d t * s i g m a e y ( f i ) ) ;
24 i n d u c t o r s ( ind ) . J i y = zeros ( s i z e ( f i ) ) ;
i n d u c t o r s ( i n d ) . C j e y = ( d t * dy ) / ( L * dz * dx ) ;
26 case ’ z ’
f i = c r e a t e l i n e a r i n d e x l i s t ( e p s r z , i s : i e , j s : j e , k s : ke − 1 ) ;
28 i n d u c t o r s ( i n d ) . C e z j = −(2 * d t ) . . .
. / ( 2 * e p s r z ( f i ) * e p s 0+d t * s i g m a e z ( f i ) ) ;
30 i n d u c t o r s ( ind ) . J i z = zeros ( s i z e ( f i ) ) ;
i n d u c t o r s ( i n d ) . C j e z = ( d t * dz ) / ( L * dx * dy ) ;
32 end
i n d u c t o r s ( ind ) . f i e l d i n d i c e s = f i ;
34 end
 

4.2.4.3 Initialization of Inductor Updating Coefficients The updating coefficients for modeling in-
ductors are initialized in the subroutine initialize inductor updating coefficients, which is shown
in Listing 4.9, based on the updating equation (4.24). Comparing (4.24) with (1.28) one can ob-
serve that the form of the updating equation modeling an inductor is the same as the form of the
general updating equation. Therefore, there is no need to recalculate the coefficients that have
been initialized as general updating coefficients. However, a coefficient term Ce zj has not been
defined in the implementation of the general updating equations. Therefore, the coefficient term
Ce zj associated with the inductor is defined as inductors(i).Cezj in Listing 4.9. Furthermore,
the Ji z term is also associated with the inductor, and it is also defined as inductors(i).Jiz and is
initialized with zeros.
As discussed in Section 4.1.6, during the FDTD time-marching iteration, at every time step
n+ 12 n− 12
the new value of Ji z (i, j, k) is to be calculated by (4.23) using E zn (i, j, k) and Ji z (i, j, k) before
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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 n− 12 tz n
Ji z (i, j, k) = Ji z (i, j, k) + E (i, j, k)
Lxy z
n− 12
= Ji z (i, j, k) + C j e z (i, j, k) × E zn (i, j, k),

where

tz
C j e z (i, j, k) = .
Lxy

Therefore, C j e z is an additional coefficient that can be initialized before the time-marching loop.
Hence, the parameter inductors(i).Cjez is constructed as shown in Listing 4.9.

4.2.4.4 Initialization of Resistor Updating Coefficients The initialization of updating coefficients


related to resistors is performed in the subroutine initialize resistor updating coefficients, which
is shown in Listing 4.10. The initialization of resistor coefficients is straightforward; the indices
of field components associated with a resistor are determined in the temporary parameter fi, and
the elements of the general coefficient arrays are accessed through fi and are recalculated based
on the resistor updating equation (4.16).

4.2.4.5 Initialization of Capacitor Updating Coefficients The initialization of updating coefficients


related to capacitors is performed in the subroutine initialize capacitor updating coefficients,
which is shown in Listing 4.11. The initialization of capacitor coefficients is similar to the initial-
ization of resistor coefficients and is based on the updating equation (4.20).

4.2.4.6 Initialization of Diode Updating Coefficients The algorithm for modeling diodes is signifi-
cantly different compared with other lumped element components, and it requires the initializa-
tion of a different set of parameters. The updating coefficients for modeling diodes are initial-
ized in initialize diode updating coefficients, and implementation of this subroutine is shown in
Listing 4.12.
As mentioned in Section 4.2.3, only one electric field component is associated with a diode;
therefore, it needs a special updating based on the equations in Section 4.1.8. For example, for a
diode oriented in the positive z direction and defined between the nodes (is , j s , ks ) and (ie, j e, ke),
only the field component E z (is , j s , ks ) is updated as illustrated in Fig. 4.9.
As discussed in Section 4.1.8, the new value of the electric field component associated with a
diode is obtained by the solution of the equation

Ae Bx + x + C = 0, (4.42)

where
n
x = E zn+1 (i, j, k), A = −Ce zd (i, j, k)e B×Ez (i, j,k) , B = (q z/2kT),
 n+ 1 n+ 1

C = Ce ze (i, j, k) × E zn (i, j, k) + Ce zhy (i, j, k) × Hy 2 (i, j, k) − Hy 2 (i − 1, j, k)
 n+ 1 n+ 1

+ Ce zhx (i, j, k) × Hx 2 (i, j, k) − Hx 2 (i, j − 1, k) + Ce zd (i, j, k).
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation of Lumped Elements 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 ’ ) ;
2

for ind = 1: n u m b e r o f resistors


4 i s = r e s i s t o r s ( ind ). is ;
j s = r e s i s t o r s ( ind ). js ;
6 ks = r e s i s t o r s ( ind ) . ks ;
i e = r e s i s t o r s ( ind ) . ie ;
8 j e = r e s i s t o r s ( ind ) . je ;
ke = r e s i s t o r s ( i n d ) . 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 ) )
14 case ’ x ’
f i = c r e a t e l i n e a r i n d e x l i s t ( e p s r x , i s : i e −1 , j s : j e , k s : ke ) ;
16 a t e r m = ( d t * dx ) / ( R * dy * dz ) ;
Cexe ( f i ) = . . .
18 ( 2 * e p s 0 * e p s r x ( f i )− d t * s i g m a e x ( f i )− a t e r m ) . . .
. / ( 2 * e p s 0 * e p s r x ( f i )+ d t * s i g m a e x ( f i )+ a t e r m ) ;
20 C e x h z ( f i )= ( 2 * d t / dy ) . . .
. / ( 2 * e p s r x ( f i ) * e p s 0+d t * s i g m a e x ( f i )+ a t e r m ) ;
22 C e x h y ( f i )= −(2 * d t / dz ) . . .
. / ( 2 * e p s r x ( f i ) * e p s 0 + d t * s i g m a e x ( f i )+ a t e r m ) ;
24 case ’ y ’
f i = c r e a t e l i n e a r i n d e x l i s t ( e p s r y , i s : i e , j s : j e −1 , k s : ke ) ;
26 a t e r m = ( d t * dy ) / ( R * dz * dx ) ;
Ceye ( f i ) = . . .
28 ( 2 * e p s 0 * e p s r y ( f i )− d t * s i g m a e y ( f i )− a t e r m ) . . .
. / ( 2 * e p s 0 * e p s r y ( f i )+ d t * s i g m a e y ( f i )+ a t e r m ) ;
30 C e y h x ( f i )= ( 2 * d t / dz ) . . .
. / ( 2 * e p s r y ( f i ) * e p s 0+d t * s i g m a e y ( f i )+ a t e r m ) ;
32 C e y h z ( f i )= −(2 * d t / dx ) . . .
. / ( 2 * e p s r y ( f i ) * e p s 0 + d t * s i g m a e y ( f i )+ a t e r m ) ;
34 case ’ z ’
f i = c r e a t e l i n e a r i n d e x l i s t ( e p s r z , i s : i e , j s : j e , k s : ke − 1 ) ;
36 a t e r m = ( d t * dz ) / ( R * dx * dy ) ;
Ceze ( f i ) = . . .
38 ( 2 * e p s 0 * e p s r z ( f i )− d t * s i g m a e z ( f i )− a t e r m ) . . .
. / ( 2 * e p s 0 * e p s r z ( f i )+ d t * s i g m a e z ( f i )+ a t e r m ) ;
40 C e z h y ( f i )= ( 2 * d t / dx ) . . .
. / ( 2 * e p s r z ( f i ) * e p s 0+d t * s i g m a e z ( f i )+ a t e r m ) ;
42 C e z h x ( f i )= −(2 * d t / dy ) . . .
. / ( 2 * e p s r z ( f i ) * e p s 0+d t * s i g m a e z ( f i )+ a t e r m ) ;
44 end
r e s i s t o r s ( ind ) . f i e l d i n d i c e s = f i ;
46 end
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

106 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


4 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 ;
6 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 ;
8 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 ) )
14 case ’ x ’
f i = c r e a t e l i n e a r i n d e x l i s t ( e p s r x , i s : i e −1 , j s : j e , k s : ke ) ;
16 a t e r m = ( 2 * C * dx ) / ( dy * dz ) ;
Cexe ( f i ) = . . .
18 ( 2 * e p s 0 * e p s r x ( f i )− d t * s i g m a e x ( f i )+ a t e r m ) . . .
. / ( 2 * e p s 0 * e p s r x ( f i )+ d t * s i g m a e x ( f i )+ a t e r m ) ;
20 C e x h z ( f i )= ( 2 * d t / dy ) . . .
. / ( 2 * e p s r x ( f i ) * e p s 0+d t * s i g m a e x ( f i )+ a t e r m ) ;
22 C e x h y ( f i )= −(2 * d t / dz ) . . .
. / ( 2 * e p s r x ( f i ) * e p s 0 + d t * s i g m a e x ( f i )+ a t e r m ) ;
24 case ’ y ’
f i = c r e a t e l i n e a r i n d e x l i s t ( e p s r y , i s : i e , j s : j e −1 , k s : ke ) ;
26 a t e r m = ( 2 * C * dy ) / ( dz * dx ) ;
Ceye ( f i ) = . . .
28 ( 2 * e p s 0 * e p s r y ( f i )− d t * s i g m a e y ( f i )+ a t e r m ) . . .
. / ( 2 * e p s 0 * e p s r y ( f i )+ d t * s i g m a e y ( f i )+ a t e r m ) ;
30 C e y h x ( f i )= ( 2 * d t / dz ) . . .
. / ( 2 * e p s r y ( f i ) * e p s 0+d t * s i g m a e y ( f i )+ a t e r m ) ;
32 C e y h z ( f i )= −(2 * d t / dx ) . . .
. / ( 2 * e p s r y ( f i ) * e p s 0 + d t * s i g m a e y ( f i )+ a t e r m ) ;
34 case ’ z ’
f i = c r e a t e l i n e a r i n d e x l i s t ( e p s r z , i s : i e , j s : j e , k s : ke − 1 ) ;
36 a t e r m = ( 2 * C * dz ) / ( dx * dy ) ;
Ceze ( f i ) = . . .
38 ( 2 * e p s 0 * e p s r z ( f i )− d t * s i g m a e z ( f i )+ a t e r m ) . . .
. / ( 2 * e p s 0 * e p s r z ( f i )+ d t * s i g m a e z ( f i )+ a t e r m ) ;
40 C e z h y ( f i )= ( 2 * d t / dx ) . . .
. / ( 2 * e p s r z ( f i ) * e p s 0+d t * s i g m a e z ( f i )+ a t e r m ) ;
42 C e z h x ( f i )= −(2 * d t / dy ) . . .
. / ( 2 * e p s r z ( f i ) * e p s 0+d t * s i g m a e z ( f i )+ a t e r m ) ;
44 end
c a p a c i t o r s ( ind ) . f i e l d i n d i c e s = f i ;
46 end
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation of Lumped Elements 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

q = 1 . 6 0 2 * 1 e −19; % c h a r g e o f an e l e c t r o n
4 k = 1 . 3 8 0 6 6 e −23; % Boltzman c o n s t a n t , j o u l e / k e l v i n
T = 273+27; % K e l v i n ; room t e m p e r a t u r e
6 I 0 = 1e −14; % saturation current

8 for ind = 1: number of diodes


i s = diodes ( ind ). is ;
10 j s = diodes ( ind ). js ;
ks = diodes ( ind ) . ks ;
12 i e = diodes ( ind ) . ie ;
j e = diodes ( ind ) . je ;
14 ke = d i o d e s ( i n d ) . ke ;

16 i f strcmp ( d i o d e s ( ind ) . d i r e c t i o n ( 2 ) , ’ n ’ )
s g n = −1;
18 else
sgn = 1;
20 end
sw i t ch ( d i o d e s ( i n d ) . d i r e c t i o n ( 1 ) )
22 case ’ x ’
f i = c r e a t e l i n e a r i n d e x l i s t ( eps r x , is , js , ks ) ;
24 d i o d e s ( i n d ) . B = s g n * q * dx / ( 2 * k * T ) ;
d i o d e s ( ind ) . Cexd = . . .
26 −s g n * ( 2 * d t * I 0 / ( dy * dz ) ) . . .
. / ( 2 * e p s r x ( f i ) * eps 0 + dt * sigma e x ( fi ));
28 d i o d e s ( i n d ) . Exn = 0 ;
case ’ y ’
30 f i = c r e a t e l i n e a r i n d e x l i s t ( eps r y , is , js , ks ) ;
d i o d e s ( i n d ) . B = s g n * q * dy / ( 2 * k * T ) ;
32 d i o d e s ( i n d ) . Ceyd = . . .
−s g n * ( 2 * d t * I 0 / ( dz * dx ) ) . . .
34 . / ( 2 * e p s r y ( f i ) * eps 0 + dt * sigma e y ( fi ));
d i o d e s ( i n d ) . Eyn = 0 ;
36 case ’ z ’
f i = c r e a t e l i n e a r i n d e x l i s t ( eps r z , is , js , ks ) ;
38 d i o d e s ( i n d ) . B = s g n * q * dz / ( 2 * k * T ) ;
d i o d e s ( ind ) . Cezd = . . .
40 −s g n * ( 2 * d t * I 0 / ( dx * dy ) ) . . .
. / ( 2 * e p s r z ( f i ) * eps 0 + dt * sigma e z ( fi ));
42 d i o d e s ( i n d ) . Ezn = 0 ;
end
44 diodes ( ind ) . f i e l d i n d i c e s = f i ;
end
 

Here the E zn+1 (i, j, k) is the electric field component that is sought. The term B is a constant
that can be constructed before the time-marching loop starts and stored as parameter diodes(i).B.
However, the parameters A and C are expressions that have to be recalculated at every time step of
the time-marching iteration using the previous values of electric and magnetic field components.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

108 Active and Passive Lumped Elements

Comparing the first three terms on the right-hand side of the equation expressing C in (4.34)
with the updating equation for general media (1.28), one can see that their forms are the same and
that the coefficients Ce ze , Ce zhy , and Ce zhx are different only by a minus sign. These coefficients
were initialized as Ceze, Cezhy, and Cezhx in the subroutine initialize updating coefficients,
and there is no need to redefine them. We only need to keep in mind that the components of these
parameters with the indices (is , j s , ks )—Ceze(is,js,ks), Cezhy(is,js,ks), and Cezhz(is,js,ks)—
are the negatives of the coefficients that are used to recalculate C while updating E zn+1 (is , j s , ks )
as associated with a diode.
However, the fourth term in the expression of C includes a coefficient, Ce zd (i, j, k), which has
not been defined before. Therefore, a parameter, diodes(i).Cezd, is defined to store the value of
Ce zd (is , j s , ks ) in Listing 4.12.
An additional parameter that is defined and initialized with zero in Listing 4.12 is diodes(i).Ezn.
This parameter stores E zn (is , j s , ks ), which is the value of electric field component at the previ-
ous time step. This parameter is used to recalculate the coefficient C at every time step, and it
should be available when recalculating C. Therefore, at every time step the value of E zn (is , j s , ks )
is stored in the parameter diodes(i).Ezn to have it available at the next time step for the
calculation of C.

4.2.5 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 fields 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 fields into other parameters. For instance,
in a microwave circuit simulation, once the transient electric and magnetic fields 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 repre-
sented similar to lumped element components by prism-like volumes and their directions. The
voltages across and the currents flowing through these volumes will be calculated using the electric
field components across and the magnetic field components around these volumes, respectively,
during the time-marching loop.
For instance, consider the volume defined between the nodes (is , j s , ks ) and (ie, j e, ke). This
volume is placed between two parallel PEC plates. An average value of voltage can be calculated
between the PEC plates across the volume. Here we employ the integral form of (4.2), which can
be given as

V=− E · dl. (4.43)
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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


ke−1
V = −d z × E z (is , j s , k). (4.44)
k=ks

However, it can be seen in Fig. 4.11 that there are multiple paths for performing the discrete
summation and that the voltages calculated through these paths should be very close to each other.
Therefore, an average of these voltage values can be calculated by

−d z 
ie  
j e ke−1
V= × E z (i, j, k). (4.45)
(ie − is + 1) × ( j e − j s + 1) i=is j = j s k=ks
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

110 Active and Passive Lumped Elements

This expression can be written in the form


ie  
j e ke−1
V = Csvf × E z (i, j, k), (4.46)
i=is j = j s k=ks

where
−d z
Csvf = . (4.47)
(ie − is + 1) × ( j e − j s + 1)

The coefficient Csvf is a scaling factor multiplied by the sum of the field components E z (is : ie, j s :
j e, ks : ke − 1) to obtain the average voltage.
The aforementioned equations still hold for the cases where is is equal to ie or j s is equal to
j e. In those cases the voltage is sampled along a line segment or across a surface.
4.2.5.2 Calculation of Sampled Currents To calculate the current flowing through a surface we can
employ Ampere’s law in integral form, which is given by

Ifree = H · dl, (4.48)

where Ifree is the total free current. We need to describe the integral in (4.48) as a summation
of magnetic field components in the discrete space. For instance, consider the case shown in
Fig. 4.12. The figure shows magnetic field components enclosing a surface. The positions of the
fields are given with respect to the Yee cell, and indices of the fields are given with respect to
the nodes (is , j s , ks ) and (ie, j e, ke). These fields can be used to calculate the enclosed total free

Figure 4.12 A surface enclosed by magnetic field components and z-directed current flowing through it.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation of Lumped Elements 111

current by


ie 
je
Iz (ke − 1) = d x × Hx (i, j s − 1, ke − 1) + d y × Hy (ie, j, ke − 1)
i=is j= js


ie 
je
−dx × Hx (i, j e, ke − 1) − d y × Hy (is − 1, j, ke − 1). (4.49)
i=is j= js

Here we indexed Iz by (ke − 1) since the magnetic field components with the index (ke − 1) in the
z direction are used to calculate Iz .
As discussed before, we can determine the position of the current sampling by a volume
identified by the node indices (is , j s , ks ) and (ie, j e, ke). Then, a surface intersecting with the
cross-section of this volume and enclosing it can be used to determine the magnetic field com-
ponents that are used to calculate the current as illustrated in Fig. 4.12. It is possible that the
volume identified by the nodes (is , j s , ks ) and (ie, j e, ke) reduces to a surface or a line segment
or even to a point in the case where ie = is , j e = j s , and ke = ks . The expression in (4.49) still
can be used to calculate the current in those cases. However, one should notice that the surface
represented by the magnetic field components indexed by (ke − 1) is not coinciding with the
nodes; it instead crosses the centers of the cells. Therefore, if sampling of both the voltage and
the current is required at the same position, one should sample one of these quantities over mult-
iple positions and should take the average to obtain both the voltage and current effectively at the
same position.
Furthermore, another point that should be kept in mind is that the voltages and currents are
sampled at different time instants and a half time step apart from each other, since the voltages
are calculated from electric field components and currents are calculated from magnetic field
components, which are offset in time due to the leap-frog Yee algorithm. This time difference
can also be compensated for as pointed out in [11].

4.2.6 Definition and Initialization of Output Parameters


Definition of types of results sought from a simulation is part of the construction of an electromag-
netics problem in the FDTD method. This can be done in the definition 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 field, magnetic field, voltages, and currents can be defined
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 fields on some plane cuts while the
simulation is running. The definition 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 definition 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 figures 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 defined with the parameter plotting step.
For instance, a value of 10 implies that the figures will be refreshed once every 10 time steps.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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

3 sampled electric fields = [];


sampled magnetic fields = [ ] ;
5 sampled voltages = [ ] ;
sampled currents = [ ] ;
7

% figure refresh rate


9 p l o t t i n g s t e p = 10;

11 % mode o f o p e r a t i o n
run simulation = true ;
13 show material mesh = true ;
show problem space = true ;
15

% d e f i n e sampled e l e c t r i c f i e l d s
17 % component : v e c t o r component ’ x ’ , ’ y ’ , ’ z ’ , o r m a g n i t u d e ’m’
% d i s p l a y p l o t = true , in order to plot f i e l d during simulation
19 s a m p l e d e l e c t r i c f i e l d s ( 1 ) . x = 30 * dx ;
s a m p l e d e l e c t r i c f i e l d s ( 1 ) . y = 30 * dy ;
21 s a m p l e d e l e c t r i c f i e l d s ( 1 ) . z = 10 * dz ;
s a m p l e d e l e c t r i c f i e l d s ( 1 ) . component = ’ x ’ ;
23 sampled electric fields ( 1 ) . display plot = true ;

25 % d e f i n e sampled m a g n e t i c f i e l d s
% component : v e c t o r component ’ x ’ , ’ y ’ , ’ z ’ , o r m a g n i t u d e ’m’
27 % d i s p l a y p l o t = true , in order to plot f i e l d during simulation
s a m p l e d m a g n e t i c f i e l d s ( 1 ) . x = 30 * dx ;
29 s a m p l e d m a g n e t i c f i e l d s ( 1 ) . y = 30 * dy ;
s a m p l e d m a g n e t i c f i e l d s ( 1 ) . z = 10 * dz ;
31 s a m p l e d m a g n e t i c f i e l d s ( 1 ) . component = ’m ’ ;
sampled magnetic fields ( 1 ) . display plot = true ;
33

% define sampled voltages


35 sampled voltages ( 1 ) . m i n x = 5 . 0 e −3;
sampled voltages ( 1 ) . min y = 0 ;
37 sampled voltages ( 1 ) . min z = 0 ;
sampled voltages ( 1 ) . max x = 5 . 0 e −3;
39 sampled voltages ( 1 ) . max y = 2 . 0 e −3;
sampled voltages ( 1 ) . max z = 4 . 0 e −3;
41 sampled voltages ( 1 ) . d i r e c t i o n = ’ zp ’ ;
sampled voltages ( 1 ) . display plot = true ;
43

% define sampled currents


45 sampled currents ( 1 ) . min x = 5 . 0 e −3;
sampled currents ( 1 ) . min y = 0;
47 sampled currents ( 1 ) . min z = 4 . 0 e −3;
sampled currents ( 1 ) . max x = 5 . 0 e −3;
49 sampled currents ( 1 ) . max y = 2 . 0 e −3;
sampled currents ( 1 ) . max z = 4 . 0 e −3;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation of Lumped Elements 113

51 s a m p l e d c u r r e n t s ( 1 ) . d i r e c t i o n = ’ xp ’ ;
sampled currents ( 1 ) . display plot = true ;
53

% d i s p l a y problem s p a c e p a r a m e t e r s
55 problem space display . labels = true ;
problem space display . a x i s a t o r i g i n = false ;
57 problem space display . axis outside domain = true ;
problem space display . grid xn = false ;
59 problem space display . grid xp = true ;
problem space display . grid yn = false ;
61 problem space display . grid yp = true ;
problem space display . grid zn = true ;
63 problem space display . grid zp = false ;
problem space display . outer boundaries = true ;
65 problem space display . cpml boundaries = true ;

67 % define animation
% f i e l d t y p e s h a l l be ’ e ’ o r ’ h ’
69 % p l a n e c u t s h a l l be ’ xy ’ , yz , o r z x
% component s h a l l be ’ x ’ , ’ y ’ , ’ z ’ , o r ’m;
71 animation ( 1 ) . f i e l d t y p e = ’ e ’ ;
a n i m a t i o n ( 1 ) . component = ’m ’ ;
73 animation ( 1 ) . p l a n e c u t ( 1 ) . t y pe = ’ xy ’ ;
animation ( 1 ) . plane cut ( 1 ) . p o s i t i o n = 0;
75 animation ( 1 ) . p l a n e c u t ( 2 ) . t y pe = ’ yz ’ ;
animation ( 1 ) . plane cut ( 2 ) . p o s i t i o n = 0;
77 animation ( 1 ) . p l a n e c u t ( 3 ) . t y pe = ’ zx ’ ;
animation ( 1 ) . plane cut ( 3 ) . p o s i t i o n = 0;
79 animation ( 1 ) . enable = true ;
animation ( 1 ) . d i s p l a y g r i d = f a l s e ;
81 animation ( 1 ) . d i s p l a y o b j e c t s = true ;

83 animation (2). field type = ’h ’ ;


animation (2). component = ’ x ’ ;
85 animation (2). p l a n e c u t ( 1 ) . t y pe = ’ xy ’ ;
animation (2). p l a n e c u t ( 1 ) . p o s i t i o n = −5;
87 animation (2). p l a n e c u t ( 2 ) . t y pe = ’ xy ’ ;
animation (2). plane cut ( 2 ) . position = 5;
89 animation (2). enable = true ;
animation (2). display grid = true ;
91 animation (2). 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 defined. If this parameter is true, then the program proceeds with run-
ning the simulation; otherwise, it stops after calling the subroutines display problem space and
display material mesh as shown in Listing 3.1. The display problem space is a subroutine that
displays the three-dimensional view of the problem space, and it is controlled by a logical
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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 sub-
routine that launches a utility program with a graphical user interface, display material mesh gui,
and it is controlled by a parameter named show material mesh. For instance, the material grid
in Fig. 3.13 is obtained using display material mesh gui.
During the FDTD time-marching loop the electric and magnetic fields are calculated all over
the problem space at their respective positions on the Yee grid. Since all of the field components
are available, any of them can be captured, plotted, or stored. For instance, some field components
on some plane cuts can be captured and plotted on figures so as to demonstrate the real-time pro-
gression of fields on these plane cuts. Or some fields can be captured and stored for postprocessing.
Here we limit our implementation to field components sampled at nodes of the FDTD grid. To
define a node, we need its position in the Cartesian coordinates. Therefore, the parameters x, y,
and z are defined in the structures sampled electric fields(i) and sampled magnetic fields(i).
Since the fields are vectors, their x, y, and z components or magnitudes can be sampled. Hence,
the parameter component, which can take one of the values ‘x’, ‘y’, ‘z’, or ‘m’, is defined with
sampled electric fields(i) and sampled magnetic fields(i). If the component takes the value
‘m’ then the magnitude of the field is calculated using
 
Em = E x2 + E y2 + E z2 , Hm = Hx2 + Hy2 + Hz2 .

One additional parameter is display plot, which takes one of the values true or false and
determines whether this field component will be plotted while the simulation is running or not.
Meanwhile, the volumes representing the sampled voltages and currents are identified by
the parameters min x, min y, min z, max x, max y, and max z. The directions of the sampled
voltages and currents are defined by the parameter direction, which can take one of the values
‘xp’, ‘yp’, ‘zp’, ‘xn’, ‘yn’, or ‘zn’.
As discussed already, since all of the field components are available at every time step of the
simulation, they can be captured on desired plane cuts and plotted; thus, a propagation of fields
on these plane cuts can be simulated. The definition of animation as an output is done using a
parameter animation. The parameter animation is an array so each element in the array generates
a figure that displays the fields. An element animation(i) has the following subfields that are used
to define the properties of the animation. The subfield field type can take a value either ‘e’ or ‘h’,
determining whether the electric field or magnetic field will be animated, respectively. Then the
subfield component is used to define which component of the field to display, and it takes one of
the values ‘x’, ‘y’, ‘z’, or ‘m’. Then several plane cuts can be defined to be displayed on a figure using
the subfield plane cut(j). The parameter plane cut(j).type can take one of the values ‘xy’, ‘yz’,
or ‘zx’, describing which principal plane the plane cut is parallel to. Then the parameter plane -
cut(j).position determines the position of the plane cut. For instance, if type is ‘yz’, and position
is 5, then the plane cut is the plane at x = 5. Finally, three other subfields of animation(i) are the
logical parameters enable, display grid, and display objects. The animation can be disabled by
simply setting enable ‘false’, the FDTD grid can be displayed during the simulation by setting
display grid ‘true’, and the objects in the problem space can be displayed by a wire grid by setting
display objects ‘true’.
4.2.6.1 Initialization of Output Parameters The initialization of output parameters is imple-
mented in the subroutine initialize output parameters, as shown in Listing 4.14. Here the
parameter sampled electric fields represents the sampled electric field components, and
sampled magnetic fields represents the sampled magnetic field components. Similarly, the
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation of Lumped Elements 115

parameters sampled voltages and sampled currents represent sampled voltages and currents,
respectively. As indicated before, the electric and magnetic field components are sampled at spec-
ified positions, which coincide with respective nodes in the Yee grid. The indices of the sampling
nodes are determined in Listing 4.14 and are stored in the parameters is, js, and ks. Furthermore,
a one-dimensional array with size number of time steps is constructed as sampled value and
initialized with zeros. This parameter is used to store the new computed values of the sampled
Listing 4.14 initialize output parameters.m
1 disp ( ’ i n i t i a l i z i n g the output parameters ’ ) ;

3 number of sampled electric fields = size ( sampled electric fields , 2 ) ;


number of sampled magnetic fields = size ( sampled magnetic fields , 2 ) ;
5 number of sampled voltages = size ( sampled voltages , 2 ) ;
number of sampled currents = size ( sampled currents , 2 ) ;
7

% i n i t i a l i z e sampled e l e c t r i c f i e l d t e r m s
9 f o r i n d =1: n u m b e r o f s a m p l e d e l e c t r i c f i e l d s
i s = round ( ( s a m p l e d e l e c t r i c f i e l d s ( i n d ) . x ...
11 − f d t d d o m a i n . m i n x ) / dx ) + 1 ;
j s = round ( ( s a m p l e d e l e c t r i c f i e l d s ( i n d ) . y ...
13 − f d t d d o m a i n . m i n y ) / dy ) + 1 ;
k s = round ( ( s a m p l e d e l e c t r i c f i e l d s ( i n d ) . z ...
15 − f d t d d o m a i n . m i n z ) / dz ) + 1 ;
s a m p l e d e l e c t r i c f i e l d s ( ind ) . i s = i s ;
17 s a m p l e d e l e c t r i c f i e l d s ( ind ) . j s = j s ;
s a m p l e d e l e c t r i c f i e l d s ( ind ) . ks = ks ;
19 s a m p l e d e l e c t r i c f i e l d s ( ind ) . sampled value = ...
zeros (1 , number of time steps ) ;
21 s a m p l e d e l e c t r i c f i e l d s ( ind ) . time = . . .
( [ 1 : number of time steps ] ) * dt ;
23 end

25 % i n i t i a l i z e sampled m a g n e t i c f i e l d t e r m s
f o r i n d =1: n u m b e r o f s a m p l e d m a g n e t i c f i e l d s
27 i s = round ( ( s a m p l e d m a g n e t i c f i e l d s ( i n d ) . x ...
− f d t d d o m a i n . m i n x ) / dx ) + 1 ;
29 j s = round ( ( s a m p l e d m a g n e t i c f i e l d s ( i n d ) . y ...
− f d t d d o m a i n . m i n y ) / dy ) + 1 ;
31 k s = round ( ( s a m p l e d m a g n e t i c f i e l d s ( i n d ) . z ...
− f d t d d o m a i n . m i n z ) / dz ) + 1 ;
33 s a m p l e d m a g n e t i c f i e l d s ( ind ) . i s = i s ;
s a m p l e d m a g n e t i c f i e l d s ( ind ) . j s = j s ;
35 s a m p l e d m a g n e t i c f i e l d s ( ind ) . ks = ks ;
s a m p l e d m a g n e t i c f i e l d s ( ind ) . sampled value = ...
37 zeros (1 , number of time steps ) ;
s a m p l e d m a g n e t i c f i e l d s ( ind ) . time = . . .
39 ( [ 1 : number of time steps ] −0.5)* dt ;
end
41

% i n i t i a l i z e sampled v o l t a g e t e r m s
43 f o r i n d =1: n u m b e r o f s a m p l e d v o l t a g e s
i s = round ( ( s a m p l e d v o l t a g e s ( i n d ) . m i n x − f d t d d o m a i n . m i n x ) / dx ) + 1 ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

116 Active and Passive Lumped Elements

45 j s = round ( ( s a m p l e d v o l t a g e s ( ind ) . min y − fdtd domain . min y ) / dy ) + 1 ;


k s = round ( ( s a m p l e d v o l t a g e s ( ind ) . min z − fdtd domain . min z ) / dz ) + 1 ;
47 i e = round ( ( s a m p l e d 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 x ) / dx ) + 1 ;
j e = round ( ( s a m p l e d 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 y ) / dy ) + 1 ;
49 ke = round ( ( s a m p l e d 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 z ) / dz ) + 1 ;
sampled voltages ( ind ). is = is ;
51 sampled voltages ( ind ). js = js ;
sampled voltages ( ind ) . ks = ks ;
53 sampled voltages ( ind ) . ie = ie ;
sampled voltages ( ind ) . je = je ;
55 sampled voltages ( ind ) . ke = ke ;
sampled voltages ( ind ) . sampled value = . . .
57 zeros (1 , number of time steps ) ;

59 sw i t ch ( s a m p l e d v o l t a g e s ( i n d ) . d i r e c t i o n ( 1 ) )
case ’ x ’
61 f i = c r e a t e l i n e a r i n d e x l i s t ( Ex , i s : i e −1 , j s : j e , k s : ke ) ;
s a m p l e d v o l t a g e s ( i n d ) . C s v f = −dx / ( ( j e − j s + 1 ) * ( ke−k s + 1 ) ) ;
63 case ’ y ’
f i = c r e a t e l i n e a r i n d e x l i s t ( Ey , i s : i e , j s : j e −1 , k s : ke ) ;
65 s a m p l e d v o l t a g e s ( i n d ) . C s v f = −dy / ( ( ke−k s + 1 ) * ( i e − i s + 1 ) ) ;
case ’ z ’
67 f i = c r e a t e l i n e a r i n d e x l i s t ( Ez , i s : i e , j s : j e , k s : ke − 1 ) ;
s a m p l e d v o l t a g e s ( i n d ) . C s v f = −dz / ( ( i e − i s + 1 ) * ( j e − j s + 1 ) ) ;
69 end
i f strcmp ( s a m p l e d v o l t a g e s ( ind ) . d i r e c t i o n ( 2 ) , ’ n ’ )
71 sampled voltages ( ind ) . C s v f = . . .
−1 * s a m p l e d v o l t a g e s ( i n d ) . C s v f ;
73 end
sampled voltages ( ind ) . f i e l d i n d i c e s = f i ;
75 s a m p l e d v o l t a g e s ( ind ) . time = ( [ 1 : n u m b e r o f t i m e s t e p s ] ) * dt ;
end
77

% i n i t i a l i z e sampled c u r r e n t t e r m s
79 f o r i n d =1: n u m b e r o f s a m p l e d c u r r e n t s
i s = round ( ( s a m p l e d c u r r e n t s ( i n d ) . m i n x − f d t d d o m a i n . m i n x ) / dx ) + 1 ;
81 j s = round ( ( s a m p l e d c u r r e n t s ( i n d ) . m i n y − f d t d d o m a i n . m i n y ) / dy ) + 1 ;
k s = round ( ( s a m p l e d c u r r e n t s ( i n d ) . m i n z − f d t d d o m a i n . m i n z ) / dz ) + 1 ;
83 i e = round ( ( s a m p l e d c u r r e n t s ( i n d ) . max x − f d t d d o m a i n . m i n x ) / dx ) + 1 ;
j e = round ( ( s a m p l e d c u r r e n t s ( i n d ) . max y − f d t d d o m a i n . m i n y ) / dy ) + 1 ;
85 ke = round ( ( s a m p l e d c u r r e n t s ( i n d ) . max z − f d t d d o m a i n . m i n z ) / dz ) + 1 ;
sampled currents ( ind ) . i s = i s ;
87 sampled currents ( ind ) . j s = j s ;
sampled currents ( ind ) . ks = ks ;
89 sampled currents ( ind ) . i e = i e ;
sampled currents ( ind ) . j e = j e ;
91 s a m p l e d c u r r e n t s ( i n d ) . ke = ke ;
sampled currents ( ind ) . sampled value = . . .
93 zeros (1 , number of time steps ) ;
s a m p l e d c u r r e n t s ( ind ) . time = ( [ 1 : n u m b e r o f t i m e s t e p s ] −0.5)* dt ;
95 end
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation of Lumped Elements 117

component while the FDTD iterations proceed. Another one-dimensional array with size num-
ber of time steps is time, which is used to store the time instants of the respective captured
values. One should notice that there is a half time step duration (d t/2) shift between the electric
field and magnetic field time arrays.
The indices of the nodes indicating the positions of the sampled voltages are calculated and
assigned to the parameters is, js, ks, ie, je, and ke. The indices of the fields that are used to
calculate sampled voltages are determined and assigned to the parameter field indices. Then
coefficient Csvf , which is a scaling factor as described in Section 4.2.5, is calculated using (4.47)
and is assigned to the parameter Csvf.

4.2.6.2 Initialization of Figures for Runtime Display So far we have defined four types of outputs for
an FDTD simulation: namely, sampled electric and magnetic fields, voltages, and currents. While
the FDTD simulation is running, the progress of these sampled parameters can be displayed
on MATLAB figures. In the subroutine define output parameters, while defining the sampled
components, a parameter display plot is associated to each defined component indicating whether
the real-time progress of this component displayed. If there are any components defined for
runtime display, figures displaying these components can be opened and their properties can
be set before the FDTD time-marching loop starts. This figure initialization process can be
performed in the subroutine initialize display parameters, which is given in Listing 4.15. Here
figures are launched for every sampled component that is displayed, and their axis labels are set.
Furthermore, the number of the figure associated with each sampled component is stored in the
parameter figure number.
Listing 4.15 initialize display parameters.m

1 disp ( ’ i n i t i a l i z i n g d i s p l a y parameters ’ ) ;

3 % open f i g u r e s f o r sampled e l e c t r i c f i e l d s
f o r i n d =1: n u m b e r o f s a m p l e d e l e c t r i c f i e l d s
5 i f s a m p l e d e l e c t r i c f i e l d s ( i n d ) . d i s p l a y p l o t == t r u e
s a m p l e d e l e c t r i c f i e l d s ( ind ) . figure number = f i g u r e ;
7 s a m p l e d e l e c t r i c f i e l d s ( i n d ) . p l o t h a n d l e = p l o t ( 0 , 0 , ’ b− ’ ) ;
x l a b e l ( ’ time ( ns ) ’ , ’ f o n t s i z e ’ , 1 2 ) ;
9 y l a b e l ( ’ ( v o l t / meter ) ’ , ’ f o n t s i z e ’ , 1 2 ) ;
t i t l e ( [ ’ sampled e l e c t r i c f i e l d [ ’ . . .
11 num2str ( i n d ) ’ ] ’ ] , ’ f o n t s i z e ’ , 1 2 ) ;
g r i d on ;
13 hold on ;
end
15 end

17 % open f i g u r e s f o r sampled m a g n e t i c f i e l d s
f o r i n d =1: n u m b e r o f s a m p l e d m a g n e t i c f i e l d s
19 i f s a m p l e d m a g n e t i c f i e l d s ( i n d ) . d i s p l a y p l o t == t r u e
s a m p l e d m a g n e t i c f i e l d s ( ind ) . figure number = f i g u r e ;
21 s a m p l e d m a g n e t i c f i e l d s ( i n d ) . p l o t h a n d l e = p l o t ( 0 , 0 , ’ b− ’ ) ;
x l a b e l ( ’ time ( ns ) ’ , ’ f o n t s i z e ’ , 1 2 ) ;
23 y l a b e l ( ’ ( ampere / meter ) ’ , ’ f o n t s i z e ’ , 1 2 ) ;
t i t l e ( [ ’ sampled m a g n e t i c f i e l d [ ’ num2str ( i n d ) ’ ] ’ ] , . . .
25 ’ fontsize ’ ,12);
g r i d on ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

118 Active and Passive Lumped Elements

27 hold on ;
end
29 end

31 % i n i t i a l i z e f i g u r e s f o r sampled v o l t a g e s
f o r i n d =1: n u m b e r o f s a m p l e d v o l t a g e s
33 i f s a m p l e d v o l t a g e s ( i n d ) . d i s p l a y p l o t == t r u e
sampled voltages ( ind ) . figure number = f i g u r e ;
35 s a m p l e d v o l t a g e s ( i n d ) . p l o t h a n d l e = p l o t ( 0 , 0 , ’ b− ’ ) ;
x l a b e l ( ’ time ( ns ) ’ , ’ f o n t s i z e ’ , 1 2 ) ;
37 ylabel ( ’ ( volt ) ’ , ’ fontsize ’ ,12);
t i t l e ( [ ’ sampled v o l t a g e [ ’ num2str ( i n d ) ’ ] ’ ] , . . .
39 ’ fontsize ’ ,12);
g r i d on ;
41 hold on ;
end
43 end

45 % i n i t i a l i z e f i g u r e s f o r sampled c u r r e n t s
f o r i n d =1: n u m b e r o f s a m p l e d c u r r e n t s
47 i f s a m p l e d c u r r e n t s ( i n d ) . d i s p l a y p l o t == t r u e
sampled currents ( ind ) . figure number = f i g u r e ;
49 s a m p l e d c u r r e n t s ( i n d ) . p l o t h a n d l e = p l o t ( 0 , 0 , ’ b− ’ ) ;
x l a b e l ( ’ time ( ns ) ’ , ’ f o n t s i z e ’ , 1 2 ) ;
51 y l a b e l ( ’ ( ampere ) ’ , ’ f o n t s i z e ’ , 1 2 ) ;
t i t l e ( [ ’ sampled c u r r e n t [ ’ num2str ( i n d ) ’ ] ’ ] , . . .
53 ’ fontsize ’ ,12);
g r i d on ;
55 hold on ;
end
57 end

59 % i n i t i a l i z e f i e l d animation parameters
initialize animation parameters ;
 

Finally a subroutine initialize animation parameters is called, which performs the initializa-
tion of parameters for field animation on the plane cuts defined in define output parameters.
Furthermore, figures and display parameters for other types of sampled outputs can be initial-
ized in this routine.

4.2.7 Running an FDTD Simulation: The Time-Marching Loop


So far we have discussed all definition 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 field 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.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation of Lumped Elements 119

Therefore, so far we have constructed the necessary components for starting an FDTD sim-
ulation for a problem space assuming PEC boundaries and including objects of isotropic and
linear materials and lumped element components. Now we are ready to implement the subroutine
run fdtd time marching loop, which includes the steps of the leap-frog time-marching algorithm
of the FDTD method. The implementation of run fdtd time marching loop is given in Listing
4.16. We discuss the functions and provide the implementation of subroutines of these steps in
this section.
Listing 4.16 starts with the definition and initialization of a parameter current time, which
is used to include the current value of time instant during the FDTD loop. Then the MATLAB
function cputime is used to capture the time on the computer system. This is first called to capture
the start time of the FDTD loop and is stored in start time. The function cputime is called one
more time to capture the time on the system after the FDTD loop is completed. The captured
value is copied to end time. Hence, the difference between the start and end times is used to
calculate the total simulation time spent for the time-marching iterations.

4.2.7.1 Updating Magnetic Fields The time-marching iterations are performed number of time -
steps times. At every iteration first the magnetic field components are updated in the subroutine
update magnetic fields, as given in Listing 4.17. Here the new values of the magnetic field com-
ponents are calculated all over the problem space based on the general updating equations (1.29)–
(1.31), excluding the impressed magnetic current terms since there are no impressed magnetic
currents defined.

Listing 4.16 run fdtd time marching loop.m


disp ( [ ’ S t a r t i n g the time marching loop ’ ] ) ;
2 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 ) ] ) ;
4

s t a r t t i m e = cputime ;
6 current time = 0;

8 for time step = 1: number of time steps


update magnetic fields ;
10 capture sampled magnetic fields ;
capture sampled currents ;
12 update electric fields ;
update voltage sources ;
14 update current sources ;
update inductors ;
16 update diodes ;
capture sampled electric fields ;
18 capture sampled voltages ;
display sampled parameters ;
20 end

22 e n d t i m e = cputime ;
t o t a l t i m e i n m i n u t e s = ( end time − s t a r t t i m e ) / 6 0 ;
24 disp ( [ ’ T o t a l s i m u l a t i o n time i s ’ . . .
num2str ( t o t a l t i m e i n m i n u t e s ) ’ m i n u t e s . ’ ] ) ;
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

120 Active and Passive Lumped Elements

Listing 4.17 update magnetic fields.m


1 % update magnetic f i e l d s

3 current time = current time + dt / 2 ;

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

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


9 + 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 fields, which is performed in the subroutine update electric fields and is shown in
Listing 4.18. The electric field components are updated using the general updating equations
given in (1.26)–(1.28), except for the impressed electric current terms. While discussing the
lumped element components, it has been shown that impressed current terms are needed for
modeling inductors. Since only a small number of electric field components need to be updated
for modeling the inductors; these components are recalculated by addition of impressed current
related terms in the subroutine update inductors.
One should notice that in Listing 4.18, the electric field components that are tangential to the
boundaries are excluded in the updating. The reason is the specific arrangement of field positions

Listing 4.18 update electric fields.m


% 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
2 % on t h e b o u n d a r i e s

4 current time = current time + dt / 2 ;

6 E x ( 1 : nx , 2 : ny , 2 : nz ) = C e x e ( 1 : nx , 2 : ny , 2 : nz ) . * E x ( 1 : nx , 2 : ny , 2 : nz ) . . .
+ C e x h z ( 1 : nx , 2 : ny , 2 : nz ) . * . . .
8 ( Hz ( 1 : nx , 2 : ny , 2 : nz )−Hz ( 1 : nx , 1 : ny −1 ,2: nz ) ) . . .
+ C e x h y ( 1 : nx , 2 : ny , 2 : nz ) . * . . .
10 ( Hy ( 1 : nx , 2 : ny , 2 : nz )−Hy ( 1 : nx , 2 : ny , 1 : nz − 1 ) ) ;

12 E y ( 2 : nx , 1 : ny , 2 : nz )= C e y e ( 2 : nx , 1 : ny , 2 : nz ) . * E y ( 2 : nx , 1 : ny , 2 : nz ) . . .
+ C e y h x ( 2 : nx , 1 : ny , 2 : nz ) . * ...
14 ( Hx ( 2 : nx , 1 : ny , 2 : nz )−Hx ( 2 : nx , 1 : ny , 1 : nz − 1 ) ) . . .
+ C e y h z ( 2 : nx , 1 : ny , 2 : nz ) . * ...
16 ( Hz ( 2 : nx , 1 : ny , 2 : nz )−Hz ( 1 : nx −1 ,1: ny , 2 : nz ) ) ;

18 E z ( 2 : nx , 2 : ny , 1 : nz )= C e z e ( 2 : nx , 2 : ny , 1 : nz ) . * E z ( 2 : nx , 2 : ny , 1 : nz ) . . .
+ C e z h y ( 2 : nx , 2 : ny , 1 : nz ) . * ...
20 ( Hy ( 2 : nx , 2 : ny , 1 : nz )−Hy ( 1 : nx −1 ,2: ny , 1 : nz ) ) . . .
+ C e z h x ( 2 : nx , 2 : ny , 1 : nz ) . * . . .
22 ( Hx ( 2 : nx , 2 : ny , 1 : nz )−Hx ( 2 : nx , 1 : ny −1 ,1: nz ) ) ;
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation of Lumped Elements 121

on the Yee cell. While updating an electric field component, the magnetic field components
encircling it are required. However, for an electric field component resting tangential to the
boundary of the problem space, at least one of the required magnetic field components would be
out of the problem space and thus would be undefined. Therefore, the electric field components
tangential to the boundaries cannot be updated using the general updating equations. However,
if these components are not updated, they maintain their initial values, which are zeros, thus
naturally simulating the PEC boundaries. Therefore, there is no need for any additional effort to
enforce PEC boundaries. However, some other types of boundaries may require special updates
for these electric field components.
The updating coefficient values that model the lumped element components were assigned to
the respective positions in the updating coefficient arrays; therefore, the updating of the electric
field in update electric fields completes the modeling of capacitors and resistors. The modeling of
other lumped elements requires addition of some other terms to the electric fields at their respective
positions. The following sections elaborate on updates for these other lumped elements.

4.2.7.3 Updating Electric Fields Associated with Voltage Sources The updating equations modeling
the voltage sources are derived and represented by (4.10). This equation includes an additional
voltage source specific term,

n+ 12
Ce zs (i, j, k) × Vs (i, j, k), (4.50)

which was omitted in the implementation of update electric fields in Listing 4.18. This term
can be added to the electric field components that are associated with the voltage sources. The
indices of the electric field components requiring an additional update are stored in the parameter
voltage sources(i).field indices. The coefficient terms are constructed as Cexs, Ceys, and Cezs,
based on the direction of the voltage source. The value of the voltage at the current time step can
be retrieved from the waveform array voltage sources(i).waveform. The additional update of
electric field components due to voltage sources is performed in update voltage sources as shown
in Listing 4.19.

Listing 4.19 update voltage sources.m


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

4 for ind = 1: n u m b e r o f v o l t a g e s o u r c e s
f i = v o l t a g e s o u r c e s ( ind ) . f i e l d i n d i c e s ;
6 sw i t ch ( v o l t a g e s o u r c e s ( i n d ) . d i r e c t i o n ( 1 ) )
case ’ x ’
8 Ex ( f i ) = Ex ( f i ) + v o l t a g e s o u r c e s ( ind ) . Cexs . . .
* v o l t a g e s o u r c e s ( ind ) . v o l t a g e p e r e field ( time step ) ;
10 case ’ y ’
Ey ( f i ) = Ey ( f i ) + v o l t a g e s o u r c e s ( ind ) . Ceys . . .
12 * v o l t a g e s o u r c e s ( ind ) . v o l t a g e p e r e field ( time step ) ;
case ’ z ’
14 Ez ( f i ) = Ez ( f i ) + v o l t a g e s o u r c e s ( ind ) . Cezs . . .
* v o l t a g e s o u r c e s ( ind ) . v o l t a g e p e r e field ( time step ) ;
16 end
end
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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
3

for ind = 1: number of current sources


5 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 ) )
7 case ’ x ’
Ex ( f i ) = Ex ( f i ) + c u r r e n t s o u r c e s ( ind ) . Cexs . . .
9 * 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 field ( time step ) ;
case ’ y ’
11 Ey ( f i ) = Ey ( f i ) + c u r r e n t s o u r c e s ( ind ) . Ceys . . .
* 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 field ( time step ) ;
13 case ’ z ’
Ez ( f i ) = Ez ( f i ) + c u r r e n t s o u r c e s ( ind ) . Cezs . . .
15 * 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 field ( time step ) ;
end
17 end
 

4.2.7.4 Updating Electric Fields Associated with Current Sources Updating of the field components
associated with the current sources is similar to that for the voltage sources. The updating equations
modeling the current sources are derived and given by (4.15). This equation includes an additional
current source specific term,

n+ 12
Ce zs (i, j, k) × Is (i, j, k). (4.51)

The additional update of electric field components due to current sources is performed in
update current sources as shown in Listing 4.20.

4.2.7.5 Updating Electric Fields Associated with Inductors The updating equations modeling the
inductors are derived as in equation (4.24), which includes an additional impressed electric current
source term

n+ 12
Ce zj (i, j, k) × Ji z (i, j, k). (4.52)

The coefficients in the additional terms have been constructed in Listing 4.9 as Cexj, Ceyj, and
n+ 1
Cezj. However, the impressed current term Ji z 2 1should be recalculated at every time step using
n−
the previous value of the impressed current, Ji z 2 , and the associated electric field component,
E z , based on equation (4.23), before adding 1the terms in equation (4.52) to E zn+1 . However,
n
n+
since update electric
1
fields overwrites E zn , Ji z 2 must be calculated before update electric fields.
n+
Therefore, Ji z 2 can be recalculated after updating the electric fields due to inductors for use in
the following time step. The algorithm for updating electric field components and calculating
the impressed currents can be followed in Listing 4.21, which shows the implementation of
update inductors.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation of Lumped Elements 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
3

for ind = 1: number of inductors


5 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 ) )
7 case ’ x ’
Ex ( f i ) = Ex ( f i ) + i n d u c t o r s ( ind ) . C e x j . . .
9 . * 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 . . .
11 + i n d u c t o r s ( ind ) . C j e x . * Ex ( f i ) ;
case ’ y ’
13 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 ;
15 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 ) ;
17 case ’ z ’
Ez ( f i ) = Ez ( f i ) + i n d u c t o r s ( ind ) . C e z j . . .
19 . * 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 . . .
21 + i n d u c t o r s ( ind ) . C j e z . * Ez ( f i ) ;
end
23 end
 

4.2.7.6 Updating Electric Fields Associated with Diodes Update of electric field components for
modeling diodes is more complicated compared to other types of lumped elements. As discussed
in Section 4.1.8, the new value of the electric field component associated with a diode is obtained
by the solution of the equation

Ae Bx + x + C = 0, (4.53)

where
n
x = E zn+1 (i, j, k), A = −Ce zd (i, j, k)e B×Ez (i, j,k) , B = (q z/2kT),
 n+ 1 n+ 1

C = Ce ze (i, j, k) × E zn (i, j, k) + Ce zhy (i, j, k) × Hy 2 (i, j, k) − Hy 2 (i − 1, j, k)
 n+ 1 n+ 1

+ Ce zhx (i, j, k) × Hx 2 (i, j, k) − Hx 2 (i, j − 1, k) + Ce zd (i, j, k). (4.54)

The coefficients B, and Ce zd are constructed as parameters diodes(i).B and diodes(i).Cezd in


the subroutine initialize diode updating coefficients. However, the coefficients A and C must be
recalculated at every time step using the equations just shown. As discussed before, the coefficients
Ce ze , Ce zhy , and Ce zhx are negatives of the corresponding coefficients appearing in the general
updating equations, which were executed in update electric fields. Therefore, after execution
of update electric fields the electric field component associated with the diode, E zn+1 , would be
holding the negative value of the sum of first three terms on the right-hand side of equation (4.54).
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

124 Active and Passive Lumped Elements

Then the coefficient 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 field compo-
nent, E zn (i, j, k). Since this component is overwritten in update electric fields, we copy it to the
parameter diodes(ind).Ezn before executing update electric fields. Therefore, at every time step
after the value of the electric field component associated with a diode is obtained, it is copied to
diodes(ind).Ezn for use in the following time step. Similarly, the new value of A can be calculated
using E zn (i, j, k).
Once the parameters A and C are recalculated, the new value of electric field component E zn+1
can be calculated by solving (4.53). As discussed in Section 4.8, this equation can easily be solved
numerically by using the Newton-Raphson method. The updating procedure of electric field
components for modeling diodes is implemented in the subroutine update diodes, which is shown
in Listing 4.22. Comparing the given implementation with the previous discussion helps in under-
standing this complicated updating process. Finally, a function with name solve diode equation is

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
3

for ind = 1: number of diodes


5 f i = diodes ( ind ) . f i e l d i n d i c e s ;
B = diodes ( ind ) . B ;
7 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 ’
9 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 ;
11 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 ) ;
13 Ex ( f i ) = E ;
d i o d e s ( i n d ) . Exn = E ;
15 case ’ y ’
E = d i o d e s ( i n d ) . Eyn ;
17 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 ) ;
19 E = solve diode equation (A , B, C , E ) ;
Ey ( f i ) = E ;
21 d i o d e s ( i n d ) . Eyn = E ;
case ’ z ’
23 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 ;
25 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 ) ;
27 Ez ( f i ) = E ;
d i o d e s ( i n d ) . Ezn = E ;
29 end
end
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation of Lumped Elements 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


function [ x ] = solve diode equation ( A , B , C , x )
2 % 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
4 % u s i n g t h e Newton−Raphson method

6 t o l e r a n c e = 1e −25;
max iter = 50;
8 i t e r = 0;
f = A * exp ( B * x ) + x + C ;
10 w h i l e ( ( i t e r < m a x i t e r ) && ( abs ( f ) > t o l e r a n c e ) )
f p = A * B * exp ( B * x ) + 1 ;
12 x = x − f / fp ;
f = A * exp ( B * x ) + x + C ;
14 i t e r = i t e r + 1;
end
 

4.2.7.7 Capturing the Sampled Magnetic Field Components After the magnetic field components are
updated by update magnetic fields, they can be sampled for the current time step. As mentioned
before, although all of the field components in the problem space can be captured, for now we limit
our discussion with sampling the magnetic field values at predefined positions coinciding with the
nodes of the problem space. The indices of the nodes for which the magnetic field will be sampled
are stored in the parameters is, js, and ks. However, examining the field positioning scheme of
the Yee cell reveals that the magnetic field components are not defined at the node positions.
But it is possible to take the average of the four surrounding field components as the field value
of the node. This procedure is illustrated in Listing 4.24, which shows the implementation of
the subroutine capture sampled magnetic fields. For instance, to sample the y component of the
magnetic field at node (is , j s , ks ), an average of the components Hy (is , j s , ks ), Hy (is − 1, j s , ks ),
Hy (is , j s , ks − 1), and Hy (is − 1, j s , ks − 1) can be used as the sampled values as illustrated in
Fig. 4.13(a).
If the magnitude of the field vector is sought, the x, y, and z components of the field vector can
be sampled, and then their vector magnitude can be calculated as shown in Listing 4.24.

4.2.7.8 Capturing the Sampled Currents As discussed before, the currents flowing through a
given surface can be calculated using the magnetic fields components circling around the surface.
Therefore, after the magnetic field components are updated by update magnetic fields, the cur-
rents can be calculated for the current time step. The procedure for capturing the electric current
is implemented in the subroutine capture sampled currents as shown in Listing 4.25.

4.2.7.9 Capturing the Sampled Electric Field Components After the electric field components are
updated by update electric fields, they can be sampled for the current time step. Since there is not
an electric field component defined at the position of the sampling node (is , j s , ks ), an average
of the two field components around the node can be used as the sampled value. For instance,
to sample the y component of the electric field, an average of the components E y (is , j s , ks ) and
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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

3 f o r i n d =1: n u m b e r of sampled magnetic fields


is = sampled m a g n e t i c f i e l d s ( ind ) . i s ;
5 js = sampled m a g n e t i c f i e l d s ( ind ) . j s ;
ks = sampled m a g n e t i c f i e l d s ( ind ) . ks ;
7

sw i t ch ( s a m p l e d m a g n e t i c f i e l d s ( i n d ) . component )
9 case ’ x ’
s a m p l e d v a l u e = 0 . 2 5 * sum ( sum ( Hx ( i s , j s −1: j s , ks −1: k s ) ) ) ;
11 case ’ y ’
s a m p l e d v a l u e = 0 . 2 5 * sum ( sum ( Hy ( i s −1: i s , j s , ks −1: k s ) ) ) ;
13 case ’ z ’
s a m p l e d v a l u e = 0 . 2 5 * sum ( sum ( Hz ( i s −1: i s , j s −1: j s , k s ) ) ) ;
15 c a s e ’m ’
s v x = 0 . 2 5 * sum ( sum ( Hx ( i s , j s −1: j s , ks −1: k s ) ) ) ;
17 s v y = 0 . 2 5 * sum ( sum ( Hy ( i s −1: i s , j s , ks −1: k s ) ) ) ;
s v z = 0 . 2 5 * sum ( sum ( Hz ( i s −1: i s , j s −1: j s , k s ) ) ) ;
19 sampled value = sqrt ( svx ˆ2 + svy ˆ2 + svz ˆ 2 ) ;
end
21 s a m p l e d m a g n e t i c f i e l d s ( ind ) . sampled value ( time step ) = . . .
sampled value ;
23 end
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation of Lumped Elements 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
4 i s = sampled currents ( ind ) . i s ;
j s = sampled currents ( ind ) . j s ;
6 ks = sampled currents ( ind ) . ks ;
i e = sampled currents ( ind ) . i e ;
8 j e = sampled currents ( ind ) . j e ;
ke = s a m p l e d c u r r e n t s ( i n d ) . ke ;
10

sw i t ch ( s a m p l e d c u r r e n t s ( i n d ) . d i r e c t i o n ( 1 ) )
12 case ’ x ’
sampled value = . . .
14 + dy * sum ( sum ( sum ( Hy ( i e −1 , j s : j e , ks − 1 ) ) ) ) . . .
+ dz * sum ( sum ( sum ( Hz ( i e −1 , j e , k s : ke ) ) ) ) . . .
16 − dy * sum ( sum ( sum ( Hy ( i e −1 , j s : j e , ke ) ) ) ) . . .
− dz * sum ( sum ( sum ( Hz ( i e −1 , j s −1 , k s : ke ) ) ) ) ;
18 case ’ y ’
sampled value = . . .
20 + dz * sum ( sum ( sum ( Hz ( i s −1 , j e −1 , k s : ke ) ) ) ) . . .
+ dx * sum ( sum ( sum ( Hx ( i s : i e , j e −1 , ke ) ) ) ) . . .
22 − dz * sum ( sum ( sum ( Hz ( i e , j e −1 , k s : ke ) ) ) ) . . .
− dx * sum ( sum ( sum ( Hx ( i s : i e , j e −1 , ks − 1 ) ) ) ) ;
24 case ’ z ’
sampled value = . . .
26 + dx * sum ( sum ( sum ( Hx ( i s : i e , j s −1 , ke − 1 ) ) ) ) . . .
+ dy * sum ( sum ( sum ( Hy ( i e , j s : j e , ke − 1 ) ) ) ) . . .
28 − dx * sum ( sum ( sum ( Hx ( i s : i e , j e , ke − 1 ) ) ) ) . . .
− dy * sum ( sum ( sum ( Hy ( i s −1 , j s : j e , ke − 1 ) ) ) ) ;
30 end
i f strcmp ( s a m p l e d c u r r e n t s ( ind ) . d i r e c t i o n ( 2 ) , ’ n ’ )
32 s a m p l e d v a l u e = −1 * s a m p l e d v a l u e ;
end
34 sampled currents ( ind ) . sampled value ( time step ) = sampled value ;
end
 

Listing 4.26 capture sampled electric fields.m


% Capturing e l e c t r i c fields
2

f o r i n d =1: n u m b e r of sampled electric fields


4 is = sampled e l e c t r i c f i e l d s ( ind ) . i s ;
js = sampled e l e c t r i c f i e l d s ( ind ) . j s ;
6 ks = s a m p l e d e l e c t r i c f i e l d s ( ind ) . ks ;

8 sw i t ch ( s a m p l e d e l e c t r i c f i e l d s ( i n d ) . component )
case ’ x ’
10 s a m p l e d v a l u e = 0 . 5 * sum ( E x ( i s −1: i s , j s , k s ) ) ;
case ’ y ’
12 s a m p l e d v a l u e = 0 . 5 * sum ( E y ( i s , j s −1: j s , k s ) ) ;
case ’ z ’
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

128 Active and Passive Lumped Elements

14 s a m p l e d v a l u e = 0 . 5 * sum ( E z ( i s , j s , ks −1: k s ) ) ;
c a s e ’m ’
16 s v x = 0 . 5 * sum ( E x ( i s −1: i s , j s , k s ) ) ;
s v y = 0 . 5 * sum ( E y ( i s , j s −1: j s , k s ) ) ;
18 s v z = 0 . 5 * sum ( E z ( i s , j s , ks −1: k s ) ) ;
sampled value = sqrt ( svx ˆ2 + svy ˆ2 + svz ˆ 2 ) ;
20 end
s a m p l e d e l e c t r i c f i e l d s ( ind ) . sampled value ( time step ) = sampled value ;
22 end
 

4.2.7.10 Capturing the Sampled Voltages The indices of the field components that are required
for calculating the voltage across a volume indicated by the nodes (is , j s , ks ) and (ie, j e, ke) are
determined in the subroutine initialize output parameters and are stored in the paramater field -
indices. Furthermore, another parameter Csvf is defined as a coefficient that would transform
the sum of the electric field components to a voltage value as discussed in Section 4.2.5. Then
a procedure for calculating the sampled voltages is implemented in the subroutine capture -
sampled voltages shown in Listing 4.27.

4.2.7.11 Displaying the Sampled Parameters After all fields are updated and the sampled param-
eters are captured, the sampled parameters defined for runtime display can be plotted using the
subroutine display sampled parameters, which is shown in Listing 4.28.
One should notice that in Listing 4.28 the instructions are executed once every plotting step
time steps. Then for each sampled parameter requiring display, the respective figure is activated
using the respective figure number. Then the sampled parameter is plotted from the first time
step to current time step using MATLAB’s plot function.
Finally, at the end of display sampled parameters another subroutine display animation is
called to display the fields captured on the predefined plane cuts.

Listing 4.27 capture sampled voltages.m


1 % C a p t u r i n g sampled v o l t a g e s

3 f o r i n d =1: n u m b e r o f s a m p l e d v o l t a g e s
fi = sampled voltages ( ind ) . f i e l d i n d i c e s ;
5 C s v f = sampled voltages ( ind ) . C s v f ;
sw i t ch ( s a m p l e d v o l t a g e s ( i n d ) . d i r e c t i o n ( 1 ) )
7 case ’ x ’
s a m p l e d v a l u e = C s v f * sum ( E x ( f i ) ) ;
9 case ’ y ’
s a m p l e d v a l u e = C s v f * sum ( E y ( f i ) ) ;
11 case ’ z ’
s a m p l e d v a l u e = C s v f * sum ( E z ( f i ) ) ;
13 end
sampled voltages ( ind ) . sampled value ( time step ) = sampled value ;
15 end
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation of Lumped Elements 129

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
4 return ;
end
6

r e m a i n i n g t i m e = ( n u m b e r o f t i m e s t e p s −t i m e s t e p ) . . .
8 * ( cputime−s t a r t t i m e ) / ( 6 0 * t i m e s t e p ) ;
d i s p ( [ num2str ( t i m e s t e p ) ’ o f ’ . . .
10 num2str ( n u m b e r o f t i m e s t e p s ) ’ i s c o m p l e t e d , ’ . . .
num2str ( r e m a i n i n g t i m e ) ’ m i n u t e s r e m a i n i n g ’ ] ) ;
12

% d i s p l a y sampled e l e c t r i c f i e l d s
14 for ind = 1: n u m b e r o f s a m p l e d e l e c t r i c f i e l d s
i f s a m p l e d e l e c t r i c f i e l d s ( i n d ) . d i s p l a y p l o t == t r u e
16 sampled time = . . .
s a m p l e d e l e c t r i c f i e l d s ( i n d ) . t i m e ( 1 : t i m e s t e p ) * 1 e9 ;
18 sampled value = . . .
s a m p l e d e l e c t r i c f i e l d s ( ind ) . sampled value ( 1 : time step ) ;
20 f i g u r e ( s a m p l e d e l e c t r i c f i e l d s ( ind ) . figure number ) ;
delete ( s a m p l e d e l e c t r i c f i e l d s ( ind ) . plot handle ) ;
22 s a m p l e d e l e c t r i c f i e l d s ( ind ) . plot handle = . . .
p l o t ( s a m p l e d t i m e , s a m p l e d v a l u e ( 1 : t i m e s t e p ) , ’ b− ’ , . . .
24 ’ linewidth ’ ,1.5);
drawnow ;
26 end
end
28

% d i s p l a y sampled m a g n e t i c f i e l d s
30 for ind = 1: number of sampled magnetic fields
i f s a m p l e d m a g n e t i c f i e l d s ( i n d ) . d i s p l a y p l o t == t r u e
32 sampled time = . . .
s a m p l e d m a g n e t i c f i e l d s ( i n d ) . t i m e ( 1 : t i m e s t e p ) * 1 e9 ;
34 sampled value = . . .
s a m p l e d m a g n e t i c f i e l d s ( ind ) . sampled value ( 1 : time step ) ;
36 f i g u r e ( s a m p l e d m a g n e t i c f i e l d s ( ind ) . figure number ) ;
delete ( s a m p l e d m a g n e t i c f i e l d s ( ind ) . p l o t handle ) ;
38 s a m p l e d m a g n e t i c f i e l d s ( ind ) . p l o t handle = . . .
p l o t ( s a m p l e d t i m e , s a m p l e d v a l u e ( 1 : t i m e s t e p ) , ’ b− ’ , . . .
40 ’ linewidth ’ ,1.5);
drawnow ;
42 end
end
44

% d i s p l a y sampled v o l t a g e s
46 for ind = 1: number of sampled voltages
i f s a m p l e d v o l t a g e s ( i n d ) . d i s p l a y p l o t == t r u e
48 sampled time = . . .
s a m p l e d v o l t a g e s ( i n d ) . t i m e ( 1 : t i m e s t e p ) * 1 e9 ;
50 sampled value = . . .
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

130 Active and Passive Lumped Elements

sampled voltages ( ind ) . sampled value ( 1 : time step ) ;


52 f i g u r e ( sampled voltages ( ind ) . figure number ) ;
delete ( sampled voltages ( ind ) . plot handle ) ;
54 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− ’ , . . .
56 ’ linewidth ’ ,1.5);
drawnow ;
58 end
end
60

% d i s p l a y sampled c u r r e n t s
62 for ind = 1: number of sampled currents
i f s a m p l e d c u r r e n t s ( i n d ) . d i s p l a y p l o t == t r u e
64 sampled time = . . .
s a m p l e d c u r r e n t s ( i n d ) . t i m e ( 1 : t i m e s t e p ) * 1 e9 ;
66 sampled value = . . .
sampled currents ( ind ) . sampled value ( 1 : time step ) ;
68 f i g u r e ( sampled currents ( ind ) . figure number ) ;
delete ( sampled currents ( ind ) . plot handle ) ;
70 sampled currents ( ind ) . plot handle = . . .
p l o t ( s a m p l e d t i m e , s a m p l e d v a l u e ( 1 : t i m e s t e p ) , ’ b− ’ , . . .
72 ’ linewidth ’ ,1.5);
drawnow ;
74 end
end
76

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

4.2.8 Displaying FDTD Simulation Results


After the FDTD time-marching loop is completed, the output parameters can be displayed. Fur-
thermore, 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 defined four types of outputs: sampled electric and
magnetic fields, 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 defined 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 ’ ) ;

3 display transient parameters ;


 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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

% f i g u r e s f o r sampled e l e c t r i c f i e l d s
4 f o r i n d =1: n u m b e r o f s a m p l e d e l e c t r i c f i e l d s
i f s a m p l e d e l e c t r i c f i e l d s ( i n d ) . d i s p l a y p l o t == f a l s e
6 s a m p l e d e l e c t r i c f i e l d s ( ind ) . figure number = f i g u r e ;
x l a b e l ( ’ time ( ns ) ’ , ’ f o n t s i z e ’ , 1 2 ) ;
8 y l a b e l ( ’ ( v o l t / meter ) ’ , ’ f o n t s i z e ’ , 1 2 ) ;
t i t l e ( [ ’ sampled e l e c t r i c f i e l d [ ’ . . .
10 num2str ( i n d ) ’ ] ’ ] , ’ f o n t s i z e ’ , 1 2 ) ;
g r i d on ; hold on ;
12 else
f i g u r e ( s a m p l e d e l e c t r i c f i e l d s ( ind ) . figure number ) ;
14 delete ( s a m p l e d e l e c t r i c f i e l d s ( ind ) . plot handle ) ;
end
16 sampled time = . . .
s a m p l e d e l e c t r i c f i e l d s ( i n d ) . t i m e ( 1 : t i m e s t e p ) * 1 e9 ;
18 sampled value = . . .
s a m p l e d e l e c t r i c f i e l d s ( ind ) . sampled value ( 1 : time step ) ;
20 p l o t ( s a m p l e d t i m e , s a m p l e d v a l u e ( 1 : t i m e s t e p ) , ’ b− ’ , . . .
’ linewidth ’ ,1.5);
22 drawnow ;
end
 
The partial implementation of display transient parameters is given in Listing 4.30. Listing
4.30 shows the instructions for plotting only the sampled electric field components. The other
parameters are plotted similarly. One can notice that, if a parameter has not been displayed during
the time-marching loop, a new figure is launched and initialized for it. Then the sampled data are
plotted.

4.3 SIMULATION EXAMPLES


So far we have discussed all the basic components for performing an FDTD simulation, including
the definition of the problem, initialization of the problem workspace, running an FDTD time-
marching loop, and capturing and displaying the outputs. In this section we provide examples of
some FDTD simulations. We provide the definitions of the problems and show the simulation
results.

4.3.1 A Resistor Excited by a Sinusoidal Voltage Source


The first 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 definition 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 defined 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 defined. A voltage source with
50 internal resistance is defined, and the sinusoidal source waveform with frequency 500 MHz
is assigned to the voltage source. Then a resistor with 50 resistance is defined. Listing 4.34
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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

% A f a c t o r t h a t determines d u r a t i o n of a time s t e p
7 % wrt CFL l i m i t
courant factor = 0.9;
9

% A f a c t o r d e t e r m i n i n g t h e a c c u r a c y l i m i t o f FDTD r e s u l t s
11 number of cells per wavelength = 20;

13 % D i m e n s i o n s o f a u n i t c e l l i n x , y , and z d i r e c t i o n s ( m e t e r s )
dx = 1.0 e −3;
15 dy = 1.0 e −3;
dz = 1.0 e −3;
17

% ==<b o u n d a r y c o n d i t i o n s >========
19 % Here we d e f i n e t h e b o u n d a r y c o n d i t i o n s p a r a m e t e r s
% ’ pec ’ : p e r f e c t e l e c t r i c c o n d u c t o r
21 b o u n d a r y . t y p e x p = ’ pec ’ ;
boundary . a i r b u f f e r n u m b e r o f c e l l s x p = 3 ;
52

% PEC : p e r f e c t e l e c t r i c c o n d u c t o r
54 material types ( 2 ) . eps r = 1;
m a t e r i a l t y p e s ( 2 ) . mu r = 1;
56 m a t e r i a l t y p e s ( 2 ) . s i g m a e = 1 e10 ;
m a t e r i a l t y p e s ( 2 ) . sigma m = 0 ;
58 material types ( 2 ) . color = [1 0 0];
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation Examples 133

Listing 4.32 define geometry.m


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

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

Listing 4.33 define sources and lumped elements.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
11 w a v e f o r m s . s i n u s o i d a l ( 1 ) . f r e q u e n c y = 1 e9 ;
w a v e f o r m s . s i n u s o i d a l ( 2 ) . f r e q u e n c y = 5 e8 ;
13 waveforms . u n i t s t e p ( 1 ) . s t a r t t i m e s t e p = 50;

15 % voltage sources
% d i r e c t i o n : ’ xp ’ , ’ xn ’ , ’ yp ’ , ’ yn ’ , ’ zp ’ , o r ’ zn ’
17 % r e s i s t a n c e : ohms , m a g i t u d e : volts
v o l t a g e s o u r c e s ( 1 ) . min x = 0 ;
19 v o l t a g e s o u r c e s ( 1 ) . min y = 0 ;
v o l t a g e s o u r c e s ( 1 ) . min z = 0 ;
21 v o l t a g e s o u r c e s ( 1 ) . max x = 1 . 0 e −3;
v o l t a g e s o u r c e s ( 1 ) . max y = 2 . 0 e −3;
23 v o l t a g e s o u r c e s ( 1 ) . max z = 4 . 0 e −3;
v o l t a g e s o u r c e s ( 1 ) . d i r e c t i o n = ’ zp ’ ;
25 v o l t a g e s o u r c e s ( 1 ) . r e s i s t a n c e = 50;
v o l t a g e s o u r c e s ( 1 ) . magnitude = 1 ;
27 v o l t a g e s o u r c e s ( 1 ) . waveform type = ’ s i n u s o i d a l ’ ;
v o l t a g e s o u r c e s ( 1 ) . waveform index = 2;
29

% resistors
31 % direction : ’ x ’ , ’ y ’ , or ’ z ’
% resistance : ohms
33 resistors (1). m i n x = 7 . 0 e −3;
resistors (1). mi n y = 0 ;
35 resistors (1). min z = 0 ;
resistors (1). max x = 8 . 0 e −3;
37 resistors (1). max y = 2 . 0 e −3;
resistors (1). max z = 4 . 0 e −3;
39 resistors (1). direction = ’z ’ ;
resistors (1). r e s i s t a n c e = 50;
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

134 Active and Passive Lumped Elements

Listing 4.34 define output parameters.m



% figure refresh rate
9 p l o t t i n g s t e p = 100;

11 % mode o f o p e r a t i o n
run simulation = true ;
13 show material mesh = true ;
show problem space = true ;
15

% define sampled voltages


17 sampled voltages ( 1 ) . m i n x = 5 . 0 e −3;
sampled voltages ( 1 ) . min y = 0 ;
19 sampled voltages ( 1 ) . min z = 0 ;
sampled voltages ( 1 ) . max x = 5 . 0 e −3;
21 sampled voltages ( 1 ) . max y = 2 . 0 e −3;
sampled voltages ( 1 ) . max z = 4 . 0 e −3;
23 sampled voltages ( 1 ) . d i r e c t i o n = ’ zp ’ ;
sampled voltages ( 1 ) . display plot = true ;
25

% define sampled currents


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

shows the outputs defined for this simulation. A sampled voltage is defined between the parallel
PEC plates. Furthermore, a sampled current is defined for the upper PEC plate.
Figure 4.15 shows the result of this simulation. Figure 4.15(a) shows a comparison of the source
voltage and the sampled voltage. As can be seen, the sampled voltage is half the source voltage
as expected. Furthermore, the sampled current shown in 4.15(b) confirms that the sum of the
resistances is 100 .

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 definition of
the problem are given in Listings 4.35, 4.36, and 4.37.
In Listing 4.35, two parallel PEC plates are defined 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 defined. A voltage source with 50 internal resistance is
defined, and the sinusoidal source waveform with frequency 500 MHz is assigned to the voltage
source. Then a diode in the negative z direction is defined. Listing 4.37 shows the output defined
for this simulation; a sampled voltage is defined across the diode.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation Examples 135

0.5
(volt)

−0.5
voltage source
sampled voltage
−1
0 1 2 3 4 5 6
time (ns)
(a) Source waveform and sampled voltage

0.01

0.008

0.006

0.004

0.002
(ampere)

−0.002

−0.004

−0.006

−0.008
sampled current
−0.01
0 1 2 3 4 5 6
time (ns)
(b) Sampled current

Figure 4.15 Sinusoidal voltage source waveform with 500 MHz frequency and sampled voltage and current.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

136 Active and Passive Lumped Elements

(a) A voltage source terminated by a diode

10

5
(volt)

−5

voltage source
−10 sampled voltage
0 1 2 3 4 5 6
time (ns)
(b) Source waveform and sampled voltage

Figure 4.16 Sinusoidal voltage source waveform with 500 MHz frequency and sampled voltage.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation Examples 137

Listing 4.35 define geometry.m


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

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

Listing 4.36 define sources and lumped elements.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
11 w a v e f o r m s . s i n u s o i d a l ( 1 ) . f r e q u e n c y = 1 e9 ;
w a v e f o r m s . s i n u s o i d a l ( 2 ) . f r e q u e n c y = 5 e8 ;
13 waveforms . u n i t s t e p ( 1 ) . s t a r t t i m e s t e p = 50;

15 % voltage sources
% d i r e c t i o n : ’ xp ’ , ’ xn ’ , ’ yp ’ , ’ yn ’ , ’ zp ’ , o r ’ zn ’
17 % r e s i s t a n c e : ohms , m a g i t u d e : volts
v o l t a g e s o u r c e s ( 1 ) . min x = 0 ;
19 v o l t a g e s o u r c e s ( 1 ) . min y = 0 ;
v o l t a g e s o u r c e s ( 1 ) . min z = 0 ;
21 v o l t a g e s o u r c e s ( 1 ) . max x = 0 . 0 e −3;
v o l t a g e s o u r c e s ( 1 ) . max y = 2 . 0 e −3;
23 v o l t a g e s o u r c e s ( 1 ) . max z = 1 . 0 e −3;
v o l t a g e s o u r c e s ( 1 ) . d i r e c t i o n = ’ zp ’ ;
25 v o l t a g e s o u r c e s ( 1 ) . r e s i s t a n c e = 50;
v o l t a g e s o u r c e s ( 1 ) . magnitude = 10;
27 v o l t a g e s o u r c e s ( 1 ) . waveform type = ’ s i n u s o i d a l ’ ;
v o l t a g e s o u r c e s ( 1 ) . waveform index = 2;
29

% diodes
31 % d i r e c t i o n : ’ xp ’ , ’ xn ’ , ’ yp ’ , ’ yn ’ , ’ zp ’ , o r ’ zn ’
d i o d e s ( 1 ) . m i n x = 2 . 0 e −3;
33 d i o d e s ( 1 ) . m i n y = 1 . 0 e −3;
d i o d e s ( 1 ) . m i n z = 0 . 0 e −3;
35 d i o d e s ( 1 ) . max x = 2 . 0 e −3;
d i o d e s ( 1 ) . max y = 1 . 0 e −3;
37 d i o d e s ( 1 ) . max z = 1 . 0 e −3;
d i o d e s ( 1 ) . d i r e c t i o n = ’ zn ’ ;
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

138 Active and Passive Lumped Elements

Listing 4.37 define output parameters.m


% figure refresh rate
9 p l o t t i n g s t e p = 10;

11 % mode o f o p e r a t i o n
run simulation = true ;
13 show material mesh = true ;
show problem space = true ;
15

% define sampled voltages


17 sampled voltages ( 1 ) . m i n x = 2 . 0 e −3;
sampled voltages ( 1 ) . m i n y = 1 . 0 e −3;
19 sampled voltages ( 1 ) . min z = 0 ;
sampled voltages ( 1 ) . max x = 2 . 0 e −3;
21 sampled voltages ( 1 ) . max y = 1 . 0 e −3;
sampled voltages ( 1 ) . max z = 1 . 0 e −3;
23 sampled voltages ( 1 ) . d i r e c t i o n = ’ zp ’ ;
sampled voltages ( 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 definition of
the problem are given in Listings 4.38 and 4.39.

Listing 4.38 define geometry.m


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

15 % d e f i n e a PEC p l a t e
b r i c k s ( 2 ) . min x = 0 ;
17 b r i c k s ( 2 ) . mi n y = 0 ;
b r i c k s ( 2 ) . m i n z = 1e −3;
19 b r i c k s ( 2 ) . max x = 1e −3;
b r i c k s ( 2 ) . max y = 1e −3;
21 b r i c k s ( 2 ) . max z = 1e −3;
bricks ( 2 ) . material type = 2;
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Exercises 139

0.8

0.6

(volt)
0.4

0.2
sampled voltage
analytical solution
0
voltage source
0 1 2 3 4 5
time (ns)
(a) A voltage source terminated by (b) Sampled voltage and analytical solution
a capacitor

Figure 4.17 Unit step voltage source waveform and sampled voltage.

In Listing 4.38, two parallel PEC plates are defined 1 mm apart. A voltage source with 50
internal resistances is places at one end and a capacitor with 10 p F capacitance is placed at the
other end between these two plates as shown in Listing 4.39. A unit step waveform is assigned to
the voltage source. The unit step function is excited 50 time steps after the start of simulation.
Figure 4.17(b) shows the result of this simulation, where the sampled voltage across the capacitor
is compared with the analytical solution of the equivalent lumped circuit problem. A simple circuit
analysis reveals that the voltage across a capacitor excited by a unit step function can be calculated
from

t−t0
vC (t) = 1 − e − RC , (4.56)

where t0 is time delay, which is represented in this example by 50 time steps, and R is 50 .

4.4 EXERCISES
4.1 A stripline structure that has width/height ratio of 1.44 and an air substrate is forming
a transmission line with 50 characteristic impedance. Construct such a 50 stripline
structure, and keep all boundaries as PEC. The geometry and dimensions of such a stripline
is shown in Fig. 4.18 as a reference. Feed the stripline with a voltage source from one end,
and let the other end touch the problem space boundary. Capture the voltage on the stripline
around the center of the stripline. Show that if the voltage source is excited by a unit step
waveform with 1 volt magnitude, the sampled voltage will be a pulse with 0.5 volts.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

140 Active and Passive Lumped Elements

Figure 4.18 Dimensions of 50 stripline.

Listing 4.39 define sources and lumped elements.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
11 w a v e f o r m s . s i n u s o i d a l ( 1 ) . f r e q u e n c y = 1 e9 ;
w a v e f o r m s . s i n u s o i d a l ( 2 ) . f r e q u e n c y = 5 e8 ;
13 waveforms . u n i t s t e p ( 1 ) . s t a r t t i m e s t e p = 50;

15 % voltage sources
% d i r e c t i o n : ’ xp ’ , ’ xn ’ , ’ yp ’ , ’ yn ’ , ’ zp ’ , o r ’ zn ’
17 % r e s i s t a n c e : ohms , m a g i t u d e : volts
v o l t a g e s o u r c e s ( 1 ) . min x = 0 ;
19 v o l t a g e s o u r c e s ( 1 ) . min y = 0 ;
v o l t a g e s o u r c e s ( 1 ) . min z = 0 ;
21 v o l t a g e s o u r c e s ( 1 ) . max x = 0 . 0 e −3;
v o l t a g e s o u r c e s ( 1 ) . max y = 1 . 0 e −3;
23 v o l t a g e s o u r c e s ( 1 ) . max z = 1 . 0 e −3;
v o l t a g e s o u r c e s ( 1 ) . d i r e c t i o n = ’ zp ’ ;
25 v o l t a g e s o u r c e s ( 1 ) . r e s i s t a n c e = 50;
v o l t a g e s o u r c e s ( 1 ) . magnitude = 1 ;
27 v o l t a g e s o u r c e s ( 1 ) . waveform type = ’ u n i t s t e p ’ ;
v o l t a g e s o u r c e s ( 1 ) . waveform index = 1;
29

% capacitors
31 % d i r e c t i o n : ’ x ’ , ’ y ’ , or ’ z ’
% capacitance : farads
33 c a p a c i t o r s ( 1 ) . m i n x = 1 . 0 e −3;
c a p a c i t o r s ( 1 ) . min y = 0 . 0 ;
35 c a p a c i t o r s ( 1 ) . min z = 0 . 0 ;
c a p a c i t o r s ( 1 ) . max x = 1 . 0 e −3;
37 c a p a c i t o r s ( 1 ) . max y = 1 . 0 e −3;
c a p a c i t o r s ( 1 ) . max z = 1 . 0 e −3;
39 capacitors ( 1 ) . direction = ’z ’ ;
c a p a c i t o r s ( 1 ) . c a p a c i t a n c e = 10 e −12;
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Exercises 141

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.


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

142 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.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

5
Source Waveforms
and Transformation from
Time Domain to Frequency Domain

Sources are necessary components of a finite-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 fields appearing in scattering problems. In any case a source excites electric
and magnetic fields with a waveform as a function of time. The type of waveform can be selected
specific 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 single-
frequency 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


Definition 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
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

144 Source Waveforms

finite duration of the waveform is going to add other frequency components to the spectrum. The
initial conditions for the sources are zero before the simulation is started in an FDTD simulation,
and the sources are active during the duration of simulation. Therefore, if a sinusoidal signal
(sin(2π t), 0 < t < 4) is used for a source its duration is finite as shown in Fig. 5.1(a).
The Fourier transform of a continuous time function x(t) is X(ω) given by

+∞
X(ω) = x(t)e − j ωt d t, (5.1)
−∞

while the inverse Fourier transform is


+∞
1
x(t) = X(ω)e j ωt d ω. (5.2)
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 finite sinusoidal function.
If the simulation runs for a longer duration as shown in Fig. 5.2(a), the Fourier transform of the
waveform becomes more pronounced at 1 Hz as shown in Fig. 5.2(b). In Fig. 5.1(b) the ratio of
the highest harmonic to the main signal at 1 Hz is 0.53/2 ≡ −11.53dB, while in Fig. 5.2(b) this
ratio is 0.96/4 ≡ −12.39dB. In this case running the simulation twice as long in time reduced the
effect of the highest harmonic.

0.8

0.6

0.4

0.2
magnitude

−0.2

−0.4

−0.6

−0.8

−1
−2 0 2 4 6 8
time (s)

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


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Common Source Waveforms 145

2.5

1.5
magnitude

0.5

0
−3 −2 −1 0 1 2 3
frequency (Hz)

Figure 5.1 (b) A sinusoidal waveform excited for 4 seconds: X (ω) magnitude.

0.8

0.6

0.4

0.2
magnitude

−0.2

−0.4

−0.6

−0.8

−1
−2 0 2 4 6 8 10
time (s)

Figure 5.2 (a) A sinusoidal waveform excited for 8 seconds: x (t).


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

146 Source Waveforms

4.5

3.5

3
magnitude

2.5

1.5

0.5

0
−3 −2 −1 0 1 2 3
frequency (Hz)

Figure 5.2 (b) A sinusoidal waveform excited for 8 seconds: X (ω) magnitude.

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 finite 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 sufficient 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)
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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

c c
fmax = = , (5.5)
λmin nc s max

where c is the speed of light in free space, s max is the maximum of the cell dimensions (x, y, or
z), and λmin is the wavelength of the highest frequency in free space. Once the highest frequency
in the spectrum of the frequency domain Gaussian waveform is determined, it is possible to find
a τ that constructs the corresponding time-domain Gaussian waveform. Following is a procedure
that determines τ , so that one can construct the Gaussian waveform in the time domain before
the simulation starts with a good estimate of the highest frequency at which the simulation results
will be acceptable.
Consider the Gaussian waveform plotted in Fig. 5.3(a) and the magnitude of its Fourier trans-
form pair plotted in Fig. 5.3(b) using (5.4). The function (5.4) is real, and its phase vanishes; hence,
the phase of the Fourier transform is not plotted here. We consider the maximum valid frequency
of the Gaussian spectrum as the frequency where the magnitude of G(ω) is 10% of its maximum

0.9

0.8

0.7

0.6
magnitude

0.5

0.4

0.3

0.2

0.1

0
−8 −6 −4 −2 0 2 4 6 8
time (s)

Figure 5.3 (a) A Gaussian waveform and its Fourier transform: g (t).
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

148 Source Waveforms

max
2.5

2
magnitude

1.5

1
10% of max

0.5

fmax
0
−0.5 0 0.5
frequency (Hz)

Figure 5.3 (b) A Gaussian waveform and its Fourier transform: G (ω) magnitude.

magnitude as illustrated in Fig. 5.3(b). Therefore, by solving the equation


2
τ 2 ωmax
0.1 = e − 4 ,

we can find a relation between τ and fmax , such that



2.3
τ= . (5.6)
π fmax

Using (5.5) in (5.6), we can tie nc and s max to τ as



2.3nc s max ∼ nc s max
τ= = . (5.7)
πc 2c
Once the parameters nc and s max are defined, 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
waveform’s maximum coincides with time instant zero. However, in an FDTD simulation the
initial conditions of the fields 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.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Common Source Waveforms 149

0.9

0.8

0.7

0.6
magnitude

0.5

0.4

0.3

0.2
t
0
0.1

0
−2 0 2 4 6 8 10 12 14
time (s)

Figure 5.4 Gaussian waveform shifted by t0 = 4.5τ in time.

With time shifting the Gaussian waveform takes the form


(t−t0 )2
g(t) = e − τ2 , (5.8)

where t0 is the amount of time shift. We can find t0 as the time instant in (5.3) where g(t = 0) =
e −20 , which is a negligible value and is good for more than 16 digits of numerical accuracy. Solving
(5.8) with g(0) = e −20 we can find

t0 = 20τ ∼= 4.5τ. (5.9)

Using the time shift t0 , we obtain a Gaussian waveform as illustrated in Fig. 5.4, which can be
used as a source waveform in FDTD simulations to obtain acceptable results for frequencies up
to fmax .

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
g(t) = − te τ . (5.10)
τ
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

150 Source Waveforms

The Fourier transform of this function can be determined as



j ωτ 2 π e − τ 2 ω2
G(ω) = √ e 4 . (5.11)
2

The normalized derivative of a Gaussian waveform and its Fourier transform are illustrated in
Figs. 5.5(a) and 5.5(b), respectively. One can notice that the function in the frequency domain
vanishes at zero frequency. The form of the function suggests that there is a minimum frequency,
fmin , and a maximum frequency, fmax , that determine the bounds of the valid frequency spectrum
for an FDTD simulation considering 10% of the maximum as the limit. Having determined the
maximum usable frequency from the number of cells per wavelength and maximum cell size using
(5.5), one can find the parameter τ that sets G(ω) to 10% of its maximum value at fmax and
can use τ in (5.10) to construct a time-domain waveform for the FDTD simulation. However,
this procedure requires solution of a nonlinear equation and is not convenient. The equations
readily available for a Gaussian waveform can be used instead for convenience. For instance, τ
can be calculated using (5.7). Similar to the Gaussian waveform, the derivative of a Gaussian
waveform is also centered at time instant zero as it appears in (5.10) and as shown in Fig. 5.5(a).
Therefore, it also needs a time shift to have practically zero value at time instant zero; hence, it
can be written as

2e (t−t0 )2
g(t) = − (t − t0 )e − τ 2 . (5.12)
τ
The time shift value t0 can be obtained as well using the readily available equation (5.9).

0.8

0.6

0.4

0.2
magnitude

−0.2

−0.4

−0.6

−0.8

−1
−8 −6 −4 −2 0 2 4 6 8
time (s)

Figure 5.5 (a) Normalized derivative of a Gaussian waveform and its Fourier transform: g (t).
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Common Source Waveforms 151

2.5

2
magnitude

1.5

1
10% of max 10% of max

0.5

f min f max
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8
frequency (Hz)

Figure 5.5 (b) Normalized derivative of a Gaussian waveform and its Fourier transform: G (ω) magnitude.

5.1.4 Cosine-Modulated Gaussian Waveform


Another common waveform used in FDTD applications is the cosine-modulated Gaussian wave-
form. 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 corre-
sponds 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 first 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 , (5.13)

while its Fourier transform can be written as


√ √
τ π − τ 2 (ω−ωc )2 τ π − τ 2 (ω+ωc )2
G(ω) = e 4 + e 4 , (5.14)
2 2
where ωc = 2π fc . A cosine-modulated Gaussian waveform and its Fourier transform are illus-
trated in Fig. 5.6. To construct a cosine-modulated Gaussian waveform with spectrum having  f
bandwidth centered at fc , first we find τ in (5.14) that satisfies the  f bandwidth requirement.
We can utilize (5.6) to find τ such that

2 2.3 ∼ 0.966
τ= = . (5.15)
πf f
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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
find the required time shift value, t0 . Then the final equation for the cosine-modulated Gaussian
waveform takes the form
(t−t0 )2
g(t) = cos(ωc (t − t0 )) × e − τ2 . (5.16)

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
definition and implementation of these source waveforms in an FDTD MATLAB code.
In Section 4.2.1 we showed that we can define the parameters specific to various types of
waveforms in a structure named waveforms. We have shown how a unit step function and a
sinusoidal waveform can be defined as subfields of the structure waveforms. We can add new
subfields to the structure waveforms to define 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 definition of the source waveforms. In addition to the unit step function and
sinusoidal waveform, the Gaussian waveform is defined as the subfield waveforms.gaussian, the
derivative of a Gaussian waveform is defined as waveforms.derivative gaussian, and the cosine-
modulated Gaussian waveform is defined as waveforms.cosine modulated gaussian. Each of
these subfields is an array, so more than one waveform of the same type can be defined in

0.8

0.6

0.4

0.2
magnitude

−0.2

−0.4

−0.6

−0.8

−1
−8 −6 −4 −2 0 2 4 6 8
time (s)

Figure 5.6 (a) Cosine modulated Gaussian waveform and its Fourier transform: g (t).
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Initialization of Source Waveforms 153

0.9

0.8

0.7

0.6
magnitude

0.5

0.4

0.3

0.2

0.1 ∆f

0
−4 −3 −2 −1 0 1 2 3 4
frequency (Hz) fc

Figure 5.6 (b) Cosine modulated Gaussian waveform and its Fourier transform: G (ω) magnitude.

the same structure waveforms. For instance, in this listing two sinusoidal waveforms and two
Gaussian waveforms are defined. The Gaussian and the derivative of Gaussian waveforms have
the parameter number of cells per wavelength, which is the accuracy parameter nc described
in the previous section used to determine the maximum frequency of the spectrum of the Gaussian
waveform. If the number of cells per wavelength is assigned zero, then the number of cells -
per wavelength that is defined in the subroutine define problem space parameters will be used
as the default value.
The cosine-modulated Gaussian waveform has the parameter bandwidth, which specifies the
width of the frequency band  f . One more parameter is modulation frequency, which is the
center frequency of the band, fc .
Once the waveform types are defined, the desired waveform type can be assigned to the sources
as illustrated in Listing 5.1. For instance, for the voltage source voltage sources(1) the parameter
waveform type is assigned the value ‘gaussian’, and the parameter waveform index is assigned
the value 2, indicating that the waveform waveforms.gaussian(2) is the waveform of the voltage
source.
The initialization of the waveforms is performed in the subroutine initialize waveforms, which
is called in initialize sources and lumped elements before the initialization of lumped sources as
discussed in Section 4.2.3. The implementation of initialize waveforms is extended to include
the Gaussian, derivative of Gaussian, and cosine-modulated Gaussian waveforms based on the
discussions in Section 5 as shown in Listing 5.2. After the waveforms are initialized, the constructed
waveforms are copied to appropriate subfields in the source structures in initialize sources and -
lumped elements.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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

voltage sources = [ ] ;
4 current sources = [ ] ;
diodes = [ ] ;
6 resistors = [];
inductors = [ ] ;
8 capacitors = [ ] ;

10 % d e f i n e s o u r c e waveform t y p e s and p a r a m e t e r s
w a v e f o r m s . s i n u s o i d a l ( 1 ) . f r e q u e n c y = 1 e9 ;
12 w a v e f o r m s . s i n u s o i d a l ( 2 ) . f r e q u e n c y = 5 e8 ;
waveforms . u n i t s t e p ( 1 ) . s t a r t t i m e s t e p = 50;
14 waveforms . g a u s s i a n ( 1 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 0 ;
waveforms . g a u s s i a n ( 2 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 15;
16 waveforms . d e r i v a t i v e g a u s s i a n ( 1 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 20;
w a v e f o r m s . c o s i n e m o d u l a t e d g a u s s i a n ( 1 ) . b a n d w i d t h = 1 e9 ;
18 w a v e f o r m s . c o s i n e m o d u l a t e d g a u s s i a n ( 1 ) . m o d u l a t i o n f r e q u e n c y = 2 e9 ;

20 % voltage sources
% d i r e c t i o n : ’ xp ’ , ’ xn ’ , ’ yp ’ , ’ yn ’ , ’ zp ’ , o r ’ zn ’
22 % r e s i s t a n c e : ohms , m a g i t u d e : volts
v o l t a g e s o u r c e s ( 1 ) . min x = 0 ;
24 v o l t a g e s o u r c e s ( 1 ) . min y = 0 ;
v o l t a g e s o u r c e s ( 1 ) . min z = 0 ;
26 v o l t a g e s o u r c e s ( 1 ) . max x = 1 . 0 e −3;
v o l t a g e s o u r c e s ( 1 ) . max y = 2 . 0 e −3;
28 v o l t a g e s o u r c e s ( 1 ) . max z = 4 . 0 e −3;
v o l t a g e s o u r c e s ( 1 ) . d i r e c t i o n = ’ zp ’ ;
30 v o l t a g e s o u r c e s ( 1 ) . r e s i s t a n c e = 50;
v o l t a g e s o u r c e s ( 1 ) . magnitude = 1 ;
32 v o l t a g e s o u r c e s ( 1 ) . waveform type = ’ gaussian ’ ;
v o l t a g e s o u r c e s ( 1 ) . waveform index = 2;
 

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 input–output relationship is available in the time
domain after an FDTD simulation is completed. The input and output time functions can be
transformed to the frequency domain by the use of the Fourier transform to obtain the response
of the system in the case of time-harmonic excitations. The Fourier transform is an integration
applied to a continuous time function. In the FDTD method the values are sampled at discrete
time instants; therefore, the continuous time integration can be approximated by a discrete time
summation. The Fourier transform of a continuous time function x(t) is given as X(ω) using (5.1).
In FDTD the time function is sampled at a period t; therefore, the values x(nt) are known.
Then the Fourier transform (5.1) can be expressed for discrete samples x(nt) as
n=N
X(ω) = t n=1 steps x(nt)e − j ωnt , (5.17)
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Transformation from Time Domain to Frequency Domain 155

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

3 % i n i t i a l i z e s i n u s o i d a l waveforms
i f i s f i e l d ( waveforms , ’ s i n u s o i d a l ’ )
5 f o r i n d =1: s i z e ( w a v e f o r m s . s i n u s o i d a l , 2 )
w a v e f o r m s . s i n u s o i d a l ( i n d ) . waveform = . . .
7 s i n ( 2 * pi * waveforms . s i n u s o i d a l ( ind ) . f r e q u e n c y * time ) ;
waveforms . s i n u s o i d a l ( ind ) . t 0 = 0 ;
9 end
end
11

% i n i t i a l i z e u n i t s t e p waveforms
13 i f i s f i e l d ( waveforms , ’ u n i t s t e p ’ )
f o r i n d =1: s i z e ( w a v e f o r m s . u n i t s t e p , 2 )
15 s t a r t i n d e x = waveforms . u n i t s t e p ( ind ) . s t a r t t i m e s t e p ;
w a v e f o r m s . u n i t s t e p ( i n d ) . waveform ( 1 : n u m b e r o f t i m e s t e p s ) = 1 ;
17 w a v e f o r m s . u n i t s t e p ( i n d ) . waveform ( 1 : s t a r t i n d e x −1) = 0 ;
waveforms . u n i t s t e p ( ind ) . t 0 = 0 ;
19 end
end
21

% i n i t i a l i z e G a u s s i a n waveforms
23 i f i s f i e l d ( waveforms , ’ g a u s s i a n ’ )
f o r i n d =1: s i z e ( w a v e f o r m s . g a u s s i a n , 2 )
25 i f w a v e f o r m s . g a u s s i a n ( i n d ) . n u m b e r o f c e l l s p e r w a v e l e n g t h == 0
nc = n u m b e r o f c e l l s p e r w a v e l e n g t h ;
27 else
nc = w a v e f o r m s . g a u s s i a n ( i n d ) . n u m b e r o f c e l l s p e r w a v e l e n g t h ;
29 end
w a v e f o r m s . g a u s s i a n ( i n d ) . maximum frequency = . . .
31 c / ( nc * max ( [ dx , dy , dz ] ) ) ;
t a u = ( nc * max ( [ dx , dy , dz ] ) ) / ( 2 * c ) ;
33 waveforms . g a u s s i a n ( ind ) . tau = tau ;
t 0 = 4 . 5 * waveforms . g a u s s i a n ( ind ) . tau ;
35 waveforms . g a u s s i a n ( ind ) . t 0 = t 0 ;
w a v e f o r m s . g a u s s i a n ( i n d ) . waveform = exp ( − ( ( t i m e − t 0 ) / t a u ) . ˆ 2 ) ;
37 end
end
39

% i n i t i a l i z e d e r i v a t i v e of G a u s s i a n waveforms
41 i f i s f i e l d ( waveforms , ’ d e r i v a t i v e g a u s s i a n ’ )
f o r i n d =1: s i z e ( w a v e f o r m s . d e r i v a t i v e g a u s s i a n , 2 )
43 wfrm = w a v e f o r m s . d e r i v a t i v e g a u s s i a n ( i n d ) ;
i f wfrm . n u m b e r o f c e l l s p e r w a v e l e n g t h == 0
45 nc = n u m b e r o f c e l l s p e r w a v e l e n g t h ;
else
47 nc = . . .
waveforms . d e r i v a t i v e g a u s s i a n ( ind ) . n u m b e r o f c e l l s p e r w a v e l e n g t h ;
49 end
w a v e f o r m s . d e r i v a t i v e g a u s s i a n ( i n d ) . maximum frequency = . . .
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

156 Source Waveforms

51 c / ( nc * max ( [ dx , dy , dz ] ) ) ;
t a u = ( nc * max ( [ dx , dy , dz ] ) ) / ( 2 * c ) ;
53 waveforms . d e r i v a t i v e g a u s s i a n ( ind ) . tau = tau ;
t 0 = 4 . 5 * waveforms . d e r i v a t i v e g a u s s i a n ( ind ) . tau ;
55 waveforms . d e r i v a t i v e g a u s s i a n ( ind ) . t 0 = t 0 ;
w a v e f o r m s . d e r i v a t i v e g a u s s i a n ( i n d ) . waveform = . . .
57 −( s q r t ( 2 * exp ( 1 ) ) / t a u ) * ( t i m e − t 0 ) . * exp ( − ( ( t i m e − t 0 ) / t a u ) . ˆ 2 ) ;
end
59 end

61 % i n i t i a l i z e c o s i n e modulated G a u s s i a n w a v e f o r m s
i f i s f i e l d ( waveforms , ’ c o s i n e m o d u l a t e d g a u s s i a n ’ )
63 f o r i n d =1: s i z e ( w a v e f o r m s . c o s i n e m o d u l a t e d g a u s s i a n , 2 )
frequency = . . .
65 waveforms . c o s i n e m o d u l a t e d g a u s s i a n ( ind ) . m o d u l a t i o n f r e q u e n c y ;
tau = 0 . 9 6 6 / waveforms . c o s i n e m o d u l a t e d g a u s s i a n ( ind ) . bandwidth ;
67 waveforms . c o s i n e m o d u l a t e d g a u s s i a n ( ind ) . tau = tau ;
t 0 = 4 . 5 * waveforms . c o s i n e m o d u l a t e d g a u s s i a n ( ind ) . tau ;
69 waveforms . c o s i n e m o d u l a t e d g a u s s i a n ( ind ) . t 0 = t 0 ;
w a v e f o r m s . c o s i n e m o d u l a t e d g a u s s i a n ( i n d ) . waveform = . . .
71 c o s ( 2 * p i * f r e q u e n c y * ( t i m e − t 0 ) ) . * exp ( − ( ( t i m e − t 0 ) / t a u ) . ˆ 2 ) ;
end
73 end
 

where Nsteps is the number of time steps. It is easy to implement a function based on (5.17)
that calculates the Fourier transform of the discrete samples x(nt) for a list of frequencies.
Implementation of such a function, time to frequency domain, is shown in Listing 5.3. This
function accepts a parameter x, which is an array of sampled time-domain values of a function.
The parameter frequency array includes list of frequencies for which the transform is to be
performed. The output parameter of the function X is an array including the transform at the
respective frequencies.

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
3 % 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
5 % 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
7

number of time steps = size ( x , 2 ) ;


9 number of frequencies = size ( frequency array , 2 ) ;
X = zeros (1 , number of frequencies ) ;
11 w = 2 * pi * f r e q u e n c y a r r a y ;
for n = 1: number of time steps
13 t = n * dt + t i m e s h i f t ;
X = X + x ( n ) * exp (− j * w * t ) ;
15 end
X = X * dt ;
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Transformation from Time Domain to Frequency Domain 157

Another input parameter that needs consideration is time shift. As discussed in previous chap-
ters, the electric field-related values and magnetic field-related values are sampled at different time
instants during the FDTD time-marching scheme. There is a half time step duration in between,
and the function time to frequency domain accepts a value time shift to account for this time
shift in the Fourier transform. For electric field-related values (e.g., sampled voltages), time -
shift can take the value 0, whereas for the magnetic field-related values (e.g., sampled currents),
time shift can take the value -dt/2.
The function implementation given in Listing 5.3 is intended for an easy understanding of the
time-to-frequency-domain transform action, and is not necessarily the best or optimum algorithm
for this purpose. More efficient discrete Fourier transform implementations, such as fast Fourier
transforms (FFTs), can be used as well.
Similarly, the inverse Fourier transform can also be implemented. Consider a band-limited
frequency domain function X(ω) sampled at uniformly distributed discrete frequency points with
sampling period ω, where the sampling frequencies include zero and positive frequencies. Then
the inverse Fourier transform (5.2) can be expressed as

ω   
x(t) = X(0) + m=1
m=M−1
X(mω)e j ωt + X∗ (mω)e − j ωt , (5.18)

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



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 )
2 % 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
4 % 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
6

number of frequencies = size ( X , 2 ) ;


8 number of time points = size ( time array , 2 ) ;
x = zeros (1 , number of time points ) ;
10 dw = 2 * p i * d f ;
x = X ( 1 ) ; % z e r o f r e q u e n c y component
12 for m = 2: number of frequencies
w = ( m−1) * dw ;
14 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 ) ;
16 end
x = x * df ;
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

158 Source Waveforms

Listing 5.5 define output parameters.m


16 % 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 ;
18 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 define 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 defined to store the frequency-domain-specific parameters. The subfields
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: calcu-
late frequency domain outputs and display frequency domain outputs. The time-to-frequency-
domain 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 subfield 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 specific frequency spectrum characteristics. Then we provided functions that perform
time-to-frequency-domain transformation, which can be used to obtain simulation results in the
frequency domain after an FDTD simulation is completed. In this section we provide examples
that utilize source waveforms and transformation functions.
Listing 5.6 initialize output parameters.m
8 % i n t i a l i z e f r e q u e n c y domain p a r a m e t e r s
frequency domain . f r e q u e n c i e s = [ frequency domain . s t a r t : ...
10 f r e q u e n c y d o m a i n . s t e p : f r e q u e n c y d o m a i n . end ] ;
frequency domain . number of frequencies = . . .
12 s i z e ( frequency domain . frequencies , 2 ) ;
 

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

3 display transient parameters ;


calculate frequency domain outputs ;
5 display frequency domain outputs ;
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation Examples 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 ’ ) ;

3 frequency array = frequency domain . frequencies ;

5 % sampled e l e c t r i c f i e l d s i n f r e q u e n c y domain
f o r i n d =1: n u m b e r o f s a m p l e d e l e c t r i c f i e l d s
7 x = s a m p l e d e l e c t r i c f i e l d s ( ind ) . sampled value ;
t i m e s h i f t = 0;
9 [ X ] = t i m e t o f r e q u e n c y d o m a i n ( x , dt , f r e q u e n c y a r r a y , t i m e s h i f t ) ;
s a m p l e d e l e c t r i c f i e l d s ( ind ) . frequency domain value = X ;
11 s a m p l e d e l e c t r i c f i e l d s ( ind ) . f r e q u e n c i e s = f r e q u e n c y a r r a y ;
end
31

% sampled c u r r e n t s i n f r e q u e n c y domain
33 f o r i n d =1: n u m b e r o f s a m p l e d c u r r e n t s
x = sampled currents ( ind ) . sampled value ;
35 t i m e s h i f t = −d t / 2 ;
[ X ] = t i m e t o f r e q u e n c y d o m a i n ( x , dt , f r e q u e n c y a r r a y , t i m e s h i f t ) ;
37 sampled currents ( ind ) . frequency domain value = X ;
sampled currents ( ind ) . f r e q u e n c i e s = f r e q u e n c y a r r a y ;
39 end

41 % v o l t a g e s o u r c e s i n f r e q u e n c y domain
f o r i n d =1: n u m b e r o f v o l t a g e s o u r c e s
43 x = v o l t a g e s o u r c e s ( i n d ) . waveform ;
t i m e s h i f t = 0;
45 [ X ] = t i m e t o f r e q u e n c y d o m a i n ( x , dt , f r e q u e n c y a r r a y , t i m e s h i f t ) ;
v o l t a g e s o u r c e s ( ind ) . frequency domain value = X ;
47 v o l t a g e s o u r c e s ( ind ) . f r e q u e n c i e s = f r e q u e n c y a r r a y ;
end
 

Listing 5.9 display frequency domain outputs.m


41 % 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
43 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 ;
45 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 ) ;
47 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 ) ;
49 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 ) ;
51 g r i d on ;
subplot ( 2 , 1 , 2 ) ;
53 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 ) ;
55 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 ;
57 drawnow ;
end
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

160 Source Waveforms

5.4.1 Recovering a Time Waveform from Its Fourier Transform


The first 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 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
3 % 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 ;
5 t a u = s q r t ( 2 . 3 ) / ( p i * maximum frequency ) ;
t 0 = 4.5 * tau ;
7 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 ) ;
9 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 ) ;
11 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 ) ;
13 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 ) ;
15 g r i d on ;

17 % P e r f o r m t i m e t o f r e q u e n c y domain t r a n s f o r m
f r e q u e n c y a r r a y = [ 0 : 1 0 0 0 ] * 2 e6 ;
19 dt = t i m e a r r a y (2) − t i m e a r r a y ( 1 ) ;
G = t i m e t o f r e q u e n c y d o m a i n ( g , dt , f r e q u e n c y a r r a y , 0 ) ;
21

figure ( 2 ) ;
23 subplot ( 2 , 1 , 1 ) ;
p l o t ( f r e q u e n c y a r r a y * 1 e −9 , abs ( G ) , ’ b− ’ , ’ l i n e w i d t h ’ , 1 . 5 ) ;
25 t i t l e ( ’ G ( \ omega ) = F ( g ( t ) ) ’ , ’ f o n t s i z e ’ , 1 2 ) ;
x l a b e l ( ’ f r e q u e n c y ( GHz ) ’ , ’ f o n t s i z e ’ , 1 2 ) ;
27 y l a b e l ( ’ magnitude ’ , ’ f o n t s i z e ’ , 1 2 ) ;
s e t ( gca , ’ f o n t s i z e ’ , 1 2 ) ;
29 g r i d on ;
subplot ( 2 , 1 , 2 ) ;
31 p l o t ( f r e q u e n c y a r r a y * 1 e −9 , a n g l e ( G ) * 1 8 0 / pi , ’ r− ’ , ’ l i n e w i d t h ’ , 1 . 5 ) ;
x l a b e l ( ’ f r e q u e n c y ( GHz ) ’ , ’ f o n t s i z e ’ , 1 2 ) ;
33 y l a b e l ( ’ phase ( d e g r e e s ) ’ , ’ f o n t s i z e ’ , 1 2 ) ;
s e t ( gca , ’ f o n t s i z e ’ , 1 2 ) ;
35 g r i d on ;
drawnow ;
37

% P e r f o r m f r e q u e n c y t o t i m e domain t r a n s f o r m
39 df = f r e q u e n c y a r r a y (2) − f r e q u e n c y a r r a y ( 1 ) ;
g2 = f r e q u e n c y t o t i m e d o m a i n ( G , df , t i m e a r r a y ) ;
41

figure ( 3 ) ;
43 p l o t ( t i m e a r r a y * 1 e9 , abs ( g2 ) , ’ b− ’ , ’ l i n e w i d t h ’ , 1 . 5 ) ;
t i t l e ( ’ g ( t )= F ˆ{ −1}( G ( \ omega ) ) ’ , ’ f o n t s i z e ’ , 1 4 ) ;
45 x l a b e l ( ’ time ( ns ) ’ , ’ f o n t s i z e ’ , 1 2 ) ;
y l a b e l ( ’ magnitude ’ , ’ f o n t s i z e ’ , 1 2 ) ;
47 s e t ( gca , ’ f o n t s i z e ’ , 1 2 ) ;
g r i d on ;
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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 defined 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 defined between the parallel PEC plates at the load end as shown in
Listing 5.13.

0.9

0.8

0.7

0.6
magnitude

2
0.5 g(t)=e−((t−t0)/τ)
0.4

0.3

0.2

0.1

0
0 2 4 6 8 10
time (ns)

Figure 5.7 (a) A Gaussian waveform and its Fourier transform: g (t).
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

162 Source Waveforms

−9
x 10 G(ω) = F(g(t))
1

magnitude
0.5

0
0 0.5 1 1.5 2
frequency (GHz)
200
phase (degrees)

100

−100

−200
0 0.5 1 1.5 2
frequency (GHz)

Figure 5.7 (b) A Gaussian waveform and its Fourier transform: G (ω).

0.9

0.8

0.7

0.6
magnitude

0.5 g(t)= F−1(G(ω))


0.4

0.3

0.2

0.1

0
0 2 4 6 8 10
time (ns)

Figure 5.7 (c) A Gaussian waveform and its Fourier transform: g (t) recovered from G (ω).
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation Examples 163

Rs=50Ω C=10pF
Vo
Vs L=10nH

(a) Circuit simulated in FDTD (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 ’ ) ;

3 bricks = [ ] ;
spheres = [ ] ;
5

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

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

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

3 voltage sources = [ ] ;
current sources = [ ] ;
5 diodes = [ ] ;
resistors = [];
7 inductors = [ ] ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

164 Source Waveforms

capacitors = [ ] ;
9

% d e f i n e s o u r c e waveform t y p e s and p a r a m e t e r s
11 w a v e f o r m s . s i n u s o i d a l ( 1 ) . f r e q u e n c y = 1 e9 ;
w a v e f o r m s . s i n u s o i d a l ( 2 ) . f r e q u e n c y = 5 e8 ;
13 waveforms . u n i t s t e p ( 1 ) . s t a r t t i m e s t e p = 50;
waveforms . g a u s s i a n ( 1 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 0 ;
15 waveforms . g a u s s i a n ( 2 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 15;
waveforms . d e r i v a t i v e g a u s s i a n ( 1 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 20;
17 w a v e f o r m s . c o s i n e m o d u l a t e d g a u s s i a n ( 1 ) . b a n d w i d t h = 4 e9 ;
w a v e f o r m s . c o s i n e m o d u l a t e d g a u s s i a n ( 1 ) . m o d u l a t i o n f r e q u e n c y = 2 e9 ;
19

% voltage sources
21 % d i r e c t i o n : ’ xp ’ , ’ xn ’ , ’ yp ’ , ’ yn ’ , ’ zp ’ , o r ’ zn ’
% r e s i s t a n c e : ohms , m a g i t u d e : volts
23 v o l t a g e s o u r c e s ( 1 ) . min x = 0 ;
v o l t a g e s o u r c e s ( 1 ) . min y = 0 ;
25 v o l t a g e s o u r c e s ( 1 ) . min z = 0 ;
v o l t a g e s o u r c e s ( 1 ) . max x = 0 ;
27 v o l t a g e s o u r c e s ( 1 ) . max y = 1 . 0 e −3;
v o l t a g e s o u r c e s ( 1 ) . max z = 2 . 0 e −3;
29 v o l t a g e s o u r c e s ( 1 ) . d i r e c t i o n = ’ zp ’ ;
v o l t a g e s o u r c e s ( 1 ) . r e s i s t a n c e = 50;
31 v o l t a g e s o u r c e s ( 1 ) . magnitude = 1 ;
v o l t a g e s o u r c e s ( 1 ) . waveform type = ’ cosine modulated gaussian ’ ;
33 v o l t a g e s o u r c e s ( 1 ) . waveform index = 1;

35 % inductors
% direction : ’ x ’ , ’ y ’ , or ’ z ’
37 % inductance : henrys
inductors ( 1 ) . m i n x = 1 . 0 e −3;
39 inductors ( 1 ) . min y = 0 . 0 ;
inductors ( 1 ) . min z = 0 . 0 ;
41 inductors ( 1 ) . max x = 1 . 0 e −3;
inductors ( 1 ) . max y = 1 . 0 e −3;
43 inductors ( 1 ) . max z = 1 . 0 e −3;
inductors ( 1 ) . direction = ’z ’ ;
45 inductors ( 1 ) . i n d u c t a n c e = 10 e −9;

47 % capacitors
% d i r e c t i o n : ’ x ’ , ’ y ’ , or ’ z ’
49 % capacitance : farads
c a p a c i t o r s ( 1 ) . m i n x = 1 . 0 e −3;
51 c a p a c i t o r s ( 1 ) . min y = 0 . 0 ;
c a p a c i t o r s ( 1 ) . m i n z = 1 . 0 e −3;
53 c a p a c i t o r s ( 1 ) . max x = 1 . 0 e −3;
c a p a c i t o r s ( 1 ) . max y = 1 . 0 e −3;
55 c a p a c i t o r s ( 1 ) . max z = 2 . 0 e −3;
capacitors ( 1 ) . direction = ’ z ’ ;
57 c a p a c i t o r s ( 1 ) . c a p a c i t a n c e = 10 e −12;
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation Examples 165

Listing 5.13 define output parameters.m



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

3 sampled electric fields = [];


sampled magnetic fields = [ ] ;
5 sampled voltages = [ ] ;
sampled currents = [ ] ;
7

% figure refresh rate


9 p l o t t i n g s t e p = 10;

11 % mode o f o p e r a t i o n
run simulation = true ;
13 show material mesh = true ;
show problem space = true ;
15

% f r e q u e n c y domain p a r a m e t e r s
17 f r e q u e n c y d o m a i n . s t a r t = 2 e7 ;
f r e q u e n c y d o m a i n . end = 4 e9 ;
19 f r e q u e n c y d o m a i n . s t e p = 2 e7 ;

21 % define sampled voltages


sampled voltages ( 1 ) . m i n x = 1 . 0 e −3;
23 sampled voltages ( 1 ) . min y = 0 . 0 ;
sampled voltages ( 1 ) . min z = 0 . 0 ;
25 sampled voltages ( 1 ) . max x = 1 . 0 e −3;
sampled voltages ( 1 ) . max y = 1 . 0 e −3;
27 sampled voltages ( 1 ) . max z = 2 . 0 e −3;
sampled voltages ( 1 ) . d i r e c t i o n = ’ zp ’ ;
29 sampled voltages ( 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 find the transfer function of this
circuit by normalizing the output voltage Vo to Vs . Furthermore, we can perform a circuit analysis
to find the transfer function of the equivalent circuit in Fig. 5.8(b), which yields

Vo (ω) s 2 LC + 1
T(ω) = = 2 , (5.19)
Vs (ω) s LC + s RC + 1

where s = j ω. The transfer function obtained from the FDTD simulation and the exact equation
(5.19) are compared as shown in Fig. 5.11. These two results agree with each other very well at low
frequencies; however, there is a deviation at high frequencies. One of the reasons for the difference
is that the two circuits in Figs. 5.8(a) and 5.8(b) are not exactly the same. For instance, the parallel
plates introduce a capacitance, and the overall circuit is a loop and introduces an inductance in
Fig. 5.8(a). However, these additional effects are not accounted for in the lumped circuit in Fig.
5.8(b). Therefore, an electromagnetic simulation including lumped element components should
account for the additional effects due to the physical structure of the circuit to obtain more accurate
data at higher frequencies.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

166 Source Waveforms

1
voltage source
0.8 sampled voltage
0.6

0.4
(volt)

0.2

−0.2

−0.4

−0.6
0 0.5 1 1.5 2 2.5 3 3.5
time (ns)

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. Define a Gaussian
source waveform, assign it to the voltage source and run the FDTD simulation. By the time
the simulation is completed, the sampled voltage and current will be captured, transformed
to frequency domain, and stored in the frequency domain value field of the parameters
sampled voltages(i) and sampled currents(i). Input impedance of this stripline can be

−10
x 10
4
magnitude

0
0 1 2 3 4
frequency (GHz)
phase (degrees)

200

−200
0 1 2 3 4
frequency (GHz)

Figure 5.10 (a) Frequency-domain response of source waveform V s and output voltage V o : Fourier transform
of V s .
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Exercises 167

−10
x 10

1.5

magnitude 1

0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4
frequency (GHz)
200
phase (degrees)

100

−100

−200
0 0.5 1 1.5 2 2.5 3 3.5 4
frequency (GHz)

Figure 5.10 (b) Frequency-domain response of source waveform V s and output voltage V o : Fourier transform
of V o .

1.4
|Vo/Vs| simulated
1.2 |Vo/Vs| exact

1
magnitude

0.8

0.6

0.4

0.2

0
0 0.5 1 1.5 2 2.5 3 3.5 4
frequency (GHz)

Figure 5.11 Transfer function T (ω) = V o (ω)


V s (ω)
.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

168 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 reflections due to the imperfect termination of the 50 resistor. If
your stripline structure is long enough and the Gaussian waveform is narrow enough, the
Gaussian waveform and reflections should not overlap. Determine from the transient voltage
a number of time steps that would be used to run the FDTD simulations such that the
simulation would end before the reflections are captured and only the Gaussian waveform
would be observed as the sampled transient voltage. This way you would be simulating an
infinitely long stripline structure. Therefore, when you calculate the input impedance, you
would actually be calculating the characteristic impedance of the stripline. Rerun the FDTD
simulation with the time step you have determined as discussed, calculate and plot the input
impedance for a wide frequency band, and verify that the characteristic impedance of the
stripline is 50 .
5.3 Consider the circuit in Exercise 4.4. Set the waveform of the voltage source as the Gaussian
waveform, and define a sampled current to capture the current flowing through the circuit.
Rerun the FDTD simulation, calculate and plot the input impedance for a wide frequency
band, and verify that the circuit resonates at 100 MHz. Note that you may need to run the
simulation for a large number of time steps since it will take a long time for the low-frequency
components in the Gaussian waveform to decay.
5.4 Consider Exercise 5.3. Now set the waveform of the voltage-source derivative of the Gaussian
waveform. Rerun the FDTD simulation, calculate and plot the input impedance for a wide
frequency band, and verify that the circuit resonates at 100 MHz. Note that with the
derivative of the Gaussian waveform you should be able to obtain the results with a much
smaller number of time steps compared with the amount of steps used in Exercise 5.3 since
the derivative of the Gaussian waveform does not include zero frequency and since very
low-frequency components are negligible.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

6
Scattering Parameters

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 finite-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 reflected power waves a i
and b i associated with port i are defined as

Vi + Zi × Ii Vi − Zi∗ × Ii
ai = √ , bi = √ , (6.1)
2 |Re{Zi }| 2 |Re{Zi }|

where Vi , and Ii are the voltage and the current flowing into the i th port of a junction and Zi
is the impedance looking out from the i th port as illustrated in Fig. 6.1 [13]. In general, Zi is
complex; however, in most of the microwaves applications it is real and equal to 50 . Then the
S-parameters matrix can be expressed as
⎡ ⎤ ⎡ ⎤ ⎡ ⎤
b1 S11 S12 · · · S1N a1
⎢ b 2 ⎥ ⎢ S21 S22 · · · S2N ⎥ ⎢ a2 ⎥
⎢ ⎥ ⎢ ⎥ ⎢ ⎥
⎢ .. ⎥ = ⎢ .. .. .. . ⎥ × ⎢ . ⎥. (6.2)
⎣ . ⎦ ⎣ . . . .. ⎦ ⎣ .. ⎦
bN SN1 SN2 · · · SNN aN

By definition, the subscripts mn indicate output port number, m, and input port number, n, of
the scattering parameter Smn . If only the port n is excited while all other ports are terminated by
matched loads, the output power wave at port m, b m , and the input power wave at port n, a n , can
be used to calculate Smn using

bm
Smn = . (6.3)
an

This technique can be applied to FDTD simulation results to obtain S-parameters for an input port
n. A multiport circuit can be constructed in an FDTD problem space where all ports are terminated
by matching loads and only the reference port n is excited by a source. Then sampled voltages
and currents can be captured at all ports during the FDTD time-marching loop. S-parameters

169
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

170 Scattering Parameters

I1 I2
a1 + + a2
N-port circuit V2 b
b1 _V1 _ 2

Z1 Z2
IN
+VN _ ZN
bN
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 reflected power waves, a i and b i , from which the S-parameters can be obtained
for the reference port using (6.3). One should keep in mind that in an FDTD simulation only one
of the ports can be excited. Therefore, to obtain a complete set of S-parameters for all of the port
excitations in the circuit, more than one FDTD run may be required depending on the type and
symmetry conditions of the problem.
The S-parameters are complex quantities, as they are obtained using (6.3). Generally S-
parameters are plotted by their magnitudes in decibels such that |Smn |d B = 20 log10 (|Smn |) and
by their phases.

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 S-
parameter calculations. To define a port we need a sampled voltage and a sampled current defined
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 filter 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 defined 10 cells away from the ends of the
microstrip terminations as implemented in Listing 6.2.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

S-Parameter Calculations 171

Figure 6.2 (a) A microstrip low-pass filter terminated by a voltage source and a resistor on two ends: three-
dimensional view.

We associate a sampled voltage and sampled current pair to a port, and thus we have two
ports. In Listing 6.2 a new parameter ports is defined and initialized as an empty array. At the
end of the listing the sampled voltages and currents are associated to ports through their indices.
For instance, the subfield sampled voltage index of ports(2) is assigned the value 2, implying
that sampled voltages(2) is the sampled voltage associated to the second port. The subfield
impedance is assigned the impedance of the respective port, which is supposed to be equal to
the microstrip-line characteristic impedance and the resistance of the voltage source and resistor

Figure 6.2 (b) A microstrip low-pass filter terminated by a voltage source and a resistor on two ends: dimensions.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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

3 bricks = [ ] ;
spheres = [ ] ;
5

% define a substrate
7 b r i c k s ( 1 ) . min x = 0 ;
b r i c k s ( 1 ) . mi n y = 0 ;
9 b r i c k s ( 1 ) . min z = 0 ;
b r i c k s ( 1 ) . max x = 50 * dx ;
11 b r i c k s ( 1 ) . max y = 46 * dy ;
b r i c k s ( 1 ) . max z = 3 * dz ;
13 bricks ( 1 ) . material type = 4;

15 % d e f i n e a PEC p l a t e
b r i c k s ( 2 ) . m i n x = 14 * dx ;
17 b r i c k s ( 2 ) . mi n y = 0 ;
b r i c k s ( 2 ) . m i n z = 3 * dz ;
19 b r i c k s ( 2 ) . max x = 20 * dx ;
b r i c k s ( 2 ) . max y = 20 * dy ;
21 b r i c k s ( 2 ) . max z = 3 * dz ;
bricks ( 2 ) . material type = 2;
23

% d e f i n e a PEC p l a t e
25 b r i c k s ( 3 ) . m i n x = 30 * dx ;
b r i c k s ( 3 ) . mi n y = 26 * dy ;
27 b r i c k s ( 3 ) . m i n z = 3 * dz ;
b r i c k s ( 3 ) . max x = 36 * dx ;
29 b r i c k s ( 3 ) . max y = 46 * dy ;
b r i c k s ( 3 ) . max z = 3 * dz ;
31 bricks ( 3 ) . material type = 2;

33 % d e f i n e a PEC p l a t e
b r i c k s ( 4 ) . min x = 0 ;
35 b r i c k s ( 4 ) . mi n y = 20 * dy ;
b r i c k s ( 4 ) . m i n z = 3 * dz ;
37 b r i c k s ( 4 ) . max x = 50 * dx ;
b r i c k s ( 4 ) . max y = 26 * dy ;
39 b r i c k s ( 4 ) . max z = 3 * dz ;
bricks ( 4 ) . material type = 2;
41

% d e f i n e a PEC p l a t e a s ground
43 b r i c k s ( 5 ) . min x = 0 ;
b r i c k s ( 5 ) . mi n y = 0 ;
45 b r i c k s ( 5 ) . min z = 0 ;
b r i c k s ( 5 ) . max x = 50 * dx ;
47 b r i c k s ( 5 ) . max y = 46 * dy ;
b r i c k s ( 5 ) . max z = 0 ;
49 bricks ( 5 ) . material type = 2;
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

S-Parameter Calculations 173

Listing 6.2 define output parameters.m



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

3 sampled electric fields = [];


sampled magnetic fields = [ ] ;
5 sampled voltages = [ ] ;
sampled currents = [ ] ;
7 ports = [ ] ;

9 % figure refresh rate


p l o t t i n g s t e p = 100;
11

% mode o f o p e r a t i o n
13 run simulation = true ;
show material mesh = true ;
15 show problem space = true ;

17 % f r e q u e n c y domain p a r a m e t e r s
f r e q u e n c y d o m a i n . s t a r t = 20 e6 ;
19 f r e q u e n c y d o m a i n . end = 20 e9 ;
f r e q u e n c y d o m a i n . s t e p = 20 e6 ;
21

% define sampled voltages


23 sampled voltages ( 1 ) . m i n x = 14 * dx ;
sampled voltages ( 1 ) . m i n y = 10 * dy ;
25 sampled voltages ( 1 ) . min z = 0 ;
sampled voltages ( 1 ) . max x = 20 * dx ;
27 sampled voltages ( 1 ) . max y = 10 * dy ;
sampled voltages ( 1 ) . max z = 3 * dz ;
29 sampled voltages ( 1 ) . d i r e c t i o n = ’ zp ’ ;
sampled voltages (1). display plot = false ;
31

sampled voltages (2). m i n x = 30 * dx ;


33 sampled voltages (2). m i n y = 36 * dy ;
sampled voltages (2). min z = 0 . 0 ;
35 sampled voltages (2). max x = 36 * dx ;
sampled voltages (2). max y = 36 * dy ;
37 sampled voltages (2). max z = 3 * dz ;
sampled voltages (2). d i r e c t i o n = ’ zp ’ ;
39 sampled voltages (2). display plot = false ;

41 % define sampled currents


sampled currents ( 1 ) . m i n x = 14 * dx ;
43 sampled currents ( 1 ) . m i n y = 10 * dy ;
sampled currents ( 1 ) . m i n z = 3 * dz ;
45 sampled currents ( 1 ) . max x = 20 * dx ;
sampled currents ( 1 ) . max y = 10 * dy ;
47 sampled currents ( 1 ) . max z = 3 * dz ;
sampled currents ( 1 ) . d i r e c t i o n = ’ yp ’ ;
49 sampled currents (1). display plot = false ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

174 Scattering Parameters

51 sampled currents (2). m i n x = 30 * dx ;


sampled currents (2). m i n y = 36 * dy ;
53 sampled currents (2). m i n z = 3 * dz ;
sampled currents (2). max x = 36 * dx ;
55 sampled currents (2). max y = 36 * dy ;
sampled currents (2). max z = 3 * dz ;
57 sampled currents (2). d i r e c t i o n = ’ yn ’ ;
sampled currents (2). display plot = false ;
59

% define ports
61 ports ( 1 ) . sampled voltage index = 1;
ports ( 1 ) . sampled current index = 1;
63 ports ( 1 ) . impedance = 5 0 ;
ports ( 1 ) . is source port = true ;
65

ports (2). sampled voltage index = 2;


67 ports (2). sampled current index = 2;
ports (2). impedance = 5 0 ;
69 ports (2). is source port = false ;
 

terminating the microstrip line. One additional subfield of ports is is source port, which indicates
whether the port is the source port or not. In this two ports example the first port is the excitation
port due to the voltage source; therefore, ports(1).is source port is assigned the value true
whereas for the second port ports(2).is source port is false.
One should notice that the direction of the second sampled current sampled currents(2).-
direction is toward the negative x direction as xn. The reference currents are defined as flow-
ing into the circuit for the purpose of calculating the network parameters, as can be seen in
Fig. 6.1.
Furthermore, one should notice that we can compute only the set of S-parameters (S11 and S21 )
for which the first port is the excitation port. The other set of S-parameters (S12 and S22 ) can be
obtained from (S11 and S21 ) due to the symmetry in the structure. If the structure is not symmetric,
we should assign the voltage source to the second port location and repeat the simulation. Another
approach for obtaining all S-parameters is that, instead of defining a single source, sources can
be defined at every port separately, each having internal impedance equal to the port impedance.
Then the FDTD simulations can be repeated in a loop a number of times equals the number
of ports, where each time one of the ports is set as the excitation port. Each time, the sources
associated with the excitation port are activated while other sources are deactivated. The inactive
sources will not generate power and serve only as passive terminations. Each time, the S-parameter
set for the excitation port as the input can be calculated and stored.
Listing 6.2 illustrates how we can define the ports. The only initialization required for the
ports is the determination of the number of ports in initialize output parameters as illustrated in
Listing 6.3. After the FDTD time-marching loop is completed, the S-parameters are calculated in
calculate frequency domain outputs after frequency-domain transformation of sampled voltages
and currents as shown in Listing 6.4. First, the incident and reflected power waves are calculated
for every port using (6.1). Then the S-parameters are calculated for the active port using (6.3).
The calculated S-parameters are plotted as the last step in display frequency domain outputs, as
shown in Listing 6.5.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

S-Parameter Calculations 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 ’ ) ;

3 number of sampled electric fields = size ( sampled electric fields , 2 ) ;


number of sampled magnetic fields = size ( sampled magnetic fields , 2 ) ;
5 number of sampled voltages = size ( sampled voltages , 2 ) ;
number of sampled currents = size ( sampled currents , 2 ) ;
7 number of ports = size ( ports , 2 ) ;
 

Listing 6.4 calculate frequency domain outputs.m


59 % c a l c u l a t i o n o f S−p 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
61 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 ;
63 s c i = p o r t s ( ind ) . sampled current index ;
Z = p o r t s ( i n d ) . impedance ;
65 V = sampled voltages ( s v i ) . frequency domain value ;
I = sampled currents ( s c i ) . frequency domain value ;
67 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 * ( V−c o n j ( Z ) . * I ) . / s q r t ( r e a l ( Z ) ) ;
69 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

% c a l c u l a t e t h e S−p a r a m e t e r s
73 f o r i n d =1: n u m b e r o f p o r t s
i f p o r t s ( i n d ) . i s s o u r c e p o r t == t r u e
75 f o r o i n d =1: n u m b e r o f p o r t s
p o r t s ( ind ) . S ( oind ) . v a l u e s = p o r t s ( oind ) . b . / p o r t s ( ind ) . a ;
77 end
end
79 end
 

Listing 6.5 display frequency domain outputs.m


117 % f i g u r e s f o r S−p 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
119 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;
121 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 ;
123 Sdb = 20 * l o g 1 0 ( abs ( S ) ) ;
Sphase = angle ( S ) * 1 8 0 / pi ;
125 figure ;
subplot ( 2 , 1 , 1 ) ;
127 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 ) ;
129 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 ) ;
131 g r i d on ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

176 Scattering Parameters

subplot ( 2 , 1 , 2 ) ;
133 p l o t ( f r e q u e n c i e s , S p h a s e , ’ r− ’ , ’ l i n e w i d t h ’ , 1 . 5 ) ;
x l a b e l ( ’ f r e q u e n c y ( GHz ) ’ , ’ f o n t s i z e ’ , 1 2 ) ;
135 y l a b e l ( ’ phase ( d e g r e e s ) ’ , ’ f o n t s i z e ’ , 1 2 ) ;
g r i d on ;
137 drawnow ;
end
139 end
end
 

The sample circuit in Fig. 6.1 is run for 20,000 time steps, and the S-parameters of the circuit are
obtained at the reference planes 10 cells away from the terminations where the ports are defined.
Although the reference planes for the S-parameters are defined away from the terminations, it is
possible to define the planes at the terminations. It is sufficient to place the sampled voltages and
currents on the terminations.
Figure 6.3(a) shows the calculated S11 up to 20 GHz, and Fig. 6.3(b) shows the calculated S21 .
It can be seen that the circuit acts as a low-pass filter where the pass band is up to 5.5 GHz.
Comparing the results in Figs. 6.3 with the ones published in [14] it is evident that there are
differences between the sets of results: some spikes appear in Figs. 6.3. This is because of the
PEC boundaries, which make the FDTD simulation space into a cavity that resonates at certain
frequencies. Figure 6.4 shows the sampled voltage captured at the second port of this microstrip
filter. One can notice that, although the simulation is performed in 20,000 time steps, which

10
S11

−10
magnitude (dB)

−20

−30

−40

−50
0 5 10 15 20
frequency (GHz)

Figure 6.3 (a) S-parameters of the microstrip low-pass filter: S 11 .


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

S-Parameter Calculations 177

10
S21

−10
magnitude (dB)

−20

−30

−40

−50
0 5 10 15 20
frequency (GHz)

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

0.1
(volt)

0.05

−0.05

−0.1
0 2 4 6 8 10 12
time (ns)

Figure 6.4 Sampled voltage at the second port of the microstrip low-pass filter.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

178 Scattering Parameters

0.25
sampled voltage at port 2
0.2

0.15

0.1
(volt)

0.05

−0.05

−0.1
0 2 4 6 8 10 12
time (ns)

Figure 6.5 Sampled voltage at the second port of the microstrip low-pass filter with σ e = 0.2.

is a large number of time steps for this problem, the transient response still did not damp out.
This behavior exposes itself as spikes (numerical errors) in the S-parameter plots at different
frequencies as shown in Figs. 6.3. If the filter has slight loss, the attenuation will improve the
numerical errors, as the time-domain response will be diminishing (as shown in Fig. 6.5) for the
filter lossy dielectric substrate. Therefore, the truncation at a diminishing time-domain waveform
will not cause significant errors even though the cavity modes of the PEC closed box still exist.
This is clearly shown in Figs. 6.6(a) and 6.6(b). If the simulation had been performed such that
boundaries simulate open space, the simulation time would take less and the S-parameters results
would be clear of these spikes. Chapters 7 and 8 discuss algorithms that simulate open boundaries
for FDTD simulations.

6.3 SIMULATION EXAMPLES


6.3.1 Quarter-Wave Transformer
In this example the simulation of a microstrip quarter-wave transformer is presented. The geome-
try 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 defined as an absorber. The
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation Examples 179

10
S11

−10
magnitude (dB)

−20

−30

−40

−50
0 5 10 15 20
frequency (GHz)

Figure 6.6 (a) S-parameters of the microstrip low-pass filter with σ e = 0.2: S 11 .

10
S21

−10
magnitude (dB)

−20

−30

−40

−50
0 5 10 15 20
frequency (GHz)

Figure 6.6 (b) S-parameters of the microstrip low-pass filter with σ e = 0.2: S 21 .
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

180 Scattering Parameters

RL=100 Ω Absorber
Sampled voltage 2
Sampled current 2
z
y
x

Absorbers

Voltage source
Sampled voltage 1
Sampled current 1 4 mm 10 mm 4 mm

50 Ω line 70.7 Ω line 100 Ω line

10 mm
1 mm 0.4 mm
1.8 mm

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 five sides are surrounded by the absorber material. The definition of the relevant problem
space parameters and geometry are shown in Listing 6.6. The definition of the voltage source and
the resistor are shown in Listing 6.7. In the previous example, the sampled voltages and sampled
currents are defined on the microstrip lines away from the voltage source and the terminating
resistor. In this example the sampled voltages and sampled currents are defined on the voltage
source and the terminating resistor. Then the sampled voltages and currents are assigned to ports.
The definition of the output parameters is shown in Listing 6.8.
The FDTD simulation is run for 5,000 time steps, and the S-parameters of the simulation are
plotted in Fig. 6.8. The plotted S11 indicates that a good match has been obtained at 4 GHz.
Furthermore, the results are free of spikes, indicating that the absorbers used in the simulation
suppressed the cavity resonances. However, one should keep in mind that although the use of
absorbers improves the FDTD simulation results, it may introduce some other undesired errors
to the simulation results. In the following chapters, more advanced absorbing boundaries are
discussed that minimize these errors.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation Examples 181

magnitude (dB)
S11

−20

−40
0 1 2 3 4 5 6 7 8
frequency (GHz)
0
magnitude (dB)

S21
−0.5

−1

−1.5
0 1 2 3 4 5 6 7 8
frequency (GHz)

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

bricks = [ ] ;
4 spheres = [ ] ;

6 % define a b r i c k with material type 4


b r i c k s ( 1 ) . min x = 0 ;
8 b r i c k s ( 1 ) . min y = 0 ;
b r i c k s ( 1 ) . min z = 0 ;
10 b r i c k s ( 1 ) . max x = 10 e −3;
b r i c k s ( 1 ) . max y = 18 e −3;
12 b r i c k s ( 1 ) . max z = 1e −3;
bricks ( 1 ) . material type = 4;
14

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


16 b r i c k s ( 2 ) . m i n x = 4e −3;
b r i c k s ( 2 ) . min y = 0 ;
18 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;
20 b r i c k s ( 2 ) . max y = 4e −3;
b r i c k s ( 2 ) . max z = 1e −3;
22 bricks ( 2 ) . material type = 2;

24 % 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;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

182 Scattering Parameters

26 bricks (3). mi n y = 4e −3;


bricks (3). m i n z = 1e −3;
28 bricks (3). max x = 5 . 4 e −3;
bricks (3). max y = 14 e −3;
30 bricks (3). max z = 1e −3;
bricks (3). material type = 2;
32

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


34 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;
36 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;
38 b r i c k s ( 4 ) . max y = 18 e −3;
b r i c k s ( 4 ) . max z = 1e −3;
40 bricks ( 4 ) . material type = 2;

42 % d e f i n e a b s o r b e r f o r zp s i d e
b r i c k s ( 5 ) . m i n x = −1e −3;
44 b r i c k s ( 5 ) . mi n y = −2e −3;
b r i c k s ( 5 ) . m i n z = 3e −3;
46 b r i c k s ( 5 ) . max x = 11 e −3;
b r i c k s ( 5 ) . max y = 20 e −3;
48 b r i c k s ( 5 ) . max z = 4e −3;
bricks ( 5 ) . material type = 5;
50

% d e f i n e a b s o r b e r f o r xn s i d e
52 b r i c k s ( 6 ) . m i n x = −1e −3;
b r i c k s ( 6 ) . mi n y = −2e −3;
54 b r i c k s ( 6 ) . min z = 0 ;
b r i c k s ( 6 ) . max x = 0 ;
56 b r i c k s ( 6 ) . max y = 20 e −3;
b r i c k s ( 6 ) . max z = 4e −3;
58 bricks ( 6 ) . material type = 5;

60 % d e f i n e a b s o r b e r f o r xp s i d e
b r i c k s ( 7 ) . m i n x = 10 e −3;
62 b r i c k s ( 7 ) . mi n y = −2e −3;
b r i c k s ( 7 ) . min z = 0 ;
64 b r i c k s ( 7 ) . max x = 11 e −3;
b r i c k s ( 7 ) . max y = 20 e −3;
66 b r i c k s ( 7 ) . max z = 4e −3;
bricks ( 7 ) . material type = 5;
68

% d e f i n e a b s o r b e r f o r yn s i d e
70 b r i c k s ( 8 ) . m i n x = −1e −3;
b r i c k s ( 8 ) . mi n y = −2e −3;
72 b r i c k s ( 8 ) . min z = 0 ;
b r i c k s ( 8 ) . max x = 11 e −3;
74 b r i c k s ( 8 ) . max y = −1e −3;
b r i c k s ( 8 ) . max z = 4e −3;
76 bricks ( 8 ) . material type = 5;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation Examples 183

78 % d e f i n e a b s o r b e r f o r yp s i d e
b r i c k s ( 9 ) . m i n x = −1e −3;
80 b r i c k s ( 9 ) . mi n y = 19 e −3;
b r i c k s ( 9 ) . min z = 0 ;
82 b r i c k s ( 9 ) . max x = 11 e −3;
b r i c k s ( 9 ) . max y = 20 e −3;
84 b r i c k s ( 9 ) . max z = 4e −3;
bricks ( 9 ) . material type = 5;
 

Listing 6.7 define sources and lumped elements.m


voltage sources (1). m i n x = 4e −3;
24 voltage sources (1). min y = 0 ;
voltage sources (1). min z = 0 ;
26 voltage sources (1). max x = 5 . 8 e −3;
voltage sources (1). max y = 0 . 4 e −3;
28 voltage sources (1). max z = 1e −3;
voltage sources (1). d i r e c t i o n = ’ zp ’ ;
30 voltage sources (1). r e s i s t a n c e = 50;
voltage sources (1). magnitude = 1 ;
32 voltage sources (1). waveform type = ’ gaussian ’ ;
voltage sources (1). waveform index = 1;
34

resistors (1). m i n x = 4 . 8 e −3;


36 resistors (1). mi n y = 1 7 . 6 e −3;
resistors (1). min z = 0 ;
38 resistors (1). max x = 5 . 2 e −3;
resistors (1). max y = 18 e −3;
40 resistors (1). max z = 1e −3;
resistors (1). direction = ’z ’ ;
42 resistors (1). r e s i s t a n c e = 100;
 

Listing 6.8 define output parameters.m


% f r e q u e n c y domain p a r a m e t e r s
17 f r e q u e n c y d o m a i n . s t a r t = 2 e7 ;
f r e q u e n c y d o m a i n . end = 8 e9 ;
19 f r e q u e n c y d o m a i n . s t e p = 2 e7 ;

21 % define sampled voltages


sampled voltages ( 1 ) . m i n x = 4e −3;
23 sampled voltages ( 1 ) . min y = 0 ;
sampled voltages ( 1 ) . min z = 0 ;
25 sampled voltages ( 1 ) . max x = 5 . 8 e −3;
sampled voltages ( 1 ) . max y = 0 . 4 e −3;
27 sampled voltages ( 1 ) . max z = 1e −3;
sampled voltages ( 1 ) . d i r e c t i o n = ’ zp ’ ;
29 sampled voltages (1). display plot = false ;

31 % d e f i n e sampled v o l t a g e s
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

184 Scattering Parameters

sampled voltages (2). m i n x = 4 . 8 e −3;


33 sampled voltages (2). m i n y = 1 7 . 6 e −3;
sampled voltages (2). min z = 0 ;
35 sampled voltages (2). max x = 5 . 2 e −3;
sampled voltages (2). max y = 18 e −3;
37 sampled voltages (2). max z = 1e −3;
sampled voltages (2). d i r e c t i o n = ’ zp ’ ;
39 sampled voltages (2). display plot = false ;

41 % define sampled currents


sampled currents ( 1 ) . m i n x = 4e −3;
43 sampled currents ( 1 ) . min y = 0 ;
sampled currents ( 1 ) . m i n z = 0 . 4 e −3;
45 sampled currents ( 1 ) . max x = 5 . 8 e −3;
sampled currents ( 1 ) . max y = 0 . 4 e −3;
47 sampled currents ( 1 ) . max z = 0 . 6 e −3;
sampled currents ( 1 ) . d i r e c t i o n = ’ zp ’ ;
49 sampled currents (1). display plot = false ;

51 % define sampled currents


sampled currents ( 2 ) . m i n x = 4 . 8 e −3;
53 sampled currents ( 2 ) . m i n y = 1 7 . 6 e −3;
sampled currents ( 2 ) . m i n z = 0 . 4 e −3;
55 sampled currents ( 2 ) . max x = 5 . 2 e −3;
sampled currents ( 2 ) . max y = 18 e −3;
57 sampled currents ( 2 ) . max z = 0 . 6 e −3;
sampled currents ( 2 ) . d i r e c t i o n = ’ zp ’ ;
59 sampled currents (2). display plot = false ;

61 % define ports
ports ( 1 ) . sampled voltage index = 1;
63 ports ( 1 ) . sampled current index = 1;
ports ( 1 ) . impedance = 5 0 ;
65 ports ( 1 ) . is source port = true ;

67 ports (2). sampled voltage index = 2;


ports (2). sampled current index = 2;
69 ports (2). impedance = 1 0 0 ;
ports (2). is source port = false ;
 

6.4 EXERCISES

6.1 Consider the low-pass filter circuit in the example described in Section 6.2. Use the same
type of absorber as shown in the example in Section 6.3.1 to terminate the boundaries of the
low-pass filter circuit. Use absorbers with 5 cells thickness, and leave at least 5 cells air gap
between the circuit and the absorbers in the xn, xp, yn, and y p directions. Leave at least 10
cells air gap between the circuit and the absorbers in the zp direction. In the zn direction
the PEC boundary will serve as the ground plane of the circuit. The FDTD problem space
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Exercises 185

Figure 6.9 The problem space for the low-pass filter with absorbers on the x n, x p, yn, yp, and zp sides.

is illustrated in Fig. 6.9 as a reference. Rerun the simulation for 3,000 time steps, and verify
that the spikes in Fig. 6.3 due to cavity resonances are suppressed.
6.2 Consider the quarter-wave transformer circuit shown in Example 6.3.1. Redefine the voltage
source and the resistor such that voltage source will feed the 100 line and will have
100 internal resistance, while the resistor will terminate the 50 line and will have 50
resistance. Set Port 2 as the active port, and run the simulation. Obtain the figures plotting
S12 and S22 , and verify that they are similar to the S21 and S11 in Fig. 6.8, respectively.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

7
Perfectly Matched Layer Absorbing
Boundary

Because computational storage space is finite, the finite-difference time-domain (FDTD) prob-
lem space size is finite and needs to be truncated by special boundary conditions. In the previous
chapters we discussed some examples for which the problem space is terminated by perfect electric
conductor (PEC) boundaries. However, many applications, such as scattering and radiation prob-
lems, require the boundaries simulated as open space. The types of special boundary conditions
that simulate electromagnetic waves propagating continuously beyond the computational space
are called absorbing boundary conditions (ABCs). However, the imperfect truncation of the problem
space will create numerical reflections, which will corrupt the computational results in the problem
space after certain amounts of simulation time. So far, several various types of ABCs have been
developed. However, the perfectly matched layer (PML) introduced by Berenger [15,16] has been
proven to be one of the most robust ABCs [17,18,19,20] in comparison with other techniques
adopted in the past. PML is a finite-thickness special medium surrounding the computational
space based on fictitious constitutive parameters to create a wave-impedance matching condition,
which is independent of the angles and frequencies of the wave incident on this boundary. The
theory and implementation of the PML boundary condition are illustrated in this chapter.

7.1 THEORY OF PML


In this section we demonstrate analytically the reflectionless characteristics of PML at the vacuum–
PML and PML–PML interfaces [15] in detail.

7.1.1 Theory of PML at the Vacuum-PML Interface


We provide the analysis of reflection at a vacuum–PML 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 field components that exist in the two-
dimensional space. These field components can be expressed in the time-harmonic domain as

E x = −E0 sin φ0 e j ω(t−αx−βy) , (7.1a)


j ω(t−αx−βy)
E y = E0 cos φ0 e , (7.1b)
Hz = H0 e j ω(t−αx−βy) . (7.1c)

187
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

188 Perfectly Matched Layer

E Ey
φ0 k̂

Ex Hz
Figure 7.1 The field decomposition of a T E z polarized plane wave.

Maxwell’s equations for a TEz polarized wave are

∂ Ex ∂ Hz
ε0 + σ e Ex = , (7.2a)
∂t ∂y
∂ Ey ∂ Hz
ε0 + σ e Ey = − , (7.2b)
∂t ∂x
∂ Hz ∂ Ex ∂ Ey
µ0 + σ m Hz = − . (7.2c)
∂t ∂y ∂x

In a T E z PML medium, Hz can be broken into two artificial components associated with the x
and y directions as

Hzx = Hzx0 e − j ωβy e j ω(t−αx) , (7.3a)


Hzy = Hzy0 e − j ωαx e j ω(t−βy) , (7.3b)

where Hz = Hzx + Hzy . Therefore, a modified set of Maxwell’s equations for a T E z polarized
PML medium can be expressed as

∂ Ex ∂(Hzx + Hzy )
ε0 + σ pe y E x = , (7.4a)
∂t ∂y
∂ Ey ∂(Hzx + Hzy )
ε0 + σ pe x E y = − , (7.4b)
∂t ∂x
∂ Hzx ∂ Ey
µ0 + σ pmx Hzx = − , (7.4c)
∂t ∂x
∂ Hzy ∂ Ex
µ0 + σ pmy Hzy = , (7.4d)
∂t ∂y

where σ pe x , σ pe y , σ pmx , and σ pmy are the introduced fictitious conductivities. With the given
conductivities the PML medium described by (7.4) is an anisotropic medium. When σ pmx =
σ pmy = σ m , merging (7.4c) and (7.4d) yields (7.2c). Field components E y and Hzx together can
represent a wave propagating in the x direction, and field components of E x and Hzy represent a
wave propagating in the y direction. Substituting the field equations for the x and y propagating
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Theory of PML 189

waves in (7.1a), (7.1b), (7.3a), and (7.3b) into the modified Maxwell’s equations given, one can
obtain

σ pe y
ε0 E0 sin φ0 − j E0 sin φ0 = β(Hzx0 + Hzy0 ), (7.5a)
ω
σ pe x
ε0 E0 cos φ0 − j E0 cos φ0 = α(Hzx0 + Hzy0 ), (7.5b)
ω
σ pmx
µ0 Hzx0 − j Hzx0 = α E0 cos φ0 , (7.5c)
ω
σ pmy
µ0 Hzy0 − j Hzy0 = β E0 sin φ0 . (7.5d)
ω

Using equations (7.5c) and (7.5d) to eliminate magnetic field terms from equations (7.5a) and
(7.5b) yields

   
σ pe y α cos φ0 β sin φ0
ε0 µ0 1− j sin φ0 = β    +    , (7.6a)
ε0 ω 1 − j σ pmx /µ0 ω 1 − j σ pmy /µ0 ω
   
σ pe x α cos φ0 β sin φ0
ε0 µ0 1 − j cos φ0 = α    +    . (7.6b)
ε0 ω 1 − j σ pmx /µ0 ω 1 − j σ pmy /µ0 ω

The unknown constants α and β can be obtained from (7.6a) and (7.6b) as
√  
µ0 ε0 σ pe x
α= 1− j cos φ0 , (7.7a)
G ωε0
√  
µ0 ε0 σ pe y
β= 1− j sin φ0 , (7.7b)
G ωε0

where

G= wx cos2 φ0 + w y sin2 φ0 , (7.8)

and

1 − j σ pe x /ωε0 1 − j σ pe y /ωε0
wx = , wy = , (7.9)
1 − j σ pmx /ωµ0 1 − j σ pmy /ωµ0

Therefore, the generalized field component can be expressed as


 
x cos φ0 +y sin φ0 σ cos φ σ sin φ
j ω t− − peεx c G 0 x − peεy c G 0 y
ψ = ψ0 e cG
e 0 e 0 , (7.10)

where the first exponential represents the phase of a plane wave and the second and third expo-
nentials govern the decrease in the magnitude of the wave along the x axis and y axis, respectively.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

190 Perfectly Matched Layer

Once α and β are determined by (7.7), the split magnetic field can be determined from (7.5c) and
(7.5d) as

ε0 wx cos2 φ0
Hzx0 = E0 , (7.11a)
µ0 G

ε0 w y sin2 φ0
Hzy0 = E0 . (7.11b)
µ0 G

The magnitude of the total magnetic field Hz is then given as



ε0
H0 = Hzx0 + Hzy0 = E0 G. (7.12)
µ0

The wave impedance in a T E z PML medium can be expressed as



E0 µ0 1
Z= = . (7.13)
H0 ε0 G

It is important to note that if the conductivity parameters are chosen such that
σ pe x σ pmx σ pe y σ pmy
= and = , (7.14)
ε0 µ0 ε0 µ0

then the term G becomes equal to unity as wx and w y becomes equal to unity. Therefore, the
wave impedance of this PML medium becomes the same as that of the interior free space. In
other words, when the constitutive conditions of (7.14) are satisfied, a T E z polarized wave can
propagate from free space into the PML medium without reflection for all frequencies, and all
incident angles as can be concluded from (7.8). One should notice that, when the electric and
magnetic losses are assigned to be zero, the field updating equation (7.4) for the PML region
becomes that of a vacuum region.

7.1.2 Theory of PML at the PML–PML Interface


The reflection of fields 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 reflection coefficient

σ pex1 , σ pmx1 σ pex 2 , σ pmx 2


σ pey1 , σ pmy1 σ pey 2 , σ pmy 2

φ2
φ1

y
x

Figure 7.2 The plane wave transition at the interface between two PML media.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Theory of PML 191

for an arbitrary incident wave between two lossy media can be expressed as

Z2 cos φ2 − Z1 cos φ1
rp = , (7.15)
Z2 cos φ2 + Z1 cos φ1

where Z1 and Z2 are the intrinsic impedances of respective mediums. Applying (7.13), the reflection
coefficient r p becomes

G1 cos φ2 − G2 cos φ1
rp = . (7.16)
G1 cos φ2 + G2 cos φ1

The Snell-Descartes law at the interface normal to x of two lossy media can be described as
   
σ y1 sin φ1 σ y2 sin φ2
1−i = 1−i . (7.17)
ε0 ω G1 ε0 ω G2

When the two media have the same conductivities σ pe y1 = σ pe y2 = σ pe y and σ pmy1 = σ pmy2 = σ pmy ,
(7.17) becomes

sin φ1 sin φ2
= . (7.18)
G1 G2

Moreover, when (σ pe x1 , σ pmx1 ), (σ pe x2 , σ pmx2 ), and (σ pe y , σ pmy ) satisfy the matching condition in
equation (7.14), G1 = G2 = 1. Then (7.18) reduces to φ1 = φ2 , and equation (7.16) reduces to
r p = 0. Therefore, theoretically when two PML media satisfy (7.14) and lie at an interface normal
to the x axis with the same (σ pe y , σ pmy ), a wave can transmit through this interface with no
reflections, at any angle of incidence and any frequency. When (σ pe x1 , σ pmx1 , σ pe y1 , σ pmy1 ) are
assigned to be (0, 0, 0, 0), the PML medium 1 becomes a vacuum. Therefore, when (σ pe x2 , σ pmx2 )
satisfies (7.14), the reflection coefficient at this interface is also null, which agrees with the previous
vacuum–PML analysis. However, if the two media have the same (σ pe y , σ pmy ) but do not satisfy
(7.14), then the reflection coefficient becomes

sin φ1 cos φ2 − sin φ2 cos φ1


rp = . (7.19)
sin φ1 cos φ2 + sin φ2 cos φ1

Substituting (7.18) into equation (7.19), the reflection coefficient of two unmatched PML media
becomes
√ √
wx1 − wx2
rp = √ √ . (7.20)
wx1 + wx2

Equation (7.20) shows that the reflection coefficient for two unmatched PML media is highly
dependent on frequency, regardless of the incident angle. When the two PML media follow the
reflectionless condition in (7.14), wx1 = wx2 = 1, the reflection coefficient becomes null.
The analysis can be applied to two PML media lying at the interface normal to the y axis as
well. The Snell-Descartes law related to this interface is
   
σx1 sin φ1 σx2 sin φ2
1−i = 1−i . (7.21)
ε0 ω G1 ε0 ω G2
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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 reflection coefficient at this interface is r p = 0. To match the vacuum–PML interface normal
to the y axis, the reflectionless condition can be achieved when (σ pe y2 , σ pmy2 ) of the PML medium
satisfies (7.14).
Based on the previous discussion, if a two-dimensional FDTD problem space is attached with an
adequate thickness of PML media as shown in Fig. 7.3, the outgoing waves will be absorbed without
any undesired numerical reflections. The PML regions must be assigned appropriate conductivity
values satisfying the matching condition (7.14); the positive and negative x boundaries of the PML
regions have nonzero σ pe x , and σ pmx , whereas the positive and negative y boundaries of the PML
regions have nonzero σ pe y , and σ pmy values. The coexistence of nonzero values of σ pe x , σ pmx , σ pe y ,
and σ pmy is required at the four corner PML overlapping regions. Using a similar analysis, the
conditions of (7.14) can be applied to a T Mz polarized wave to travel from free space to PML
and from PML to PML without reflection [21]. Using the same impedance matching condition
in (7.14), the modified Maxwell’s equations for two-dimensional T Mz PML updating equations
are obtained as

∂ E zx ∂ Hy
ε0 + σ pe x E zx = , (7.22a)
∂t ∂x

∂ E zy ∂ Hx
ε0 + σ pe y E zy = − , (7.22b)
∂t ∂y
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Three-Dimensional PML 193

∂ Hx ∂(E zx + E zy )
µ0 + σ pmy Hx = − , (7.22c)
∂t ∂y
∂ Hy ∂(E zx + E zy )
µ0 + σ pmx Hy = . (7.22d)
∂t ∂x

The finite difference approximation schemes can be applied to the modified Maxwell’s equations
(7.4) and (7.22) to obtain the field-updating equations for the PML regions in the two-dimensional
FDTD problem space.

7.2 PML EQUATIONS FOR THREE-DIMENSIONAL PROBLEM SPACE

For a three-dimensional problem space, each field component of the electric and magnetic fields
is broken into two field components similar to the two-dimensional case. Therefore, the modified
Maxwell’s equations have 12 field components instead of the original six components. These
modified split electric field equations presented in [16] are

∂ E xy ∂(Hzx + Hzy )
ε0 + σ pe y E xy = , (7.23a)
∂t ∂y
∂ E xz ∂(Hy x + Hy z )
ε0 + σ pe z E xz = − , (7.23b)
∂t ∂z
∂ Eyx ∂(Hzx + Hzy )
ε0 + σ pe x E y x = − , (7.23c)
∂t ∂x
∂ Eyz ∂(Hxy + Hxz )
ε0 + σ pe z E y z = , (7.23d)
∂t ∂z
∂ E zx ∂(Hy x + Hy z )
ε0 + σ pe x E zx = , (7.23e)
∂t ∂x
∂ E zy ∂(Hxy + Hxz )
ε0 + σ pe y E zy = − , (7.23f)
∂t ∂y

whereas the modified Maxwell’s split magnetic field equations are

∂ Hxy ∂(Ezx + Ezy )


µ0 + σ pmy Hxy = − , (7.24a)
∂t ∂y
∂ Hxz ∂(E y x + E y z )
µ0 + σ pmz Hxz = , (7.24b)
∂t ∂z
∂ Hy z ∂(E xy + E xz )
µ0 + σ pmz Hy z = − , (7.24c)
∂t ∂z
∂ Hy x ∂(E zx + E zy )
µ0 + σ pmx Hy x = , (7.24d)
∂t ∂x
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

194 Perfectly Matched Layer

∂ Hzy ∂(E xy + E xz )
µ0 + σ pmy Hzy = , (7.24e)
∂t ∂y
∂ Hzx ∂(E y x + E y z )
µ0 + σ pmx Hzx = − . (7.24f)
∂t ∂x

Then the matching condition for a three-dimensional PML is given by

σ pe x σ pmx σ pe y σ pe y σ pe z σ pmz
= , = , and = . (7.25)
ε0 µ0 ε0 µ0 ε0 µ0

If a three-dimensional FDTD problem space is attached with adequate thickness of PML media
as shown in Fig. 7.4, the outgoing waves will be absorbed without any undesired numerical

(a) Nonzero σ pex and σ pmx (b) Nonzero σ pey and σ pmy

(c) Nonzero σ pez and σ pmz (d) Overlapping PML regions

Figure 7.4 Nonzero regions of PML conductivities for a three-dimensional FDTD simulation domain.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

PML Loss Functions 195

reflections. The PML regions must be assigned appropriate conductivity values satisfying the
matching condition (7.25); the positive and negative x boundaries of PML regions have nonzero
σ pe x and σ pmx , the positive and negative y boundaries of PML regions have nonzero σ pe y and σ pmy ,
and the positive and negative z boundaries of PML regions have nonzero σ pe z and σ pmz values as
illustrated in Fig. 7.4. The coexistence of nonzero values of σ pe x , σ pmx , σ pe y , σ pmy , σ pe z , and σ pmz
is required at the PML overlapping regions.
Finally, applying the finite difference schemes to the modified Maxwell’s equations (7.23) and
(7.24), one can obtain the FDTD field updating equations for the three-dimensional PML regions.

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 specific conductivities are assigned such that the outgoing waves penetrate
without reflection and attenuate while traveling in the PML medium. The PML medium is
governed by the modified Maxwell’s equations (7.4), (7.22), (7.23), and (7.24), which can be used
to obtain the updating equations for the field components in the PML regions. Furthermore, the
outer boundaries of the PML regions are terminated by PEC walls. When a finite-thickness PML
medium backed by a PEC wall is adopted, an incident plane wave may not be totally attenuated
within the PML region, and small reflections to the interior domain from the PEC back wall may
occur. For a finite-width PML medium where the conductivity distribution is uniform, there is
an apparent reflection coefficient, which is expressed as

σ cos φ0
−2 δ
R(φ0 ) = e ε0 c
, (7.26)

where σ is the conductivity of the medium. Here the exponential term is the attenuation factor
of the field magnitudes of the plane waves as shown in equation (7.10), and δ is the thickness of
the PML medium. The factor 2 in the exponent is due to the travel distance, which is twice the
distance between the vacuum–PML interface and the PEC backing. If φ0 is 0, equation (7.26) is
the reflection coefficient for a finite-thickness PML medium at normal incidence. If φ0 is π/2, the
incident plane wave is grazing to the PML medium and is attenuated by the perpendicular PML
medium. From (7.26), the effectiveness of a finite-width PML is dependent on the losses within
the PML medium. In addition, (7.26) can be used not only to predict the ideal performance of a
finite-width PML medium but also to compute the appropriate loss distribution based on the loss
profiles described in the following paragraphs.
As presented in [15], significant reflections were observed when constant uniform losses are
assigned throughout the PML media, which is a result of the discrete approximation of fields and
material parameters at the domain–PML interfaces and sharp variation of conductivity profiles.
This mismatch problem can be tempered using a spatially gradually increasing conductivity distri-
bution, which is zero at the domain–PML interface and tends to be a maximum conductivity σmax
at the end of the PML region. In [18] two major types of mathematical functions are proposed as
the conductivity distributions or loss profiles: power and geometrically increasing functions. The
power-increasing function is defined as
 ρ n pml
σ (ρ) = σmax , (7.27a)
δ
 
n pml + 1 ε0 c ln(R(0))
σmax = − , (7.27b)
2s N
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

196 Perfectly Matched Layer

where ρ is the distance from the computational domain–PML interface to the position of the field
component, and δ is the thickness of the PML cells. The parameter N is the number of PML cells,
s is the cell size used for a PML cell, and R(0) is the reflection coefficient of the finite-width
PML medium at normal incidence. The distribution function is linear for n pml = 1 and parabolic
for n pml = 2. To determine the conductivity profile using (7.27a) the parameters R(0) and n pml
must be predefined. These parameters are used to determine σmax using (7.27b), which is then
used in the calculation of σ (ρ). Usually n pml takes a value such as 2, 3, or 4 and R(0) takes a very
small value such as 10−8 for a satisfactory PML performance.
The geometrically increasing distribution for σ (ρ) is given by
ρ
σ (ρ) = σ0 g s , (7.28a)
ε0 c ln(g)
σ0 = − ln(R(0)), (7.28b)
2s g N − 1

where the parameter g is a real number used for a geometrically increasing function.

7.4 FDTD UPDATING EQUATIONS FOR PML AND MATLAB IMPLEMENTATION


7.4.1 PML Updating Equations—Two-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 modified Maxwell’s equations (7.4). After
some manipulations one can obtain the two-dimensional T E z PML updating equations based on
the field 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

2ε0 − tσ pe y (i, j )


Ce xe (i, j ) = ,
2ε0 + tσ pe y (i, j )
2t
Ce xhz (i, j ) =   .
2ε0 + tσ pe
e (i, j ) y
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

2ε0 − tσ pe x (i, j )


Ce ye (i, j ) = ,
2ε0 + tσ pe x (i, j )
2t
Ce yhz (i, j ) = −   .
2ε0 + 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)
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

PML Updating Equations 197

where
2µ0 − tσ pmx (i, j )
C hzxh (i, j ) = ,
2µ0 + tσ pmx (i, j )
2t
C hzxe y (i, j ) = −   .
2µ0 + tσ pmx (i, j ) x

n+ 1 n− 1  
Hzy 2 (i, j ) = C hzyh (i, j ) × Hzy 2 (i, j ) + C hzye x (i, j ) × E xn (i, j + 1) − E xn (i, j ) , (7.32)

where
2µ0 − tσ pmy (i, j )
C hzyh (i, j ) = ,
2µ0 + tσ pmy (i, j )
2t
C hzye x (i, j ) =   .
2µ0 + tσ pmy (i, j ) y

One should recall that Hz (i, j ) = Hzx (i, j ) + Hzy (i, j ). As illustrated in Fig. 7.3 certain PML
conductivities are defined at certain regions. Therefore, each of the equations (7.29)–(7.32) is
applied in a two-dimensional problem space where its respective PML conductivity is defined.
Figure 7.5 shows the PML regions where the conductivity parameters are nonzero and the
respective field components that need to be updated at each region. Figure 7.5(a) shows the
regions where σ pe x is defined. These regions are denoted as xn and xp. One can notice from (7.4b)
and (7.30) that σ pe x appears in the equation where E y is updated. Therefore, the components of E y
lying in the xn and xp regions are updated at every time step using (7.30). The other components
of E y that are located in the intermediate region can be updated using the regular non-PML
updating equation (1.34). Similarly, σ pe y is nonzero in the regions that are denoted as yn and y p
in Fig. 7.5(b). The components of E x lying in the yn and y p regions are updated at every time
step using (7.29), and the components located in the intermediate region are updated using the
regular non-PML updating equation (1.33).
Since the magnetic field Hz is the sum of two split fields Hzx and Hzy in the PML regions, its
update is more complicated. The PML regions and non-PML regions are shown in Figs. 7.5(c) and
7.5(d), where the PML regions are denoted as xn, xp, yn, and y p. The magnetic field components
of Hz lying in the non-PML region can be updated using the regular updating equation (1.35).
However, the components of Hz in the PML regions are not directly calculated; the components
of Hzx and Hzy are calculated in the PML regions using the appropriate updating equations, and
then they are summed up to yield Hz in the PML region. The conductivity σ pmx is nonzero in
the xn and xp regions as shown in Fig. 7.5(c). The components of Hzx are calculated in the same
regions using (7.31). However, components of Hzx need to be calculated in the yn and y p regions
as well. Since σ pmx is zero in these regions setting σ pmx zero in (7.31) will yield the required
updating equation for Hzx in the yn and y p regions as

n+ 1 n− 1  
Hzx 2 (i, j ) = C hzxh (i, j ) × Hzx 2 (i, j ) + C hzxe y (i, j ) × E yn (i + 1, j ) − E yn (i, j ) , (7.33)

where
t
C hzxh (i, j ) = 1, C hzxe y (i, j ) = − .
µ0 x
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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

where

t
C hzyh (i, j ) = 1, C hzye x (i, j ) = .
µ0 y
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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 Equations—Two-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 modified Maxwell’s equations (7.22).
After some manipulations one can obtain the two-dimensional T Mz PML updating equations
based on the field positioning scheme given in Fig. 1.11 as
 n+ 1 n+ 1

n+1
E zx (i, j ) = Ce zxe (i, j ) × E zx
n
(i, j ) + Ce zxhy (i, j ) × Hy 2 (i, j ) − Hy 2 (i − 1, j ) , (7.35)

where
2ε0 − tσ pe x (i, j )
Ce zxe (i, j ) = ,
2ε0 + tσ pe x (i, j )
2t
Ce zxhy (i, j ) =   .
2ε0 + tσ pe x (i, j ) x

 n+ 1 n+ 1

n+1
E zy (i, j ) = Ce zye (i, j ) × E zn (i, j ) + Ce zyhx (i, j ) × Hx 2 (i, j ) − Hx 2 (i, j − 1) , (7.36)

where
2ε0 (i, j ) − tσ pe y (i, j )
Ce zye (i, j ) = ,
2ε0 (i, j ) + tσ pe y (i, j )
2t
Ce zyhx (i, j ) = −   .
2ε0 + tσ pe y (i, j ) y

n+ 12 n− 12  
Hx (i, j ) = C hxh (i, j ) × Hx (i, j ) + C hxe z (i, j ) × E zn (i, j + 1) − E zn (i, j ) , (7.37)

where
2µ0 − tσ pmy (i, j )
C hxh (i, j ) = ,
2µ0 + tσ pmy (i, j )
2t
C hxe z (i, j ) = −   .
2µ0 + tσ pmy (i, j ) y

n+ 12 n− 12  
Hy (i, j ) = C hyh (i, j ) × Hy (i, j ) + C hye z (i, j ) × E zn (i + 1, j ) − E zn (i, j ) , (7.38)

where
2µ0 − tσ pmx (i, j )
C hyh (i, j ) = ,
2µ0 + tσ pmx (i, j )
2t
C hye z (i, j ) =   .
2µ0 + tσ pmx (i, j ) x
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

200 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 defined in the regions denoted as xn
and xp. Therefore, components of Hy lying in these regions are updated at every time step using
the PML updating equation (7.38). The components of Hy lying in the intermediate region are
updated using the regular updating equation (1.38). The conductivity σ pmy is nonzero in the yn
and y p regions shown in Fig. 7.6(b); therefore, the components of Hx lying in the yn and y p
regions are updated using the PML updating equation (7.37). The components of Hx lying in the
intermediate region are updated using the regular updating equation (1.37).
The components of E z are the sum of two split fields E zx and E zy in all of the PML regions xn,
xp, yn, and y p as illustrated in Figs. 7.6(c) and 7.6(d). The components of E z in the intermediate
non-PML region are updated using the regular updating equation (1.36). The conductivity σ pe x
is nonzero in the xn and xp regions as shown in Fig. 7.6(c); therefore, components of E zx in these
regions are updated using (7.35). Furthermore, the components of E zx in the yn and y p regions
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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
E zx (i, j ) = Ce zxe (i, j ) × E zx
n
(i, j ) + Ce zxhy (i, j ) × Hy 2 (i, j ) − Hy 2 (i − 1, j ) , (7.39)

where

t
Ce zxe (i, j ) = 1, Ce zxhy (i, j ) = .
ε0 x

Similarly, σ pe y is nonzero in the yn and y p regions as shown in Fig. 7.6(d); therefore, components
of E zy in these regions are updated using (7.36). Furthermore, the components of E zy in the xn
and xp regions need to be calculated as well. Since σ pe y is zero in these regions, setting σ pe y to
zero in (7.36) yields the updating equation for E zy in the xn and xp regions as
 n+ 1 n+ 1

n+1
E zy (i, j ) = Ce zye (i, j ) × E zn (i, j ) + Ce zyhx (i, j ) × Hx 2 (i, j ) − Hx 2 (i, j − 1) , (7.40)

where

t
Ce zye (i, j ) = 1, Ce zyhx (i, j ) = − .
ε0 y

After all the components of E zx and E zy are updated in the PML regions, they are added to
calculate E z .

7.4.3 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 definition, ini-
tialization, 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 correspond-
ing details are provided only when necessary.

7.4.3.1 Definition of the Two-Dimensional FDTD Problem The types of boundaries surrounding
the problem space are defined in the subroutine define problem space parameters 2d, a partial
code of which is shown in Listing 7.2. Here if a boundary on one side is defined as PEC, the variable
boundary.type takes the value ‘pec’, whereas for PML it takes the value ‘pml’. The parameter
air buffer number of cells determines the distance in number of cells between the objects in the
problem space and the boundaries, whether PEC or PML. The parameter pml number of cells
determines the thickness of the PML regions in number of cells. In this implementation the power
increasing function (7.27a) is used for the PML conductivity distributions along the thickness of
the PML regions. Two additional parameters are required for the PML, the theoretical reflection
coefficient (R(0)) and the order of PML (n pml ), as discussed in Section 7.3. These two parameters
are defined as boundary.pml R 0 and boundary.pml order, respectively.
In the subroutine define geometry 2d two-dimensional geometrical objects such as circles and
rectangles can be defined by their coordinates, sizes, and material types.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

202 Perfectly Matched Layer

Listing 7.1 fdtd solve 2d.m



% i n i t i a l i z e the matlab workspace
2 clear all ; close all ; clc ;

4 % d e f i n e t h e problem
define problem space parameters 2d ;
6 define geometry 2d ;
define sources 2d ;
8 define output parameters 2d ;

10 % i n i t i a l i z e t h e problem s p a c e and p a r a m e t e r s
initialize fdtd material grid 2d ;
12 initialize fdtd parameters and arrays 2d ;
initialize sources 2d ;
14 initialize updating coefficients 2d ;
initialize boundary conditions 2d ;
16 initialize output parameters 2d ;
initialize display parameters 2d ;
18

% draw t h e o b j e c t s i n t h e problem s p a c e
20 draw objects 2d ;

22 % FDTD t i m e m a r c h i n g l o o p
run fdtd time marching loop 2d ;
24

% display simulation results


26 post process and display results 2d ;
 

The sources exciting the two-dimensional problem space are defined in the subroutine define -
sources 2d. Unlike the three-dimensional case, in this implementation the impressed current
sources are defined as sources explicitly as shown in Listing 7.3.
Outputs of the program are defined in the subroutine define output parameters 2d. In this
implementation the output parameters are sampled electric fields and sampled magnetic -
fields captured at certain positions.
7.4.3.2 Initialization of the Two-Dimensional FDTD Problem The steps of the initialization process
are shown in Listing 7.1. This process starts with the subroutine initialize fdtd material grid -
2d. In this subroutine the first task is the calculation of the dimensions of the two-dimensional
problem space and the number of cells nx and ny in the x and y dimensions, respectively. If some
of the boundaries are defined as PML, the PML regions are also included in the problem space.
Therefore, nx and ny include the PML number of cells as well. Then the material component
arrays of the two-dimensional problem space are constructed using the material averaging schemes
that were discussed in Section 3.2. Next, while creating the material grid, the PML regions are
assigned free-space parameters. At this point the PML regions are treated as if they are free-space
regions; however, later PML conductivity parameters are assigned to these regions, and special
updating equations are used to update fields in these regions. Furthermore, new parameters are
defined and assigned appropriate values as n pml xn, n pml xp, n pml yn, and n pml yp to hold
the numbers of cells for the thickness of the PML regions. Four logical parameters, is pml xn,
is pml xp, is pml yn, and is pml yp, are defined to indicate whether the respective side of the
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

PML Updating Equations 203

Listing 7.2 define problem space parameters 2d.m



% ==<b o u n d a r y c o n d i t i o n s >========
18 % 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
20 % ’ pml ’ : p e r f e c t l y matched l a y e r

22 b o u n d a r y . t y p e x n = ’ pml ’ ;
boundary . a i r b u f f e r n u m b e r o f c e l l s x n = 10;
24 boundary . p m l n u m b e r o f c e l l s x n = 5 ;

26 b o u n d a r y . t y p e x p = ’ pml ’ ;
boundary . a i r b u f f e r n u m b e r o f c e l l s x p = 10;
28 boundary . p m l n u m b e r o f c e l l s x p = 5 ;

30 b o u n d a r y . t y p e y n = ’ pml ’ ;
boundary . a i r b u f f e r n u m b e r o f c e l l s y n = 10;
32 boundary . p m l n u m b e r o f c e l l s y n = 5 ;

34 b o u n d a r y . t y p e y p = ’ pml ’ ;
boundary . a i r b u f f e r n u m b e r o f c e l l s y p = 10;
36 boundary . p m l n u m b e r o f c e l l s y p = 5 ;

38 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 October 13, 2009 14:16

204 Perfectly Matched Layer

Listing 7.3 define sources 2d.m



disp ( ’ defining sources ’ ) ;
2

impressed J = [ ] ;
4 impressed M = [ ] ;

6 % d e f i n e s o u r c e waveform t y p e s and p a r a m e t e r s
waveforms . g a u s s i a n ( 1 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 0 ;
8 waveforms . g a u s s i a n ( 2 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 15;

10 % electric current sources


% direction : ’ xp ’ , ’ xn ’ , ’ yp ’ , ’ yn ’ , ’ zp ’ , o r ’ zn ’
12 impressed J ( 1 ) . m i n x = −0.1 e −3;
impressed J ( 1 ) . m i n y = −0.1 e −3;
14 impressed J ( 1 ) . max x = 0 . 1 e −3;
impressed J ( 1 ) . max y = 0 . 1 e −3;
16 impressed J ( 1 ) . d i r e c t i o n = ’ zp ’ ;
impressed J ( 1 ) . magnitude = 1 ;
18 impressed J ( 1 ) . waveform type = ’ gaussian ’ ;
impressed J ( 1 ) . waveform index = 1;
20

% % magnetic c u r r e n t s o u r c e s
22 % % d i r e c t i o n : ’ xp ’ , ’ xn ’ , ’ yp ’ , ’ yn ’ , ’ zp ’ , o r ’ zn ’
% i m p r e s s e d M ( 1 ) . m i n x = −0.1 e −3;
24 % i m p r e s s e d M ( 1 ) . m i n y = −0.1 e −3;
% i m p r e s s e d M ( 1 ) . max x = 0 . 1 e −3;
26 % i m p r e s s e d M ( 1 ) . max y = 0 . 1 e −3;
% i m p r e s s e d M ( 1 ) . d i r e c t i o n = ’ zp ’ ;
28 % impressed M ( 1 ) . magnitude = 1 ;
% impressed M ( 1 ) . waveform type = ’ gaussian ’ ;
30 % impressed M ( 1 ) . waveform index = 1;
 

The subroutine initialize fdtd parameters and arrays 2d includes the definition of some pa-
rameters such as ε0 , µ0 , c , and t that are required for the FDTD calculation and definition and
initialization of field arrays Ex, Ey, Ez, Hx, Hy, and Hz. The field arrays are defined for all the
problem space including the PML regions.
In the subroutine initialize sources 2d the indices indicating the positions of the impressed
electric and magnetic currents are determined and stored as the subfields of the respective param-
eters impressed J and impressed M. Since the impressed currents are used as explicit sources,
their source waveforms are also computed. A two-dimensional problem can have two modes of
operation as T E and T M. The mode of operation is determined by the sources. For instance, an
impressed electric current Ji z excites Ez fields in the problem space, thus giving rise to a T Mz
operation. Similarly, impressed magnetic currents Mi x and Mi y also give rise to T Mz operation.
The impressed currents Mi z , Ji x , and Ji y give rise to T E z operation. Therefore, the mode of
operation is determined by the impressed currents as shown in Listing 7.4, which includes the
partial code of initialize sources 2d. Here a logical parameter is TEz is defined to indicate that
the mode of operation is T E z , whereas another logical parameter is TMz is defined to indicate
that the mode of operation is T Mz .
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

PML Updating Equations 205

Listing 7.4 initialize sources 2d.m


% d e t e r m i n e i f T E z o r TMz
60 is TEz = false ;
is TMz = f a l s e ;
62 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 )
64 case ’ x ’
is TEz = true ;
66 case ’ y ’
is TEz = true ;
68 case ’ z ’
is TMz = true ;
70 end
end
72 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 )
74 case ’ x ’
is TMz = true ;
76 case ’ y ’
is TMz = true ;
78 case ’ z ’
is TEz = true ;
80 end
end
 

The regular updating coefficients of the two-dimensional FDTD method are calculated in
the subroutine initialize updating coefficients 2d based on the updating equations (1.33)–(1.38),
including the impressed current coefficients as well.
Some coefficients and field arrays need to be defined and initialized for the application of
the PML boundary conditions. The PML initialization process is performed in the subrou-
tine initialize boundary conditions 2d, which is shown in Listing 7.5. The indices of the nodes

Listing 7.5 initialize boundary conditions 2d.m


1 disp ( ’ i n i t i a l i z i n g boundary c o n d i t i o n s ’ ) ;

3 % d e t e r m i n e t h e b o u n d a r i e s o f t h e non−pml r e g i o n
p i s = n p m l x n +1;
5 p i e = nx−n p m l x p +1;
p j s = n p m l y n +1;
7 p j e = ny−n p m l y p +1;

9 if is any side pml


if is TEz
11 initialize pml boundary conditions 2d TEz ;
end
13 i f is TMz
initialize pml boundary conditions 2d TMz ;
15 end
end
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

206 Perfectly Matched Layer

Listing 7.6 initialize pml boundary conditions 2d TEz.m


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

4 Hzx xn = zeros ( n pml xn , ny ) ;


Hzy xn = zeros ( n pml xn , ny−n pml yn −n p m l y p ) ;
6 Hzx xp = zeros ( n pml xp , ny ) ;
Hzy xp = zeros ( n pml xp , ny−n pml yn −n p m l y p ) ;
8 Hzx yn = zeros ( nx−n pml xn −n pml xp , n p m l y n ) ;
Hzy yn = zeros ( nx , n p m l y n ) ;
10 Hzx yp = zeros ( nx−n pml xn −n pml xp , n p m l y p ) ;
Hzy yp = zeros ( nx , n p m l y p ) ;
12

pml order = boundary . pml order ;


14 R 0 = boundary . pml R 0 ;

16 i f is pml xn
s i g m a p e x x n = z e r o s ( n pml xn , ny ) ;
18 s i g m a p m x x n = z e r o s ( n pml xn , ny ) ;

20 sigma max = −( p m l o r d e r + 1 ) * e p s 0 * c * l o g ( R 0 ) / ( 2 * dx * n p m l x n ) ;
rho e = ( [ n pml xn : −1:1] − 0 . 7 5 ) / n pml xn ;
22 rho m = ( [ n p m l x n : − 1 : 1 ] − 0 . 2 5 ) / n p m l x n ;
f o r ind = 1: n pml xn
24 s i g m a p e x x n ( ind , : ) = sigma max * r h o e ( i n d ) ˆ p m l o r d e r ;
s i g m a p m x x n ( ind , : ) = . . .
26 ( mu 0 / e p s 0 ) * sigma max * rho m ( i n d ) ˆ p m l o r d e r ;
end
28

% C o e f f i e c i e n t s updating Ey
30 C e y e x n = ( 2 * e p s 0 − d t * s i g m a p e x x n ) . / ( 2 * e p s 0+d t * s i g m a p e x x n ) ;
C e y h z x n= −(2 * d t / dx ) . / ( 2 * e p s 0 + d t * s i g m a p e x x n ) ;
32

% C o e f f i e c i e n t s u p d a t i n g Hzx
34 C h z x h x n = ( 2 * mu 0 − d t * s i g m a p m x x n ) . / ( 2 * mu 0+d t * s i g m a p m x x n ) ;
C h z x e y x n = −(2 * d t / dx ) . / ( 2 * mu 0 + d t * s i g m a p m x x n ) ;
36

% C o e f f i e c i e n t s u p d a t i n g Hzy
38 Chzyh xn = 1;
C h z y e x x n = d t / ( dy * mu 0 ) ;
40 end
i f is pml yp
95 s i g m a p e y y p = z e r o s ( nx , n p m l y p ) ;
s i g m a p m y y p = z e r o s ( nx , n p m l y p ) ;
97

sigma max = −( p m l o r d e r + 1 ) * e p s 0 * c * l o g ( R 0 ) / ( 2 * dy * n p m l y p ) ;
99 rho e = ( [ 1 : n pml yp ] − 0 . 7 5 ) / n pml yp ;
rho m = ( [ 1 : n p m l y p ] − 0 . 2 5 ) / n p m l y p ;
101 f o r ind = 1: n pml yp
s i g m a p e y y p ( : , i n d ) = sigma max * r h o e ( i n d ) ˆ p m l o r d e r ;
103 sigma pmy yp ( : , ind ) = . . .
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

PML Updating Equations 207

( mu 0 / e p s 0 ) * sigma max * rho m ( i n d ) ˆ p m l o r d e r ;


105 end

107 % C o e f f i e c i e n t s updating Ex
C e x e y p = ( 2 * e p s 0 − d t * s i g m a p e y y p ) . / ( 2 * e p s 0+d t * s i g m a p e y y p ) ;
109 C e x h z y p = ( 2 * d t / dy ) . / ( 2 * e p s 0 + d t * s i g m a p e y y p ) ;

111 % C o e f f i e c i e n t s u p d a t i n g Hzx
Chzxh yp = 1;
113 C h z x e y y p = −d t / ( dx * mu 0 ) ;

115 % C o e f f i e c i e n t s u p d a t i n g Hzy
C h z y h y p = ( 2 * mu 0 − d t * s i g m a p m y y p ) . / ( 2 * mu 0+d t * s i g m a p m y y p ) ;
117 C h z y e x y p = ( 2 * d t / dy ) . / ( 2 * mu 0 + d t * s i g m a p m y y p ) ;
end
 
determining the non-PML rectangular region as illustrated in Fig. 7.7 are calculated as ( pis , p j s )
and ( pie, p j e). Then two separate subroutines dedicated to the initialization of the T E z and T Mz
cases are called based on the mode of operation.
The coefficients and fields required for the T E z PML boundaries are initialized in the sub-
routine initialize pml boundary conditions 2d TEz, and partial code for this case is shown in
Listing 7.6. Figure 7.8 shows the field distribution for the T E z case. The field components in
the shaded region are updated by the PML updating equations. The field components on the
outer boundary are not updated and are kept at zero value during the FDTD iterations since
they are simulating the PEC boundaries. The magnetic field components Hzx and Hzy are defined
in the four PML regions shown in Fig. 7.5; therefore, the corresponding field arrays Hzx xn,
Hzx xp, Hzx yn, Hzx yp, Hzy xn, Hzy xp, Hzy yn, and Hzy yp are initialized in Listing 7.6.

Figure 7.8 TEz field components in the PML regions.


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

208 Perfectly Matched Layer

Figure 7.9 Field components updated by PML equations.

Then for each region the corresponding conductivity parameters and PML updating coefficients
are calculated. Listing 7.6 shows the initialization for the xn and y p regions.
One should take care while calculating the conductivity arrays. The conductivities σ pe x and
σ pe y are associated with the electric fields E x and E y , respectively, whereas σ pmx and σ pmy are
associated with the magnetic field Hz . Therefore, the conductivity components are located in
different positions. As mentioned before, the conductivity σ (ρ) is zero at the PML interior-
domain interface, and it increases to a maximum value σmax at the end of the PML region.
In this implementation the imaginary PML regions are shifted inward by a quarter cell size as
shown in Fig. 7.8. If the thickness of the PML region is N cells, this shift ensures that N electric
field components and N magnetic field components are updated across the PML thickness. For
instance, consider the cross-section of a two-dimensional problem space shown in Fig. 7.9, which
illustrates the field components updated in the xn and xp regions. The distance of the electric field
components E y from the interior boundary of the PML is denoted as ρe whereas for the magnetic
field components Hz it is denoted as ρm . The distances ρe and ρm are used in (7.27a) to calculate
the values of σ pe x and σ pmx , respectively. These values are stored in arrays sigma pex xn and
sigma pmx xn for the xn region as shown in Listing 7.6 and in sigma pex xp and sigma pmx xp
for the xp region. Calculation of σ pe y and σ pmy follows the same logic. Then these parameters are
used to calculate the respective PML updating coefficients in (7.29)–(7.32).
The initialization of the auxiliary split fields and the PML updating coefficients for the two-
dimensional T Mz case is performed in the subroutine initialize pml boundary conditions 2d -
Tmz, a partial code of which is given for the xp and yn regions in Listing 7.7. The initialization of
the T Mz case follows the same logic as the T E z case. The field positioning and PML regions are
shown in Fig. 7.10, while the positions of the field components updated by the PML equations
and conductivity positions are shown in Fig. 7.11 as a reference.

7.4.3.3 Running the Two-Dimensional FDTD Simulation: The Time-Marching Loop After the ini-
tialization process is completed, the subroutine run fdtd time marching loop 2d including the
time-marching loop of FDTD procedure is called. The implementation of the FDTD updating
loop is shown in Listing 7.8.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

PML Updating Equations 209

Listing 7.7 initialize pml boundary conditions 2d TMz.m


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

4 Ezx xn = zeros ( n pml xn , nym1 ) ;


Ezy xn = zeros ( n pml xn , nym1−n pml yn −n p m l y p ) ;
6 Ezx xp = zeros ( n pml xp , nym1 ) ;
Ezy xp = zeros ( n pml xp , nym1−n pml yn −n p m l y p ) ;
8 Ezx yn = zeros ( nxm1−n pml xn −n pml xp , n p m l y n ) ;
Ezy yn = zeros ( nxm1 , n p m l y n ) ;
10 Ezx yp = zeros ( nxm1−n pml xn −n pml xp , n p m l y p ) ;
Ezy yp = zeros ( nxm1 , n p m l y p ) ;
12

pml order = boundary . pml order ;


14 R 0 = boundary . pml R 0 ;

42 i f is pml xp
s i g m a p e x x p = z e r o s ( n pml xp , nym1 ) ;
44 s i g m a p m x x p = z e r o s ( n pml xp , nym1 ) ;

46 sigma max = −( p m l o r d e r + 1 ) * e p s 0 * c * l o g ( R 0 ) / ( 2 * dx * n p m l x p ) ;
rho e = ( [ 1 : n pml xp ] − 0 . 7 5 ) / n pml xp ;
48 rho m = ( [ 1 : n p m l x p ] − 0 . 2 5 ) / n p m l x p ;
for ind = 1: n pml xp
50 s i g m a p e x x p ( ind , : ) = sigma max * r h o e ( i n d ) ˆ p m l o r d e r ;
s i g m a p m x x p ( ind , : ) = . . .
52 ( mu 0 / e p s 0 ) * sigma max * rho m ( i n d ) ˆ p m l o r d e r ;
end
54

% C o e f f i e c i e n t s u p d a t i n g Hy
56 C h y h x p = ( 2 * mu 0 − d t * s i g m a p m x x p ) . / ( 2 * mu 0 + d t * s i g m a p m x x p ) ;
C h y e z x p = ( 2 * d t / dx ) . / ( 2 * mu 0 + d t * s i g m a p m x x p ) ;
58

% C o e f f i e c i e n t s updating Ezx
60 C e z x e x p = ( 2 * e p s 0 − d t * s i g m a p e x x p ) . / ( 2 * e p s 0+d t * s i g m a p e x x p ) ;
C e z x h y x p = ( 2 * d t / dx ) . / ( 2 * e p s 0 + d t * s i g m a p e x x p ) ;
62

% C o e f f i e c i e n t s updating Ezy
64 Cezye xp = 1;
C e z y h x x p = −d t / ( dy * e p s 0 ) ;
66 end

68 i f is pml yn
s i g m a p e y y n = z e r o s ( nxm1 , n p m l y n ) ;
70 s i g m a p m y y n = z e r o s ( nxm1 , n p m l y n ) ;

72 sigma max = −( p m l o r d e r + 1 ) * e p s 0 * c * l o g ( R 0 ) / ( 2 * dy * n p m l y n ) ;
rho e = ( [ n pml yn : −1:1] − 0 . 7 5 ) / n pml yn ;
74 rho m = ( [ n p m l y n : − 1 : 1 ] − 0 . 2 5 ) / n p m l y n ;
f o r ind = 1: n pml yp
76 s i g m a p e y y n ( : , i n d ) = sigma max * r h o e ( i n d ) ˆ p m l o r d e r ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

210 Perfectly Matched Layer

sigma pmy yn ( : , ind ) = . . .


78 ( mu 0 / e p s 0 ) * sigma max * rho m ( i n d ) ˆ p m l o r d e r ;
end
80

% C o e f f i e c i e n t s u p d a t i n g Hx
82 C h x h y n = ( 2 * mu 0 − d t * s i g m a p m y y n ) . / ( 2 * mu 0+d t * s i g m a p m y y n ) ;
C h x e z y n= −(2 * d t / dy ) . / ( 2 * mu 0 + d t * s i g m a p m y y n ) ;
84

% C o e f f i e c i e n t s updating Ezx
86 Cezxe yn = 1;
C e z x h y y n = d t / ( dx * e p s 0 ) ;
88

% C o e f f i e c i e n t s updating Ezy
90 C e z y e y n = ( 2 * e p s 0 − d t * s i g m a p e y y n ) . / ( 2 * e p s 0+d t * s i g m a p e y y n ) ;
C e z y h x y n = −(2 * d t / dy ) . / ( 2 * e p s 0 + d t * s i g m a p e y y n ) ;
92 end
 

During the time-marching loop the first step at every iteration is the update of magnetic
field components using the regular updating equations in update magnetic fields 2d as shown in
Listing 7.9. In the T E z case the Hz field components in the intermediate regions of Figs. 7.5(c) and
7.5(d) are updated based on (1.35). In the T Mz case the Hx field components in the intermediate
region of Fig. 7.6(b) and Hy field components in the intermediate region of Fig. 7.6(a) are updated
based on (1.37) and (1.38), respectively.
Then in update impressed M the impressed current terms appearing in (1.35), (1.37), and
(1.38) are added to their respective field terms Hz , Hx , and Hy .

Figure 7.10 TMz field components in the PML regions.


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

PML Updating Equations 211

Figure 7.11 Field components updated by PML equations.

The subroutine update magnetic fields for PML 2d is used to update the magnetic field com-
ponents needing special PML updates. As can be followed in Listing 7.11 the T E z and T Mz cases
are treated in separate subroutines.
The T Mz case is implemented in Listing 7.12, where Hx is updated in the yn and y p regions
of Fig. 7.6(b) using (7.37). Hy is updated in the xn and xp regions of Fig. 7.6(a) using (7.38).

Listing 7.8 run fdtd time marching loop 2d.m


disp ( [ ’ S t a r t i n g the time marching loop ’ ] ) ;
2 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 ) ] ) ;
4

s t a r t t i m e = cputime ;
6 current time = 0;

8 for time step = 1: number of time steps


update magnetic fields 2d ;
10 update impressed M ;
update magnetic fields for PML 2d ;
12 capture sampled magnetic fields 2d ;
update electric fields 2d ;
14 update impressed J ;
update electric fields for PML 2d ;
16 capture sampled electric fields 2d ;
display sampled parameters 2d ;
18 end

20 e n d t i m e = cputime ;
t o t a l t i m e i n m i n u t e s = ( end time − s t a r t t i m e ) / 6 0 ;
22 disp ( [ ’ T o t a l s i m u l a t i o n time i s ’ . . .
num2str ( t o t a l t i m e i n m i n u t e s ) ’ m i n u t e s . ’ ] ) ;
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

212 Perfectly Matched Layer

Listing 7.9 update magnetic fields 2d.m



1 % update magnetic f i e l d s

3 current time = current time + dt / 2 ;

5 % TEz
if is TEz
7 Hz ( p i s : p i e −1 , p j s : p j e −1) = . . .
Chzh ( p i s : p i e −1 , p j s : p j e − 1 ) . * Hz ( p i s : p i e −1 , p j s : p j e −1) . . .
9 + C h z e x ( p i s : p i e −1 , p j s : p j e −1) . . .
. * ( E x ( p i s : p i e −1 , p j s +1: p j e )− E x ( p i s : p i e −1 , p j s : p j e − 1 ) ) ...
11 + C h z e y ( p i s : p i e −1 , p j s : p j e −1) . . .
. * ( E y ( p i s +1: p i e , p j s : p j e −1)− E y ( p i s : p i e −1 , p j s : p j e − 1 ) ) ;
13 end

15 % TMz
i f is TMz
17 Hx ( : , p j s : p j e −1) = Chxh ( : , p j s : p j e −1) . * Hx ( : , p j s : p j e −1) . . .
+ C h x e z ( : , p j s : p j e −1) . * ( E z ( : , p j s +1: p j e )− E z ( : , p j s : p j e − 1 ) ) ;
19

Hy ( p i s : p i e − 1 , : ) = Chyh ( p i s : p i e − 1 , : ) . * Hy ( p i s : p i e − 1 , : ) . . .
21 + C h y e z ( p i s : p i e − 1 , : ) . * ( E z ( p i s +1: p i e , : ) − E z ( p i s : p i e − 1 , : ) ) ;
end
 

Listing 7.10 update impressed M.m



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

4 for ind = 1: number of impressed M


i s = impressed M ( ind ) . i s ;
6 j s = impressed M ( ind ) . j s ;
i e = impressed M ( ind ) . i e ;
8 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 ) )
10 case ’ x ’
Hx ( i s : i e , j s : j e −1) = Hx ( i s : i e , j s : j e −1) . . .
12 + 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 ) . waveform ( t i m e s t e p ) ;
case ’ y ’
14 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 ) . waveform ( t i m e s t e p ) ;
16 case ’ z ’
Hz ( i s : i e −1 , j s : j e −1) = Hz ( i s : i e −1 , j s : j e −1) ...
18 + 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 ) . waveform ( t i m e s t e p ) ;
end
20 end
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

PML Updating Equations 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
3 return ;
end
5 if is TEz
update magnetic fields for PML 2d TEz ;
7 end
i f is TMz
9 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 com-
ponents of Hzx and Hzy , located at the same positions, are added to obtain Hz at the same
positions.
The update of the electric field components using the regular updating equations is per-
formed in update electric fields 2d as shown in Listing 7.14. In the T Mz case the E z field com-
ponents in the intermediate regions of Figs. 7.6(c) and 7.6(d) are updated based on (1.36). In
the T E z case the E x field components in the intermediate region of Fig. 7.5(b) and E y field
components in the intermediate region of Fig. 7.5(a) are updated based on (1.33) and (1.34),
respectively.

Listing 7.12 update magnetic fields for PML 2d TMz.m


% 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
2 % TMz
i f is pml xn
4 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 ) ) ;
6 end

8 i f is pml xp
Hy ( p i e : nx , 2 : ny ) = C h y h x p . * Hy ( p i e : nx , 2 : ny ) . . .
10 + C h y e z x p . * ( E z ( p i e +1: nxp1 , 2 : ny )− E z ( p i e : nx , 2 : ny ) ) ;
end
12

i f is pml yn
14 Hx ( 2 : nx , 1 : p j s −1) = C h x h y n . * Hx ( 2 : nx , 1 : p j s −1) . . .
+ C h x e z y n . * ( E z ( 2 : nx , 2 : p j s )− E z ( 2 : nx , 1 : p j s − 1 ) ) ;
16 end

18 i f is pml yp
Hx ( 2 : nx , p j e : ny ) = C h x h y p . * Hx ( 2 : nx , p j e : ny ) . . .
20 + C h x e z y p . * ( E z ( 2 : nx , p j e +1: nyp1 )− E z ( 2 : nx , p j e : ny ) ) ;
end
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

214 Perfectly Matched Layer

Listing 7.13 update magnetic fields for PML 2d TEz.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
% TEz
3 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 , : ) ) ;
5 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 ) ) ;
7 end
i f is pml xp
9 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 , : ) ) ;
11 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 ) ) ;
13 end
i f is pml yn
15 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 ) ) ;
17 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 ) ) ;
19 end
i f is pml yp
21 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 ) ) ;
23 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 ) ) ;
25 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 , : ) ;
27 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 , : ) ;
29 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 ;
31 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 , : ) ;
33 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 field terms E z , E x , and E y .

The subroutine update electric fields for PML 2d is used to update the electric field compo-
nents needing special PML updates. As can be followed in Listing 7.15 the T E z and T Mz cases
are treated in separate subroutines.
The T E z case is implemented in Listing 7.16, where E x is updated in the yn and y p regions of
Fig. 7.5(b) using (7.29). E y is updated in the xn and xp regions of Fig. 7.5(a) using (7.30).
The T Mz case is implemented in Listing 7.17, where E zx is updated in the xn and xp re-
gions of Fig. 7.6(c) using (7.35). E zx is updated in the yn and y p regions of Fig. 7.6(c) using
(7.39). E zy is updated in the yn and y p regions of Fig. 7.6(d) using (7.36). E zy is updated in
the xn and xp regions of Fig. 7.6(d) using (7.40). After all these updates are completed, the
components of E zx and E zy , located at the same positions, are added to obtain E z at the same
positions.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation Examples 215

Listing 7.14 update electric fields 2d.m


1 current time = current time + dt / 2 ;

3 if is TEz
E x ( : , p j s +1: p j e −1) = C e x e ( : , p j s +1: p j e − 1 ) . * E x ( : , p j s +1: p j e −1) . . .
5 + C e x h z ( : , p j s +1: p j e − 1 ) . * . . .
( Hz ( : , p j s +1: p j e −1)−Hz ( : , p j s : p j e − 2 ) ) ;
7

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


9 + 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 end

13 i f is TMz
E z ( p i s +1: p i e −1 , p j s +1: p j e −1) = . . .
15 C e z e ( p i s +1: p i e −1 , p j s +1: p j e − 1 ) . * E z ( p i s +1: p i e −1 , p j s +1: p j e −1) . . .
+ C e z h y ( p i s +1: p i e −1 , p j s +1: p j e −1) . . .
17 . * ( Hy ( p i s +1: p i e −1 , p j s +1: p j e −1)−Hy ( p i s : p i e −2 , p j s +1: p j e − 1 ) ) . . .
+ C e z h x ( p i s +1: p i e −1 , p j s +1: p j e −1) . . .
19 . * ( Hx ( p i s +1: p i e −1 , p j s +1: p j e −1)−Hx ( p i s +1: p i e −1 , p j s : p j e − 2 ) ) ;
end
 

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 reflection coefficient R(0) is 10−8 . The problem space is excited by a z-directed
impressed magnetic current as defined in Listing 7.18. The impressed magnetic current is centered
at the origin and has a Gaussian waveform. A sampled magnetic field 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 defined in Listing 7.19. The problem is run for 1,800 time steps. The captured
sampled magnetic field Hz is plotted in Fig. 7.12(b) as a function of time. The captured field
includes the effect of the reflected fields from the PML boundaries as well.

Listing 7.15 update electric fields for PML 2d.m


% 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
2 % 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
4 return ;
end
6 if is TEz
update electric fields for PML 2d TEz ;
8 end
i f is TMz
10 update electric fields for PML 2d TMz ;
end
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

216 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
3 i f is pml xn
Ey ( 2 : pis , : ) = Ceye xn . * Ey ( 2 : pis , : ) . . .
5 + C e y h z x n . * ( Hz ( 2 : p i s , : ) − Hz ( 1 : p i s − 1 , : ) ) ;
end
7

i f is pml xp
9 E y ( p i e : nx , : ) = C e y e x p . * E y ( p i e : nx , : ) . . .
+ C e y h z x p . * ( Hz ( p i e : nx , : ) − Hz ( p i e −1: nx − 1 , : ) ) ;
11 end

13 i f is pml yn
Ex ( : , 2 : p j s ) = Cexe yn . * Ex ( : , 2 : p j s ) . . .
15 + C e x h z y n . * ( Hz ( : , 2 : p j s )−Hz ( : , 1 : p j s − 1 ) ) ;
end
17

i f is pml yp
19 E x ( : , p j e : ny ) = C e x e y p . * E x ( : , p j e : ny ) . . .
+ C e x h z y p . * ( Hz ( : , p j e : ny )−Hz ( : , p j e −1: ny − 1 ) ) ;
21 end
 

Listing 7.17 update electric fields for PML 2d TMz.m


% 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
2 % TMz
i f is pml xn
4 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 ) ) ;
6 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 ) ) ;
8 end
i f is pml xp
10 Ezx xp = Cezxe xp .* Ezx xp + Cezxhy xp .* ...
( Hy ( p i e : nx , 2 : ny )−Hy ( p i e −1: nx −1 ,2: ny ) ) ;
12 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 ) ) ;
14 end
i f is pml yn
16 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 ) ) ;
18 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 ) ) ;
20 end
i f is pml yp
22 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 ) ) ;
24 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 ) ) ;
26 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 , : ) ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation Examples 217

28 E z ( 2 : p i s , p j e : ny ) = E z x x n ( : , p j e −1:nym1 ) + E z y y p ( 1 : p i s − 1 , : ) ;
E z ( p i e : nx , p j e : ny ) = E z x x p ( : , p j e −1:nym1 ) + E z y y p ( p i e −1:nxm1 , : ) ;
30 E z ( p i e : nx , 2 : p j s ) = E z x x p ( : , 1 : p j s −1) + E z y y n ( p i e −1:nxm1 , : ) ;
E z ( p i s +1: p i e −1 ,2: p j s ) = E z x y n + E z y y n ( p i s : p i e − 2 , : ) ;
32 E z ( p i s +1: p i e −1 , p j e : ny ) = E z x y p + E z y y p ( p i s : p i e − 2 , : ) ;
E z ( 2 : p i s , p j s +1: p j e −1) = E z x x n ( : , p j s : p j e −2) + E z y x n ;
34 E z ( p i e : nx , p j s +1: p j e −1) = E z x x p ( : , p j s : p j e −2) + E z y x p ;
 

To determine how well the PML boundaries simulate the open boundaries, a reference case
is constructed as shown in Fig. 7.13(a). The cell size, the source, and the output of this problem
space is the same as the previous one, but in this case the problem space size is 600 × 600 cells, and
it is terminated by PEC boundaries on four sides. Any fields excited by the source will propagate,
will hit the PEC boundaries, and will propagate back to the center. Since the problem size is large,
it will take some time until the reflected fields arrive at the sampling point. Therefore, the fields
captured at the sampling point before any reflected fields arrive is the same as the fields that would
be observed if the boundaries are open space. In the given example no reflection is observed in
the 1,800 time steps of simulation. Therefore, this case can be considered as a reference case for
an open space during the 1,800 time steps. The captured sampled magnetic field is shown in Fig.
7.13(b) as a function of time.
No difference can be seen by looking at the responses of the PML case and the reference case.
The difference between the two cases is a measure for the amount of reflection from the PML
and can be determined numerically. The difference denoted as errort is the error as a function of

H1
y

x
M1

Figure 7.12 (a) A two-dimensional TEz FDTD problem terminated by PML boundaries and its simulation results:
an empty two-dimensional problem space.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

218 Perfectly Matched Layer

−7
x 10
1

0.5
(ampere/meter)

−0.5

−1

−1.5
0 0.5 1 1.5 2 2.5 3 3.5 4
time (ns)

Figure 7.12 (b) A two-dimensional TEz FDTD problem terminated by PML boundaries and its simulation results:
sampled H z in time.

time and calculated by

 pml re f

|Hz − Hz |
errort = 20 × log10 re f
, (7.41)
max(|Hz |)

pml re f
where Hz is the sampled magnetic field in the PML problem case and Hz is the sampled
magnetic field in the reference case. The error as a function of time is plotted in Fig. 7.14(a). The
error in frequency domain as well is obtained as error f from the difference between the Fourier
transforms of the sampled magnetic fields from the PML and reference cases by

 pml re f

|F(Hz ) − F(Hz )|
error f = 20 × log10 re f
, (7.42)
F(|Hz |)

where the operator F( ) denotes the Fourier transform. The error in frequency-domain error f
is plotted in Fig. 7.14(b). The errors obtained in this example can further be reduced by us-
ing a larger number of cells of PML thickness, a better choice of R(0), and a higher order
of PML n pml . One can see in Fig. 7.14(b) that the performance of the PML degrades at low
frequencies.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation Examples 219

Listing 7.18 define sources 2d.m


disp ( ’ defining sources ’ ) ;
2

impressed J = [ ] ;
4 impressed M = [ ] ;

6 % d e f i n e s o u r c e waveform t y p e s and p a r a m e t e r s
waveforms . g a u s s i a n ( 1 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 0 ;
8 waveforms . g a u s s i a n ( 2 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 25;

10 % magnetic c u r r e n t s o u r c e s
% d i r e c t i o n : ’ xp ’ , ’ xn ’ , ’ yp ’ , ’ yn ’ , ’ zp ’ , o r ’ zn ’
12 i m p r e s s e d M ( 1 ) . m i n x = −1e −3;
i m p r e s s e d M ( 1 ) . m i n y = −1e −3;
14 i m p r e s s e d M ( 1 ) . max x = 1e −3;
i m p r e s s e d M ( 1 ) . max y = 1e −3;
16 i m p r e s s e d M ( 1 ) . d i r e c t i o n = ’ zp ’ ;
impressed M ( 1 ) . magnitude = 1 ;
18 impressed M ( 1 ) . waveform type = ’ gaussian ’ ;
impressed M ( 1 ) . waveform index = 2;
 

7.5.2 Electric Field Distribution


Since the fields are calculated on a plane by the two-dimensional FDTD program, it is possible to
capture and display the electric and magnetic field distributions as a runtime animation while the
simulation is running. Furthermore, it is possible to calculate the field distribution as a response of
a time-harmonic excitation at predefined frequencies. Then the time-harmonic field distribution
can be compared with results obtained from simulation of the same problem using frequency-
domain 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 ’ ) ;

3 sampled electric fields = [];


sampled magnetic fields = [];
5 sampled transient E planes = [];
sampled frequency E planes = [];
7

% figure refresh rate


9 p l o t t i n g s t e p = 10;

11 % f r e q u e n c y domain p a r a m e t e r s
f r e q u e n c y d o m a i n . s t a r t = 20 e6 ;
13 f r e q u e n c y d o m a i n . end = 20 e9 ;
f r e q u e n c y d o m a i n . s t e p = 20 e6 ;
15

% define sampled magnetic f i e l d s


17 sampled magnetic f i e l d s ( 1 ) . x = 8e −3;
sampled magnetic f i e l d s ( 1 ) . y = 8e −3;
19 sampled magnetic f i e l d s ( 1 ) . component = ’ z ’ ;
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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
1

0.5
(ampere/meter)

−0.5

−1

−1.5
0 0.5 1 1.5 2 2.5 3 3.5 4
time (ns)

Figure 7.13 (b) A two-dimensional TEz FDTD problem used as open boundary reference and its simulation results:
sampled H z in time.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation Examples 221

−20

−40

−60
errort (dB)

−80

−100

−120

−140

−160

−180

−200
0 0.5 1 1.5 2 2.5 3 3.5 4
time (ns)
(a) Error in time
0

−10

−20

−30
errorf (dB)

−40

−50

−60

−70

−80
0 5 10 15 20
frequency (GHz)
(b) Error in frequency domain

Figure 7.14 Error in time and frequency domains.


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

222 Perfectly Matched Layer

Figure 7.15 A two-dimensional problem space including a cylinder and a line source.

electric field distribution in a problem space including a cylinder of circular cross-section with
radius 0.2 m, and dielectric constant 4, due to a current line source placed 0.2 m away from
the cylinder and excited at 1 GHz frequency. Figure 7.15 illustrates the geometry of the two-
dimensional problem space. The problem space is composed of square cells with 5 mm on a side
and is terminated by PML boundaries with 8 cells thickness. The air gap between the cylinder
and the boundaries is 30 cells in the xn, yn, and y p directions and 80 cells in the xp direction.
The definition of the geometry is shown in Listing 7.20. The line source is an impressed current
density with a sinusoidal waveform as shown in Listing 7.21.
In this example we define two new output types: (1) transient electric field distributions repre-
sented with a parameter named sampled transient E planes; and (2) electric field distributions
calculated at certain frequencies represented with a parameter named sampled frequency E -
planes. The definition of these parameters is shown in Listing 7.22, and the initialization of these
parameters are performed in the subroutine initialize output parameters 2d is shown in 7.23.
The electric fields at node positions are captured and displayed as an animation while
the simulation is running in the subroutine display sampled parameters 2d as shown in
Listing 7.24.

Listing 7.20 define geometry 2d.m



6 % define a circle
circles (1). center x = 0.4;
8 circles (1). center y = 0.5;
circles (1). radius = 0.2;
10 circles (1). material type = 4;
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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

% electric current sources


12 % direction : ’ xp ’ , ’ xn ’ , ’ yp ’ , ’ yn ’ , ’ zp ’ , o r ’ zn ’
impressed J ( 1 ) . min x = 0 . 8 ;
14 impressed J ( 1 ) . min y = 0 . 5 ;
impressed J ( 1 ) . max x = 0 . 8 ;
16 impressed J ( 1 ) . max y = 0 . 5 ;
impressed J ( 1 ) . d i r e c t i o n = ’ zp ’ ;
18 impressed J ( 1 ) . magnitude = 1 ;
impressed J ( 1 ) . waveform type = ’ s i n u s o i d a l ’ ;
20 impressed J ( 1 ) . waveform index = 1;
 

Listing 7.22 define output parameters 2d.m


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

sampled electric fields = [];


4 sampled magnetic fields = [];
sampled transient E planes = [];
6 sampled frequency E planes = [];
% d e f i n e sampled e l e c t r i c field distributions
23 % component can be ’ x ’ , ’ y ’ , ’ z ’ , o r ’m’ ( m a g n i t u d e )
% transient
25 sampled transient E planes ( 1 ) . component = ’ z ’ ;

27 % f r e q u e n c y domain
s a m p l e d f r e q u e n c y E p l a n e s ( 1 ) . component = ’ z ’ ;
29 s a m p l e d f r e q u e n c y E p l a n e s ( 1 ) . f r e q u e n c y = 1 e9 ;
 

Listing 7.23 initialize output parameters 2d.m


1 disp ( ’ i n i t i a l i z i n g the output parameters ’ ) ;

3 number of sampled electric fields = size ( sampled electric fields , 2 ) ;


number of sampled magnetic fields = size ( sampled magnetic fields , 2 ) ;
5 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 ) ;
36 % 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
38 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

% i n i t i a l i z e sampled t i m e h a r m o n i c e l e c t r i c f i e l d
42 f o r i n d =1: n u m b e r o f s a m p l e d f r e q u e n c y E p l a n e s
s a m p l e d f r e q u e n c y E p l a n e s ( i n d ) . s a m p l e d f i e l d = z e r o s ( nxp1 , nyp1 ) ;
44 end
x c o o r = l i n s p a c e ( f d t d d o m a i n . min x , f d t d d o m a i n . max x , nxp1 ) ;
46 y c o o r = l i n s p a c e ( f d t d d o m a i n . min y , f d t d d o m a i n . max y , nyp1 ) ;
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

224 Perfectly Matched Layer

Listing 7.24 display sampled parameters 2d.m



% 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
37 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 ) ;
39 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 ;
41 sw i t ch ( component )
case ’ x ’
43 E s ( 2 : nx , : ) = 0 . 5 * ( E x ( 1 : nx − 1 , : ) + E x ( 2 : nx , : ) ) ;
case ’ y ’
45 E s ( : , 2 : ny ) = 0 . 5 * ( E y ( : , 1 : ny −1) + E y ( : , 2 : ny ) ) ;
case ’ z ’
47 Es = Ez ;
c a s e ’m ’
49 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 ) ) ;
51 E z s = Ez ;
Es = sqrt ( Exs . ˆ 2 + Eys . ˆ 2 + Ezs . ˆ 2 ) ;
53 end
imagesc ( xcoor , ycoor , Es . ’ ) ;
55 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 ) ’ ] ’ ] ) ;
57 drawnow ;
end
 

Listing 7.25 capture sampled electric fields 2d.m



% 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
24 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
26 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 ;
28 sw i t ch ( component )
case ’ x ’
30 E s ( 2 : nx , : ) = 0 . 5 * ( E x ( 1 : nx − 1 , : ) + E x ( 2 : nx , : ) ) ;
case ’ y ’
32 E s ( : , 2 : ny ) = 0 . 5 * ( E y ( : , 1 : ny −1) + E y ( : , 2 : ny ) ) ;
case ’ z ’
34 Es = Ez ;
c a s e ’m ’
36 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 ) ) ;
38 E z s = Ez ;
Es = sqrt ( Exs . ˆ 2 + Eys . ˆ 2 + Ezs . ˆ 2 ) ;
40 end
I = find ( Es > sampled frequency E planes ( ind ) . s a m p l e d f i e l d ) ;
42 sampled frequency E planes ( ind ) . s a m p l e d f i e l d ( I ) = Es ( I ) ;
end
44 end
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation Examples 225

Listing 7.26 display frequency domain outputs 2d.m


% 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
42 f o r i n d =1: n u m b e r o f s a m p l e d f r e q u e n c y E p l a n e s
figure ;
44 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 ;
46 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 ) ) ;
48 imagesc ( xcoor , ycoor , Es . ’ ) ;
a x i s equal ; a x i s xy ; colorbar ;
50 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 ) ’] ’ ]);
52 drawnow ;
end
 
The electric fields 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 fields 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 fields 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 efficient 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
field is sampled at a point between the cylinder and the line source as shown in Fig. 7.15. The
sampled electric field 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 field 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
figures are normalized to different values.

7.5.3 Electric Field Distribution Using DFT


The previous example demonstrated how the magnitude of electric field 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 field
distributions for multiple frequencies.
The output for the field distribution is defined in the subroutine define output parameters as
shown in Listing 7.27. One can notice that it is possible to define multiple field distributions with
different frequencies. The excitation waveform as well shall include the desired frequencies in its
spectrum. An impressed current line source is defined as shown in Listing 7.28. To calculate field
distributions for multiple frequencies we have to implement an on-the-fly DFT. Therefore, the
subroutine capture sampled electric fields 2d is modified as shown in Listing 7.29.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

226 Perfectly Matched Layer

0.05
sampled electric field
0.04

0.03

0.02
(volt/meter)

0.01

−0.01

−0.02

−0.03

−0.04

−0.05
0 10 20 30 40 50 60 70 80 90
time (ns)

Figure 7.16 Sampled electric field at a point between the cylinder and the line source.

Figure 7.17 Magnitude of electric field distribution calculated by FDTD.


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation Examples 227

Figure 7.18 Magnitude of electric field distribution calculated by BVS.

Listing 7.27 define output parameters 2d.m



27 % f r e q u e n c y domain
sampled frequency E planes (1). component = ’z ’;
29 sampled frequency E planes (1). frequency = 1 e9 ;
sampled frequency E planes (2). component = ’z ’;
31 sampled frequency E planes (2). frequency = 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 ;
8 waveforms . g a u s s i a n ( 2 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 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

% magnetic current sources


12 % direction : ’ xp ’ , ’ xn ’ , ’ yp ’ , ’ yn ’ , ’ zp ’ , o r ’ zn ’
impressed J ( 1 ) . min x = 0 . 8 ;
14 impressed J ( 1 ) . min y = 0 . 5 ;
impressed J ( 1 ) . max x = 0 . 8 ;
16 impressed J ( 1 ) . max y = 0 . 5 ;
impressed J ( 1 ) . d i r e c t i o n = ’ zp ’ ;
18 impressed J ( 1 ) . magnitude = 1 ;
impressed J ( 1 ) . waveform type = ’ gaussian ’ ;
20 impressed J ( 1 ) . waveform index = 2;
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

228 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



% 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
24 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 ;
26 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 ;
28 sw i t ch ( component )
case ’ x ’
30 E s ( 2 : nx , : ) = 0 . 5 * ( E x ( 1 : nx − 1 , : ) + E x ( 2 : nx , : ) ) ;
case ’ y ’
32 E s ( : , 2 : ny ) = 0 . 5 * ( E y ( : , 1 : ny −1) + E y ( : , 2 : ny ) ) ;
case ’ z ’
34 Es = Ez ;
c a s e ’m ’
36 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 ) ) ;
38 E z s = Ez ;
Es = sqrt ( Exs . ˆ 2 + Eys . ˆ 2 + Ezs . ˆ 2 ) ;
40 end
sampled frequency E planes ( ind ) . s a m p l e d f i e l d = . . .
42 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 ) ;
44 end
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Exercises 229

Figure 7.20 Magnitude of electric field distribution calculated by FDTD using DFT at 2 GHz.

The FDTD simulation is run, and electric field distributions are calculated for 1 GHz and 2
GHz and are plotted in Figs. 7.19 and 7.20, respectively. One can notice that the result obtained
at 1 GHz using the on-the-fly DFT technique is the same as the ones shown in Section 7.5.2.

7.6 EXERCISES

7.1 The performance of the two-dimensional PML for the T E z case is evaluated in Section
7.5.1. Follow the same procedure, and evaluate the performance of the two-dimensional
PML case for the T Mz case. You can use the same parameters as the given example. Notice
that you need to use an electric current source to excite the T Mz mode, and you can sample
E z at a point close to the PML boundaries.
7.2 In Sections 7.5.2 and 7.5.3 new code sections are added to the two-dimensional FDTD
program to add the functionality of displaying the electric field distributions. Follow the
same procedure, and add new code sections to the program such that the program will
display magnetic field distributions as animations while the simulation is running and it will
display the magnitude of the magnetic field distribution as the response of time-harmonic
excitations at a number of frequencies.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

8
The Convolutional Perfectly
Matched Layer

In the previous chapter we discussed the perfectly matched layers (PMLs) as a boundary to
terminate the finite-difference time-domain (FDTD) lattices to simulate open boundary problems.
However, the PML is shown to be ineffective for absorbing evanescent waves. As a result, the PML
must be placed sufficiently far from an obstacle such that the evanescent waves have sufficiently
decayed [23]. However, this increases the number of cells in an FDTD computational domain
and, hence, the computational memory and time requirements. Another problem reported for
PML is that it suffers from late-time reflections when terminating highly elongated lattices or
when simulating fields with very long time signatures [23]. This is partly due to the weakly causal
nature of the PML [24].
A strictly causal form of the PML, which is referred to as the complex frequency-shifted PML
(CFS-PML) was developed in [25]. It has been shown that the CFS-PML is highly effective at
absorbing evanescent waves and signals with a long time signature. Therefore, using the CFS-
PML, the boundaries can be placed closer to the objects in the problem space and a time and
memory saving can be achieved, thus avoiding the aforementioned weaknesses of the PML.
An efficient implementation of the CFS-PML, known as the convolutional PML (CPML), is
introduced in [23]. The theoretical analyses of the CPML and other forms of PML can be found
in [26]. In this chapter we introduce the formulation of the CPML based on [23] and provide a
MATLAB implementation of the concept.

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

1 ∂ Hz 1 ∂ Hy
j ωεx E x + σxe E x = − , (8.1a)
Se y ∂ y Se z ∂z

231
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

232 The Convolutional Perfectly Matched Layer

1 ∂ Hx 1 ∂ Hz
j ωε y E y + σ ye E y = − , (8.1b)
Se z ∂z Se x ∂ x
1 ∂ Hy 1 ∂ Hx
j ωεz E z + σze E z = − , (8.1c)
Se x ∂ x Se y ∂ y

where Se x , Se y , and Se z are the stretched coordinate metrics, and σxe , σ ye , and σze are the electric
conductivities of the terminating media. One can notice that (8.1) is in the frequency domain with
e j ωt time-harmonic convention.
Equations (8.1) reduce to Berenger’s PML in the case where
σpex σpey σpez
Se x = 1 + , Se y = 1 + , and Se z = 1 + . (8.2)
j ωε0 j ωε0 j ωε0

Here σpex , σpey , and σpez are the PML conductivities.


It should be noted that equations 8.1a–8.1c and 8.2 follow the form given in [23], but the
subscript notations have been modified to indicate the electric and magnetic parameters sepa-
rately. 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 field update
equations are

1 ∂ Ez 1 ∂ Ey
j ωµx Hx + σxm Hx = − + , (8.3a)
Smy ∂ y Smz ∂z
1 ∂ Ex 1 ∂ Ez
j ωµ y Hy + σ ym Hy = − + , (8.3b)
Smz ∂z Smx ∂ x
1 ∂ Ey 1 ∂ Ex
j ωµz Hz + σzm Hz = − + . (8.3c)
Smx ∂ x Smy ∂ y

Equations (8.3) reduce to the PML in the case where


σ pmx σ pmy σ pmz
Smx = 1 + , Smy = 1 + , and Smz = 1 + . (8.4)
j ωµ0 j ωµ0 j ωµ0

8.1.2 Complex Stretching Variables in CFS-PML


In the CPML method the choice of the complex stretching variables follows the new definition
proposed by Kuzuoglu and Mittra [25], such that
σpex σpex
Se x = 1 + , ⇒ Se x = κe x + .
j ωε0 αe x + j ωε0

Then the complex stretching variables are given as


σ pei σpmi
Sei = κei + , Smi = κmi + , i = x, y, or z,
αei + j ωε0 αmi + j ωµ0

where the parameters κei , κmi , αei , and αmi are the new parameters taking the values

κei ≥ 1, κmi ≥ 1, αei ≥ 0, and αmi ≥ 0.


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Formulation of CPML 233

8.1.3 The Matching Conditions at the PML–PML Interface


For zero reflection at the PML–PML interface, one should have

Sei = Smi . (8.5)

This condition leads to

κei = κmi , (8.6a)


σ pei σpmi
= . (8.6b)
αei + j ωε0 αmi + j ωµ0

To satisfy (8.6b), we must have

σ pei σpmi αei αmi


= , and = . (8.7)
ε0 µ0 ε0 µ0

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 field updating equations from them. For instance, (8.1a) is expressed
in the time domain as

∂ Ex ∂ Hz ∂ Hy
εx + σxe E x = S¯e y ∗ − S¯e z ∗ , (8.8)
∂t ∂y ∂z

where S¯e y is a function of time that is the inverse Laplace transform of Se−1 ¯
y , and Se z is the inverse
−1
Laplace transform of Se z . One should notice that the product operations in the frequency-domain
equations (8.1) and (8.3) are expressed as convolution operations in the time domain.
The terms S¯ei and Smi ¯ are then given in open form as

 
δ(t) σ pei − σ pei
+
α pei
t δ(t)
S¯ei (t) = − e ε0 κei ε0
u(t) = + ξei (t), (8.9a)
κei ε0 κei2 κei
 
σ
¯ (t) = δ(t) − pmi e − δ(t)
σpmi αpmi
+ t
Smi µ0 κmi µ0
u(t) = + ξmi (t), (8.9b)
κmi µ0 κmi
2 κmi

where δ(t) is the unit impulse function and u(t) is the unit step function. Inserting (8.9) in (8.8)
leads to

∂ Ex 1 ∂ Hz 1 ∂ Hy ∂ Hz ∂ Hy
εx + σxe E x = − + ξe y (t) ∗ − ξe z (t) ∗ . (8.10)
∂t κe y ∂ y κe z ∂z ∂y ∂z

At this point the central difference approximation of the derivatives can be used to express (8.10)
in discrete time and space and then to obtain the field updating equation for E xn+1 . However,
(8.10) includes two convolution terms, and these terms also need to be expressed in discrete time
and space before proceeding with the construction of the updating equations.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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
τ =t
∂ Hz ∂ Hz (t − τ )
ξe y ∗ = ξe y (τ ) d τ. (8.11)
∂y τ =0 ∂y

In the discrete domain, (8.11) takes the form

τ =t 
m=n−1
∂ Hz (t − τ )  n−m+ 12 n−m+ 12 
ξe y (τ ) dτ  Z0e y (m) Hz (i, j, k) − Hz (i, j − 1, k) , (8.12)
τ =0 ∂y
m=0

where
τ =(m+1)t
1
Z0e y (m) = ξe y (τ )d τ
y τ =mt
τ =(m+1)t σ 
σpey − ε pei
α pei
κ + ε τ
=− e 0 ei 0 dτ
yε0 κe2y τ =mt
σ 
− κpei +α pei mt
= ae y e ei ε0
, (8.13)

and

 σpey 
σpey − +α t
ae y =   e κe y pey ε0 − 1 . (8.14)
y σpey κe y + αe y κe2y

Having derived the expression for Z0e y (m) we can express the discrete convolution term in (8.12)
n+ 1
with a new parameter ψexy 2 (i, j, k), such that


m=n−1  
n+ 1 n−m+ 12 n−m+ 12
ψexy 2 (i, j, k) = Z0e y (m) Hz (i, j, k) − Hz (i, j − 1, k) . (8.15)
m=0

Here the subscript exy indicates that this term is updating E x and is associated with the deriva-
tive of the magnetic field term with respect to y. Then equation (8.10) can be written in
discrete form as

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


εx (i, j, k) + σxe (i, j, k) x
t 2
n+ 12 n+ 12
1 Hz (i, j, k) − Hz (i, j − 1, k)
=
κe y (i, j, k) y
n+ 12 n+ 12
1 Hy (i, j, k) − Hy (i, j, k − 1)

κe z (i, j, k) z
n+ 1 n+ 1
+ ψexy 2 (i, j, k) − ψexz 2 (i, j, k). (8.16)
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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


m=n−1
ψ(n) = Ae mT B(n − m), (8.17)
m=0

where, for instance,

A = ae y
 
σpey t
T=− + αe y
κe y ε0
n−m+ 12 n−m+ 12
B = Hz (i, j, k) − Hz (i, j − 1, k).

Equation (8.17) can be written in open form as

ψ(n) = AB(n) + Ae T B(n − 1) + Ae 2T B(n − 2) + · · · + Ae (n−2)T B(2) + Ae (n−1)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 (n−2)T B(2) + Ae (n−2)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 first 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)
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

236 The Convolutional Perfectly Matched Layer

where
σpey  
ae y =   bey − 1 , (8.22)
y σpey κe y + αe y κe y
2

σ 
− κe y +αpey t
pey
bey = e ε
0 . (8.23)

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 modified to treat the specific host medium. Yet the application
of the CPML remains unchanged [23].
The FDTD flowchart can be modified to include the steps of the CPML as shown in
Fig. 8.1. The auxiliary parameters and coefficients required by the CPML are initialized before
the time-marching loop. During the time-marching loop, at every time step, first the magnetic
field 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 field values. Afterward, these terms are
added to their respective magnetic field components only at the CPML regions for which they
were defined. The next step is updating the electric field 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
field values and are added to their respective electric field components only at the CPML regions
for which they were defined. 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)
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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

Output data Update electric field components


at time instant (n+1)∆t

Calculate the new values of CPML parameters ψe*,


and add them to the electric field components

Increment time step, n n+1

Yes No
Stop Last iteration?

Figure 8.1 The FDTD flowchart including the steps of CPML algorithm.

n+ 1
Notice that the negative sign in front of the ψexz 2 (i, j, k) term in (8.16) is embedded in the
coefficient Ce xhy (i, j, k) as can be followed from (1.26). Here two new coefficients can be
defined such that

Cψexy (i, j, k) ⇐ yCe xhz (i, j, k), (8.26a)


Cψexz (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)
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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
+ Cψexy (i, j, k) × ψexy 2 (i, j, k) + Cψexz (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 modifications are applied to the coefficients 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
+ Cψexy (i, j, k) × ψexy 2 (i, j, k) + Cψexz (i, j, k) × ψexz 2 (i, j, k). (8.29)

With the given form of updating equation and coefficients, E xn+1 (i, j, k) is updated using the first
n+ 1 n+ 1
three terms on the right side in the entire domain as usual. Then ψexy 2 (i, j, k) and ψexz 2 (i, j, k)
n+ 1
are calculated (e.g., using (8.21) for ψexy 2 (i, j, k)), and the last two terms of (8.29) are added to
E xn+1 (i, j, k) at their respective CPML regions. It should be mentioned that the same procedure
applies for updating the other electric and magnetic field components as well by using their
respective updating equations and CPML parameters.

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 defined 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 defined at the region where its associated parameters are defined. For
instance, ψexy is associated with σpey , αe y , and κe y as can be observed in (8.21). Then the term ψexy
is defined for the yn and y p regions. Similarly, the term ψexz is defined 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 defined 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 field
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 field components and the regions at which these equations are
applied is given in Appendix B.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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 domain–PML interface and increasing to a maximum value
at the outer boundary. In the CPML case there are two additional types of parameter scaling
profiles, which are different from the conductivity scaling profiles.
The maximum conductivity of the conductivity profile is computed in [23] using σmax =
σfactor × σopt , where

npml + 1
σopt = √ . (8.30)
150π εr i
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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
 ρ npml
σ pei (ρ) = σmax , (8.31)
δ
where ρ is the distance from the computational domain–PML interface to the position of the field
component and δ is the thickness of the CPML layer. Similarly, σpmi can be calculated by
µ0  ρ npml
σpmi (ρ) = σmax , (8.32)
ε0 δ

which satisfies the reflectionless condition (8.7).


The value of κei is unity at the inner domain–CPML interface, and it increases to a maximum
value κmax such that
 ρ npml
κei (ρ) = 1 + (κmax − 1) , (8.33)
δ
whereas κmi is given by
 ρ npml
κmi (ρ) = 1 + (κmax − 1) . (8.34)
δ
In these equations ρ indicates the distances of the respective field components from the inner
domain–CPML interface. It should be noted that the values that ρ can take in (8.33) and (8.34)
are different since the electric and magnetic field components are located at different positions.
The parameter αei takes a maximum value αmax at the inner domain–CPML interface and is
linearly scaled to a minimum value, αmin , at the outer boundary such that
 ρ
αei (ρ) = αmin + (αmax − αmin ) 1 − . (8.35)
δ
Similarly, αmi is calculated as
µ0   ρ 
αmi (ρ) = αmin + (αmax − αmin ) 1 − . (8.36)
ε0 δ

This scaling of the CPML parameter profile is chosen as before specifically to reduce the
reflection error of evanescent modes; α must be nonzero at the front boundary interface. However,
for the CFS-PML to absorb purely propagating modes at low frequency, α should actually decrease
to zero away from the boundary interface [23].
The choice of the parameters σfactor , κmax , αmax , αmin , and npml and the thickness of the CPML
layer in terms of number of cells determine the performance of the CPML. In [23] parametric
studies have been performed to evaluate the effects of these parameters. Usually σfactor can be taken
in the range 0.7–1.5, κmax in the range 5–11, αmax in the range 0–0.05, thickness of CPML as 8
cells, and npml as 2, 3, or 4.

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.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

MATLAB Implementation of CPML in the Three-Dimensional FDTD Method 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 defined 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
define 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



% ==<b o u n d a r y c o n d i t i o n s >========
19 % Here we d e f i n e t h e b o u n d a r y c o n d i t i o n s p a r a m e t e r s
% ’ pec ’ : p e r f e c t e l e c t r i c c o n d u c t o r
21 % ’ 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
23 % 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

25 b o u n d a r y . t y p e x n = ’ cpml ’ ;
boundary . a i r b u f f e r n u m b e r o f c e l l s x n = 4 ;
27 boundary . c p m l n u m b e r o f c e l l s x n = 5 ;

29 b o u n d a r y . t y p e x p = ’ cpml ’ ;
boundary . a i r b u f f e r n u m b e r o f c e l l s x p = 4 ;
31 boundary . c p m l n u m b e r o f c e l l s x p = 5 ;

33 b o u n d a r y . t y p e y n = ’ cpml ’ ;
boundary . a i r b u f f e r n u m b e r o f c e l l s y n = 0 ;
35 b o u n d a r y . c p m l n u m b e r o f c e l l s y n = −5;

37 b o u n d a r y . t y p e y p = ’ cpml ’ ;
boundary . a i r b u f f e r n u m b e r o f c e l l s y p = 0 ;
39 b o u n d a r y . c p m l n u m b e r o f c e l l s y p = −5;

41 b o u n d a r y . t y p e z n = ’ pec ’ ;
boundary . a i r b u f f e r n u m b e r o f c e l l s z n = 0 ;
43 boundary . c p m l n u m b e r o f c e l l s z n = 5 ;

45 b o u n d a r y . t y p e z p = ’ pec ’ ;
boundary . a i r b u f f e r n u m b e r o f c e l l s z p = 6 ;
47 boundary . c p m l n u m b e r o f c e l l s z p = 5 ;

49 boundary . cpml order = 3;


boundary . c p m l sigma factor = 1.5;
51 boundary . cpml kappa max = 7 ;
boundary . cpml alpha min = 0;
53 boundary . cpml alpha max = 0 . 0 5 ;
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

242 The Convolutional Perfectly Matched Layer

Figure 8.3 A problem space with 20 × 20 × 4 cells brick.

Another parameter required for a boundary defined as CPML is the thickness of the CPML
layer in terms of number of cells. A new parameter cpml number of cells is defined as a subfield
of the parameter boundary, and the thicknesses of the CPML regions are assigned to this new pa-
rameter. One can notice that the thickness of CPML is 5 cells in the xn and xp regions and −5 cells
in the yn and y p regions. As discussed before, objects in an FDTD problem space can be defined
as penetrating into CPML; thus, these objects resemble structures extending to infinity. As a con-
vention, if cpml number of cells is defined as a negative number, it is assumed that the CPML
layers are extending to inside of the domain rather than extending outside from the end of the air
buffer region. For instance, if air buffer number of cells is zero, and the cpml number of cells
is a negative number at the yn region, then the objects on the yn side will be penetrating to the
CPML region. Figure 8.3 illustrates a problem space including a 20 × 20 × 4 cells brick and
having its boundaries defined as shown in Listing 8.1. The solid thick line shows the boundaries
of the problem space. The dash-dot thick line shows the inner boundaries of the CPML regions.
The brick penetrates into the CPML in yn and y p regions. The zn and zp boundaries are PEC.
The other parameters described in Section 8.3 are defined in define problem space parameters
as well. The order of the polynomial distribution npml is defined as boundary.cpml order as
shown in Listing 8.1. The σfactor is defined as boundary.cpml sigma factor, κmax is defined as
boundary.cpml kappa max, αmax is defined as boundary.cpml alpha max, and similarly, αmin is
defined as boundary.cpml alpha min.

8.4.2 Initialization of CPML


To employ the CPML algorithm in the time-marching loop, several coefficient and auxiliary
parameter arrays need to be defined and initialized for the respective CPML regions before the
time-marching loop starts. Before defining 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
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

MATLAB Implementation of CPML in the Three-Dimensional FDTD Method 243

position of the outer boundary needs to be updated accordingly. The necessary modifications are
implemented in calculate domain size, and the modified section of the code is given in Listing 8.2.
It can be noticed in the code that, for the sides where the boundary type is CPML, the problem
space boundary is extended outward by the thickness of the CPML.
Listing 8.2 calculate domain size

% D e t e r m i n e t h e problem s p a c e b o u n d a r i e s including air buffers
36 fdtd domain . min x = fdtd domain . min x . . .
− dx * b o u n d a r y . a i r b u f f e r n u m b e r o f cells xn ;
38 fdtd domain . min y = fdtd domain . min y . . .
− dy * b o u n d a r y . a i r b u f f e r n u m b e r o f cells yn ;
40 fdtd domain . min z = fdtd domain . min z . . .
− dz * b o u n d a r y . a i r b u f f e r n u m b e r o f cells zn ;
42 f d t d d o m a i n . max x = f d t d d o m a i n . max x . . .
+ dx * b o u n d a r y . a i r b u f f e r n u m b e r o f cells xp ;
44 f d t d d o m a i n . max y = f d t d d o m a i n . max y . . .
+ dy * b o u n d a r y . a i r b u f f e r n u m b e r o f cells yp ;
46 f d t d d o m a i n . max z = f d t d d o m a i n . max z . . .
+ dz * b o u n d a r y . a i r b u f f e r n u m b e r o f cells zp ;
48

% D e t e r m i n e t h e problem s p a c e b o u n d a r i e s i n c l u d i n g cpml l a y e r s
50 i f s t r c m p ( b o u n d a r y . t y p e x n , ’ cpml ’ ) && . . .
( b o u n d a r y . c p m l n u m b e r o f c e l l s x n >0)
52 fdtd domain . min x = fdtd domain . min x . . .
− dx * b o u n d a r y . c p m l n u m b e r o f c e l l s x n ;
54 end
i f s t r c m p ( b o u n d a r y . t y p e x p , ’ cpml ’ ) && . . .
56 ( b o u n d a r y . c p m l n u m b e r o f c e l l s x p >0)
f d t d d o m a i n . max x = f d t d d o m a i n . max x . . .
58 + dx * b o u n d a r y . c p m l n u m b e r o f c e l l s x p ;
end
60 i f s t r c m p ( b o u n d a r y . t y p e y n , ’ cpml ’ ) && . . .
( b o u n d a r y . c p m l n u m b e r o f c e l l s y n >0)
62 fdtd domain . min y = fdtd domain . min y . . .
− dy * b o u n d a r y . c p m l n u m b e r o f c e l l s y n ;
64 end
i f s t r c m p ( b o u n d a r y . t y p e y p , ’ cpml ’ ) && . . .
66 ( b o u n d a r y . c p m l n u m b e r o f c e l l s y p >0)
f d t d d o m a i n . max y = f d t d d o m a i n . max y . . .
68 + dy * b o u n d a r y . c p m l n u m b e r o f c e l l s y p ;
end
70 i f s t r c m p ( b o u n d a r y . t y p e z n , ’ cpml ’ ) && . . .
( b o u n d a r y . c p m l n u m b e r o f c e l l s z n >0)
72 fdtd domain . min z = fdtd domain . min z . . .
− dz * b o u n d a r y . c p m l n u m b e r o f c e l l s z n ;
74 end
i f s t r c m p ( b o u n d a r y . t y p e z p , ’ cpml ’ ) && . . .
76 ( b o u n d a r y . c p m l n u m b e r o f c e l l s z p >0)
f d t d d o m a i n . max z = f d t d d o m a i n . max z . . .
78 + dz * b o u n d a r y . c p m l n u m b e r o f c e l l s z p ;
end
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

244 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
field components on the outer faces of the problem space are not updated, and their values
are left zero during the time-marching loop which naturally simulates the PEC boundaries.
However, the CPML requires special treatment, and the initialization of the CPML is coded
in initialize boundary conditions accordingly as shown in Listing 8.3. In this subroutine several

Listing 8.3 initialize boundary conditions


% i n i t i a l i z e boundary parameters
2

% 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


4 is cpml xn = false ; is cpml xp = false ; is cpml yn = false ;
is cpml yp = false ; is cpml zn = false ; is cpml zp = false ;
6 is any side cpml = false ;
if s t r c m p ( b o u n d a r y . t y p e x n , ’ cpml ’ )
8 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 ) ;
10 end
i f s t r c m p ( b o u n d a r y . t y p e x p , ’ cpml ’ )
12 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 ) ;
14 end
i f s t r c m p ( b o u n d a r y . t y p e y n , ’ cpml ’ )
16 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 ) ;
18 end
i f s t r c m p ( b o u n d a r y . t y p e y p , ’ cpml ’ )
20 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 ) ;
22 end
i f s t r c m p ( b o u n d a r y . t y p e z n , ’ cpml ’ )
24 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 ) ;
26 end
i f s t r c m p ( b o u n d a r y . t y p e z p , ’ cpml ’ )
28 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 ) ;
30 end

32 if ( is cpml xn | | is cpml xp | | is cpml yn . . .


| | is cpml yp | | is cpml zn | | is cpml zp )
34 is any side cpml = true ;
end
36

% 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


38 if is any side cpml
initialize CPML ABC ;
40 end
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

MATLAB Implementation of CPML in the Three-Dimensional FDTD Method 245

frequently used parameters are defined for convenience. For instance, the parameter is cpml xn
is a logical parameter that indicates whether the xn boundary is CPML, and n cpml xn stores
the thickness of the CPML for the xn region. Similar parameters are defined for other sides as
well. Then another subroutine, initialize CPML ABC, is called to continue the CPML specific
initialization process.
Listing 8.4 shows the contents of initialize CPML ABC for the xn and xp regions. The
code listing for the other sides follows the same procedure. Let’s consider the xp region, for
example. In the code, distribution of the CPML parameters σpex , σ pmx , κe x , κmx , αe x , and αmx along
the CPML thickness are calculated as one-dimensional arrays first, with the respective names

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


4 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 ;
6 alpha min = boundary . cpml alpha min ;
alpha max = boundary . cpml alpha max ;
8

% I n i t i a l i z e cpml f o r xn r e g i o n
10 if is cpml xn

12 % d e f i n e one−d i m e n s i o n a l t e m p o r a r y cpml p a r a m e t e r a r r a y s
sigma max = s i g m a r a t i o * ( p o r d e r + 1 ) / ( 1 5 0 * p i * dx ) ;
14 n c e l l s = n cpml xn ;
rho e = ( [ n c e l l s : −1:1] −0.75)/ n c e l l s ;
16 rho m = ( [ n c e l l s : − 1 : 1 ] − 0 . 2 5 ) / n c e l l s ;
s i g m a p e x x n = sigma max * r h o e . ˆ p o r d e r ;
18 s i g m a p m x x n = sigma max * rho m . ˆ p o r d e r ;
s i g m a p m x x n = ( mu 0 / e p s 0 ) * s i g m a p m x x n ;
20 k a p p a e x x n = 1 + ( kappa max − 1 ) * r h o e . ˆ p o r d e r ;
k a p p a m x x n = 1 + ( kappa max − 1 ) * rho m . ˆ p o r d e r ;
22 a l p h a e x x n = a l p h a m i n + ( a l p h a m a x − a l p h a m i n ) * (1 − r h o e ) ;
a l p h a m x x n = a l p h a m i n + ( a l p h a m a x − a l p h a m i n ) * (1 − rho m ) ;
24 a l p h a m x x n = ( mu 0 / e p s 0 ) * a l p h a m x x n ;

26 % d e f i n e one−d i m e n s i o n a l cpml p a r a m e t e r a r r a y s
c p m l b e x x n = exp ( ( − d t / e p s 0 ) . . .
28 * ( ( s i g m a p e x x n . / k a p p a e x x n )+ a l p h a e x x n ) ) ;
c p m l a e x x n = ( 1 / dx ) * ( c p m l b e x x n − 1 . 0 ) . * s i g m a p e x x n . . .
30 . / ( k a p p a e x x n . * ( s i g m a p e x x n +k a p p a e x x n . * a l p h a e x x n ) ) ;
c p m l b m x x n = exp ( ( − d t / mu 0 ) . . .
32 * ( ( s i g m a p m x x n . / k a p p a m x xn )+ a l p h a m x x n ) ) ;
c p m l a m x x n = ( 1 / dx ) * ( cpml b mx xn − 1 . 0 ) . * s i g m a p m x x n . . .
34 . / ( k a p p a m x xn . * ( s i g m a p m x x n+k a p p a m x xn . * a l p h a m x x n ) ) ;

36 % C r e a t e and i n i t i a l i z e 2D cpml c o n v o l u t i o n p a r a m e t e r s
Psi eyx xn = z e r o s ( n c e l l s , ny , nzp1 ) ;
38 Psi ezx xn = z e r o s ( n c e l l s , nyp1 , nz ) ;
Psi hyx xn = z e r o s ( n c e l l s , nyp1 , nz ) ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

246 The Convolutional Perfectly Matched Layer

40 P s i h z x x n = z e r o s ( n c e l l s , ny , nzp1 ) ;

42 % Create 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


% Notice 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
44 CPsi eyx x n = C e y h z ( 2 : n c e l l s + 1 , : , : ) * dx ;
CPsi ezx x n = C e z h y ( 2 : n c e l l s + 1 , : , : ) * dx ;
46 CPsi hyx x n = C h y e z ( 1 : n c e l l s , : , : ) * dx ;
CPsi hzx 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
50 % N o t i c e t h a t E y ( 1 , : , : ) and E z ( 1 , : , : ) a r e n o t u p d a t e d by cmpl
for i = 1: n c e l l s
52 Ceyhz ( i + 1 , : , : ) = Ceyhz ( i + 1 , : , : ) / kappa ex xn ( i ) ;
Cezhy ( i + 1 , : , : ) = Cezhy ( i + 1 , : , : ) / kappa ex xn ( i ) ;
54 C h y e z ( i , : , : ) = C h y e z ( i , : , : ) / k a p p a m x xn ( i ) ;
C h z e y ( i , : , : ) = C h z e y ( i , : , : ) / k a p p a m x xn ( i ) ;
56 end

58 % D e l e t e t e m p o r a r y a r r a y s . T h e s e a r r a y s w i l l n o t be u s e d any more .
c l e a r sigma pex xn sigma pmx xn ;
60 c l e a r k a p p a e x x n k a p p a m x xn ;
clear alpha ex xn alpha mx xn ;
62 end

64 % I n i t i a l i z e cpml f o r xp r e g i o n
if is cpml xp
66

% d e f i n e one−d i m e n s i o n a l t e m p o r a r y cpml p a r a m e t e r a r r a y s
68 sigma max = s i g m a r a t i o * ( p o r d e r + 1 ) / ( 1 5 0 * p i * dx ) ;
n c e l l s = n cpml xp ;
70 rho e = ( [ 1 : n c e l l s ] −0.75)/ n c e l l s ;
rho m = ( [ 1 : n c e l l s ] − 0 . 2 5 ) / n c e l l s ;
72 s i g m a p e x x p = sigma max * r h o e . ˆ p o r d e r ;
s i g m a p m x x p = sigma max * rho m . ˆ p o r d e r ;
74 s i g m a p m x x p = ( mu 0 / e p s 0 ) * s i g m a p m x x p ;
k a p p a e x x p = 1 + ( kappa max − 1 ) * r h o e . ˆ p o r d e r ;
76 k a p p a m x x p = 1 + ( kappa max − 1 ) * rho m . ˆ p o r d e r ;
a l p h a e x x p = a l p h a m i n + ( a l p h a m a x − a l p h a m i n ) * (1 − r h o e ) ;
78 a l p h a m x x p = a l p h a m i n + ( a l p h a m a x − a l p h a m i n ) * (1 − rho m ) ;
a l p h a m x x p = ( mu 0 / e p s 0 ) * a l p h a m x x p ;
80

% d e f i n e one−d i m e n s i o n a l cpml p a r a m e t e r a r r a y s
82 c p m l b e x x p = exp ( ( − d t / e p s 0 ) . . .
* ( ( s i g m a p e x x p . / k a p p a e x x p )+ a l p h a e x x p ) ) ;
84 c p m l a e x x p = ( 1 / dx ) * ( c p m l b e x x p − 1 . 0 ) . * s i g m a p e x x p . . .
. / ( k a p p a e x x p . * ( s i g m a p e x x p +k a p p a e x x p . * a l p h a e x x p ) ) ;
86 c p m l b m x x p = exp ( ( − d t / mu 0 ) . . .
* ( ( s i g m a p m x x p . / k a p p a m x x p )+ a l p h a m x x p ) ) ;
88 c p m l a m x x p = ( 1 / dx ) * ( c p m l b m x xp − 1 . 0 ) . * s i g m a p m x x p . . .
. / ( k a p p a m x x p . * ( s i g m a p m x x p+k a p p a m x x p . * a l p h a m x x p ) ) ;
90

% C r e a t e and i n i t i a l i z e 2D cpml c o n v o l u t i o n p a r a m e t e r s
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

MATLAB Implementation of CPML in the Three-Dimensional FDTD Method 247

92 Psi eyx xp = zeros ( ncells , ny , nzp1 );


Psi ezx xp = zeros ( ncells , nyp1 , nz );
94 Psi hyx xp = zeros ( ncells , nyp1 , nz );
Psi hzx xp = zeros ( ncells , ny , nzp1 );
96

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


98 % Notice 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
CPsi eyx x p = C e y h z ( nxp1−n c e l l s : nx , : , : ) * dx ;
100 CPsi ezx x p = C e z h y ( nxp1−n c e l l s : nx , : , : ) * dx ;
CPsi hyx x p = C h y e z ( nxp1−n c e l l s : nx , : , : ) * dx ;
102 CPsi hzx x p = C h z e y ( nxp1−n c e l l s : nx , : , : ) * dx ;

104 % 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 ( nxp1 , : , : ) and E z ( nxp1 , : , : ) a r e n o t u p d a t e d by cmpl
106 for i = 1: n c e l l s
C e y h z ( nx−n c e l l s +i , : , : ) = C e y h z ( nx−n c e l l s +i ,: ,:)/ kappa ex xp ( i );
108 C e z h y ( nx−n c e l l s +i , : , : ) = C e z h y ( nx−n c e l l s +i ,: ,:)/ kappa ex xp ( i );
C h y e z ( nx−n c e l l s +i , : , : ) = C h y e z ( nx−n c e l l s +i ,: ,:)/ kappa mx xp ( i );
110 C h z e y ( nx−n c e l l s +i , : , : ) = C h z e y ( nx−n c e l l s +i ,: ,:)/ kappa mx xp ( i );
end
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 .
114 c l e a r sigma pex xp sigma pmx xp ;
c l e a r kappa ex xp kappa mx xp ;
116 clear alpha ex xp alpha mx xp ;
end
 

sigma pex xp, sigma pmx xp, kappa ex xp, kappa mx xp, alpha ex xp, and alpha mx xp, us-
ing the equations given in Section 8.3. The parameters σpex , κe x , and αe x are used to update the E y
and E z field components, and the distances of these field components from the interior interface
of the CPML are used in equations (8.31), (8.33), and (8.35) as ρe . The positions of the field
components and the respective distances of the field components from the CPML interface are
illustrated in Fig. 8.4. One can see that CPML interface is assumed to be offset from the first
CPML cell by a quarter cell size. This is to ensure that the same number of electric and magnetic
field components are updated by the CPML algorithm. Similarly, Fig. 8.5 illustrates the magnetic
field components of Hy and Hz being updated using the CPML in the xp region. The distances
of these field components from the CPML interface are denoted as ρh and are used in equations
(8.32), (8.34), and (8.36) to calculate σ pmx , κmx , and αmx .
Then Listing 8.4 continues with calculation of a e x , b e x , a mx , and b mx as cpml a ex xp,
cpml b ex xp, cpml a mx xp, and cpml b mx xp using the equations in Appendix B. Then the
CPML auxiliary parameters ψe y x , ψe zx , ψhy x , and ψhzx are defined as two dimensional arrays with
the names Psi eyx xp, Psi ezx xp, Psi hyx xp, and Psi hzx xp and are initialized with zero value.
The coefficients Cψe y x , Cψe zx , Cψhy x , and Cψhzx are calculated and stored as two-dimensional ar-
rays with the respective names CPsi eyx xp, CPsi ezx xp, CPsi hyx xp, and CPsi hzx xp. Then
the FDTD updating coefficients Ceyhz, Cezhy, Chyez, and Chzey are scaled with the respective
κ values in the xp region. Finally, the parameters that will not be used anymore during the FDTD
calculations are cleared from MATLAB’s workspace.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

248 The Convolutional Perfectly Matched Layer

ρe(2)
ρe(1)

Ey and Ez components
updated by CPML

Figure 8.4 Positions of the electric field components updated by CPML in the x p region.

ρh(2)
ρh(1)

Hy and Hz components
updated by CPML

Figure 8.5 Positions of the magnetic field components updated by CPML in the x p region.

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 first 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.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

MATLAB Implementation of CPML in the Three-Dimensional FDTD Method 249

Listing 8.5 run fdtd time marching loop



disp ( [ ’ S t a r t i n g the time marching loop ’ ] ) ;
2 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 ) ] ) ;
4

s t a r t t i m e = cputime ;
6 current time = 0;

8 for time step = 1: number of time steps


update magnetic fields ;
10 update magnetic field CPML ABC ;
capture sampled magnetic fields ;
12 capture sampled currents ;
update electric fields ;
14 update electric field CPML ABC ;
update voltage sources ;
16 update current sources ;
update inductors ;
18 update diodes ;
capture sampled electric fields ;
20 capture sampled voltages ;
display sampled parameters ;
22 end

24 e n d t i m e = cputime ;
t o t a l t i m e i n m i n u t e s = ( end time − s t a r t t i m e ) / 6 0 ;
26 disp ( [ ’ T o t a l s i m u l a t i o n time i s ’ . . .
num2str ( t o t a l t i m e i n m i n u t e s ) ’ m i n u t e s . ’ ] ) ;
 

The implementation of update magnetic field CPML ABC is given in Listing 8.6. The mag-
netic field components are updated for the current time step using the regular updating equations
in update magnetic fields, and then in update magnetic field CPML ABC, first the auxil-
iary ψ parameters are calculated using the current values of the electric field components.
These terms are then added to the appropriate magnetic field components in their respective
CPML regions.
Similarly, the implementation of update electric field CPML ABC is given in Listing 8.7.
The electric field components are updated for the current time step using the regular updating
equations in update electric fields, and then in update electric field CPML ABC, first the aux-
iliary ψ parameters are calculated using the current values of the magnetic field components.
These terms are then added to the appropriate electric field components in their respective
CPML regions.
One can notice in the code listings that the arrays representing ψe and ψh are two-dimensional,
whereas the arrays representing a ei , a mi , b ei , and b mi are one-dimensional. Therefore, ψe and
ψh are updated in a “for” loop using the one-dimensional arrays; if they were defined as two-
dimensional arrays, the “for” loop would be avoided, which would speed up the calculation with
the trade-off of increased memory. In the two-dimensional array case, the coefficients repre-
senting Cψe and Cψm can be distributed over a ei , a mi , b ei , and b mi in the initialization process
initialize CPML ABC, which further reduces the amount of calculations during the CPML
updates.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

250 The Convolutional Perfectly Matched Layer

Listing 8.6 update magnetic field CPML ABC



1 % 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
3 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 , : , : ) ...
5 + 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 , : , : ) ...
7 + cpml a mx xn ( i ) * ( Ey ( i +1 ,: ,:) − Ey ( i , : , : ) ) ;
end
9 Hy ( 1 : n c p m l x n , : , : ) = Hy ( 1 : n c p m l x n , : , : ) . . .
+ CPsi hyx xn ( : , : , : ) .* Psi hyx xn ( : , : , : ) ;
11 Hz ( 1 : n c p m l x n , : , : ) = Hz ( 1 : n c p m l x n , : , : ) . . .
+ CPsi hzx xn ( : , : , : ) .* Psi hzx xn ( : , : , : ) ;
13 end

15 if is cpml xp
n s t = nx − n c p m l x p ;
17 for i = 1: n cpml xp
P s i h y x x p ( i , : , : ) = cpml b mx xp ( i ) * P s i h y x x p ( i , : , : ) . . .
19 + cpml a mx xp ( i ) * ( Ez ( i+n s t +1 ,: ,:) − Ez ( i+n st , : , : ) ) ;
P s i h z x x p ( i , : , : ) = cpml b mx xp ( i ) * P s i h z x x p ( i , : , : ) . . .
21 + cpml a mx xp ( i ) * ( Ey ( i + n s t +1 ,: ,:) − Ey ( i+n s t , : , : ) ) ;
end
23

Hy ( n s t +1: nx , : ,:) = Hy ( n s t +1: nx , : , : ) ...


25 + CPsi hyx xp (: ,: ,:) .* Psi hyx xp (: ,: ,:);
Hz ( n s t +1: nx , : ,:) = Hz ( n s t +1: nx , : , : ) ...
27 + CPsi hzx xp (: ,: ,:) .* 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 filter 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 defines 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 filter 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 filter, whereas Fig. 8.7 shows the sampled currents
observed at the ports of the low-pass filter. It can be seen that the signals are sufficiently decayed
after 3,000 time steps. After the transient voltages and currents are obtained, they are used for
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation Examples 251

Listing 8.7 update electric field CPML ABC


% a p p l y CPML t o e l e c t r i c f i e l d components
2 if is cpml xn
for i = 1: n cpml xn
4 Psi eyx xn ( i , : , : ) = cpml b ex xn ( i ) * Psi eyx xn ( i , : , : ) ...
+ c p m l a e x x n ( i ) * ( Hz ( i + 1 , : , : ) − Hz ( i , : ,:));
6 Psi ezx xn ( i , : , : ) = cpml b ex xn ( i ) * Psi ezx xn ( i , : , : ) ...
+ c p m l a e x x n ( i ) * ( Hy ( i + 1 , : , : ) − Hy ( i , : ,:));
8 end
Ey ( 2 : n cpml xn + 1 , : , : ) = Ey ( 2 : n cpml xn + 1 , : , : ) ...
10 + CPsi eyx xn .* Psi eyx xn ;
Ez ( 2 : n cpml xn + 1 , : , : ) = Ez ( 2 : n cpml xn + 1 , : , : ) ...
12 + CPsi ezx xn .* Psi ezx xn ;
end
14

if is cpml xp
16 n s t = nx − n c p m l x p ;
for i = 1: n cpml xp
18 Psi eyx xp ( i , : , : ) = cpml b ex xp ( i ) * Psi eyx xp ( i ,: ,:) ...
+ c p m l a e x x p ( i ) * ( Hz ( i + n s t , : , : ) − Hz ( i+n st − 1 ,: ,:));
20 Psi ezx xp ( i , : , : ) = cpml b ex xp ( i ) * Psi ezx xp ( i ,: ,:) ...
+ c p m l a e x x p ( i ) * ( Hy ( i + n s t , : , : ) − Hy ( i+n st − 1 ,: ,:));
22 end
E y ( n s t +1: nx , : , : ) = E y ( n s t +1: nx , : , : ) . . .
24 + CPsi eyx xp .* Psi eyx xp ;
E z ( n s t +1: nx , : , : ) = E z ( n s t +1: nx , : , : ) . . .
26 + CPsi ezx xp .* Psi ezx xp ;
end
 

Listing 8.8 define problem space parameters.m


% ==<b o u n d a r y c o n d i t i o n s >========
19 % Here we d e f i n e t h e b o u n d a r y c o n d i t i o n s p a r a m e t e r s
% ’ pec ’ : p e r f e c t e l e c t r i c c o n d u c t o r
21 % ’ 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
23 % 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

25 b o u n d a r y . t y p e x n = ’ cpml ’ ;
boundary . a i r b u f f e r n u m b e r o f c e l l s x n = 5 ;
27 boundary . c p m l n u m b e r o f c e l l s x n = 8 ;

29 b o u n d a r y . t y p e x p = ’ cpml ’ ;
boundary . a i r b u f f e r n u m b e r o f c e l l s x p = 5 ;
31 boundary . c p m l n u m b e r o f c e l l s x p = 8 ;

33 b o u n d a r y . t y p e y n = ’ cpml ’ ;
boundary . a i r b u f f e r n u m b e r o f c e l l s y n = 5 ;
35 boundary . c p m l n u m b e r o f c e l l s y n = 8 ;

37 b o u n d a r y . t y p e y p = ’ cpml ’ ;
boundary . a i r b u f f e r n u m b e r o f c e l l s y p = 5 ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

252 The Convolutional Perfectly Matched Layer

39 boundary . c p m l n u m b e r o f c e l l s y p = 8 ;

41 b o u n d a r y . t y p e z n = ’ cpml ’ ;
boundary . a i r b u f f e r n u m b e r o f c e l l s z n = 5 ;
43 boundary . c p m l n u m b e r o f c e l l s z n = 8 ;

45 b o u n d a r y . t y p e z p = ’ cpml ’ ;
boundary . a i r b u f f e r n u m b e r o f c e l l s z p = 5 ;
47 boundary . c p m l n u m b e r o f c e l l s z p = 8 ;

49 boundary . cpml order = 3;


boundary . c p m l sigma factor = 1.3;
51 boundary . cpml kappa max = 7 ;
boundary . cpml alpha min = 0;
53 boundary . cpml 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 figures 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
1
source voltage

0.8

0.6
(V)

0.4

0.2

−0.2
0 0.5 1 1.5 2
time (ns)

Figure 8.6 Source voltage and sampled voltages observed at the ports of the low-pass filter.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation Examples 253

−3
x 10
12
sampled current at port 1
10 sampled current at port 2

4
(A)

−2

−4

−6
0 0.5 1 1.5 2
time (ns)

Figure 8.7 Sampled currents observed at the ports of the low-pass filter.

0
magnitude (dB)

−20

−40

−60
0 5 10 15 20
frequency (GHz)
200
phase (degrees)

−200
0 5 10 15 20
frequency (GHz)

Figure 8.8 S 11 of the low-pass filter.


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

254 The Convolutional Perfectly Matched Layer

magnitude (dB)
−20

−40

0 5 10 15 20
frequency (GHz)
200
phase (degrees)

−200
0 5 10 15 20
frequency (GHz)

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 nar-
row lines are 6 cells wide. The center-to-center distances between the strips in the square coupler
section are 24 cells. The dielectric substrate has 2.2 dielectric constant and 3 cells thickness. The
definition of the geometry of the problem is shown in Listing 8.9.
The boundaries of the problem space are the same as those in Listing 8.8: that is, an 8 cells
thick CPML, which terminates a 5 cells thick air gap surrounding the circuit.

Figure 8.10 An FDTD problem space including a microstrip branch line coupler.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation Examples 255

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

bricks = [ ] ;
4 spheres = [ ] ;

6 % define a substrate
b r i c k s ( 1 ) . m i n x = −20* dx ;
8 b r i c k s ( 1 ) . m i n y = −25* dy ;
b r i c k s ( 1 ) . min z = 0 ;
10 b r i c k s ( 1 ) . max x = 20 * dx ;
b r i c k s ( 1 ) . max y = 25 * dy ;
12 b r i c k s ( 1 ) . max z = 3 * dz ;
bricks ( 1 ) . material type = 4;
14

% d e f i n e a PEC p l a t e
16 b r i c k s ( 2 ) . m i n x = −12* dx ;
b r i c k s ( 2 ) . m i n y = −15* dy ;
18 b r i c k s ( 2 ) . m i n z = 3 * dz ;
b r i c k s ( 2 ) . max x = 12 * dx ;
20 b r i c k s ( 2 ) . max y = −9* dy ;
b r i c k s ( 2 ) . max z = 3 * dz ;
22 bricks ( 2 ) . material type = 2;

24 % d e f i n e a PEC p l a t e
b r i c k s ( 3 ) . m i n x = −12* dx ;
26 b r i c k s ( 3 ) . mi n y = 9 * dy ;
b r i c k s ( 3 ) . m i n z = 3 * dz ;
28 b r i c k s ( 3 ) . max x = 12 * dx ;
b r i c k s ( 3 ) . max y = 15 * dy ;
30 b r i c k s ( 3 ) . max z = 3 * dz ;
bricks ( 3 ) . material type = 2;
32

% d e f i n e a PEC p l a t e
34 b r i c k s ( 4 ) . m i n x = −17* dx ;
b r i c k s ( 4 ) . m i n y = −12* dy ;
36 b r i c k s ( 4 ) . m i n z = 3 * dz ;
b r i c k s ( 4 ) . max x = −7* dx ;
38 b r i c k s ( 4 ) . max y = 12 * dy ;
b r i c k s ( 4 ) . max z = 3 * dz ;
40 bricks ( 4 ) . material type = 2;

42 % d e f i n e a PEC p l a t e
b r i c k s ( 5 ) . m i n x = 7 * dx ;
44 b r i c k s ( 5 ) . mi n y = −12* dy ;
b r i c k s ( 5 ) . m i n z = 3 * dz ;
46 b r i c k s ( 5 ) . max x = 17 * dx ;
b r i c k s ( 5 ) . max y = 12 * dy ;
48 b r i c k s ( 5 ) . max z = 3 * dz ;
bricks ( 5 ) . material type = 2;
50
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

256 The Convolutional Perfectly Matched Layer

% d e f i n e a PEC p l a t e
52 b r i c k s ( 6 ) . m i n x = −15* dx ;
b r i c k s ( 6 ) . mi n y = −25* dy ;
54 b r i c k s ( 6 ) . m i n z = 3 * dz ;
b r i c k s ( 6 ) . max x = −9* dx ;
56 b r i c k s ( 6 ) . max y = −12* dy ;
b r i c k s ( 6 ) . max z = 3 * dz ;
58 bricks ( 6 ) . material type = 2;

60 % d e f i n e a PEC p l a t e
b r i c k s ( 7 ) . m i n x = 9 * dx ;
62 b r i c k s ( 7 ) . mi n y = −25* dy ;
b r i c k s ( 7 ) . m i n z = 3 * dz ;
64 b r i c k s ( 7 ) . max x = 15 * dx ;
b r i c k s ( 7 ) . max y = −12* dy ;
66 b r i c k s ( 7 ) . max z = 3 * dz ;
bricks ( 7 ) . material type = 2;
68

% d e f i n e a PEC p l a t e
70 b r i c k s ( 8 ) . m i n x = −15* dx ;
b r i c k s ( 8 ) . mi n y = 12 * dy ;
72 b r i c k s ( 8 ) . m i n z = 3 * dz ;
b r i c k s ( 8 ) . max x = −9* dx ;
74 b r i c k s ( 8 ) . max y = 25 * dy ;
b r i c k s ( 8 ) . max z = 3 * dz ;
76 bricks ( 8 ) . material type = 2;

78 % d e f i n e a PEC p l a t e
b r i c k s ( 9 ) . m i n x = 9 * dx ;
80 b r i c k s ( 9 ) . mi n y = 12 * dy ;
b r i c k s ( 9 ) . m i n z = 3 * dz ;
82 b r i c k s ( 9 ) . max x = 15 * dx ;
b r i c k s ( 9 ) . max y = 25 * dy ;
84 b r i c k s ( 9 ) . max z = 3 * dz ;
bricks ( 9 ) . material type = 2;
86

% d e f i n e a PEC p l a t e a s ground
88 b r i c k s ( 1 0 ) . m i n x = −20* dx ;
b r i c k s ( 1 0 ) . mi n y = −25* dy ;
90 b r i c k s ( 1 0 ) . min z = 0 ;
b r i c k s ( 1 0 ) . max x = 20 * dx ;
92 b r i c k s ( 1 0 ) . max y = 25 * dy ;
b r i c k s ( 1 0 ) . max z = 0 ;
94 bricks ( 1 0 ) . material type = 2;
 

The voltage source with a 50 internal resistance is placed at the input of the circuit indicated
as port 1 as shown in Fig. 8.10. The outputs of the circuit are terminated by 50 resistors. The
definition of the voltage source and resistors is shown in Listing 8.10.
Four sampled voltages and four sampled currents are defined as the outputs of the circuit as
shown in Listing 8.11. One should notice that the sampled voltages and currents are defined
directly on the voltage source and the termination resistors. Therefore, the reference planes for
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation Examples 257

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

3 voltage sources = [ ] ;
current sources = [ ] ;
5 diodes = [ ] ;
resistors = [];
7 inductors = [ ] ;
capacitors = [ ] ;
9

% d e f i n e s o u r c e waveform t y p e s and p a r a m e t e r s
11 waveforms . g a u s s i a n ( 1 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 0 ;
waveforms . g a u s s i a n ( 2 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 15;
13

% voltage sources
15 % d i r e c t i o n : ’ xp ’ , ’ xn ’ , ’ yp ’ , ’ yn ’ , ’ zp ’ , o r ’ zn ’
% r e s i s t a n c e : ohms , m a g i t u d e : volts
17 v o l t a g e s o u r c e s ( 1 ) . m i n x = −15* dx ;
v o l t a g e s o u r c e s ( 1 ) . m i n y = −25* dy ;
19 v o l t a g e s o u r c e s ( 1 ) . min z = 0 ;
v o l t a g e s o u r c e s ( 1 ) . max x = −9* dx ;
21 v o l t a g e s o u r c e s ( 1 ) . max y = −25* dy ;
v o l t a g e s o u r c e s ( 1 ) . max z = 3 * dz ;
23 v o l t a g e s o u r c e s ( 1 ) . d i r e c t i o n = ’ zp ’ ;
v o l t a g e s o u r c e s ( 1 ) . r e s i s t a n c e = 50;
25 v o l t a g e s o u r c e s ( 1 ) . magnitude = 1 ;
v o l t a g e s o u r c e s ( 1 ) . waveform type = ’ gaussian ’ ;
27 v o l t a g e s o u r c e s ( 1 ) . waveform index = 1;

29 % resistors
% direction : ’ x ’ , ’ y ’ , or ’ z ’
31 % resistance : ohms
resistors (1). m i n x = 9 * dx ;
33 resistors (1). mi n y = −25* dy ;
resistors (1). min z = 0 ;
35 resistors (1). max x = 15 * dx ;
resistors (1). max y = −25* dy ;
37 resistors (1). max z = 3 * dz ;
resistors (1). direction = ’z ’ ;
39 resistors (1). r e s i s t a n c e = 50;

41 % resistors
% direction : ’ x ’ , ’ y ’ , or ’ z ’
43 % resistance : ohms
resistors (2). m i n x = 9 * dx ;
45 resistors (2). mi n y = 25 * dy ;
resistors (2). min z = 0 ;
47 resistors (2). max x = 15 * dx ;
resistors (2). max y = 25 * dy ;
49 resistors (2). max z = 3 * dz ;
resistors (2). direction = ’z ’ ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

258 The Convolutional Perfectly Matched Layer

51 r e s i s t o r s ( 2 ) . r e s i s t a n c e = 50;

53 % resistors
% direction : ’ x ’ , ’ y ’ , or ’ z ’
55 % resistance : ohms
resistors (3). m i n x = −15* dx ;
57 resistors (3). mi n y = 25 * dy ;
resistors (3). min z = 0 ;
59 resistors (3). max x = −9* dx ;
resistors (3). max y = 25 * dy ;
61 resistors (3). max z = 3 * dz ;
resistors (3). direction = ’z ’ ;
63 resistors (3). r e s i s t a n c e = 50;
 

Listing 8.11 define output parameters.m


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

sampled electric fields = [];


4 sampled magnetic fields = [ ] ;
sampled voltages = [ ] ;
6 sampled currents = [ ] ;
ports = [ ] ;
8

% figure refresh rate


10 p l o t t i n g s t e p = 5;

12 % mode o f o p e r a t i o n
run simulation = true ;
14 show material mesh = true ;
show problem space = true ;
16

% f r e q u e n c y domain p a r a m e t e r s
18 f r e q u e n c y d o m a i n . s t a r t = 20 e6 ;
f r e q u e n c y d o m a i n . end = 10 e9 ;
20 f r e q u e n c y d o m a i n . s t e p = 20 e6 ;

22 % define sampled voltages


sampled voltages ( 1 ) . m i n x = −15* dx ;
24 sampled voltages ( 1 ) . m i n y = −25* dy ;
sampled voltages ( 1 ) . min z = 0 ;
26 sampled voltages ( 1 ) . max x = −9* dx ;
sampled voltages ( 1 ) . max y = −25* dy ;
28 sampled voltages ( 1 ) . max z = 3 * dz ;
sampled voltages ( 1 ) . d i r e c t i o n = ’ zp ’ ;
30 sampled voltages (1). display plot = false ;

32 % define sampled voltages


sampled voltages ( 2 ) . m i n x = 9 * dx ;
34 sampled voltages ( 2 ) . m i n y = −25* dy ;
sampled voltages ( 2 ) . min z = 0 ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation Examples 259

36 sampled voltages (2). max x = 15 * dx ;


sampled voltages (2). max y = −25* dy ;
38 sampled voltages (2). max z = 3 * dz ;
sampled voltages (2). d i r e c t i o n = ’ zp ’ ;
40 sampled voltages (2). display plot = false ;

42 % define sampled voltages


sampled voltages ( 3 ) . m i n x = 9 * dx ;
44 sampled voltages ( 3 ) . m i n y = 25 * dy ;
sampled voltages ( 3 ) . min z = 0 ;
46 sampled voltages ( 3 ) . max x = 15 * dx ;
sampled voltages ( 3 ) . max y = 25 * dy ;
48 sampled voltages ( 3 ) . max z = 3 * dz ;
sampled voltages ( 3 ) . d i r e c t i o n = ’ zp ’ ;
50 sampled voltages (3). display plot = false ;

52 % define sampled voltages


sampled voltages ( 4 ) . m i n x = −15* dx ;
54 sampled voltages ( 4 ) . m i n y = 25 * dy ;
sampled voltages ( 4 ) . min z = 0 ;
56 sampled voltages ( 4 ) . max x = −9* dx ;
sampled voltages ( 4 ) . max y = 25 * dy ;
58 sampled voltages ( 4 ) . max z = 3 * dz ;
sampled voltages ( 4 ) . d i r e c t i o n = ’ zp ’ ;
60 sampled voltages (4). display plot = false ;

62 % define sampled currents


sampled currents ( 1 ) . m i n x = −15* dx ;
64 sampled currents ( 1 ) . m i n y = −25* dy ;
sampled currents ( 1 ) . m i n z = 2 * dz ;
66 sampled currents ( 1 ) . max x = −9* dx ;
sampled currents ( 1 ) . max y = −25* dy ;
68 sampled currents ( 1 ) . max z = 2 * dz ;
sampled currents ( 1 ) . d i r e c t i o n = ’ zp ’ ;
70 sampled currents (1). display plot = false ;

72 % define sampled currents


sampled currents ( 2 ) . m i n x = 9 * dx ;
74 sampled currents ( 2 ) . m i n y = −25* dy ;
sampled currents ( 2 ) . m i n z = 2 * dz ;
76 sampled currents ( 2 ) . max x = 15 * dx ;
sampled currents ( 2 ) . max y = −25* dy ;
78 sampled currents ( 2 ) . max z = 2 * dz ;
sampled currents ( 2 ) . d i r e c t i o n = ’ zp ’ ;
80 sampled currents (2). display plot = false ;

82 % define sampled currents


sampled currents ( 3 ) . min x = 9 * dx ;
84 sampled currents ( 3 ) . min y = 25 * dy ;
sampled currents ( 3 ) . min z = 2 * dz ;
86 sampled currents ( 3 ) . max x = 15 * dx ;
sampled currents ( 3 ) . max y = 25 * dy ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

260 The Convolutional Perfectly Matched Layer

88 s a m p l e d c u r r e n t s ( 3 ) . max z = 2 * dz ;
s a m p l e d c u r r e n t s ( 3 ) . d i r e c t i o n = ’ zp ’ ;
90 sampled currents ( 3 ) . display plot = false ;

92 % define sampled currents


sampled currents ( 4 ) . m i n x = −15* dx ;
94 sampled currents ( 4 ) . m i n y = 25 * dy ;
sampled currents ( 4 ) . m i n z = 2 * dz ;
96 sampled currents ( 4 ) . max x = −9* dx ;
sampled currents ( 4 ) . max y = 25 * dy ;
98 sampled currents ( 4 ) . max z = 2 * dz ;
sampled currents ( 4 ) . d i r e c t i o n = ’ zp ’ ;
100 sampled currents (4). display plot = false ;

102 % define ports


ports ( 1 ) . sampled voltage index = 1;
104 ports ( 1 ) . sampled current index = 1;
ports ( 1 ) . impedance = 5 0 ;
106 ports ( 1 ) . is source port = true ;

108 ports (2). sampled voltage index = 2;


ports (2). sampled current index = 2;
110 ports (2). impedance = 5 0 ;
ports (2). is source port = false ;
112

ports (3). sampled voltage index = 3;


114 ports (3). sampled current index = 3;
ports (3). impedance = 5 0 ;
116 ports (3). is source port = false ;

118 ports (4). sampled voltage index = 4;


ports (4). sampled current index = 4;
120 ports (4). impedance = 5 0 ;
ports (4). is source port = false ;
122

% define animation
124 % f i e l d t y p e s h a l l be ’ e ’ o r ’ h ’
% p l a n e c u t s h a l l be ’ xy ’ , yz , o r z x
126 % component s h a l l be ’ x ’ , ’ y ’ , ’ z ’ , o r ’m;
animation ( 1 ) . f i e l d t y p e = ’ e ’ ;
128 a n i m a t i o n ( 1 ) . component = ’m ’ ;
animation ( 1 ) . p l a n e c u t ( 1 ) . t y pe = ’ xy ’ ;
130 a n i m a t i o n ( 1 ) . p l a n e c u t ( 1 ) . p o s i t i o n = 2 * dz ;
animation ( 1 ) . enable = true ;
132 animation ( 1 ) . d i s p l a y g r i d = f a l s e ;
animation ( 1 ) . d i s p l a y o b j e c t s = true ;
134

% d i s p l a y problem s p a c e p a r a m e t e r s
136 problem space display . labels = false ;
problem space display . a x i s a t o r i g i n = false ;
138 problem space display . axis outside domain = false ;
problem space display . grid xn = false ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation Examples 261

140 problem space display . grid xp = false ;


problem space display . grid yn = false ;
142 problem space display . grid yp = false ;
problem space display . grid zn = false ;
144 problem space display . grid zp = false ;
problem space display . outer boundaries = false ;
146 problem space display . 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 defined by associating sampled voltage–current pairs with them. Then port 1
is set to be the excitation port for this FDTD simulation.
After the definition of the problem is completed, the FDTD simulation is performed for 4,000
time steps, and the S-parameters of this circuit are calculated. Figure 8.11 shows the results of
this calculation, where S11 , S21 , S31 , and S41 are plotted. There is a good agreement between the
plotted results and those published in [14].

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

−5

−10
magnitude (dB)

−15
S11
−20
S21
S31
−25
S41
−30

−35

−40
0 2 4 6 8 10
frequency (GHz)

Figure 8.11 S-parameters of the branch line coupler.


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

262 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 infinity in these directions. The definition of the
problem space including the cell sizes and boundaries is shown in Listing 8.12. The definition of
the geometry is given in Listing 8.13. The microstrip line is fed with voltage source as defined in
Listing 8.14. A sampled voltage and a sampled current are defined 10 cells away from the source,
and they are tied to form a port as shown in Listing 8.15.

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

% 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


4 number of time steps = 1000;

6 % A f a c t o r t h a t determines d u r a t i o n of a time s t e p
% wrt CFL l i m i t
8 courant factor = 0.9;

10 % A f a c t o r d e t e r m i n i n g t h e a c c u r a c y l i m i t o f FDTD r e s u l t s
number of cells per wavelength = 20;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation Examples 263

12

% D i m e n s i o n s o f a u n i t c e l l i n x , y , and z d i r e c t i o n s ( m e t e r s )
14 dx = 2 . 0 3 0 e −4;
dy = 2 . 0 3 0 e −4;
16 dz = 1 . 3 2 5 e −4;

18 % ==<b o u n d a r y c o n d i t i o n s >========
% Here we d e f i n e t h e b o u n d a r y c o n d i t i o n s p a r a m e t e r s
20 % ’ pec ’ : p e r f e c t e l e c t r i c c o n d u c t o r
% ’ cpml ’ : c o n l v o l u t i o n a l PML
22 % i f c p m l n u m b e r o f c e l l s i s l e s s than zero
% CPML e x t e n d s i n s i d e o f t h e domain r a t h e r t h a n o u t w a r d s
24

b o u n d a r y . t y p e x n = ’ cpml ’ ;
26 boundary . a i r b u f f e r n u m b e r o f c e l l s x n = 0 ;
b o u n d a r y . c p m l n u m b e r o f c e l l s x n = −8;
28

b o u n d a r y . t y p e x p = ’ cpml ’ ;
30 boundary . a i r b u f f e r n u m b e r o f c e l l s x p = 0 ;
b o u n d a r y . c p m l n u m b e r o f c e l l s x p = −8;
32

b o u n d a r y . t y p e y n = ’ cpml ’ ;
34 boundary . a i r b u f f e r n u m b e r o f c e l l s y n = 8 ;
boundary . c p m l n u m b e r o f c e l l s y n = 8 ;
36

b o u n d a r y . t y p e y p = ’ cpml ’ ;
38 boundary . a i r b u f f e r n u m b e r o f c e l l s y p = 0 ;
b o u n d a r y . c p m l n u m b e r o f c e l l s y p = −8;
40

b o u n d a r y . t y p e z n = ’ pec ’ ;
42 boundary . a i r b u f f e r n u m b e r o f c e l l s z n = 0 ;
boundary . c p m l n u m b e r o f c e l l s z n = 8 ;
44

b o u n d a r y . t y p e z p = ’ cpml ’ ;
46 boundary . a i r b u f f e r n u m b e r o f c e l l s z p = 10;
boundary . c p m l n u m b e r o f c e l l s z p = 8 ;
48

boundary . cpml order = 3;


50 boundary . c p m l sigma factor = 1;
boundary . cpml kappa max = 1 0 ;
52 boundary . cpml alpha min = 0;
boundary . cpml 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 reflection observed from the
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

264 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

bricks = [ ] ;
4 spheres = [ ] ;

6 % define a substrate
b r i c k s ( 1 ) . min x = 0 ;
8 b r i c k s ( 1 ) . mi n y = 0 ;
b r i c k s ( 1 ) . min z = 0 ;
10 b r i c k s ( 1 ) . max x = 60 * dx ;
b r i c k s ( 1 ) . max y = 60 * dy ;
12 b r i c k s ( 1 ) . max z = 6 * dz ;
bricks ( 1 ) . material type = 4;
14

% d e f i n e a PEC p l a t e
16 b r i c k s ( 2 ) . m i n x = 24 * dx ;
b r i c k s ( 2 ) . mi n y = 0 ;
18 b r i c k s ( 2 ) . m i n z = 6 * dz ;
b r i c k s ( 2 ) . max x = 36 * dx ;
20 b r i c k s ( 2 ) . max y = 60 * dy ;
b r i c k s ( 2 ) . max z = 6 . 0 2 * dz ;
22 bricks ( 2 ) . material type = 2;
 

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

voltage sources = [ ] ;
4 current sources = [ ] ;
diodes = [ ] ;
6 resistors = [];
inductors = [ ] ;
8 capacitors = [ ] ;

10 % d e f i n e s o u r c e waveform t y p e s and p a r a m e t e r s
waveforms . g a u s s i a n ( 1 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 0 ;
12 waveforms . g a u s s i a n ( 2 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 15;

14 % voltage sources
% d i r e c t i o n : ’ xp ’ , ’ xn ’ , ’ yp ’ , ’ yn ’ , ’ zp ’ , o r ’ zn ’
16 % r e s i s t a n c e : ohms , m a g i t u d e : volts
v o l t a g e s o u r c e s ( 1 ) . m i n x = 24 * dx ;
18 v o l t a g e s o u r c e s ( 1 ) . min y = 0 ;
v o l t a g e s o u r c e s ( 1 ) . min z = 0 ;
20 v o l t a g e s o u r c e s ( 1 ) . max x = 36 * dx ;
v o l t a g e s o u r c e s ( 1 ) . max y = 0 ;
22 v o l t a g e s o u r c e s ( 1 ) . max z = 6 * dz ;
v o l t a g e s o u r c e s ( 1 ) . d i r e c t i o n = ’ zp ’ ;
24 v o l t a g e s o u r c e s ( 1 ) . r e s i s t a n c e = 50;
v o l t a g e s o u r c e s ( 1 ) . magnitude = 1 ;
26 v o l t a g e s o u r c e s ( 1 ) . waveform type = ’ gaussian ’ ;
v o l t a g e s o u r c e s ( 1 ) . waveform index = 1;
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation Examples 265

Listing 8.15 define output parameters.m


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

3 sampled electric fields = [];


sampled magnetic fields = [ ] ;
5 sampled voltages = [ ] ;
sampled currents = [ ] ;
7 ports = [ ] ;

9 % figure refresh rate


p l o t t i n g s t e p = 20;
11

% mode o f o p e r a t i o n
13 run simulation = true ;
show material mesh = true ;
15 show problem space = true ;

17 % f r e q u e n c y domain p a r a m e t e r s
f r e q u e n c y d o m a i n . s t a r t = 20 e6 ;
19 f r e q u e n c y d o m a i n . end = 10 e9 ;
f r e q u e n c y d o m a i n . s t e p = 20 e6 ;
21

% define sampled voltages


23 sampled voltages ( 1 ) . m i n x = 24 * dx ;
sampled voltages ( 1 ) . m i n y = 40 * dy ;
25 sampled voltages ( 1 ) . min z = 0 ;
sampled voltages ( 1 ) . max x = 36 * dx ;
27 sampled voltages ( 1 ) . max y = 40 * dy ;
sampled voltages ( 1 ) . max z = 6 * dz ;
29 sampled voltages ( 1 ) . d i r e c t i o n = ’ zp ’ ;
sampled voltages (1). display plot = false ;
31

% define sampled currents


33 sampled currents ( 1 ) . m i n x = 24 * dx ;
sampled currents ( 1 ) . m i n y = 40 * dy ;
35 sampled currents ( 1 ) . m i n z = 6 * dz ;
sampled currents ( 1 ) . max x = 36 * dx ;
37 sampled currents ( 1 ) . max y = 40 * dy ;
sampled currents ( 1 ) . max z = 6 * dz ;
39 sampled currents ( 1 ) . d i r e c t i o n = ’ yp ’ ;
sampled currents (1). display plot = false ;
41

% define ports
43 ports ( 1 ) . sampled voltage index = 1;
ports ( 1 ) . sampled current index = 1;
45 ports ( 1 ) . impedance = 5 0 ;
ports ( 1 ) . is source port = true ;
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

266 The Convolutional Perfectly Matched Layer

1.2
sampled voltage
source voltage
1

0.8

0.6
(volt)

0.4

0.2

−0.2
0 0.05 0.1 0.15 0.2 0.25 0.3
time (ns)

Figure 8.13 Source voltage and sampled voltage of the microstrip line.

−3
x 10
10
sampled current

6
(ampere)

−2
0 0.05 0.1 0.15 0.2 0.25 0.3
time (ns)

Figure 8.14 Current on the microstrip line.


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Exercises 267

−30

magnitude (dB)
−40

−50
0 2 4 6 8 10
frequency (GHz)
−50
phase (degrees)

−100

−150

−200
0 2 4 6 8 10
frequency (GHz)

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. Redefine the CPML absorb-
ing boundary condition (ABC) such that the substrate penetrates into the CPML on the xn
and xp sides. The geometry of the problem is illustrated in Fig. 8.18. Run the simulation,
obtain the S-parameters of the circuit, and compare the results with those you obtained for
Exercise 8.1.
8.3 Consider the microstrip line circuit in Section 8.5.3. In this example the performance of
the CPML is not examined numerically. We need a reference case to examine the CPML
performance. Extend the length of the circuit twice on the y p side, and change the boundary
type on that side to PEC such that the microstrip line is touching the PEC boundary.
The geometry of the problem is illustrated in Fig. 8.19. Run the simulation a number of
time steps such that the reflected pulse from the PEC termination will not be observed at
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

268 The Convolutional Perfectly Matched Layer

60

50

real{Z0}
40
imaginary{Z0}

30
(Ω)

20

10

−10
0 2 4 6 8 10
frequency (GHz)

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 reflected signals as if the microstrip line is infinitely long. Compare the sampled
voltage that you obtained from the circuit in Section 8.5.3 with the reference case. The
difference between the sampled voltage magnitudes is the reflection. Find the maximum
value of the reflection.

Figure 8.17 The problem space for the quarter-wave transformer with CPML boundaries on the x n, x p, yn, yp,
and zp sides.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Exercises 269

Figure 8.18 The problem space for the quarter-wave transformer with the substrate penetrating into the CPML
boundaries on the x n and x p sides.

8.4 In Exercise 8.3 you constructed a reference case for examining the CPML performance.
Change the thickness of the CPML to 5 cells on the y p side in the microstrip line circuit
in Section 8.5.3. Run the simulation, and then calculate the reflected voltage as described
in Exercise 8.3. Examine whether the reflection increases or decreases. Then repeat the

Figure 8.19 The microstrip line reference case.


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

270 The Convolutional Perfectly Matched Layer

same exercise by increasing the CPML thickness to 10 cells. Examine whether the reflection
increases or decreases.
8.5 The CPML parameters σfactor , κmax , αmax , αmin , and npml used in the example in Section 8.5.3
are not necessarily the optimum parameters for the CPML performance. Change the values
of some of these parameters, and examine whether the reflections from the 8 cell thick
CPML boundary increases or decreases. For instance, try σfactor = 1.5, κmax = 11, αmin = 0,
αmax = 0.02, and npml = 3.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

9
Near-Field to Far-Field
Transformation

In previous chapters, the finite-difference time-domain (FDTD) method is used to compute


electric and magnetic fields within a finite space around an electromagnetic object, (i.e., the
near-zone electromagnetic fields). In many applications such as antennas and radar cross-section
(RCS), it is necessary to find the radiation or scattered fields in the region that is far away from
an antenna or scatterer. With the FDTD technique, the direct evaluation of the far field calls
for an excessively large computational domain, which is not practical in applications. Instead, the
far-zone electromagnetic fields are computed from the near-field FDTD data through a near-field
to far-field (NF–FF) transformation technique [1].
A simple condition for the far field is defined as follows:

2π R
kR  1 ⇒  1, (9.1)
λ
where R is the distance from radiator to the observation point, k is the wavenumber in free space,
and λ is the wavelength. For an electrically large antenna such as a parabolic reflector, the aperture
size D is often used to determine the far-field condition [28]:

2D2
r> , (9.2)
λ
where r is the distance from the center of the antenna aperture to the observation point. In the
far-field region, the electromagnetic field at an observation point (r, θ, φ) can be expressed as
− j kr
 θ, φ) = e
E(r, F (θ, φ), (9.3a)
4πr

H = r̂ × E , (9.3b)
η0

where η0 is the wave impedance of free space, and F (θ, φ) is a term determining the angular
variations of the far-field pattern of the electric field. Thus, the radiation pattern of the antenna
is only a function of the angular position (θ, φ) and is independent of the distance r.
In general, the near-field to far-field transformation technique is implemented in a two-step
procedure. First, an imaginary surface is selected to enclose the antenna, as shown in Fig. 9.1.
The currents J and M  on the surface are determined by the computed E and H  fields inside

271
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

272 Near-Field to Far-Field Transformation

J
M

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 field from the
currents is equivalent to the radiation field from the antenna. Next, the vector potentials A  and
  
F are used to compute the radiation fields from the equivalent currents J and M. The far-field
conditions are used in the derivations to obtain the appropriate analytical formulas.
Compared with the direct FDTD simulation that requires a mesh extending many wavelengths
from the object, a much smaller FDTD mesh is needed to evaluate the equivalent currents J and
 Thus, it is much more computationally efficient to use this near-field to far-field transformation
M.
technique.
According to different computation objectives, the transformation technique can be applied
in both the time and frequency domains, as shown in Fig. 9.2. When transient or broadband
frequency-domain results are required at a limited number of observation angles, the left path in
Fig. 9.2 is adopted. For these situations, the time-domain transformation is used and the transient
far-zone fields at each angle of interest are stored while updating the field components [29,30].
In contrast, when the far fields at all observation angles are required for a limited number
of frequencies, the right path in Fig. 9.2 is adopted. For each frequency of interest a running
discrete Fourier transform (DFT) of the tangential fields (surface currents) on a closed surface is
updated at each time step. The complex frequency-domain currents obtained from the DFT are
then used to compute the far-zone fields at all observation angles through the frequency-domain
transformation.
This chapter is organized as follows. First, the surface equivalence theorem is discussed, and
the equivalent currents J and M  are obtained from the near-field FDTD data. Then the im-
portant radiation formulas are presented to calculate the far fields from the equivalent currents.
The implementation procedure is illustrated with full details. Finally, two antenna examples are
provided to demonstrate the validity of the near-to far-field technique.

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 fictitious surface currents on a surrounding closed surface.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Implementation of the Surface Equivalence Theorem 273

J
M DFT
Currents (J,M) in
Currents (J,M) in Frequency Domain at
Time Domain a specific frequency

Transformation of Transformation of
(J,M) (E,H) (J,M) (E,H)

DFT

Far Field at a selected number Far Field at all observation


of observation points, but for angles for selected number of
all valid frequencies frequencies

Figure 9.2 Two paths of the near-field to far-field transformation technique are implemented to achieve different
computation objectives.

Within a specific region, the fields generated by the fictitious currents represent the original
fields.
Figure 9.3 illustrates a typical implementation of the surface equivalent theorem. Assume that
fields generated by an arbitrary source are ( E, H).
 An imaginary surface S is selected to enclose
all the sources and scattering objects, as shown in Fig. 9.3(a). Outside the surface S is only free
space. An equivalent problem is set up in Fig. 9.3(b), where the fields outside the surface S remain
the same but inside the surface S are set to zero. It is obvious that this setup is feasible because
the fields satisfy Maxwell’s equations both inside and outside the surface S. To comply with the

E, H
E, H
S n̂
S
J s = nˆ × H
E = 0,
scatterers H = 0.
and sources Ms = −nˆ × Eˆ
(a) original problem (b) Equivalent problem for region
outside S

Figure 9.3 Surface equivalence theorem.


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

274 Near-Field to Far-Field Transformation

boundary conditions on the surface, equivalent surface currents must be introduced on S:


 
JS = n̂ × H out − H 
 in = n̂ × H, (9.4a)
 
 S = −n̂ × E out − E in = −n̂ × E.
M  (9.4b)

It is worthwhile to emphasize that Figs. 9.3(a) and 9.3(b) have the same fields outside the surface
S but different fields inside the surface S.
If the field values on the surface S in the original problem Fig. 9.3(a) can be accurately obtained
by some means, the surface currents in Fig. 9.3(b) can be determined from (9.4). Then the fields
at any arbitrary far observation point in Fig. 9.3(b) can be readily calculated from the vector
potential approach. Based on the uniqueness theorem, the computed fields are the only solution
of the problem in Fig. 9.3(b). According to the relations between Figs. 9.3(a) and 9.3(b), the
computed fields outside the surface S are also the solution for the original problem.
The implementation of the surface equivalence theorem simplifies the far-field calculation. In
the original Fig. 9.3(a) problem, materials with different permittivities and permeabilities may
exist inside the surface S. Thus, a complex Green’s function needs to be derived to calculate
the radiating field. In the problem in Fig. 9.3(b), the fields inside the surface are zero, and the
permittivity and permeability can be set the same as the outside free space. Hence, the simple free
space Green’s function is used to compute the radiating field.

9.1.2 Equivalent Surface Currents in FDTD Simulation


From the previous discussion, it is clear that the key point of the equivalence theorem implemen-
tation 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 fits the FDTD grid. It is set between the analyzed
objects and the outside absorbing boundary. The location of the box can be defined 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 first 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 ẑ. From (9.4),
the equivalent surface currents are calculated as
 
 = ẑ × x̂ Hx + ŷ Hy + ẑHz = −x̂ Hy + ŷ Hx ,
JS = ẑ × H (9.5a)
 
 S = −ẑ × E = −ẑ × x̂ E x + ŷ E y + ẑE z = x̂ E y − ŷ E x .
M (9.5b)

Thus, the scalar surface currents can be obtained:

JS = x̂ Jx + ŷ Jy ⇒ Jx = −Hy , Jy = Hx , (9.6a)


 S = x̂ Mx + ŷ My ⇒ Mx = E y ,
M My = −E x . (9.6b)
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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 fields used in (9.6) are computed from the FDTD simulation. For a time-
domain far-field calculation, the time-domain data are used directly. For a frequency-domain
far-field calculation, a DFT needs to be carried out to obtain the desired frequency components
of the fields.

Imaginary closed surface face zp ⇒ J x , J y , M x , M y

z
x y
facexn ⇒ J y , J z , M y , M z

face yn ⇒ J x , J z , M x , M z face yp ⇒ J x , J z , M x , M z

face zn ⇒ J x , J y , M x , M y
facexp ⇒ J y , J z , M y , M z

Figure 9.5 Equivalent surface currents on the imaginary closed surface.


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

276 Near-Field to Far-Field Transformation

Similar methodology is used to obtain the surface currents on the other five surfaces. On the
bottom surface,

JS = x̂ Jx + ŷ Jy ⇒ Jx = Hy , Jy = −Hx , (9.7a)


 S = x̂ Mx + ŷ My ⇒ Mx = −E y ,
M My = E x . (9.7b)

On the left surface,

JS = x̂ Jx + ẑJz ⇒ Jx = −Hz , Jz = Hx , (9.8a)


 S = x̂ Mx + ẑMz ⇒ Mx = E z ,
M Mz = −E x . (9.8b)

On the right surface,

JS = x̂ Jx + ẑJz ⇒ Jx = Hz , Jz = −Hx , (9.9a)


 S = x̂ Mx + ẑMz ⇒ Mx = −E z ,
M Mz = E x . (9.9b)

On the front surface,

JS = ŷ Jy + ẑJz ⇒ Jy = −Hz , Jz = Hy , (9.10a)


 S = ŷ My + ẑMz ⇒ My = E z ,
M Mz = −E y . (9.10b)

On the back surface,

JS = ŷ Jy + ẑJz ⇒ Jy = Hz , Jz = −Hy , (9.11a)


 S = ŷ My + ẑMz ⇒ My = −E z ,
M Mz = E y . (9.11b)

To obtain complete source currents for the far-field calculation, equations (9.6)–(9.11) must be
calculated at every FDTD cell on the equivalent closed surface. It is preferable that the magnetic
and electric currents should be located at the same position, namely, the center of each Yee’s cell
surface that touches the equivalent surface S. Because of the spatial offset between the components
of the E and H field locations on Yee’s cell, averaging of the field components may be performed
to obtain the value of the current components at the center location. The obtained surface currents
are then used to compute the far-field pattern in the next section.

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 infinite 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 flow along the
opposite direction for horizontal electric current and vertical magnetic currents. This arrangement
is valid for ground planes simulating infinite perfect electric conductor (PEC).
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Frequency Domain Near-Field to Far-Field Transformation 277

Imaginary Imaginary
closed surface closed surface

Image
Ground plane

Figure 9.6 An imaginary closed surface on an infinite PEC ground plane using the image theory.

9.2 FREQUENCY DOMAIN NEAR-FIELD TO FAR-FIELD TRANSFORMATION


In this section, the obtained equivalent surface currents are used to calculate the far-field radiation
patterns. Antenna polarization and radiation efficiency are also discussed.

9.2.1 Time-Domain to Frequency-Domain Transformation


This section focuses on the frequency-domain far-field calculation. For the time-domain analysis,
readers are suggested to study reference [29,30]. The first thing in the frequency-domain calcula-
tion 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 finished. For a cubic
imaginary box with N × N cells on each surface, the total required storage size for the surface
currents is 4 × 6 × N2 . Note that the frequency-domain data in (9.12) have complex values.
If radiation patterns at multiple frequencies are required, a pulse excitation is used in the
FDTD simulation. For each frequency of interest, the DFT in (9.12) is performed with the
corresponding frequency value. One round of FDTD simulation is capable to provide surface
currents and radiation patterns at multiple frequencies.

9.2.2 Vector Potential Approach


For radiation problems, a vector potential approach is well developed to compute the unknown
far fields from the known electric and magnetic currents [32]. A pair of vector potential functions
is defined as
− jkR
 = µ0 e
A 
N, (9.13a)
4π R
ε0 e − j k R 
F = L, (9.13b)
4π R
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

278 Near-Field to Far-Field Transformation

Observation
point
Equivalent surface
( x′, y′, z′) R ( x, y , z )

r
r′
y ψ

x
z

Figure 9.7 The equivalent surface current source and far field.

where

 =
N JS e − j kr cos(ψ) dS ,

(9.14a)
S

=
L S e − j kr  cos(ψ) dS .
M (9.14b)
S

As illustrated in Fig. 9.7, the vector r = r r̂ denotes the position of the observation point (x, y, z),
whereas the vector r = r r̂  denotes the position of source point (x  , y  , z ) on the surface S. The
vector R = R R̂ is between the source point and the observation point, and the angle ψ represents
the angle between r and r . In the far-field calculation, the distance R is approximated by
 
  r − r  cos(ψ) for the phase term
R = r + (r ) − 2rr cos(ψ) =
2 2 (9.15)
r for the amplitude term

The computation of the components of E and H in the far fields can then be obtained using the
vector potentials, which are expressed as

Er = 0, (9.16a)
j ke − j kr  
Eθ = − Lφ + η0 Nθ , (9.16b)
4πr
j ke − j kr  
Eφ = + Lθ − η0 Nφ , (9.16c)
4πr
Hr = 0, (9.16d)
− j kr  
j ke Lθ
Hθ = + Nφ − , (9.16e)
4πr η0
 
j ke − j kr Lφ
Hφ = − Nθ + . (9.16f)
4πr η0
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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θ = Jx cos(θ )cos(φ) + Jy cos(θ )sin(φ) − Jz sin(θ ) e − j kr cos(ψ) dS , (9.17a)
S

  
Nφ = −Jx sin(φ) + Jy cos(φ) e − j kr cos(ψ) dS , (9.17b)
S

  
Lθ = Mx cos(θ )cos(φ) + My cos(θ )sin(φ) − Mz sin(θ ) e − j kr cos(ψ) dS , (9.17c)
S

  
Lφ = −Mx sin(φ) + My cos(φ) e − j kr cos(ψ) dS . (9.17d)
S

Substituting (9.17) into (9.16), the far-field pattern can be obtained at any observation point
(r, θ, φ).

9.2.3 Polarization of Radiation Field


The E and H fields 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)
field components. This can be done through unit vector transformations between LP and CP
components, such that

θ̂ − j φ̂ θ̂ + j φ̂ Ê R Ê L
θ̂ = + =√ +√ , (9.18a)
2 2 2 2
θ̂ + j φ̂ θ̂ − j φ̂ Ê L Ê R
φ̂ = − = √ − √ , (9.18b)
2j 2j j 2 j 2

where Ê R and Ê L are unit vectors for the right-hand circularly polarized (RHCP) field and
left-hand circularly polarized (LHCP) field. Substituting (9.18) into (9.16), we obtain
   
Ê Ê Ê Ê
E = θ̂ Eθ + φ̂ Eφ = √ + √
R L L R
Eθ + √ − √ Eφ
2 2 j 2 j 2
   
Eθ Eφ Eθ Eφ
= Ê R √ − √ + Ê L √ + √ = Ê R E R + Ê L E L ,
2 j 2 2 j 2
Eθ Eφ
ER = √ − √ , (9.19)
2 j 2
Eθ Eφ
EL = √ + √ . (9.20)
2 j 2

The magnitudes of the RHCP component (E R ) and the LHCP component (E L ) are then obtained.
The axial ratio is defined to describe the polarization purity of the propagating waves and is
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

280 Near-Field to Far-Field Transformation

calculated as follows [32]:

|E R | + |E L |
AR = − . (9.21)
|E R | − |E L |

For an LP wave, AR goes to infinity. For an RHCP wave AR = −1 and for an LHCP wave
AR = 1. For a general elliptically polarized wave, 1 ≤ |AR| ≤ ∞. Other expressions for direct
computation of the AR from the far-field components Eθ and Eφ are given in [33]
⎛  ⎞
  12 ! 12

1
2
Eφ2 + Eθ2 + Eθ4 + Eφ4 + 2Eθ2 Eφ2 cos (2δ) ⎟
AR = 20 log10 ⎜

⎟, (9.22)
   12 ! 12 ⎠
1
2
Eφ2 + Eθ2 + Eθ4 + Eφ4 − 2Eθ2 Eφ2 cos (2δ)

and in [34]
 
|Eφ |2 sin2 (τ ) + |Eθ |2 cos2 (τ ) + |Eφ ||Eθ | cos(δ)sin(2τ )
AR = 20 log10 , (9.23)
|Eφ |2 sin2 (τ ) + |Eθ |2 cos2 (τ ) − |Eφ ||Eθ | cos(δ)sin(2τ )

where
 
−1 2|Eφ ||Eθ | cos(δ)
2τ = tan ,
|Eθ |2 − |Eφ |2

and δ is the phase difference between Eθ and Eφ .

9.2.4 Radiation Efficiency


The radiation efficiency 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
 %  %
1  ∗ · n̂dS = 1 Re
Prad = Re E × H  · n̂dS .
J∗ × M (9.24)
2 S 2 S

The delivered power to an antenna is determined by the product of the voltage and current
provided from the voltage source and can be expressed as

1 & '
Pdel = Re Vs (ω)Is∗ (ω) , (9.25)
2

where Vs (ω) and Is (ω) represent the Fourier transformed values of the source voltage and current.
The antenna’s radiation efficiency ηa is then defined as [35]

Prad
ηa = . (9.26)
Pdel
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

MATLAB Implementation of NF-FF Transformation 281

9.3 MATLAB IMPLEMENTATION OF NEAR-FIELD TO FAR-FIELD TRANSFORMATION


In this section we demonstrate the implementation of near-field to far-field transformation in the
three-dimensional FDTD MATLAB code.

9.3.1 Definition of NF–FF 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 fields in a problem space can be calculated as if the boundaries are free space
extending to infinity. Moreover, the near-field to far-field transformation technique described in
the previous section can be used to compute the far-field patterns for a number of frequencies.
The desired frequencies as well as some other parameters for far-field radiation are defined in
the definition section of the FDTD program. The definition of certain NF–FF 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 defined with a field frequencies, which is initialized
as an empty array. Then the frequencies for which the far-field 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 NF–FF
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 ’ ) ;

3 sampled electric fields = [];


sampled magnetic fields = [ ] ;
5 sampled voltages = [ ] ;
sampled currents = [ ] ;
7 ports = [ ] ;
fa r fi e l d . frequencies = [ ] ;
9

% figure refresh rate


11 p l o t t i n g s t e p = 10;

13 % mode o f o p e r a t i o n
run simulation = true ;
15 show material mesh = true ;
show problem space = true ;
17

% f a r f i e l d c a l c u l a t i o n parameters
19 f a r f i e l d . f r e q u e n c i e s ( 1 ) = 3 e9 ;
f a r f i e l d . f r e q u e n c i e s ( 2 ) = 5 e9 ;
21 f a r f i e l d . f r e q u e n c i e s ( 3 ) = 6 e9 ;
f a r f i e l d . f r e q u e n c i e s ( 4 ) = 9 e9 ;
23 f a r f i e l d . number of cells from outer boundary = 10;
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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

% d e f i n e t h e problem
5 define problem space parameters ;
define geometry ;
7 define sources and lumped elements ;
define output parameters ;
9

% i n i t i a l i z e t h e problem s p a c e and p a r a m e t e r s
11 initialize fdtd material grid ;
display problem space ;
13 display material mesh ;
if run simulation
15 initialize fdtd parameters and arrays ;
initialize sources and lumped elements ;
17 initialize updating coefficients ;
initialize boundary conditions ;
19 initialize output parameters ;
initialize farfield arrays ;
21 initialize display parameters ;

23 % FDTD t i m e m a r c h i n g l o o p
run fdtd time marching loop ;
25

% display simulation results


27 post process and display results ;
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 NF–FF 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 first step in the NF–FF initialization process is to determine the nodes indicating the
boundaries of the imaginary NF–FF surface: (li, l j, lk) and (ui, u j, uk). Once the start and end
nodes are determined they are used to construct the NF–FF auxiliary arrays. Two sets of arrays
are needed for the NF–FF transformation: The first set is used to capture and store the fictitious
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-fly DFTs of these
currents. The naming conventions of these arrays are elaborated as follows.
There are six faces on the imaginary surface, and the fictitious 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
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

MATLAB Implementation of NF-FF Transformation 283

Listing 9.3 initialize farfield arrays


% i n i t i a l i z e farfield arrays
2 number of farfield frequencies = size ( f a r f i e l d . frequencies , 2 ) ;

4 i f n u m b e r o f f a r f i e l d f r e q u e n c i e s == 0
return ;
6 end
nc farbuffer = f a r f i e l d . number of cells from outer boundary ;
8 l i = nc farbuffer + 1;
l j = nc farbuffer + 1;
10 lk = nc farbuffer + 1;
u i = nx − n c f a r b u f f e r +1;
12 u j = ny − n c f a r b u f f e r +1;
uk = nz − n c f a r b u f f e r +1;
14

f a r f i e l d w = 2* p i * f a r f i e l d . f r e q u e n c i e s ;
16

tjxyp = zeros (1 , u i −l i , 1 , uk−l k ) ;


18 tjxzp = zeros (1 , u i −l i , uj −l j , 1 ) ;
tjyxp = zeros (1 , 1 , uj −l j , uk−l k ) ;
20 tjyzp = zeros (1 , u i −l i , uj −l j , 1 ) ;
tjzxp = zeros (1 , 1 , uj −l j , uk−l k ) ;
22 tjzyp = zeros (1 , u i −l i , 1 , uk−l k ) ;
tjxyn = zeros (1 , u i −l i , 1 , uk−l k ) ;
24 tjxzn = zeros (1 , u i −l i , uj −l j , 1 ) ;
tjyxn = zeros (1 , 1 , uj −l j , uk−l k ) ;
26 tjyzn = zeros (1 , u i −l i , uj −l j , 1 ) ;
tjzxn = zeros (1 , 1 , uj −l j , uk−l k ) ;
28 tjzyn = zeros (1 , u i −l i , 1 , uk−l k ) ;
tmxyp = zeros (1 , u i −l i , 1 , uk−l k ) ;
30 tmxzp = zeros (1 , u i −l i , uj −l j , 1 ) ;
tmyxp = zeros (1 , 1 , uj −l j , uk−l k ) ;
32 tmyzp = zeros (1 , u i −l i , uj −l j , 1 ) ;
tmzxp = zeros (1 , 1 , uj −l j , uk−l k ) ;
34 tmzyp = zeros (1 , u i −l i , 1 , uk−l k ) ;
tmxyn = zeros (1 , u i −l i , 1 , uk−l k ) ;
36 tmxzn = zeros (1 , u i −l i , uj −l j , 1 ) ;
tmyxn = zeros (1 , 1 , uj −l j , uk−l k ) ;
38 tmyzn = zeros (1 , u i −l i , uj −l j , 1 ) ;
tmzxn = zeros (1 , 1 , uj −l j , uk−l k ) ;
40 tmzyn = zeros (1 , u i −l i , 1 , uk−l k ) ;

42 cjxyp = zeros ( number of farfield frequencies , u i −l i , 1 , uk−l k ) ;


cjxzp = zeros ( number of farfield frequencies , u i −l i , uj −l j , 1 ) ;
44 cjyxp = zeros ( number of farfield frequencies , 1 , uj −l j , uk−l k ) ;
cjyzp = zeros ( number of farfield frequencies , u i −l i , uj −l j , 1 ) ;
46 cjzxp = zeros ( number of farfield frequencies , 1 , uj −l j , uk−l k ) ;
cjzyp = zeros ( number of farfield frequencies , u i −l i , 1 , uk−l k ) ;
48 cjxyn = zeros ( number of farfield frequencies , u i −l i , 1 , uk−l k ) ;
cjxzn = zeros ( number of farfield frequencies , u i −l i , uj −l j , 1 ) ;
50 cjyxn = zeros ( number of farfield frequencies , 1 , uj −l j , uk−l k ) ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

284 Near-Field to Far-Field Transformation

cjyzn = zeros ( number of farfield frequencies , u i −l i , uj −l j , 1 ) ;


52 cjzxn = zeros ( number of farfield frequencies , 1 , uj −l j , uk−l k ) ;
cjzyn = zeros ( number of farfield frequencies , u i −l i , 1 , uk−l k ) ;
54 cmxyp = zeros ( number of farfield frequencies , u i −l i , 1 , uk−l k ) ;
cmxzp = zeros ( number of farfield frequencies , u i −l i , uj −l j , 1 ) ;
56 cmyxp = zeros ( number of farfield frequencies , 1 , uj −l j , uk−l k ) ;
cmyzp = zeros ( number of farfield frequencies , u i −l i , uj −l j , 1 ) ;
58 cmzxp = zeros ( number of farfield frequencies , 1 , uj −l j , uk−l k ) ;
cmzyp = zeros ( number of farfield frequencies , u i −l i , 1 , uk−l k ) ;
60 cmxyn = zeros ( number of farfield frequencies , u i −l i , 1 , uk−l k ) ;
cmxzn = zeros ( number of farfield frequencies , u i −l i , uj −l j , 1 ) ;
62 cmyxn = zeros ( number of farfield frequencies , 1 , uj −l j , uk−l k ) ;
cmyzn = zeros ( number of farfield frequencies , u i −l i , uj −l j , 1 ) ;
64 cmzxn = zeros ( number of farfield frequencies , 1 , uj −l j , uk−l k ) ;
cmzyn = zeros ( number of farfield frequencies , u i −l i , 1 , uk−l 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 first dimension is 1; this dimension is
added to facilitate the on-the-fly DFT calculations, as is illustrated later. The fields are calculated
in three-dimensional space and are stored in three-dimensional arrays. However, it is required
to capture the fields coinciding with the faces of the imaginary surface. Therefore, the sizes of
the other three dimensions of the fictitious current arrays are determined by the number of field
components coinciding with imaginary surface faces.
The fictitious current arrays are used to calculate DFTs of these currents. Then the cur-
rents obtained in the frequency domain are stored in their respective arrays. Thus, each fictitious
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 first dimension of the fre-
quency domain arrays is equal to the number of frequencies for which the far field calculation is
sought.
One additional parameter defined in Listing 9.3 is farfield w. Since the far-field 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 NF–FF DFT during Time-Marching Loop


While the FDTD time-marching loop is running, the electric and magnetic fields are captured
and used to calculate fictitious magnetic and electric currents using equations (9.6)–(9.11) on
the NF–FF 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 field components are used to
calculate the value of a fictitious magnetic current component. Here the purpose is to obtain the
values of electric field components at the centers of the faces of the cells coinciding with the
NF–FF surface. For instance, Fig. 9.8 illustrates the electric field components E x on the yn face
of the imaginary NF–FF surface. The E x components are located on the edges of the faces of cells
coinciding with the NF–FF 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 fictitious
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.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

MATLAB Implementation of NF-FF Transformation 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 : ’ . . .
3 num2str ( n u m b e r o f t i m e s t e p s ) ] ) ;

5 s t a r t t i m e = cputime ;
current time = 0;
7

for time step = 1: number of time steps


9 update magnetic fields ;
update magnetic field CPML ABC ;
11 capture sampled magnetic fields ;
capture sampled currents ;
13 update electric fields ;
update electric field CPML ABC ;
15 update voltage sources ;
update current sources ;
17 update inductors ;
update diodes ;
19 capture sampled electric fields ;
capture sampled voltages ;
21 calculate JandM ;
display sampled parameters ;
23 end

25 e n d t i m e = cputime ;
t o t a l t i m e i n m i n u t e s = ( end time − s t a r t t i m e ) / 6 0 ;
27 disp ( [ ’ T o t a l s i m u l a t i o n time i s ’ . . .
num2str ( t o t a l t i m e i n m i n u t e s ) ’ m i n u t e s . ’ ] ) ;
 

Listing 9.5 calculate JandM


% 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
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 ;
4 end
j = sqrt ( −1);
6

tmyxp ( 1 ,1 ,: ,:) = 0 . 5 * ( Ez ( ui , l j : uj −1 , l k : uk −1)+ E z ( u i , l j +1: uj , l k : uk − 1 ) ) ;


8 tmzxp ( 1 ,1 ,: ,:) = −0.5*( Ey ( ui , l j : uj −1 , l k : uk −1)+ E y ( u i , l j : uj −1 , l k +1: uk ) ) ;
tmxyp ( 1 ,: ,1 ,:) = −0.5*( Ez ( l i : u i −1 , uj , l k : uk −1)+ E z ( l i +1: u i , uj , l k : uk − 1 ) ) ;
10 tmzyp ( 1 ,: ,1 ,:) = 0 . 5 * ( Ex ( l i : u i −1 , uj , l k : uk −1)+ E x ( l i : u i −1 , uj , l k +1: uk ) ) ;
tmxzp ( 1 ,: ,: ,1) = 0 . 5 * ( Ey ( l i : u i −1 , l j : uj −1 , uk )+ E y ( l i +1: u i , l j : uj −1 , uk ) ) ;
12 tmyzp ( 1 ,: ,: ,1) = −0.5*( Ex ( l i : u i −1 , l j : uj −1 , uk )+ E x ( l i : u i −1 , l j +1: uj , uk ) ) ;

14 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

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


18 + 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 14:16

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

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


24 + Hz ( l i : u i −1 , uj −1 , l k : uk −1) + Hz ( l i : u i −1 , uj −1 , l k +1: uk ) ) ;

26 t j y z p ( 1 , : , : , 1 ) = 0 . 2 5 * ( Hx ( l i : u i −1 , l j : uj −1 , uk )+ Hx ( l i +1: u i , l j : uj −1 , uk ) ...
+ Hx ( l i : u i −1 , l j : uj −1 , uk −1) + Hx ( l i +1: u i , l j : uj −1 , uk − 1 ) ) ;
28

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


30 + Hy ( l i : u i −1 , l j : uj −1 , uk −1) + Hy ( l i : u i −1 , l j +1: uj , uk − 1 ) ) ;

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

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


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

38 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

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


42 + Hz ( l i −1 , l j : uj −1 , l k : uk −1) + Hz ( l i −1 , l j : uj −1 , l k +1: uk ) ) ;

44 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

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


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

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

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


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

56 t j x z n ( 1 , : , : , 1 ) = 0 . 2 5 * ( Hy ( l i : u i −1 , l j : uj −1 , l k )+ Hy ( l i : u i −1 , l j +1: uj , l k ) ...
+ Hy ( l i : u i −1 , l j : uj −1 , l k −1) + Hy ( l i : u i −1 , l j +1: uj , l k − 1 ) ) ;
58

% fourier transform
60 f o r mi =1: n u m b e r o f f a r f i e l d f r e q u e n c i e s
e x p h = d t * exp (− j * f a r f i e l d w ( mi ) * ( time step −0.5)* dt ) ;
62 c j x y p ( mi , : , : , : ) = c j x y p ( mi , : , : , : ) + exp h * t j x y p ( 1 , : , : ,:);
c j x z p ( mi , : , : , : ) = c j x z p ( mi , : , : , : ) + exp h * t j x z p ( 1 , : , : ,:);
64 c j y x p ( mi , : , : , : ) = c j y x p ( mi , : , : , : ) + exp h * t j y x p ( 1 , : , : ,:);
c j y z p ( mi , : , : , : ) = c j y z p ( mi , : , : , : ) + exp h * t j y z p ( 1 , : , : ,:);
66 c j z x p ( mi , : , : , : ) = c j z x p ( mi , : , : , : ) + exp h * t j z x p ( 1 , : , : ,:);
c j z y p ( mi , : , : , : ) = c j z y p ( mi , : , : , : ) + exp h * t j z y p ( 1 , : , : ,:);
68

cjxyn ( mi , : ,: ,:) = cjxyn ( mi , : ,: ,:) + exp h * tjxyn (1 ,: ,: ,:);


70 cjxzn ( mi , : ,: ,:) = cjxzn ( mi , : ,: ,:) + exp h * tjxzn (1 ,: ,: ,:);
cjyxn ( mi , : ,: ,:) = cjyxn ( mi , : ,: ,:) + exp h * tjyxn (1 ,: ,: ,:);
72 cjyzn ( mi , : ,: ,:) = cjyzn ( mi , : ,: ,:) + exp h * tjyzn (1 ,: ,: ,:);
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

MATLAB Implementation of NF-FF Transformation 287

c j z x n ( mi , : , : , : ) = c j z x n ( mi , : , : , : ) + e x p h * t j z x n ( 1 , : , : , : ) ;
74 c j z y n ( mi , : , : , : ) = c j z y n ( mi , : , : , : ) + e x p h * t j z y n ( 1 , : , : , : ) ;

76 e x p e = d t * exp (− j * f a r f i e l d w ( mi ) * t i m e s t e p * d t ) ;

78 cmxyp ( mi , : ,: ,:) = cmxyp ( mi , : ,: ,:) + exp e * tmxyp (1 ,: ,: ,:);


cmxzp ( mi , : ,: ,:) = cmxzp ( mi , : ,: ,:) + exp e * tmxzp (1 ,: ,: ,:);
80 cmyxp ( mi , : ,: ,:) = cmyxp ( mi , : ,: ,:) + exp e * tmyxp (1 ,: ,: ,:);
cmyzp ( mi , : ,: ,:) = cmyzp ( mi , : ,: ,:) + exp e * tmyzp (1 ,: ,: ,:);
82 cmzxp ( mi , : ,: ,:) = cmzxp ( mi , : ,: ,:) + exp e * tmzxp (1 ,: ,: ,:);
cmzyp ( mi , : ,: ,:) = cmzyp ( mi , : ,: ,:) + exp e * tmzyp (1 ,: ,: ,:);
84

cmxyn ( mi , : ,: ,:) = cmxyn ( mi , : ,: ,:) + exp e * tmxyn (1 ,: ,: ,:);


86 cmxzn ( mi , : ,: ,:) = cmxzn ( mi , : ,: ,:) + exp e * tmxzn (1 ,: ,: ,:);
cmyxn ( mi , : ,: ,:) = cmyxn ( mi , : ,: ,:) + exp e * tmyxn (1 ,: ,: ,:);
88 cmyzn ( mi , : ,: ,:) = cmyzn ( mi , : ,: ,:) + exp e * tmyzn (1 ,: ,: ,:);
cmzxn ( mi , : ,: ,:) = cmzxn ( mi , : ,: ,:) + exp e * tmzxn (1 ,: ,: ,:);
90 cmzyn ( mi , : ,: ,:) = cmzyn ( mi , : ,: ,:) + exp e * tmzyn (1 ,: ,: ,:);
end
 

Similarly, every fictitious electric current component is calculated at the centers of the faces
of the cells by averaging four magnetic field components. For example, Fig. 9.9 illustrates the
magnetic field components Hx around the yn face of the imaginary NF–FF surface. The Hx
components are located at the centers of the faces of cells, which are not coinciding with the
NF–FF surface. To obtain equivalent Hx values at the centers of the cell faces, the average of four
Hx components are calculated for each cell. Thus, the fictitious electric current components Jz
generated by the averaged Hx components using (9.10a) are located at the centers of the cell faces.

Figure 9.8 E x field components on the yn face of the NF–FF imaginary surface and the magnetic currents
generated by them.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

288 Near-Field to Far-Field Transformation

Figure 9.9 H x field components around the yn face of the NF–FF imaginary surface and the electric currents
generated by them.

After the fictitious electric and magnetic currents are sampled on the NF–FF surface at the
current time step, they are used to update the on-the-fly DFTs for the far-field frequencies defined
in the subroutine define output parameters. For instance, one iteration of (9.12) is performed at
each time step for calculating Jy in frequency domain. Therefore, when the FDTD time-marching
loop is completed, the DFT of Jy is completed together.

9.3.4 Postprocessing for Far-Field Calculation


As the FDTD time-marching loop is completed, the frequency-domain values of fictitious currents
for the far-field frequencies over the NF–FF surface are available. Then they can be used at the
postprocessing stage of the FDTD simulation to calculate the far-field auxiliary fields based on
(9.17). Then these fields can be used to calculate the desired far-field 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-field
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-field patterns at three
principal planes: namely, the xy, xz, and y z planes. For instance, to calculate the far-fields 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 ’ ) ;

3 display transient parameters ;


calculate frequency domain outputs ;
5 display frequency domain outputs ;
calculate and display farfields ;
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

MATLAB Implementation of NF-FF Transformation 289

Listing 9.7 calculate and display farfields


% 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
2 % 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 .
4 % 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 .
6

i f n u m b e r o f f a r f i e l d f r e q u e n c i e s == 0
8 return ;
end
10

calculate radiated power ;


12

j = sqrt ( −1);
14 number of angles = 360;

16 % p a r a m e t e r s u s e d by p o l a r p l o t t i n g f u n c t i o n s
s t e p s i z e = 10; % i n c r e m e n t between t h e r i n g s i n t h e p o l a r g r i d
18 Nrings = 4; % number o f r i n g s i n t h e p o l a r g r i d
l i n e s t y l e 1 = ’ b− ’ ; % l i n e s t y l e f o r t h e t a component
20 l i n e s t y l e 2 = ’ r−− ’ ; % l i n e s t y l e f o r p h i component
s c a l e t y p e = ’ dB ’ ; % l i n e a r o r dB
22 p l o t t y p e = ’D ’ ; % the c a l c u l a t e d data i s d i r e c t i v i t y

24 % xy plane
% ===============================================
26 f a r f i e l d t h e t a = zeros ( number of angles , 1 ) ;
farfield phi = zeros ( number of angles , 1 ) ;
28 f a r f i e l d t h e t a = f a r f i e l d t h e t a + pi / 2 ;
f a r f i e l d p h i = ( pi / 1 8 0 ) * [ − 1 8 0 : 1 : 1 7 9 ] . ’ ;
30 c o n s t t h e t a = 90; % used f o r p l o t

32 % calculate farfields
calculate farfields per plane ;
34

% p l o t t i n g the f a r f i e l d data
36 f o r mi =1: n u m b e r o f f a r f i e l d f r e q u e n c i e s
f = figure ;
38 p a t 1 = f a r f i e l d d a t a T h e t a ( mi , : ) . ’ ;
p a t 2 = f a r f i e l d d a t a P h i ( mi , : ) . ’ ;
40

% i f s c a l e t y p e i s db u s e t h e s e , o t h e r w i s e comment t h e s e two l i n e s
42 p a t 1 = 10 * l o g 1 0 ( p a t 1 ) ;
p a t 2 = 10 * l o g 1 0 ( p a t 2 ) ;
44

m a x v a l = max ( max ( [ p a t 1 p a t 2 ] ) ) ;
46 max val = s t e p s i z e * c e i l ( max val / s t e p s i z e ) ;

48 l e g e n d s t r 1 = [ p l o t t y p e ’ {\ t h e t a } , f = ’ . . .
num2str ( f a r f i e l d . f r e q u e n c i e s ( mi ) * 1 e −9) ’ GHz ’ ] ;
50 l e g e n d s t r 2 = [ p l o t t y p e ’ {\ p h i } , f = ’ . . .
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

290 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

p o l a r p l o t c o n s t a n t t h e t a ( f a r f i e l d p h i , pat1 , pat2 , m a x v a l , . . .
54 s t e p s i z e , Nrings , l i n e s t y l e 1 , l i n e s t y l e 2 , const theta , ...
legend str1 , legend str2 , scale type ) ;
56 end

58 % xz plane
% ===============================================
60 f a r f i e l d t h e t a = zeros ( number of angles , 1 ) ;
farfield phi = zeros ( number of angles , 1 ) ;
62 f a r f i e l d t h e t a = ( pi / 1 8 0 ) * [ − 1 8 0 : 1 : 1 7 9 ] . ’ ;
c o n s t p h i = 0 ; % used f o r p l o t
64

% calculate farfields
66 calculate farfields per plane ;

68 % p l o t t i n g the f a r f i e l d data
f o r mi =1: n u m b e r o f f a r f i e l d f r e q u e n c i e s
70 f = figure ;
p a t 1 = f a r f i e l d d a t a T h e t a ( mi , : ) . ’ ;
72 p a t 2 = f a r f i e l d d a t a P h i ( mi , : ) . ’ ;

74 % i f s c a l e t y p e i s db u s e t h e s e , o t h e r w i s e comment t h e s e two l i n e s
p a t 1 = 10 * l o g 1 0 ( p a t 1 ) ;
76 p a t 2 = 10 * l o g 1 0 ( p a t 2 ) ;

78 m a x v a l = max ( max ( [ p a t 1 p a t 2 ] ) ) ;
max val = s t e p s i z e * c e i l ( max val / s t e p s i z e ) ;
80

legend str1 = . . .
82 [ p l o t t y p e ’ {\ t h e t a } , f = ’ . . .
num2str ( f a r f i e l d . f r e q u e n c i e s ( mi ) * 1 e −9) ’ GHz ’ ] ;
84 legend str2 = . . .
[ p l o t t y p e ’ {\ p h i } , f = ’ . . .
86 num2str ( f a r f i e l d . f r e q u e n c i e s ( mi ) * 1 e −9) ’ GHz ’ ] ;

88 p o l a r p l o t c o n s t a n t p h i ( f a r f i e l d t h e t a , pat1 , pat2 , m a x v a l , . . .
s t e p s i z e , Nrings , l i n e s t y l e 1 , l i n e s t y l e 2 , const phi , . . .
90 legend str1 , legend str2 , scale type ) ;
end
92

% yz plane
94 % ===============================================
f a r f i e l d t h e t a = zeros ( number of angles , 1 ) ;
96 farfield phi = zeros ( number of angles , 1 ) ;
f a r f i e l d p h i = f a r f i e l d p h i + pi / 2 ;
98 f a r f i e l d t h e t a = ( pi / 1 8 0 ) * [ − 1 8 0 : 1 : 1 7 9 ] . ’ ;
c o n s t p h i = 90; % used f o r p l o t
100

% calculate farfields
102 calculate farfields per plane ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

MATLAB Implementation of NF-FF Transformation 291

104 % 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
106 f = figure ;
p a t 1 = f a r f i e l d d a t a T h e t a ( mi , : ) . ’ ;
108 p a t 2 = f a r f i e l d d a t a P h i ( mi , : ) . ’ ;

110 % 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 ) ;
112 p a t 2 = 10 * l o g 1 0 ( p a t 2 ) ;

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

legend str1 = . . .
118 [ p l o t t y p e ’ {\ t h e t a } , f = ’ . . .
num2str ( f a r f i e l d . f r e q u e n c i e s ( mi ) * 1 e −9) ’ GHz ’ ] ;
120 legend str2 = . . .
[ p l o t t y p e ’ {\ p h i } , f = ’ . . .
122 num2str ( f a r f i e l d . f r e q u e n c i e s ( mi ) * 1 e −9) ’ GHz ’ ] ;

124 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 , . . .
126 legend str1 , legend str2 , scale type ) ;
end
 

function calculate farfields per plane is called to calculate far-field directivity data at the given
angles. These data are plotted using another function polar plot constant theta. For the xy plane
θ is a constant value of π/2 radians. For the xz and y z planes φ takes constant values of 0 and
π/2 radians, respectively, hence another function, which is called for plotting patterns in the xz
and y z planes is polar plot constant phi. The implementations of polar plot constant theta and
polar plot constant phi are given in Appendix C.
The near-field to far-field calculations are performed mainly in the function calculate farfields -
per plane, implementation of which is given in Listing 9.9.
One of the initial tasks in calculate farfields per plane is the calculation of total radiated power.
A subroutine named calculate radiated power is called to perform this task. The total radiated
power is stored in the parameter radiated power, as can be seen in Listing 9.8. Calculation of
radiated power is based on the discrete summation representation of (9.24).
Before calculating any far-field data, the auxiliary fields Nθ , Nφ , Lθ , and Lφ need to be calculated
based on (9.17). In (9.17) the parameters θ and φ are angles indicating the position vector of the
observation point r as illustrated in Fig. 9.7. The parameters Jx , Jy , Jz , Mx , My , and Mz are the
fictitious currents, which have already been calculated at the center points of the faces of the cells
coinciding with the NF–FF surface for the given far-field frequencies. The parameter k is the
wavenumber expressed by

k = 2π f µ0 ε0 , (9.27)

where f is the far-field frequency under consideration. Yet another term in (9.17) is r  cos(ψ),
which needs to be further defined explicitly. As shown in Fig. 9.7, r is the position vector
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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

f o r mi =1: n u m b e r o f f a r f i e l d f r e q u e n c i e s
5 powr = 0 ;
powr = dx * dy * sum ( sum ( sum ( cmyzp ( mi , : , : , : ) . * ...
7 c o n j ( c j x z p ( mi , : , : , : ) ) − cmxzp ( mi , : , : , : ) ...
. * c o n j ( c j y z p ( mi , : , : , : ) ) ) ) ) ;
9 powr = powr − dx * dy * sum ( sum ( sum ( cmyzn ( mi , : ,: ,:) ...
. * c o n j ( c j x z n ( mi , : , : , : ) ) − cmxzn ( mi , : , : ,:) ...
11 . * c o n j ( c j y z n ( mi , : , : , : ) ) ) ) ) ;
powr = powr + dx * dz * sum ( sum ( sum ( cmxyp ( mi , : ,: ,:) ...
13 . * c o n j ( c j z y p ( mi , : , : , : ) ) − cmzyp ( mi , : , : ,:) ...
. * c o n j ( c j x y p ( mi , : , : , : ) ) ) ) ) ;
15 powr = powr − dx * dz * sum ( sum ( sum ( cmxyn ( mi , : ,: ,:) ...
. * c o n j ( c j z y n ( mi , : , : , : ) ) − cmzyn ( mi , : , : ,:) ...
17 . * c o n j ( c j x y n ( mi , : , : , : ) ) ) ) ) ;
powr = powr + dy * dz * sum ( sum ( sum ( cmzxp ( mi , : ,: ,:) ...
19 . * c o n j ( c j y x p ( mi , : , : , : ) ) − cmyxp ( mi , : , : ,:) ...
. * c o n j ( c j z x p ( mi , : , : , : ) ) ) ) ) ;
21 powr = powr − dy * dz * sum ( sum ( sum ( cmzxn ( mi , : ,: ,:) ...
. * c o n j ( c j y x n ( mi , : , : , : ) ) − cmyxn ( mi , : , : ,:) ...
23 . * c o n j ( c j z x n ( mi , : , : , : ) ) ) ) ) ;
r a d i a t e d p o w e r ( mi ) = 0 . 5 * r e a l ( powr ) ;
25 end
 

Listing 9.9 calculate farfields per plane


1 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 ;
3 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
5 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
7 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

9 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 ) ;
11 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 ) ;
13 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 ) ;
15 dy dz cosphi = zeros ( number of angles , 1 ) ;
dx dz costh cosphi = zeros ( number of angles , 1 ) ;
17 d x d z s i n t h = zeros ( number of angles , 1 ) ;
dx dz sinphi = zeros ( number of angles , 1 ) ;
19 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 ) ;
21 dx dy sinphi = zeros ( number of angles , 1 ) ;
dx dy cosphi = zeros ( number of angles , 1 ) ;
23 farfield dirTheta = . . .
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

MATLAB Implementation of NF-FF Transformation 293

zeros ( number of farfield frequencies , number of angles ) ;


25 farfield dir = ...
zeros ( number of farfield frequencies , number of angles ) ;
27 farfield dirPhi = ...
zeros ( number of farfield frequencies , number of angles ) ;
29

dx s i n t h c o s p h i = dx * s i n ( f a r f i e l d t h e t a ) . * c o s ( f a r f i e l d p h i ) ;
31 dy s i n t h s i n p h i = dy * s i n ( f a r f i e l d t h e t a ) . * s i n ( f a r f i e l d p h i ) ;
dz c o s t h = dz * c o s ( f a r f i e l d t h e t a ) ;
33 dy d z c o s t h s i n p h i = dy * dz * c o s ( f a r f i e l d t h e t a ) . * s i n ( f a r f i e l d phi );
dy d z s i n t h = dy * dz * s i n ( f a r f i e l d t h e t a ) ;
35 dy d z c o s p h i = dy * dz * c o s ( f a r f i e l d p h i ) ;
dx d z c o s t h c o s p h i = dx * dz * c o s ( f a r f i e l d t h e t a ) . * c o s ( f a r f i e l d phi );
37 dx d z s i n t h = dx * dz * s i n ( f a r f i e l d t h e t a ) ;
dx d z s i n p h i = dx * dz * s i n ( f a r f i e l d p h i ) ;
39 dx d y c o s t h c o s p h i = dx * dy * c o s ( f a r f i e l d t h e t a ) . * c o s ( f a r f i e l d phi );
dx d y c o s t h s i n p h i = dx * dy * c o s ( f a r f i e l d t h e t a ) . * s i n ( f a r f i e l d phi );
41 dx d y s i n p h i = dx * dy * s i n ( f a r f i e l d p h i ) ;
dx d y c o s p h i = dx * dy * c o s ( f a r f i e l d p h i ) ;
43 ci = 0 . 5 * ( u i+ l i ) ;
cj = 0 . 5 * ( u j+ l j ) ;
45 ck = 0 . 5 * ( uk+ l k ) ;

47 % calculate directivity
f o r mi =1: n u m b e r o f f a r f i e l d f r e q u e n c i e s
49 disp ( [ ’ C a l c u l a t i n g d i r e c t i v i t y for ’ , . . .
num2str ( f a r f i e l d . f r e q u e n c i e s ( mi ) ) ’ Hz ’ ] ) ;
51 k = 2 * p i * f a r f i e l d . f r e q u e n c i e s ( mi ) * ( mu 0 * e p s 0 ) ˆ 0 . 5 ;

53 Ntheta = zeros ( number of angles , 1 ) ;


Ltheta = zeros ( number of angles , 1 ) ;
55 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 ) ;
57 rpr = zeros ( number of angles , 1 ) ;

59 f o r n j = l j : uj −1
f o r nk = l k : uk−1
61 % f o r +ax d i r e c t i o n

63 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 . . .
65 + ( nk−c k + 0 . 5 ) * d z c o s t h ;
e x p j k r p r = exp (− j * k * r p r ) ;
67 Ntheta = Ntheta . . .
+ ( c j y x p ( mi , 1 , nj − l j +1 , nk−l k + 1 ) . * d y d z c o s t h s i n p h i . . .
69 − c j z x p ( mi , 1 , nj − l j +1 , nk−l k + 1 ) . * d y d z s i n t h ) . * e x p j k r p r ;
Ltheta = Ltheta . . .
71 + ( cmyxp ( mi , 1 , nj − l j +1 , nk−l k + 1 ) . * d y d z c o s t h s i n p h i . . .
− cmzxp ( mi , 1 , nj − l j +1 , nk−l k + 1 ) . * d y d z s i n t h ) . * e x p j k r p r ;
73 Nphi = Nphi . . .
+ ( c j y x p ( mi , 1 , nj − l j +1 , nk−l k + 1 ) . * d y d z c o s p h i ) . * e x p j k r p r ;
75 Lphi = Lphi . . .
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

294 Near-Field to Far-Field Transformation

+ ( cmyxp ( mi , 1 , nj − l j +1 , nk−l k + 1 ) . * d y d z c o s p h i ) . * e x p j k r p r ;
77

% f o r −ax d i r e c t i o n
79 rpr = ( l i − ci )* dx sinth cosphi . . .
+ ( nj −c j + 0 . 5 ) * d y s i n t h s i n p h i . . .
81 + ( nk−c k + 0 . 5 ) * d z c o s t h ;
e x p j k r p r = exp (− j * k * r p r ) ;
83 Ntheta = Ntheta . . .
+ ( c j y x n ( mi , 1 , nj − l j +1 , nk−l k + 1 ) . * d y d z c o s t h s i n p h i . . .
85 − c j z x n ( mi , 1 , nj − l j +1 , nk−l k + 1 ) . * d y d z s i n t h ) . * e x p j k r p r ;
Ltheta = Ltheta . . .
87 + ( cmyxn ( mi , 1 , nj − l j +1 , nk−l k + 1 ) . * d y d z c o s t h s i n p h i . . .
− cmzxn ( mi , 1 , nj − l j +1 , nk−l k + 1 ) . * d y d z s i n t h ) . * e x p j k r p r ;
89 Nphi = Nphi . . .
+ ( c j y x n ( mi , 1 , nj − l j +1 , nk−l k + 1 ) . * d y d z c o s p h i ) . * e x p j k r p r ;
91 Lphi = Lphi . . .
+ ( cmyxn ( mi , 1 , nj − l j +1 , nk−l k + 1 ) . * d y d z c o s p h i ) . * e x p j k r p r ;
93 end
end
95 f o r n i = l i : u i −1
f o r nk = l k : uk−1
97 % f o r +ay d i r e c t i o n

99 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 . . .
101 + ( nk−c k + 0 . 5 ) * d z c o s t h ;
e x p j k r p r = exp (− j * k * r p r ) ;
103

Ntheta = Ntheta . . .
105 + ( c j x y p ( mi , ni − l i + 1 , 1 , nk−l k + 1 ) . * d x d z c o s t h c o s p h i . . .
− c j z y p ( mi , ni − l i + 1 , 1 , nk−l k + 1 ) . * d x d z s i n t h ) . * e x p j k r p r ;
107 Ltheta = Ltheta . . .
+ ( cmxyp ( mi , ni − l i + 1 , 1 , nk−l k + 1 ) . * d x d z c o s t h c o s p h i . . .
109 − cmzyp ( mi , ni − l i + 1 , 1 , nk−l k + 1 ) . * d x d z s i n t h ) . * e x p j k r p r ;
Nphi = Nphi . . .
111 + (− c j x y p ( mi , ni − l i + 1 , 1 , nk−l k + 1 ) . * d x d z s i n p h i ) . * e x p j k r p r ;
Lphi = Lphi . . .
113 + (− cmxyp ( mi , ni − l i + 1 , 1 , nk−l k + 1 ) . * d x d z s i n p h i ) . * e x p j k r p r ;

115 % f o r −ay d i r e c t i o n
rpr = ( ni − c i + 0 . 5 ) * dx sinth cosphi ...
117 + ( l j −c j ) * d y s i n t h s i n p h i . . .
+ ( nk−c k + 0 . 5 ) * d z c o s t h ;
119 e x p j k r p r = exp (− j * k * r p r ) ;

121 Ntheta = Ntheta . . .


+ ( c j x y n ( mi , ni − l i + 1 , 1 , nk−l k + 1 ) . * d x d z c o s t h c o s p h i ...
123 − c j z y n ( mi , ni − l i + 1 , 1 , nk−l k + 1 ) . * d x d z s i n t h ) . * e x p j k rpr ;
Ltheta = Ltheta . . .
125 + ( cmxyn ( mi , ni − l i + 1 , 1 , nk−l k + 1 ) . * d x d z c o s t h c o s p h i ...
− cmzyn ( mi , ni − l i + 1 , 1 , nk−l k + 1 ) . * d x d z s i n t h ) . * e x p j k rpr ;
127 Nphi = Nphi . . .
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

MATLAB Implementation of NF-FF Transformation 295

+ (− c j x y n ( mi , ni − l i + 1 , 1 , nk−l k + 1 ) . * d x d z s i n p h i ) . * e x p j k r p r ;
129 Lphi = Lphi . . .
+ (− cmxyn ( mi , ni − l i + 1 , 1 , nk−l k + 1 ) . * d x d z s i n p h i ) . * e x p j k r p r ;
131 end
end
133

f o r n i = l i : u i −1
135 f o r n j = l j : uj −1
% f o r +a z d i r e c t i o n
137

r p r = ( ni −c i + 0 . 5 ) * d x s i n t h c o s p h i . . .
139 + ( nj − c j + 0 . 5 ) * d y s i n t h s i n p h i ...
+ ( uk−c k ) * d z c o s t h ;
141 e x p j k r p r = exp (− j * k * r p r ) ;

143 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 . . .
145 + 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 ;
147 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 . . .
149 + 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 ;
151 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 ) . . .
153 .* exp jk rpr ;
L p h i = L p h i + (− cmxzp ( mi , ni − l i +1 , nj − l j + 1 , 1 ) . . .
155 . * 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

r p r = ( ni −c i + 0 . 5 ) * d x s i n t h c o s p h i . . .
161 + ( nj − c j + 0 . 5 ) * d y s i n t h s i n p h i ...
+ ( l k −c k ) * d z c o s t h ;
163 e x p j k r p r = exp ( − j * k * r p r ) ;

165 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 . . .
167 + 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 ;
169 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 . . .
171 + 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 ;
173 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 ) . . .
175 .* exp jk rpr ;
L p h i = L p h i + (− cmxzn ( mi , ni − l i +1 , nj − l j + 1 , 1 ) . . .
177 . * 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 ;
179 end
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

296 Near-Field to Far-Field Transformation

end
181 % calculate directivity
f a r f i e l d d a t a T h e t a ( mi , : ) = ( k ˆ 2 . / ( 8 * p i * e t a 0 * r a d i a t e d p o w e r ( mi ) ) ) ...
183 . * ( abs ( L p h i+ e t a 0 * N t h e t a ) . ˆ 2 ) ;
f a r f i e l d d a t a P h i ( mi , : ) =( k ˆ 2 . / ( 8 * p i * e t a 0 * r a d i a t e d p o w e r ( mi ) ) ) ...
185 . * ( abs ( L t h e t a −e t a 0 * Nphi ) . ˆ 2 ) ;
end
 

indicating the observation point while r  is the position vector indicating the source point. The
term r  cos(ψ) is actually obtained from r  · r̂ where r̂ is a unit vector in the direction of r. The
unit vector r̂ can be expressed in Cartesian coordinates as

r̂ = sin(θ ) cos(φ)x̂ + sin(θ )sin(φ) ŷ + cos(θ )ẑ. (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 NF–FF surface can be expressed as

r  = (mi + 0.5 − c i)x x̂ + (mj + 0.5 − c j )y ŷ + (lk − c k)zẑ, (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-field calculations. The parameters mi and mj are the indices
of the nodes of the faces, which include the sources under consideration. Then the term r  cos(ψ)
in (9.17) can be expressed explicitly using (9.28) and (9.29) as

r  cos(ψ) = r  · r̂ = (mi + 0.5 − c i)xsin(θ ) cos(φ)


+ (mj + 0.5 − c j )ysin(θ )sin(φ) + (lk − c k)z cos(θ ). (9.30)

Figure 9.10 Position vectors for sources on the zn and zp faces.


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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
j −1
 u
ui−1
  
Nθ = xy Jx cos(θ ) cos(φ) + Jy cos(θ )sin(φ) e − j kr cos(ψ) , (9.32a)
mi=li mj =l j

j −1
 u
ui−1
  
Nφ = xy −Jx sin(φ) + Jy cos(φ) e − j kr cos(ψ) , (9.32b)
mi=li mj =l j

j −1
 u
ui−1
  
Lθ = xy Mx cos(θ ) cos(φ) + My cos(θ )sin(φ) e − j kr cos(ψ) , (9.32c)
mi=li mj =l j

j −1
 u
ui−1
  
Lφ = xy −Mx sin(φ) + My cos(φ) e − j kr cos(ψ) . (9.32d)
mi=li mj =l j

Referring to Fig. 9.11 one can obtain r  cos(ψ) for the xn and xp faces, respectively, as

r  cos(ψ) = r  · r̂ = (li − c i)xsin(θ ) cos(φ)


+ (mj + 0.5 − c j )ysin(θ )sin(φ) + (mk + 0.5 − c k)z cos(θ ), (9.33)

Figure 9.11 Position vectors for sources on the x n and x p faces.


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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

u j −1 uk−1
    
Nθ = yz Jy cos(θ )sin(φ) − Jz sin(θ ) e − j kr cos(ψ) , (9.35a)
mj =l j mk=lk

u j −1 uk−1
    
Nφ = yz Jy cos(φ) e − j kr cos(ψ) , (9.35b)
mj =l j mk=lk

u j −1 uk−1
    
Lθ = yz My cos(θ )sin(φ) − Mz sin(θ ) e − j kr cos(ψ) , (9.35c)
mj =l j mk=lk

u j −1 uk−1
    
Lφ = yz My cos(φ) e − j kr cos(ψ) . (9.35d)
mj =l j mk=lk

Similarly, referring to Fig. 9.12 r  cos(ψ) can be obtained for the yn and y p faces,
respectively, as

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)
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation Examples 299

Then the summations in (9.32) are expressed in terms of these indices mi and mk as

 uk−1
ui−1  
Nθ = xz (Jx cos(θ ) cos(φ) − Jz sin(θ )) e − j kr cos(ψ)
, (9.38a)
mi=li mk=lk

 uk−1
ui−1  
Nφ = xz (−Jx sin(φ)) e − j kr cos(ψ)
, (9.38b)
mi=li mk=lk

 uk−1
ui−1  
Lθ = xz (Mx cos(θ ) cos(φ) − Mz sin(θ )) e − j kr cos(ψ)
, (9.38c)
mi=li mk=lk

 uk−1
ui−1  
Lφ = xz (−Mx sin(φ)) e − j kr cos(ψ)
. (9.38d)
mi=li mk=lk

The implementation of the discrete summation just described can be followed in


Listing 9.9.
Finally, having obtained the auxiliary fields Nθ , Nφ , Lθ , and Lφ and the total radiated power,
the far-field directivity data are calculated based on [1] as

k2
Dθ = |Lφ + η0 Nθ |2 , (9.39a)
8π η0 Prad
k2
Dφ = |Lθ − η0 Nφ |2 . (9.39b)
8π η0 Prad

9.4 SIMULATION EXAMPLES


In the previous sections we discussed the NF–FF 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 modified 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 definition of the cell sizes, material types, and CPML parameters
are illustrated in Listing 9.10, and the definition 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 defined
on and around the voltage source to form an input port. The definitions 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
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

300 Near-Field to Far-Field Transformation

Dimensions are in mm.


Substrate thickness = 0.787 mm.
Strip widths = 2.4 mm.
40

40
24
ε r = 2.2

12
.4
16.4
5.
2

7.6

x
y
16

ground
z
13.6 voltage source

Figure 9.13 An inverted-F antenna.

the definition of the NF–FF transformation is part of the define outputs parameters routine. In
this example the far-field frequencies are 2.4 GHz and 5.8 GHz. One additional parameter for the
NF–FF transform is the number of cells from outer boundary. The value of this parameter is
13, which means that the imaginary NF–FF surface is 13 cells away from the outer boundaries,
thus 5 cells away from the CPML interface and residing in the air gap region.

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

% 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


4 number of time steps = 7000;

6 % A f a c t o r t h a t determines d u r a t i o n of a time s t e p
% wrt CFL l i m i t
8 courant factor = 0.9;

10 % A f a c t o r d e t e r m i n i n g t h e a c c u r a c y l i m i t o f FDTD r e s u l t s
number of cells per wavelength = 20;
12

% D i m e n s i o n s o f a u n i t c e l l i n x , y , and z d i r e c t i o n s ( m e t e r s )
14 dx = 0 . 2 6 2 e −3;
dy = 0 . 4 e −3;
16 dz = 0 . 4 e −3;

18 % ==<b o u n d a r y c o n d i t i o n s >========
% Here we d e f i n e t h e b o u n d a r y c o n d i t i o n s p a r a m e t e r s
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation Examples 301

20 % ’ pec ’ : p e r f e c t e l e c t r i c c o n d u c t o r
% ’ cpml ’ : c o n l v o l u t i o n a l PML
22 % i f c p m l n u m b e r o f c e l l s i s l e s s than zero
% CPML e x t e n d s i n s i d e o f t h e domain r a t h e r t h a n o u t w a r d s
24

b o u n d a r y . t y p e x n = ’ cpml ’ ;
26 boundary . a i r b u f f e r n u m b e r o f c e l l s x n = 10;
boundary . c p m l n u m b e r o f c e l l s x n = 8 ;
28

b o u n d a r y . t y p e x p = ’ cpml ’ ;
30 boundary . a i r b u f f e r n u m b e r o f c e l l s x p = 10;
boundary . c p m l n u m b e r o f c e l l s x p = 8 ;
32

b o u n d a r y . t y p e y n = ’ cpml ’ ;
34 boundary . a i r b u f f e r n u m b e r o f c e l l s y n = 10;
boundary . c p m l n u m b e r o f c e l l s y n = 8 ;
36

b o u n d a r y . t y p e y p = ’ cpml ’ ;
38 boundary . a i r b u f f e r n u m b e r o f c e l l s y p = 10;
boundary . c p m l n u m b e r o f c e l l s y p = 8 ;
40

b o u n d a r y . t y p e z n = ’ cpml ’ ;
42 boundary . a i r b u f f e r n u m b e r o f c e l l s z n = 10;
boundary . c p m l n u m b e r o f c e l l s z n = 8 ;
44

b o u n d a r y . t y p e z p = ’ cpml ’ ;
46 boundary . a i r b u f f e r n u m b e r o f c e l l s z p = 10;
boundary . c p m l n u m b e r o f c e l l s z p = 8 ;
48

boundary . cpml order = 3;


50 boundary . c p m l sigma factor = 1.3;
boundary . cpml kappa max = 7 ;
52 boundary . cpml alpha min = 0;
boundary . cpml alpha max = 0 . 0 5 ;
68

% PEC : p e r f e c t e l e c t r i c c o n d u c t o r
70 material types ( 2 ) . eps r = 1;
m a t e r i a l t y p e s ( 2 ) . mu r = 1;
72 m a t e r i a l t y p e s ( 2 ) . s i g m a e = 1 e10 ;
m a t e r i a l t y p e s ( 2 ) . sigma m = 0 ;
74 material types ( 2 ) . color = [1 0 0];

83 % substrate
material types (4). eps r = 2.2;
85 material types (4). mu r = 1;
material types (4). sigma e = 0;
87 material types (4). sigma m = 0 ;
material types (4). color = [0 0 1];
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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

bricks = [ ] ;
4 spheres = [ ] ;

6 % define substrate
b r i c k s ( 1 ) . m i n x = −0.787 e −3;
8 b r i c k s ( 1 ) . mi n y = 0 ;
b r i c k s ( 1 ) . min z = 0 ;
10 b r i c k s ( 1 ) . max x = 0 ;
b r i c k s ( 1 ) . max y = 40 e −3;
12 b r i c k s ( 1 ) . max z = 40 e −3;
bricks ( 1 ) . material type = 4;
14

bricks (2). min x = 0 ;


16 bricks (2). mi n y = 0 ;
bricks (2). m i n z = 24 e −3;
18 bricks (2). max x = 0 ;
bricks (2). max y = 2 8 . 4 e −3;
20 bricks (2). max z = 2 6 . 4 e −3;
bricks (2). material type = 2;
22

bricks (3). min x = 0 ;


24 bricks (3). mi n y = 16 e −3;
bricks (3). m i n z = 30 e −3;
26 bricks (3). max x = 0 ;
bricks (3). max y = 2 8 . 4 e −3;
28 bricks (3). max z = 3 2 . 4 e −3;
bricks (3). material type = 2;
30

bricks (4). min x = 0 ;


32 bricks (4). mi n y = 26 e −3;
bricks (4). m i n z = 8 . 4 e −3;
34 bricks (4). max x = 0 ;
bricks (4). max y = 2 8 . 4 e −3;
36 bricks (4). max z = 3 2 . 4 e −3;
bricks (4). material type = 2;
38

bricks (5). min x = 0 ;


40 bricks (5). mi n y = 2 0 . 8 e −3;
bricks (5). m i n z = 16 e −3;
42 bricks (5). max x = 0 ;
bricks (5). max y = 2 3 . 2 e −3;
44 bricks (5). max z = 3 2 . 4 e −3;
bricks (5). material type = 2;
46

bricks (6). min x = −0.787 e −3;


48 bricks (6). mi n y = 16 e −3;
bricks (6). min z = 30 e −3;
50 bricks (6). max x = 0;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation Examples 303

b r i c k s ( 6 ) . max y = 16 e −3;
52 b r i c k s ( 6 ) . max z = 3 2 . 4 e −3;
bricks ( 6 ) . material type = 2;
54

bricks (7). m i n x = −0.787 e −3;


56 bricks (7). mi n y = 0 ;
bricks (7). min z = 0 ;
58 bricks (7). max x = −0.787 e −3;
bricks (7). max y = 16 e −3;
60 bricks (7). max z = 40 e −3;
bricks (7). 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 ’ ) ;

3 voltage sources = [ ] ;
current sources = [ ] ;
5 diodes = [ ] ;
resistors = [];
7 inductors = [ ] ;
capacitors = [ ] ;
9

% d e f i n e s o u r c e waveform t y p e s and p a r a m e t e r s
11 waveforms . g a u s s i a n ( 1 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 0 ;
waveforms . g a u s s i a n ( 2 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 15;
13

% voltage sources
15 % d i r e c t i o n : ’ xp ’ , ’ xn ’ , ’ yp ’ , ’ yn ’ , ’ zp ’ , o r ’ zn ’
% r e s i s t a n c e : ohms , m a g i t u d e : volts
17 v o l t a g e s o u r c e s ( 1 ) . m i n x = −0.787 e −3;
v o l t a g e s o u r c e s ( 1 ) . min y = 0 ;
19 v o l t a g e s o u r c e s ( 1 ) . m i n z = 24 e −3;
v o l t a g e s o u r c e s ( 1 ) . max x = 0 ;
21 v o l t a g e s o u r c e s ( 1 ) . max y = 0 ;
v o l t a g e s o u r c e s ( 1 ) . max z = 2 6 . 4 e −3;
23 v o l t a g e s o u r c e s ( 1 ) . d i r e c t i o n = ’ xp ’ ;
v o l t a g e s o u r c e s ( 1 ) . r e s i s t a n c e = 50;
25 v o l t a g e s o u r c e s ( 1 ) . magnitude = 1 ;
v o l t a g e s o u r c e s ( 1 ) . waveform type = ’ gaussian ’ ;
27 v o l t a g e s o u r c e s ( 1 ) . waveform index = 1;
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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

3 sampled electric fields = [];


sampled magnetic fields = [ ] ;
5 sampled voltages = [ ] ;
sampled currents = [ ] ;
7 ports = [ ] ;
fa r fi e ld . frequencies = [ ] ;
9

% figure refresh rate


11 p l o t t i n g s t e p = 100;

13 % mode o f o p e r a t i o n
run simulation = true ;
15 show material mesh = true ;
show problem space = true ;
17

% f a r f i e l d c a l c u l a t i o n parameters
19 f a r f i e l d . f r e q u e n c i e s ( 1 ) = 2 . 4 e9 ;
f a r f i e l d . f r e q u e n c i e s ( 2 ) = 5 . 8 e9 ;
21 f a r f i e l d . number of cells from outer boundary = 13;

23 % f r e q u e n c y domain p a r a m e t e r s
f r e q u e n c y d o m a i n . s t a r t = 20 e6 ;
25 f r e q u e n c y d o m a i n . end = 10 e9 ;
f r e q u e n c y d o m a i n . s t e p = 20 e6 ;
27

% define sampled voltages


29 sampled voltages ( 1 ) . m i n x = −0.787 e −3;
sampled voltages ( 1 ) . min y = 0 ;
31 sampled voltages ( 1 ) . m i n z = 2 4 . 4 e −3;
sampled voltages ( 1 ) . max x = 0 ;
33 sampled voltages ( 1 ) . max y = 0 ;
sampled voltages ( 1 ) . max z = 2 6 . 4 e −3;
35 sampled voltages ( 1 ) . d i r e c t i o n = ’ xp ’ ;
sampled voltages (1). display plot = false ;
37

% define sampled currents


39 sampled currents ( 1 ) . m i n x = −0.39 e −3;
sampled currents ( 1 ) . min y = 0 ;
41 sampled currents ( 1 ) . m i n z = 24 e −3;
sampled currents ( 1 ) . max x = −0.39 e −3;
43 sampled currents ( 1 ) . max y = 0 ;
sampled currents ( 1 ) . max z = 2 6 . 4 e −3;
45 sampled currents ( 1 ) . d i r e c t i o n = ’ xp ’ ;
sampled currents (1). display plot = false ;
47

% define ports
49 ports ( 1 ) . sampled voltage index = 1;
ports ( 1 ) . sampled current index = 1;
51 ports ( 1 ) . impedance = 5 0 ;
ports ( 1 ) . is source port = true ;
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation Examples 305

10
S11
5

magnitude (dB) 0

−5

−10

−15

−20

−25

−30
0 2 4 6 8 10
frequency (GHz)

Figure 9.14 Return loss of the inverted-F antenna.

↑y ↑y
9010 9010
120 60 120 60
0 θ = 90o 0 θ = 90o
xy plane xy plane
150 −10 30 150 −10 30

−20 −20
↑φ ↑φ
x x
180 0 → 180 0 →

210 330 210 330

240 300 240 300


dB 270 Dθ, f=2.4 GHz dB 270 D , f=5.8 GHz
θ
D , f=2.4 GHz D , f=5.8 GHz
φ φ

(a) 2.4 GHz (b) 5.8 GHz

Figure 9.15 Radiation patterns in the x y plane cut.


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

306 Near-Field to Far-Field Transformation

↑z ↑z
θ 0 10 θ θ 0 10 θ
← → ← →
30 30 30 30
0 φ = 0o 0 φ = 0o
xz plane xz plane
60 −10 60 60 −10 60

−20 −20

x x
90 90 → 90 90 →

120 120 120 120

150 150 150 150


dB 180 D , f=2.4 GHz dB 180 D , f=5.8 GHz
θ θ
Dφ, f=2.4 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.

↑z ↑z
θ 0 10 θ θ 0 10 θ
← → ← →
30 30 30 30
0 φ = 90o 0 φ = 90o
yz plane yz plane
60 −10 60 60 −10 60

−20 −20

y y
90 90 → 90 90 →

120 120 120 120

150 150 150 150


dB 180 Dθ, f=2.4 GHz dB 180 Dθ, f=5.8 GHz

Dφ, f=2.4 GHz Dφ, f=5.8 GHz

(a) 2.4 GHz (b) 5.8 GHz

Figure 9.17 Radiation patterns in the yz plane cut.


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation Examples 307

Dimensions are in mm.

z
y x

ε r =9.8
Strip width 1 mm.
25.4

26.1
.3
14

10

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 definition of the geometry is described in Listing 9.14, and the definition of
the voltage source is shown in Listing 9.15.
The definition of the output parameters is performed in define output parameters, the con-
tents of which are shown in Listing 9.16. The output parameters to be defined are a sampled
voltage, a sampled current, and a port. Furthermore, far-field frequencies are defined for the
NF–FF transformation. The far-field frequencies are 3.5 GHz and 4.3 GHz. Similar to the pre-
vious example, the value of number of cells from outer boundary is 13, which means that the
imaginary NF–FF surface is 13 cells away from the outer boundaries.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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

3 bricks = [ ] ;
spheres = [ ] ;
5

% define d i e l e c t r i c
7 b r i c k s ( 1 ) . min x = 0 ;
b r i c k s ( 1 ) . mi n y = 0 ;
9 b r i c k s ( 1 ) . min z = 0 ;
b r i c k s ( 1 ) . max x = 1 4 . 3 e −3;
11 b r i c k s ( 1 ) . max y = 2 5 . 4 e −3;
b r i c k s ( 1 ) . max z = 2 6 . 1 e −3;
13 bricks ( 1 ) . material type = 4;

15 bricks (2). m i n x = −8e −3;


bricks (2). mi n y = −6e −3;
17 bricks (2). min z = 0 ;
bricks (2). max x = 22 e −3;
19 bricks (2). max y = 31 e −3;
bricks (2). max z = 0 ;
21 bricks (2). material type = 2;

23 bricks (3). min x = 0 ;


bricks (3). mi n y = 1 2 . 2 e −3;
25 bricks (3). m i n z = 1e −3;
bricks (3). max x = 0 ;
27 bricks (3). max y = 1 3 . 2 e −3;
bricks (3). max z = 10 e −3;
29 bricks (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

voltage sources = [ ] ;
4 current sources = [ ] ;
diodes = [ ] ;
6 resistors = [];
inductors = [ ] ;
8 capacitors = [ ] ;

10 % d e f i n e s o u r c e waveform t y p e s and p a r a m e t e r s
waveforms . g a u s s i a n ( 1 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 0 ;
12 waveforms . g a u s s i a n ( 2 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 15;

14 % voltage sources
% d i r e c t i o n : ’ xp ’ , ’ xn ’ , ’ yp ’ , ’ yn ’ , ’ zp ’ , o r ’ zn ’
16 % r e s i s t a n c e : ohms , m a g i t u d e : volts
v o l t a g e s o u r c e s ( 1 ) . min x = 0 ;
18 v o l t a g e s o u r c e s ( 1 ) . m i n y = 1 2 . 2 e −3;
v o l t a g e s o u r c e s ( 1 ) . min z = 0 ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation Examples 309

20 voltage sources (1). max x = 0 ;


voltage sources (1). max y = 1 3 . 2 e −3;
22 voltage sources (1). max z = 1e −3;
voltage sources (1). d i r e c t i o n = ’ zp ’ ;
24 voltage sources (1). r e s i s t a n c e = 50;
voltage sources (1). magnitude = 1 ;
26 voltage sources (1). waveform type = ’ gaussian ’ ;
voltage sources (1). waveform index = 1;
 

Listing 9.16 define output parameters.m


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

3 sampled electric fields = [];


sampled magnetic fields = [ ] ;
5 sampled voltages = [ ] ;
sampled currents = [ ] ;
7 ports = [ ] ;
fa r fi e l d . frequencies = [ ] ;
9

% figure refresh rate


11 p l o t t i n g s t e p = 20;

13 % mode o f o p e r a t i o n
run simulation = true ;
15 show material mesh = true ;
show problem space = true ;
17

% f a r f i e l d c a l c u l a t i o n parameters
19 f a r f i e l d . f r e q u e n c i e s ( 1 ) = 3 . 5 e9 ;
f a r f i e l d . f r e q u e n c i e s ( 2 ) = 4 . 3 e9 ;
21 f a r f i e l d . number of cells from outer boundary = 13;

23 % f r e q u e n c y domain p a r a m e t e r s
f r e q u e n c y d o m a i n . s t a r t = 2 e9 ;
25 f r e q u e n c y d o m a i n . end = 6 e9 ;
f r e q u e n c y d o m a i n . s t e p = 20 e6 ;
27

% define sampled voltages


29 sampled voltages ( 1 ) . min x = 0 ;
sampled voltages ( 1 ) . m i n y = 1 2 . 2 e −3;
31 sampled voltages ( 1 ) . min z = 0 ;
sampled voltages ( 1 ) . max x = 0 ;
33 sampled voltages ( 1 ) . max y = 1 3 . 2 e −3;
sampled voltages ( 1 ) . max z = 1e −3;
35 sampled voltages ( 1 ) . d i r e c t i o n = ’ zp ’ ;
sampled voltages (1). display plot = false ;
37

% define sampled currents


39 sampled currents ( 1 ) . min x = 0 ;
sampled currents ( 1 ) . m i n y = 1 2 . 2 e −3;
41 sampled currents ( 1 ) . m i n z = 0 . 5 e −3;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

310 Near-Field to Far-Field Transformation

sampled currents (1). max x = 0 ;


43 sampled currents (1). max y = 1 3 . 2 e −3;
sampled currents (1). max z = 0 . 5 e −3;
45 sampled currents (1). d i r e c t i o n = ’ zp ’ ;
sampled currents (1). display plot = false ;
47

% define ports
49 ports ( 1 ) . sampled voltage index = 1;
ports ( 1 ) . sampled current index = 1;
51 ports ( 1 ) . impedance = 5 0 ;
ports ( 1 ) . is source port = true ;
 

The FDTD simulation of the DRA is performed with 10,000 time steps, and S11 of the input
port is calculated. The calculated return loss is plotted in Fig. 9.19, and it shows good agreement
with the published simulation and measurement data in [37].
Furthermore, the directivity patterns are calculated in the xy, xz, and y z plane cuts at 3.5 GHz
and 4.3 GHz. These patterns are plotted in Figs. 9.20, 9.21, and 9.22, respectively. The simulated
FDTD radiation patterns show good agreement with the published data as well [37].

9.5 EXERCISES

9.1 In this exercise we construct and study the characteristics of a half-wave dipole antenna.
Create a problem space composed of a cubic Yee cell with 0.5 mm size on a side. Set
the boundaries as CPML, and leave 10 cells air gap between the antenna and the CPML
boundaries on all sides. Place a brick of square cross-section with 1 mm width and 14.5 mm

10
S11

0
magnitude (dB)

−10

−20

−30

−40
2 2.5 3 3.5 4 4.5 5 5.5 6
frequency (GHz)

Figure 9.19 Return loss of the strip-fed rectangular DRA.


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Exercises 311

↑y ↑y
9010 9010
120 60 120 60
0 θ = 90o 0 θ = 90o
xy plane xy plane
150 −10 30 150 −10 30

−20 −20
↑φ ↑φ
x x
180 0 → 180 0 →

210 330 210 330

240 300 240 300


dB 270 Dθ, f=3.5 GHz dB 270 Dθ, f=4.3 GHz

Dφ, f=3.5 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.

↑z ↑z
θ 0 10 θ 0
← → θ 10 θ
← →
30 30 30 30
0 φ = 0o 0 φ = 0o
xz plane xz plane
60 −10 60 60 −10 60

−20 −20

x x
90 90 → 90 90 →

120 12 0 120 12 0

150 150 150 150


dB 180 Dθ, f=3.5 GHz dB 180 Dθ, f=4.3 GHz

Dφ, f=3.5 GHz Dφ, f=4.3 GHz

(a) 3.5 GHz (b) 4.3 GHz

Figure 9.21 Radiation patterns in the x z plane cut.


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

312 Near-Field to Far-Field Transformation

↑z ↑z
θ 010 θ
← → θ 010 θ
← →
30 30 30 30
0 φ = 90o 0 φ = 90o
yz plane yz plane
60 −10 60 60 −10 60

−20 −20

y y
90 90 → 90 90 →

120 12 0 120 1 20

150 150 150 150


dB 180 Dθ, f=3.5 GHz dB 180 Dθ, f=4.3 GHz

Dφ, f=3.5 GHz Dφ, f=4.3 GHz

(a) 3.5 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 define
a sampled voltage and a sampled current across and around the voltage source and associate
them to a port. The geometry of the problem is illustrated in Fig. 9.23. Run the simulation,
and calculate the input impedance of the antenna using the frequency-domain simulation
results. Identify the resonance frequency of the antenna from the input impedance results.
Then rerun the simulation to calculate the radiation pattern at the resonance frequency.
9.2 Consider the dipole antenna that you constructed in Exercise 9.1. Examine the input
impedance that you calculated, and record the real part of the input impedance at resonance
frequency. Then change the resistance of the voltage source and the port to the resistance
you recorded. Rerun the simulation, and obtain the scattering parameter (S-parameter) and
radiation pattern results. Examine whether the S-parameters and the radiation patterns have
changed.
9.3 In this exercise we try to construct a microstrip rectangular square patch antenna. Define
a problem space with grid size x = 2 mm, y = 2 mm, and z = 0.95 mm. Place a
rectangular brick in the problem space as the substrate of the antenna with dimensions
60 mm × 40 mm × 1.9 mm and 2.2 dielectric constant. Place a PEC plate as the ground of
the antenna on the bottom side of the substrate covering the entire surface area. Then place
a PEC patch on the top surface of the substrate with 56 mm width and 20 mm length in the
x and y directions, respectively. Make sure that the top patch is centered on the top surface
of the substrate. The feeding point to the top patch will be at the center of one of the long
edges of the patch. Place a voltage source with 50 internal resistance between the ground
plane and the feeding point, define a sampled voltage and a sampled current on the voltage
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Exercises 313

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.


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

314 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 configuration the patch feeding is placed right at the center of the edge of the antenna.
In this example the antenna will be fed through a microstrip line. Place a microstrip line
with 6 mm width between the antenna feeding point and the edge of the substrate. This
microstrip line with 6 mm width will simulate a characteristic impedance of 50 . Notice
that you will need to place the microstrip line off center by 1 mm to have it conforming
to the FDTD grid. Move the voltage source, the sampled voltage, and the sampled current
to the edge of the substrate where the microstrip line is extended. The geometry of the
problem is illustrated in Fig. 9.25. Run the simulation, and obtain the return loss and the
radiation pattern at the corresponding operating frequency. Does the existence of a feeding
line change the radiation pattern?
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

10
Thin-Wire Modeling

So far we have assumed that all of the objects in the finite-difference time-domain (FDTD)
problem space conform to the FDTD grid. Some subcell modeling techniques are developed to
model geometries that do not conform to the grid or have dimensions smaller than cell dimensions.
One of the most common such geometries is a thin wire that has a radius less than a cell size.
In this chapter we discuss one of the subcell modeling techniques that is proposed to model thin
wires in FDTD simulations.
There are various techniques proposed for modeling thin wires. However, we discuss the one
proposed in [38], which is based on Faraday’s law contour-path formulation. This model is easy
to understand and to implement in the FDTD program.

10.1 THIN-WIRE FORMULATION


Figure 10.1 illustrates a thin wire of radius a with its axis coinciding with a field 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 field 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 field components. We now demonstrate
the derivation of the updating equation for the component Hy (i, j, k); the derivation of updating
equations for other field components follows the same procedure.
Figure 10.1 shows the magnetic field component Hy (i, j, k) and four electric field components
circulating around Hy (i, j, k). Faraday’s law given in integral form as


∂H
−µ · d s = E · d l (10.1)
S ∂t L

can be applied on the enclosed surface shown in Fig. 10.1 to establish the relation between
Hy (i, j, k) and the electric field components located on the boundaries of the enclosed surface.
Before utilizing (10.1) it should be noted that the variation of the fields around the thin wire is
assumed to be a function of 1/r, where r represents the distance to the field position from the
thin-wire axis [38]. In more explicit form Hy can be expressed as

Hy0
Hy (r) = , (10.2)
r

315
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Thin-Wire Formulation 317

and, similarly, E x can be expressed as

E x0
E x (r) = , (10.3)
r

where Hy0 and E x0 are constants. In Fig. 10.1 one can observe that the field components Hy (i, j, k),
E x (i, j, k), and E x (i, j, k + 1) are located at r = x/2. For instance,
 
x 2Hy0
Hy = = Hy (i, j, k). (10.4)
2 x

Then

Hy (i, j, k)x
Hy0 = , (10.5)
2

hence,

Hy (i, j, k)x
Hy (r) = . (10.6)
2r

Similarly,

E x (i, j, k)x
E x (r)| j,k = , (10.7)
2r

and

E x (i, j, k + 1)x
E x (r)| j,k+1 = . (10.8)
2r

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 (10.9)
z=0 r=a ∂t 2r
z=z z=0
= E z (i, j, k)d z + E z (i + 1, j, k)d z (10.10)
z=0 z=z

r=x
E x (i, j, k + 1)x r=a
E x (i, j, k)x
+ dr + dr. (10.11)
r=a 2r r=x 2r

Notice that the electric field should vanish inside the wire; therefore, the integration limits
are from a to x. Due to the same reasoning, E z (i, j, k) is zero as well. Then evaluation of
(10.12) yields
 
−µzx x ∂ Hy (i, j, k)
ln = −zE z (i + 1, j, k)
2 a ∂t
   
x x x x
+ ln E x (i, j, k + 1) − ln E x (i, j, k). (10.12)
a 2 a 2
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

318 Thin-Wire Modeling

After applying the central difference approximation to the time derivative of magnetic field com-
ponent and re-arranging the terms, one can obtain the new value of Hy (i, j, k) in terms of other
components as

2t
Hyn+1/2 (i, j, k) = Hyn−1/2 (i, j, k) +   E zn (i + 1, j, k)
µx ln x
a
t  n 
− E x (i, j, k + 1) − E xn (i, j, k) . (10.13)
µz

Equation (10.13) can be written in the same form as the general updating equation for Hy (1.30),
such that
n+ 12 n− 12
Hy (i, j, k) = C hyh (i, j, k) × Hy (i, j, k)
 
+ C hye z (i, j, k) × E zn (i + 1, j, k) − E zn (i, j, k)
 
+ C hye x (i, j, k) × E xn (i, j, k + 1) − E xn (i, j, k) , (10.14)

where
2t
C hyh (i, j, k) = 1, C hye z (i, j, k) =  ,
µ y (i, j, k)x ln x
a
t
C hye x (i, j, k) = − .
µ y (i, j, k)z

Then one only need to modify the updating coefficients before the FDTD time-marching loop
n+ 1
according to (10.14) to have Hy 2 (i, j, k) updated due to a thin wire between nodes (i, j, k) and
(i, j, k + 1). Furthermore, we have enforced E z (i, j, k) to be zero. This can be accomplished sim-
ilarly by setting the updating coefficients for E zn (i, j, k) in (1.28) as zero. That means Ce ze (i, j, k),
Ce zhy (i, j, k), and Ce zhy (i, j, k) should be assigned zeros before the FDTD time-marching proce-
dure begins.
As mentioned before, there are four magnetic field components circulating around E zn (i, j, k) as
illustrated in Fig. 10.2; therefore, all these magnetic field components need to be updated based on
thin-wire modeling. The updating equation for Hy (i, j, k) is given in (10.13). Similarly, updating
equations can be obtained for the other three components as

n+ 12 n− 12
Hy (i − 1, j, k) = C hyh (i − 1, j, k) × Hy (i − 1, j, k)
 
+ C hye z (i − 1, j, k) × E zn (i, j, k) − E zn (i − 1, j, k)
 
+ C hye x (i − 1, j, k) × E xn (i − 1, j, k + 1) − E xn (i − 1, j, k) , (10.15)

where
2t
C hyh (i − 1, j, k) = 1, C hye z (i − 1, j, k) =  ,
µ y (i − 1, j, k)x ln x
a
t
C hye x (i − 1, j, k) = − .
µ y (i − 1, j, k)z
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

MATLAB Implementation of the Thin-Wire Formulation 319

n+ 12 n− 12
Hx (i, j, k) = C hxh (i, j, k) × Hx (i, j, k)
 
+ C hxe y (i, j, k) × E yn (i, j, k + 1) − E yn (i, j, k)
 
+ C hxe z (i, j, k) × E zn (i, j + 1, k) − E zn (i, j, k) , (10.16)

where
t
C hxh (i, j, k) = 1, C hxe y (i, j, k) = ,
µx (i, j, k)z
2t
C hxe z (i, j, k) = −  .
y
µx (i, j, k)y ln a

and
n+ 12 n− 12
Hx (i, j − 1, k) = C hxh (i, j − 1, k) × Hx (i, j − 1, k)
 
+ C hxe y (i, j − 1, k) × E yn (i, j − 1, k + 1) − E yn (i, j − 1, k)
 
+ C hxe z (i, j − 1, k) × E zn (i, j, k) − E zn (i, j − 1, k) , (10.17)

where
t
C hxh (i, j − 1, k) = 1, C hxe y (i, j − 1, k) = ,
µx (i, j − 1, k)z
2t
C hxe z (i, j − 1, k) = −  .
y
µx (i, j − 1, k)y ln a

10.2 MATLAB IMPLEMENTATION OF THE THIN-WIRE FORMULATION


Having derived the updating equations for modeling thin wires, these equations can be imple-
mented in the FDTD program. The first step is the definition of the thin-wire parameters. The
thin wires are defined as a part of the geometry, and their definition implementation is provided
in the subroutine define geometry, as shown in Listing 10.1.
A new parameter called thin wires is defined 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 field 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 field 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 sufficient 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.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

320 Thin-Wire Modeling

Listing 10.1 define geometry


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

3 bricks = [ ] ;
spheres = [ ] ;
5 thin wires = [ ] ;

7 % define a thin wire


t h i n w i r e s ( 1 ) . min x = 0 ;
9 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;
11 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 ;
13 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;
15 thin wires ( 1 ) . direction = ’ z ’ ;

17 % define a thin wire


t h i n w i r e s ( 2 ) . min x = 0 ;
19 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;
21 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 ;
23 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;
25 thin wires ( 2 ) . direction = ’ z ’ ;
 

After the definition process, the initialization process is performed. Since the thin wire is a
new type of geometry that would determine the size of the problem space, necessary codes must
be implemented in the subroutine calculate domain size. The code for this task is shown in
Listing 10.2.

Listing 10.2 calculate domain size


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

3 number of spheres = size ( spheres , 2 ) ;


number of bricks = size ( bricks , 2 ) ;
5 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
30 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 x;
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 y;
32 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 z;
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 x;
34 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 y;
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 z;
36 number of objects = number of objects + 1;
end
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

MATLAB Implementation of the Thin-Wire Formulation 321

The next step in the thin-wire implementation is the initialization of the thin-wire parame-
ters through the updating coefficients. A new subroutine named initialize thin wire updating -
coefficients is implemented for initialization of the thin-wire updating coefficients. This subrou-
tine is named initialize updating coefficients and is called after the initialization subroutines
for the updating coefficients of other types of objects are called. The implementation of initial-
ize thin wire updating coefficients is shown in Listing 10.3. In this subroutine, the electric and
magnetic field coefficients associated with thin wires are updated based on the equations derived
in Section 10.1.
Listing 10.3 initialize thin wire updating coefficients
disp ( ’ i n i t i a l i z i n g thin wire updating c o e f f i c i e n t s ’ ) ;
2

dtm = d t / mu 0 ;
4

for ind = 1: number of thin wires


6 i s = round ( ( t h i n w i r e s ( i n d ) . m i n x − fdtd domain . min x ) / dx ) + 1 ;
j s = round ( ( t h i n w i r e s ( i n d ) . m i n y − fdtd domain . min y ) / dy ) + 1 ;
8 k s = round ( ( t h i n w i r e s ( i n d ) . m i n z − fdtd domain . min z ) / dz ) + 1 ;
i e = round ( ( t h i n w i r e s ( i n d ) . max x − fdtd domain . min x ) / dx ) + 1 ;
10 j e = round ( ( t h i n w i r e s ( i n d ) . max y − fdtd domain . min y ) / dy ) + 1 ;
ke = round ( ( t h i n w i r e s ( i n d ) . max z − fdtd domain . min z ) / dz ) + 1 ;
12 r o = t h i n w i r e s ( ind ) . r a d i u s ;

14 sw i t ch ( t h i n w i r e s ( i n d ) . d i r e c t i o n ( 1 ) )
case ’ x ’
16 C e x e ( i s : i e −1 , j s , k s ) = 0 ;
C e x h y ( i s : i e −1 , j s , k s ) = 0 ;
18 C e x h z ( i s : i e −1 , j s , k s ) = 0 ;
Chyh ( i s : i e −1 , j s , ks −1: k s ) = 1 ;
20 C h y e z ( i s : i e −1 , j s , ks −1: k s ) = dtm . . .
. / ( m u r y ( i s : i e −1 , j s , ks −1: k s ) * dx ) ;
22 C h y e x ( i s : i e −1 , j s , ks −1: k s ) = −2 * dtm . . .
. / ( m u r y ( i s : i e −1 , j s , ks −1: k s ) * dz * l o g ( dz / r o ) ) ;
24 Chzh ( i s : i e −1 , j s −1: j s , k s ) = 1 ;
C h z e x ( i s : i e −1 , j s −1: j s , k s ) = 2 * dtm . . .
26 . / ( m u r z ( i s : i e −1 , j s −1: j s , k s ) * dy * l o g ( dy / r o ) ) ;
C h z e y ( i s : i e −1 , j s −1: j s , k s ) = −dtm . . .
28 . / ( m u r z ( i s : i e −1 , j s −1: j s , k s ) * dx ) ;
case ’ y ’
30 C e y e ( i s , j s : j e −1 , k s ) = 0 ;
C e y h x ( i s , j s : j e −1 , k s ) = 0 ;
32 C e y h z ( i s , j s : j e −1 , k s ) = 0 ;
Chzh ( i s −1: i s , j s : j e −1 , k s ) = 1 ;
34 C h z e x ( i s −1: i s , j s : j e −1 , k s ) = dtm . . .
. / ( m u r z ( i s −1: i s , j s : j e −1 , k s ) * dy ) ;
36 C h z e y ( i s −1: i s , j s : j e −1 , k s ) = −2 * dtm . . .
. / ( m u r z ( i s −1: i s , j s : j e −1 , k s ) * dx * l o g ( dx / r o ) ) ;
38 Chxh ( i s , j s : j e −1 , ks −1: k s ) = 1 ;
C h x e y ( i s , j s : j e −1 , ks −1: k s ) = 2 * dtm . . .
40 . / ( m u r x ( i s , j s : j e −1 , ks −1: k s ) * dz * l o g ( dz / r o ) ) ;
C h x e z ( i s , j s : j e −1 , ks −1: k s ) = −dtm . . .
42 . / ( m u r x ( i s , j s : j e −1 , ks −1: k s ) * dy ) ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

322 Thin-Wire Modeling

case ’ z ’
44 Ceze ( i s , j s , k s : ke −1) = 0 ;
Cezhx ( i s , j s , k s : ke −1) = 0 ;
46 Cezhy ( i s , j s , k s : ke −1) = 0 ;
Chxh ( i s , j s −1: j s , k s : ke −1) = 1 ;
48 Chxey ( i s , j s −1: j s , k s : ke −1) = dtm . . .
./ ( m u r x ( i s , j s −1: j s , k s : ke −1) * dz ) ;
50 Chxez ( i s , j s −1: j s , k s : ke −1) = −2 * dtm . . .
./ ( m u r x ( i s , j s −1: j s , k s : ke −1) * dy * l o g ( dy / r o ) ) ;
52 Chyh ( i s −1: i s , j s , k s : ke −1) = 1 ;
Chyez ( i s −1: i s , j s , k s : ke −1) = 2 * dtm . . .
54 ./ ( m u r y ( i s −1: i s , j s , k s : ke −1) * dx * l o g ( dx / r o ) ) ;
Chyex ( i s −1: i s , j s , k s : ke −1) = −dtm . . .
56 ./ ( m u r y ( i s −1: i s , j s , k s : ke −1) * dz ) ;
end
58 end
 

As the updating coefficients associated with the thin wires are updated appropriately, the
implementation of the thin-wire formulation is completed. The thin-wire implementation only
requires an extra preprocessing step. Then during the FDTD time-marching loop the updating
coefficients will manipulate the fields for modeling the thin-wire behavior.

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 definition of
the geometry is illustrated in Listing 10.4. The definition of the voltage source is given in Listing
10.5, and the definitions of the output parameters are given in Listing 10.6. One can notice in
Listing 10.6 that a far-field frequency is defined as 7 GHz to obtain the far-field radiation patterns
at this frequency.
The simulation of this problem is performed for 4,000 time steps. The same problem is sim-
ulated 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 mag-
nitude 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 = [ ] ;
4 spheres = [ ] ;
thin wires = [ ] ;
6

% define a thin wire


8 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 ;
10 t h i n w i r e s ( 1 ) . m i n z = 0 . 2 5 e −3;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation Examples 323

thin wires (1). max x = 0 ;


12 thin wires (1). max y = 0 ;
thin wires (1). max z = 10 e −3;
14 thin wires (1). r a d i u s = 0 . 0 5 e −3;
thin wires (1). direction = ’z ’ ;
16

% define a thin wire


18 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 ;
20 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 ;
22 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;
24 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-field 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 ’ ) ;

3 voltage sources = [ ] ;
current sources = [ ] ;
5 diodes = [ ] ;
resistors = [];
7 inductors = [ ] ;
capacitors = [ ] ;
9

% d e f i n e s o u r c e waveform t y p e s and p a r a m e t e r s
11 waveforms . g a u s s i a n ( 1 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 0 ;
waveforms . g a u s s i a n ( 2 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 15;
13

% voltage sources
15 % d i r e c t i o n : ’ xp ’ , ’ xn ’ , ’ yp ’ , ’ yn ’ , ’ zp ’ , o r ’ zn ’
% r e s i s t a n c e : ohms , m a g i t u d e : volts
17 v o l t a g e s o u r c e s ( 1 ) . min x = 0 ;
v o l t a g e s o u r c e s ( 1 ) . min y = 0 ;
19 v o l t a g e s o u r c e s ( 1 ) . m i n z = −0.25 e −3;
v o l t a g e s o u r c e s ( 1 ) . max x = 0 ;
21 v o l t a g e s o u r c e s ( 1 ) . max y = 0 ;
v o l t a g e s o u r c e s ( 1 ) . max z = 0 . 2 5 e −3;
23 v o l t a g e s o u r c e s ( 1 ) . d i r e c t i o n = ’ zp ’ ;
v o l t a g e s o u r c e s ( 1 ) . r e s i s t a n c e = 50;
25 v o l t a g e s o u r c e s ( 1 ) . magnitude = 1 ;
v o l t a g e s o u r c e s ( 1 ) . waveform type = ’ gaussian ’ ;
27 v o l t a g e s o u r c e s ( 1 ) . waveform index = 1;
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

324 Thin-Wire Modeling

Listing 10.6 define output parameters.m



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

3 sampled electric fields = [];


sampled magnetic fields = [ ] ;
5 sampled voltages = [ ] ;
sampled currents = [ ] ;
7 ports = [ ] ;
fa r fi e ld . frequencies = [ ] ;
9

% figure refresh rate


11 p l o t t i n g s t e p = 10;

13 % mode o f o p e r a t i o n
run simulation = true ;
15 show material mesh = true ;
show problem space = true ;
17

% f a r f i e l d c a l c u l a t i o n parameters
19 f a r f i e l d . f r e q u e n c i e s ( 1 ) = 7 . 0 e9 ;
f a r f i e l d . number of cells from outer boundary = 13;
21

% f r e q u e n c y domain p a r a m e t e r s
23 f r e q u e n c y d o m a i n . s t a r t = 20 e6 ;
f r e q u e n c y d o m a i n . end = 20 e9 ;
25 f r e q u e n c y d o m a i n . s t e p = 20 e6 ;

27 % define sampled voltages


sampled voltages ( 1 ) . min x = 0 ;
29 sampled voltages ( 1 ) . min y = 0 ;
sampled voltages ( 1 ) . m i n z = −0.25 e −3;
31 sampled voltages ( 1 ) . max x = 0 ;
sampled voltages ( 1 ) . max y = 0 ;
33 sampled voltages ( 1 ) . max z = 0 . 2 5 e −3;
sampled voltages ( 1 ) . d i r e c t i o n = ’ zp ’ ;
35 sampled voltages (1). display plot = false ;

37 % define sampled currents


sampled currents ( 1 ) . min x = 0 ;
39 sampled currents ( 1 ) . min y = 0 ;
sampled currents ( 1 ) . min z = 0 ;
41 sampled currents ( 1 ) . max x = 0 ;
sampled currents ( 1 ) . max y = 0 ;
43 sampled currents ( 1 ) . max z = 0 ;
sampled currents ( 1 ) . d i r e c t i o n = ’ zp ’ ;
45 sampled currents (1). display plot = false ;

47 % define ports
ports ( 1 ) . sampled voltage index = 1;
49 ports ( 1 ) . sampled current index = 1;
ports ( 1 ) . impedance = 5 0 ;
51 ports ( 1 ) . is source port = true ;
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation Examples 325

CPML boundaries

outer boundaries

voltage source

z
y x

Figure 10.3 A thin-wire dipole antenna.

10
magnitude (dB)

−10 FDTD
WIPL−D
−20
0 5 10 15 20
frequency (GHz)
50
phase (degrees)

−50

−100
0 5 10 15 20
frequency (GHz)

Figure 10.4 Return loss of the thin-wire dipole antenna.


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

326 Thin-Wire Modeling

2000

FDTD real[Z ]
in
FDTD imaginary[Zin]
1500
WIPL−D real[Z ]
in
WIPL−D imaginary[Zin]

1000
input impedance (Ω)

500

−500

−1000
0 2 4 6 8 10 12 14 16 18 20
frequency (GHz)

Figure 10.5 Input impedance of the thin-wire dipole antenna.

↑y
9010
120 60
0 θ = 90o
xy plane
150 −10 30

−20
↑φ
x
180 0 →

210 330

240 300
dB 270 D , f=7 GHz
θ

D , f=7 GHz
φ

Figure 10.6 Radiation pattern in the x y plane cut.


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Exercises 327

↑z
θ

0 10 θ

30 30
0 φ = 0o
xz plane
60 −10 60

−20

x
90 90 →

120 120

150 15 0
dB 180 D , f=7 GHz
θ

D , f=7 GHz
φ

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. Define a dipole
antenna using thin wires similar to the dipole antenna discussed in Section 10.3.1. Set
the length of each wire to 10 mm, and leave a 1 mm gap between the wires. Place a
voltage source, a sampled voltage, and a sampled current in the gap between the wires,
and associate them to a port. Set the radius of the wire as 0.1 mm, run the simulation, and
obtain the return loss of the antenna. Then increase the radius of the wire by 0.2 mm,
repeat the simulation, and observe the change in the return loss. Rerun the simulations
with incremented increase of wire radius by 0.2 mm until the increased wire radius causes
instability in the simulation. Can you determine the maximum wire radius for accurate
results in this configuration?
10.2 In this example we construct an antenna array composed of two thin-wire dipole anten-
nas. Consider the dipole antenna that you constructed in Exercise 10.1. Run the dipole
simulation using the 0.1 mm wire radius, and record the operation frequency. Rerun the
simulation, and obtain the radiation pattern at the frequency of operation. Then define
another thin-wire dipole antenna with the same dimensions as the current one, and place it
2 mm above the current one, such that the center to center distance between antennas will
be 23 mm. Place a voltage source at the feeding gap of the second antenna that has the
same properties of the voltage source of the first antenna. Do not define any ports, and if
there are already defined ports, remove them. The geometry of the problem is illustrated
in Fig. 10.9. Run the simulation, and calculate the radiation patterns at the frequency of
operation. Examine the directivity patterns of the single- and two-dipole configurations.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

328 Thin-Wire Modeling

↑z
θ

0 10 θ

30 30
0 φ = 90o
yz plane
60 −10 60

−20

y
90 90 →

1 20 120

1 50 15 0
dB 180 D , f=7 GHz
θ

D , f=7 GHz
φ

Figure 10.8 Radiation pattern in the yz plane cut.

Figure 10.9 An antenna array composed of two thin-wire dipole antennas.


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Exercises 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.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

11
Scattered Field Formulation

As discussed before, sources are the necessary components of a finite-difference time-domain


(FDTD) simulation, and their types vary depending on the type of the problem under considera-
tion. 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 fields in scattering problems.
In the previous chapters we demonstrated several examples utilizing near-zone sources. In this
chapter we present scattered field 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 fields generated somewhere outside the FDTD problem space that
illuminate the objects in the problem space. Therefore, they are the incident fields exciting the
FDTD problem space. The incident field exists in a problem space in which there are no scatterers.
Therefore, they are the fields that can be described by analytical expressions and would satisfy
Maxwell’s curl equations where the problem space medium is free space, such that


∇×H inc = ε0 ∂ Einc , (11.1a)
∂t
∂Hinc
∇ × Einc = −µ0 . (11.1b)
∂t

The most common type of incident field is the plane wave. The expressions for the field compo-
nents generated by plane waves are discussed in a subsequent section.
When the incident field illuminates the objects in an FDTD problem space, scattered fields are
generated and thus need to be calculated. The scattered field formulation is one of the simplest
techniques that can be used for calculating scattered fields.
The fields in a problem space are referred to in general as total fields. The total fields satisfy
Maxwell’s curl equations for a general medium, such that


∇×H tot = ε ∂ Etot + σ e Etot , (11.2a)
∂t
∂H tot
∇ × Etot = −µ − σmH tot . (11.2b)
∂t

331
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

332 Scattered Field Formulation

Then the scattered fields are defined as the difference between the total fields and incident fields.
Therefore, one can write

Etot = Einc + Escat , and Htot = Hinc + Hscat , (11.3)

where Escat and Hscat are the scattered electric and magnetic fields. In light of (11.3), equation
(11.2) can be rewritten in terms of incident and scattered field terms as

inc = ε
scat + ∇ × H ∂ Escat ∂ Einc
∇×H +ε + σ e Escat + σ e Einc , (11.4a)
∂t ∂t
∂H scat ∂H inc
∇ × Escat + ∇ × Einc = −µ −µ − σmH scat − σ m H inc . (11.4b)
∂t ∂t

The curls of the incident fields in (11.4) can be replaced by the time-derivative terms from (11.1),
which yields

scat + ε0 ∂ Einc ∂ Escat ∂ Einc


∇×H =ε +ε + σ e Escat + σ e Einc , (11.5a)
∂t ∂t ∂t
∂H inc ∂H scat ∂H inc
∇ × Escat − µ0 = −µ −µ − σmH scat − σ m H inc . (11.5b)
∂t ∂t ∂t

After rearranging the terms in (11.5) one can obtain

∂ Escat 
scat + (ε0 − ε) ∂ Einc − σ e Einc ,
ε + σ e Escat = ∇ × H (11.6a)
∂t ∂t

∂ Hscat 
µ + σmH scat = −∇ × Escat + (µ0 − µ) ∂ Hinc − σ m H inc . (11.6b)
∂t ∂t

At this point the derivatives in (11.6) can be represented by central finite difference approximations,
and updating equations can be obtained for the scattered field formulation.

11.2 THE SCATTERED FIELD UPDATING EQUATIONS

After applying the central finite difference approximation, equation (11.6a) can be expressed for
the x component as

n+1
Escat,x (i, j, k) − Escat,x
n
(i, j, k) n+1
Escat,x (i, j, k) + Escat,x
n
(i, j, k)
εx (i, j, k) + σxe (i, j, k)
t 2
n+ 1 n+ 1 n+ 1 n+ 1
Hscat,z2 (i, j, k) − Hscat,z2 (i, j − 1, k) Hscat,y2 (i, j, k) − Hscat,y2 (i, j, k − 1)
= −
y z
n+1
Einc,x (i, j, k) − Einc,x
n
(i, j, k)
+ (ε0 − εx (i, j, k))
t
n+1
Einc,x (i, j, k) + Einc,x
n
(i, j, k)
− σxe (i, j, k) , (11.7)
2
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

The Scattered Field Updating Equations 333

Equation (11.7) can be arranged such that the new value of the scattered electric field component
n+1
Escat,x (i, j, k) is calculated using other terms as
n+1
Escat,x (i, j, k) = Cexe (i, j, k) × Escat,x
n
(i, j, k)
n+ 1 n+ 1
!
+ Cexhz (i, j, k) × Hscat,z2 (i, j, k) − Hscat,z2 (i, j − 1, k)
n+ 1 n+ 1
!
+ Cexhy (i, j, k) × Hscat,y2 (i, j, k) − Hscat,y2 (i, j, k − 1)

+ Cexeic (i, j, k) × Einc,x


n+1
(i, j, k) + Cexeip (i, j, k) × Einc,x
n
(i, j, k), (11.8)

where
2εx (i, j, k) − σxe (i, j, k)t
Cexe (i, j, k) = ,
2εx (i, j, k) + σxe (i, j, k)t
2t
Cexhz (i, j, k) =  ,
y 2εx (i, j, k) + σxe (i, j, k)t
2t
Cexhy (i, j, k) = −  ,
z 2εx (i, j, k) + σxe (i, j, k)t
2 (ε0 − εx (i, j, k)) − σxe (i, j, k)t
Cexeic (i, j, k) = ,
2εx (i, j, k) + σxe (i, j, k)t
2 (ε0 − εx (i, j, k)) + σxe (i, j, k)t
Cexeip (i, j, k) = − .
2εx (i, j, k) + σxe (i, j, k)t

In this equation the ic term in the subscript of the coefficient Cexeic indicates that this coefficient
is multiplied with the current value of the incident field component, whereas the ip term in the
subscript of the coefficient Cexeip indicates that this coefficient is multiplied with the previous value
of the incident field component.
n+1
Similarly the updating equation can be written for Escat,y (i, j, k) as
n+1
Escat,y (i, j, k) = Ceye (i, j, k) × Escat,y
n
(i, j, k)
n+ 1 n+ 1
!
+ Ceyhx (i, j, k) × Hscat,x2 (i, j, k) − Hscat,x2 (i, j, k − 1)
n+ 1 n+ 1
!
+ Ceyhz (i, j, k) × Hscat,z2 (i, j, k) − Hscat,z2 (i − 1, j, k)

+ Ceyeic (i, j, k) × Einc,y


n+1
(i, j, k) + Ceyeip (i, j, k) × Einc,y
n
(i, j, k), (11.9)

where
2ε y (i, j, k) − σ ye (i, j, k)t
Ceye (i, j, k) = ,
2ε y (i, j, k) + σ ye (i, j, k)t
2t
Ceyhx (i, j, k) =  ,
z 2ε y (i, j, k) + σ ye (i, j, k)t
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

334 Scattered Field Formulation

2t
Ceyhz (i, j, k) = −  ,
x 2ε y (i, j, k) + σ ye (i, j, k)t
 
2 ε0 − ε y (i, j, k) − σ ye (i, j, k)t
Ceyeic (i, j, k) = ,
2ε y (i, j, k) + σ ye (i, j, k)t
 
2 ε0 − ε y (i, j, k) + σ ye (i, j, k)t
Ceyeip (i, j, k) = − .
2ε y (i, j, k) + σ ye (i, j, k)t

n+1
The updating equation can be written for Escat,z (i, j, k) as

n+1
Escat,z (i, j, k) = Ceze (i, j, k) × Escat,z
n
(i, j, k)


n+ 12 n+ 12
+ Cezhy (i, j, k) × Hscat,y (i, j, k) − Hscat,y (i, j, k − 1)


n+ 1 n+ 1
+ Cezhx (i, j, k) × Hscat,x2 (i, j, k) − Hscat,x2 (i − 1, j, k)

+ Cezeic (i, j, k) × Einc,z


n+1
(i, j, k) + Cezeip (i, j, k) × Einc,z
n
(i, j, k), (11.10)

where

2εz (i, j, k) − σze (i, j, k)t


Ceze (i, j, k) = ,
2εz (i, j, k) + σze (i, j, k)t
2t
Cezhy (i, j, k) =  ,
x 2εz (i, j, k) + σze (i, j, k)t
2t
Cezhx (i, j, k) = −  ,
y 2εz (i, j, k) + σze (i, j, k)t
2 (ε0 − εz (i, j, k)) − σze (i, j, k)t
Cezeic (i, j, k) = ,
2εz (i, j, k) + σze (i, j, k)t
2 (ε0 − εz (i, j, k)) + σze (i, j, k)t
Cezeip (i, j, k) = − .
2εz (i, j, k) + σze (i, j, k)t

Following a similar procedure, the updating equations for the magnetic field components can
n+ 1
be obtained as follows. The updating equation for Hscat,x2 (i, j, k) is

n+ 1 n− 1
Hscat,x2 (i, j, k) = Chxh (i, j, k) × Hscat,x2 (i, j, k)
 n 
+ Chxez (i, j, k) × Escat,z (i, j + 1, k) − Escat,z
n
(i, j, k)
 n 
+ Chxey (i, j, k) × Escat,y (i, j, k + 1) − Escat,y
n
(i, j, k)
n+ 1 n− 1
+ Chxhic (i, j, k) × Hinc,x2 (i, j, k) + Chxhip (i, j, k) × Hinc,x2 (i, j, k), (11.11)
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

The Scattered Field Updating Equations 335

where

2µx (i, j, k) − σxm (i, j, k)t


Chxh (i, j, k) = ,
2µx (i, j, k) + σxm (i, j, k)t
2t
Chxez (i, j, k) = −  ,
y 2µx (i, j, k) + σxm (i, j, k)t
2t
Chxey (i, j, k) =  ,
z 2µx (i, j, k) + σxm (i, j, k)t
2 (µ0 − µx (i, j, k)) − σxm (i, j, k)t
Chxhic (i, j, k) = ,
2µx (i, j, k) + σxm (i, j, k)t
2 (µ0 − µx (i, j, k)) + σxm (i, j, k)t
Chxhip (i, j, k) = − .
2µx (i, j, k) + σxm (i, j, k)t

n+ 1
The updating equation for Hscat,y2 (i, j, k) is

n+ 1 n− 1
Hscat,y2 (i, j, k) = Chyh (i, j, k) × Hscat,y2 (i, j, k)
 n 
+ Chyex (i, j, k) × Escat,x (i, j + 1, k) − Escat,x
n
(i, j, k)
 n 
+ Chyez (i, j, k) × Escat,z (i, j, k + 1) − Escat,z
n
(i, j, k)
n+ 1 n− 1
+ Chyhic (i, j, k) × Hinc,y2 (i, j, k) + Chyhip (i, j, k) × Hinc,y2 (i, j, k), (11.12)

where

2µ y (i, j, k) − σ ym (i, j, k)t


Chyh (i, j, k) = ,
2µ y (i, j, k) + σ ym (i, j, k)t
2t
Chyex (i, j, k) = −  ,
z 2µ y (i, j, k) + σ ym (i, j, k)t
2t
Chyez (i, j, k) =  ,
x 2µ y (i, j, k) + σ ym (i, j, k)t
 
2 µ0 − µ y (i, j, k) − σ ym (i, j, k)t
Chyhic (i, j, k) = ,
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

n+ 1
Finally, the updating equation for Hscat,z2 (i, j, k) is

n+ 1 n− 1
Hscat,z2 (i, j, k) = Chzh (i, j, k) × Hscat,z2 (i, j, k)
 n 
+ Chzey (i, j, k) × Escat,y (i, j + 1, k) − Escat,y
n
(i, j, k)
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

336 Scattered Field Formulation


 n 
+ Chzex (i, j, k) × Escat,x (i, j, k + 1) − Escat,x
n
(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

2µz (i, j, k) − σzm (i, j, k)t


Chzh (i, j, k) = ,
2µz (i, j, k) + σzm (i, j, k)t
2t
Chzey (i, j, k) = −  ,
x 2µz (i, j, k) + σzm (i, j, k)t
2t
Chzex (i, j, k) =  ,
y 2µz (i, j, k) + σzm (i, j, k)t
2 (µ0 − µz (i, j, k)) − σzm (i, j, k)t
Chzhic (i, j, k) = ,
2µz (i, j, k) + σzm (i, j, k)t
2 (µ0 − µz (i, j, k)) + σzm (i, j, k)t
Chzhip (i, j, k) = − .
2µz (i, j, k) + σzm (i, j, k)t

Equations (11.8)–(11.13) are the updating equations with corresponding definitions for asso-
ciated coefficients for the scattered field formulation. Comparing these equations with the set
of general updating equations (1.26)–(1.31) one can realize that the forms of the equations and
expressions of the coefficients are the same except that (11.8)–(11.13) include additional incident
field terms.

11.3 EXPRESSIONS FOR THE INCIDENT PLANE WAVES

The aforementioned scattered field updating equations are derived to calculate scattered electric
fields in a problem space in response to an incident field. The incident field in general can be
any far-zone source that can be expressed by analytical expressions. In this context incident plane
waves are the most commonly used type of incident field. This section discusses the incident plane
wave field expressions.
Figure 11.1 illustrates an incident plane wave traveling in the direction denoted by a unit
vector 
k. The incident electric field in general may have a θ component and a φ component when
expressed in a spherical coordinate system denoting its polarization. The incident electric field
can be expressed for a given point denoted by a position vector r as
 
  1
Einc = Eθ   f
θ + Eφ φ t− k · r , (11.14)
c

where f is a function determining the waveform of the incident electric field. This equation can
be rewritten by allowing a time delay t0 and spatial shift l 0 as
 
  1
Einc = Eθ   f
θ + Eφ φ (t − t0 ) − (k · r − l 0 ) . (11.15)
c
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Incident Plane Waves 337

z k̂

r Eφ
θinc Eθ

φinc y

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 field Eθ and Eφ can also
be expressed in Cartesian coordinates. Therefore, after using (11.16) in (11.15) and applying the
spherical to Cartesian coordinates transformation, one can obtain the components of the incident
electric field for any point (x, y, z) in space as
 
Einc,x = Eθ cos θinc cos φinc − Eφ sin φinc fw f , (11.17a)
 
Einc,y = Eθ cos θinc sin φinc + Eφ cos φinc fw f , (11.17b)
Einc,z = (−Eθ sin θinc ) fw f , (11.17c)

where fw f is given by
 
1
fw f = f (t − t0 ) − (x sin θinc cos φinc + y sin θinc sin φinc + z cos θinc − l 0 ) . (11.18)
c

Once the expressions for the incident electric field components are obtained, the expressions for
magnetic field components can be obtained using

inc = 1 
H k × Einc ,
η0

where η0 is the intrinsic impedance of free space, and the × denotes the cross-product operator.
Then the magnetic field components are

−1  
Hinc,x = Eφ cos θinc cos φinc + Eθ sin φinc fw f , (11.19a)
η0
−1  
Hinc,y = Eφ cos θinc sin φinc − Eθ cos φinc fw f , (11.19b)
η0
1  
Hinc,z = Eφ sin θinc fw f . (11.19c)
η0
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

338 Scattered Field Formulation

Leading edge of
the waveform

l0 = kˆ ⋅ r0 ⎛
f ⎜ ( t − t0 ) −
k̂ ⋅ r − l0 ⎞

⎝ c ⎠

FDTD
k̂ problem
space
z
⎛ k̂ ⋅ r ⎞
f ⎜ ( t − t0 ) − ⎟
⎝ c ⎠ r0
⎛ k̂ ⋅ r ⎞
f ⎜t − ⎟ y Waveform’s entry point
⎝ c ⎠ to the problem space
x

Figure 11.2 An incident plane wave delayed in time and shifted in space.

Equations (11.17)–(11.19) express an incident field with a polarization determined by (Eθ θ+
Eφ φ), propagating in a direction determined by the angles θinc and φinc and having a waveform
described by fw f . In general, the waveform can be a function that has the desired bandwidth
characteristics as discussed in Chapter 5. However, there are two additional parameters in (11.18)
we have not discussed yet: t0 and l 0 . These parameters are used to shift the given waveform in
time and space such that when the FDTD iterations start the incident field in the problem space
is zero, and as time proceeds the incident field propagates into the FDTD problem space.
Consider Fig. 11.2, which illustrates a plane wave with a Gaussian waveform propagating in a
direction k toward an FDTD problem space. This waveform is expressed by a function
 
1
f t − ( k · r) ,
c

where the maximum of the waveform appears on a plane including the origin and normal to k at
t = 0. Clearly the leading edge of this waveform is closer to the FDTD problem space. A time
delay t0 can be applied to this function such that
 
1
f (t − t0 ) − (
k · r) ,
c

and the leading edge of the waveform coincides with the origin. The value of the waveform
can be calculated as explained in Chapter 5. After applying the time delay, there is a distance
between the leading edge of the waveform and the problem space that needs to be accounted for;
otherwise, it may take considerable time after the simulation is started until the waveform enters
to the problem space. The distance between the waveform and the problem space can be found
as l 0 = 
k · r0 , where r0 is the position vector indicating the closest point of the problem space
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Incident Plane Waves 339

z
A plane wave traveling
away from origin


θinc
A plane wave traveling E
towards origin Eθ φ
y
Eφ ′
k̂′ φinc
Eθ ′
x

Figure 11.3 Two incident plane waves: one traveling toward the origin and the other traveling away from
the origin.

to the waveform. A problem space has eight corners, and one of these corners will be closest to
the waveform approaching from an arbitrary direction. If r0 indicates the corner points of the
problem space, then the minimum distance for l 0 can be calculated by l 0 = min[
k · r0 ]. After l 0 is
determined, the waveform equation can be modified as
 
1
f (t − t0 ) − (k · r − l 0 ) ,
c

which leads to (11.18).


In some scattering applications, a scatterer is placed at the origin and the scattered field due
to an incident plane wave is calculated. The direction of propagation of the plane wave must
be defined 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 field components
Eθ and Eφ are as shown in this figure. If it is desired to define the angles and field components
based on the wave traveling toward the origin such as θinc  
, φinc , Eθ , and Eφ , then the following
conversions need to be employed to use the aforementioned equations as is:

θinc = π − θinc , (11.20a)

φinc = π + φinc , (11.20b)
Eθ = Eθ , (11.20c)
Eφ = −Eφ . (11.20d)

One of the types of results that can be obtained from the scattered field due to an incident
plane wave is the radar cross-section (RCS) of a scatterer. The near-field to far-field NF-FF
transformation algorithm discussed in Chapter 9 is used for this purpose. In this case the scattered
near fields calculated in a problem space are captured on an imaginary surface enclosing the
scatterer to determine the equivalent fictitious surface currents. These currents are transformed
to the frequency domain while being captured. After the time-marching loop is completed, the
far-field terms Lθ , Lφ , Nθ , and Nφ are calculated following the procedure described in Chapter 9.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

340 Scattered Field Formulation

At this point the components of the bistatic RCS can be calculated using

k2
RCSθ = |Lφ + η0 Nθ |2 (11.21a)
8π η0 Pinc
k2
RCSφ = |Lθ − η0 Nφ |2 , (11.21b)
8π η0 Pinc

which is very similar to (9.39). The only difference is that Prad is replaced by Pinc , which is the
power carried by the incident plane wave. The Pinc can be calculated as

1
Pinc = |Einc (ω)|2 , (11.22)
2η0

where Einc (ω) is the discrete Fourier transform (DFT) of the incident electric field waveform at
the frequency for which the RCS calculation is sought.

11.4 MATLAB IMPLEMENTATION OF THE SCATTERED FIELD FORMULATION

The scattered field formulation is presented in the previous sections. In this section the imple-
mentation of the scattered field formulation is discussed.

11.4.1 Definition of the Incident Plane Wave


For a scattering problem it is necessary to define an incident field 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 field in this discussion. In the FDTD program an incident plane wave is defined
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 = [ ] ;
4 current sources = [ ] ;
diodes = [ ] ;
6 resistors = [];
inductors = [ ] ;
8 capacitors = [ ] ;
incident plane wave = [ ] ;
10

% d e f i n e s o u r c e waveform t y p e s and p a r a m e t e r s
12 waveforms . g a u s s i a n ( 1 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 0 ;
waveforms . g a u s s i a n ( 2 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 15;
14

% Define i n c i d e n t p l a n e wave , a n g l e s a r e i n d e g r e e s
16 incident plane wave . E theta = 1;
incident plane wave . E phi = 0;
18 incident plane wave . theta incident = 0;
incident plane wave . phi incident = 0;
20 incident plane wave . waveform type = ’ gaussian ’ ;
incident plane wave . waveform index = 1;
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

The Scattered Field Formulation 341

first a new empty structure, incident plane wave, is defined. Then the parameters of the incident
plane wave are defined as fields of this structure. Here E theta denotes the maximum amplitude
of the θ component, whereas E phi denotes the maximum amplitude of the φ component of the
electric field waveform. The fields theta incident and phi incident denote the angles indicating
the direction of propagation, θinc and φinc , of the incident plane wave. It should be noted here that
these parameters are based on the convention that the plane wave is propagating in a direction
away from the origin rather than toward the origin. If the parameters are readily available for
the convention wave traveling toward the origin, then the necessary transformation needs to be
performed based on the equations (11.20). Finally, the waveform of the incident plane wave need to
be defined. The definition of the waveform for the incident plane wave follows the same procedure
as the voltage source or the current source waveform. The types of waveforms are defined as a
structure waveforms, and the fields waveform type and waveform index are defined under
incident plane wave, which point to a specific waveform defined under waveforms.

11.4.2 Initialization of the Incident Fields


The next step is the initialization of the incident fields and the updating coefficients. The initializa-
tion of the incident fields 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
% i n i t i a l i z e i n c i d e n t p l a n e wave
206 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 ;
208 else
i n c i d e n t p l a n e w a v e . enabled = f a l s e ;
210 end

212 i f i n c i d e n t p l a n e w a v e . enabled
% c r e a t e i n c i d e n t f i e l d a r r a y s f o r c u r r e n t time s t e p
214 H x i c = z e r o s ( nxp1 , ny , nz ) ;
H y i c = z e r o s ( nx , nyp1 , nz ) ;
216 H z i c = z e r o s ( nx , ny , nzp1 ) ;
E x i c = z e r o s ( nx , nyp1 , nzp1 ) ;
218 E y i c = z e r o s ( nxp1 , ny , nzp1 ) ;
E z i c = z e r o s ( nxp1 , nyp1 , nz ) ;
220 % c r e a t e i n c i d e n t f i e l d a r r a y s f o r p r e v i o u s time s t e p
H x i p = z e r o s ( nxp1 , ny , nz ) ;
222 H y i p = z e r o s ( nx , nyp1 , nz ) ;
H z i p = z e r o s ( nx , ny , nzp1 ) ;
224 E x i p = z e r o s ( nx , nyp1 , nzp1 ) ;
E y i p = z e r o s ( nxp1 , ny , nzp1 ) ;
226 E z i p = z e r o s ( nxp1 , nyp1 , nz ) ;

228 % c a l c u l a t e t h e a m p l i t u d e f a c t o r s f o r f i e l d components
t h e t a i n c i d e n t = incident plane wave . t h e t a i n c i d e n t * pi /180;
230 p h i i n c i d e n t = incident plane wave . p h i i n c i d e n t * pi /180;
E theta = incident plane wave . E theta ;
232 E phi = incident plane wave . E phi ;
e t a 0 = s q r t ( mu 0 / e p s 0 ) ;
234 E x i 0 = E t h e t a * cos ( t h e t a i n c i d e n t ) * cos ( p h i i n c i d e n t ) . . .
− E phi * sin ( phi incident ) ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

342 Scattered Field Formulation

236 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 ) ;
238 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 ) . . .
240 * 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 ) . . .
242 * 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

% Create position 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


246 x p o s = z e r o s ( nxp1 , nyp1 , nzp1 ) ;
y p o s = z e r o s ( nxp1 , nyp1 , nzp1 ) ;
248 z p o s = z e r o s ( nxp1 , nyp1 , nzp1 ) ;
f o r i n d = 1 : nxp1
250 x p o s ( ind , : , : ) = ( i n d − 1 ) * dx + f d t d d o m a i n . m i n x ;
end
252 f o r i n d = 1 : nyp1
y p o s ( : , ind , : ) = ( i n d − 1 ) * dy + f d t d d o m a i n . m i n y ;
254 end
f o r i n d = 1 : nzp1
256 z pos ( : , : , ind ) = ( i n d − 1 ) * dz + f d t d d o m a i n . m i n z ;
end
258

% calculate s p a t i a l shift , l 0 , required f o r i n c i d e n t p l a n e wave


260 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 z ;
fdtd domain . min x fdtd domain . min y fdtd d o m a i n . max z ;
262 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 domain . min z ;
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 d o m a i n . max z ;
264 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 domain . min z ;
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 d o m a i n . max z ;
266 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 domain . min z ;
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 d o m a i n . max z ; ] ;
268

k vec x = sin ( theta incident ) * cos ( p h i i n c i d e n t ) ;


270 k vec y = sin ( theta incident )* sin ( phi incident ) ;
k vec z = cos ( t h e t a i n c i d e n t );
272

k dot r0 = k v e c x * r0 ( : , 1 ) ...
274 + k v e c y * r0 ( : , 2 ) . . .
+ k v e c z * r0 ( : , 3 ) ;
276

l 0 = min ( k d o t r 0 ) / c ;
278

% c a l c u l a t e k . r f o r e v e r y f i e l d component
280 k d o t r e x = ( ( x p o s ( 1 : nx , 1 : nyp1 , 1 : nzp1 )+ dx / 2 ) * k v e c x ...
+ y p o s ( 1 : nx , 1 : nyp1 , 1 : nzp1 ) * k v e c y . . .
282 + z p o s ( 1 : nx , 1 : nyp1 , 1 : nzp1 ) * k v e c z ) / c ;

284 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 . . .
286 + z p o s ( 1 : nxp1 , 1 : ny , 1 : nzp1 ) * k v e c z ) / c ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

The Scattered Field Formulation 343

288 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 . . .
290 + ( z p o s ( 1 : nxp1 , 1 : nyp1 , 1 : nz )+ dz / 2 ) * k v e c z ) / c ;

292 k d o t r h x = ( x p o s ( 1 : nxp1 , 1 : ny , 1 : nz ) * k v e c x . . .
+ ( y p o s ( 1 : nxp1 , 1 : ny , 1 : nz )+ dy / 2 ) * k v e c y . . .
294 + ( z p o s ( 1 : nxp1 , 1 : ny , 1 : nz )+ dz / 2 ) * k v e c z ) / c ;

296 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 . . .
298 + ( z p o s ( 1 : nx , 1 : nyp1 , 1 : nz )+ dz / 2 ) * k v e c z ) / c ;

300 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 . . .
302 + z p o s ( 1 : nx , 1 : ny , 1 : nzp1 ) * k v e c z ) / c ;

304 % embed spatial s h i f t in k . r


k dot r ex = k dot r ex − l 0 ;
306 k dot r ey = k dot r ey − l 0 ;
k dot r ez = k dot r ez − l 0 ;
308 k dot r hx = k dot r hx − l 0 ;
k dot r hy = k dot r hy − l 0 ;
310 k dot r hz = k dot r hz − l 0 ;

312 % s t o r e t h e waveform
w t s t r = incident plane wave . waveform type ;
314 w i s t r = num2str ( i n c i d e n t p l a n e w a v e . w a v e f o r m i n d e x ) ;
e v a l s t r = [ ’ a waveform = waveforms . ’ . . .
316 w t s t r ’ ( ’ w i s t r ’ ) . waveform ; ’ ] ;
eval ( e v a l s t r ) ;
318 i n c i d e n t p l a n e w a v e . waveform = a w a v e f o r m ;

320 clear x pos y pos z pos ;


end
 

In this code the first step is to determine whether an incident plane wave is defined. If an
incident plane wave is defined, then it indicates that the FDTD simulation is running a scattering
problem and, therefore, the algorithm of the scattered field formulation will be employed. Here
a logical parameter incident plane wave.enabled is assigned a value ’true’ or ’false’ indicating
the mode of the FDTD simulation.
The calculation of the scattered field components using the scattered field updating equation
is the same as the calculation of the total field components using the general updating equation,
except for the additional incident field terms. Therefore, the parameters corresponding to the
field arrays Ex, Ey, Ez, Hx, Hy, and Hz can be assumed as scattered fields if the mode of the
simulation is scattering. Then the field arrays corresponding to incident fields must be defined.
The new field arrays are thus defined as Exi, Eyi, Ezi, Hxi, Hyi, and Hzi and are initialized as
zeros. One should notice that the sizes of these three-dimensional arrays are the same as their
corresponding scattered field arrays.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

344 Scattered Field Formulation

In the next step the amplitudes of the electric and magnetic field waveforms are transformed
from the spherical coordinates to Cartesian coordinates based on equations (11.17) and (11.19),
yielding Ex0i, Ey0i, Ez0i, Hx0i, Hy0i, and Hz0i.
The incident field components are computed at different positions in a three-dimensional
space. The coordinates of these field components can be determined with respect to positions
of the nodes of the FDTD grid. Three three-dimensional arrays are constructed, each of which
stores the x, y, and z coordinates of the nodes.
As discussed in Section 11.3 the waveform of the incident field should be shifted in time and
space to ensure that the leading edge of the waveform enters into the problem space after the
simulation has started. These shifts are indicated as t0 and l 0 , respectively. The temporal shift t0 is
determined in the subroutine initialize waveforms, which has been called in initialize sources -
and lumped elements before. Thus, t0 for a specific waveform is readily available. The spatial
shift, however, needs to be calculated. Eight corners determine the boundaries of the problem
space, and an incident plane wave will enter to the problem space from one of these corners. The
coordinates of  these  corners are stored in an array denoted as r0. The value of l 0 is calculated
by l 0 = min  k · r0 , where 
k is the propagation vector indicating the direction of propagation.
The components of the vector  k are calculated based on (11.16) and are stored in the parameters
k vec x, k vec y, and k vec z. Then these parameters are used together with r0 to calculate l 0
and to store it in the parameter l 0.
Another term that determines the three-dimensional distribution of the waveform is  k · r as
shown in (11.18). Here the vector r is the position vector. In the three-dimensional case this dot
product would yield three-dimensional arrays. Since all field components are located at different
positions, this dot product would yield a different three-dimensional array for each component.
Therefore, the dot product is performed separately for each field and is stored in the arrays
k dot r ex, k dot r ey, k dot r ez, k dot r hx, k dot r hy, and k dot r hz. Then the spatial
shift l 0 appearing in (11.18) is embedded in these arrays.
Finally, the waveform of the incident plane wave is acquired from the structure waveforms and
is stored in the structure incident plane wave. This waveform is used only for plotting purposes
after the FDTD calculation is completed. The distribution of the waveform and incident plane
wave has to be recalculated at every time step and stored in the three-dimensional incident field
arrays for use in the scattered field updating equations.

11.4.3 Initialization of the Updating Coefficients


The scattered field formulation algorithm requires a new set of updating coefficients. As dis-
cussed in Section 11.2 the updating equations for the scattered field formulation are the same as
the general updating equations except that the scattered field updating equations have additional
terms. These terms consist of incident fields multiplied by incident field coefficients. The inci-
dent field coefficients 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 coefficient subroutines are called. Here a set of
new three-dimensional arrays is constructed representing the updating coefficients related to the
incident field 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
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

The Scattered Field Formulation 345

Listing 11.3 initialize incident field updating coefficients


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

3 i f i n c i d e n t p l a n e w a v e . e n a b l e d == f a l s e
return ;
5 end

7 % C o e f f i e c i e n t s updating Ex
C e x e i c = ( 2 * ( 1 − e p s r x ) * e p s 0 −d t * s i g m a e x ) ...
9 . / ( 2 * e p s r x * e p s 0+d t * s i g m a e x ) ;
C e x e i p = −(2 * (1 − e p s r x ) * e p s 0+d t * s i g m a e x ) ...
11 . / ( 2 * e p s r x * e p s 0+d t * s i g m a e x ) ;

13 % C o e f f i e c i e n t s updating Ey
C e y e i c = ( 2 * ( 1 − e p s r y ) * e p s 0 −d t * s i g m a e y ) ...
15 . / ( 2 * e p s r y * e p s 0+d t * s i g m a e y ) ;
C e y e i p = −(2 * (1 − e p s r y ) * e p s 0+d t * s i g m a e y ) ...
17 . / ( 2 * e p s r y * e p s 0+d t * s i g m a e y ) ;

19 % C o e f f i e c i e n t s updating Ez
C e z e i c = ( 2 * ( 1 − e p s r z ) * e p s 0 −d t * s i g m a e z ) ...
21 . / ( 2 * e p s r z * e p s 0+d t * s i g m a e z ) ;
C e z e i p = −(2 * (1 − e p s r z ) * e p s 0+d t * s i g m a e z ) ...
23 . / ( 2 * e p s r z * e p s 0+d t * s i g m a e z ) ;

25 % C o e f f i e c i e n t s u p d a t i n g Hx
C h x h i c = ( 2 * ( 1 − m u r x ) * mu 0−d t * s i g m a m x ) . / ( 2 * m u r x * mu 0+d t * s i g m a m x ) ;
27 C h x h i p = −(2 * (1 − m u r x ) * mu 0+d t * s i g m a m x ) . / ( 2 * m u r x * mu 0+d t * s i g m a m x ) ;

29 % C o e f f i e c i e n t s u p d a t i n g Hy
C h y h i c = ( 2 * ( 1 − m u r y ) * mu 0−d t * s i g m a m y ) . / ( 2 * m u r y * mu 0+d t * s i g m a m y ) ;
31 C h y h i p = −(2 * (1 − m u r y ) * mu 0+d t * s i g m a m y ) . / ( 2 * m u r y * mu 0+d t * s i g m a m y ) ;

33 % C o e f f i e c i e n t s u p d a t i n g Hz
C h z h i c =(2 * (1 − m u r z ) * mu 0−d t * s i g m a m z ) . / ( 2 * m u r z * mu 0+d t * s i g m a m z ) ;
35 C h z h i p = −(2 * (1 − m u r z ) * mu 0+d t * s i g m a m z ) . / ( 2 * m u r z * mu 0+d t * s i g m a m z ) ;
 

field components change. Therefore, the values of the incident field components need to be
recalculated at every time step. A new subroutine named update incident fields is implemented
for this purpose and is provided in Listing 11.4. This subroutine is called in run fdtd time -
marching loop, in the time-marching loop, before calling update magnetic fields and therefore
before updating the magnetic field components. Since the waveform needs to be recalculated
at every time step, this subroutine is composed of several sections, each of which pertains to a
specific type of waveform. For instance, this implementation supports the Gaussian, derivative of
Gaussian, and cosine-modulated Gaussian waveforms. Thus, at every iteration only the section
pertaining to the type of the waveform of the incident plane wave are executed. At every time step
all the six incident electric and magnetic field arrays are recalculated. One should notice that the
electric and magnetic field components are calculated at time instants a half time step off from
each other since the magnetic field components are evaluated at half-integer time steps while the
electric field components are evaluated at integer time steps.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

346 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
3 return ;
end
5

tm = c u r r e n t t i m e + d t / 2 ;
7 te = current time + dt ;

9 % update i n c i d e n t f i e l d s f o r p r e v i o u s time s t e p
Hxip = Hxic ; Hyip = Hyic ; Hzip = Hzic ;
11 Exip = Exic ; Eyip = Eyic ; Ezip = Ezic ;

13 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

% i f waveform i s G a u s s i a n w a v e f o r m s
17 i f strcmp ( i n c i d e n t p l a n e w a v e . waveform type , ’ g a u s s i a n ’ )
t a u = w a v e f o r m s . g a u s s i a n ( wi ) . t a u ;
19 t 0 = w a v e f o r m s . g a u s s i a n ( wi ) . t 0 ;
E x i c = E x i 0 * exp ( − ( ( t e − t 0 − k d o t r e x ) / t a u ) . ˆ 2 ) ;
21 E y i c = E y i 0 * exp ( − ( ( t e − t 0 − k d o t r e y ) / t a u ) . ˆ 2 ) ;
E z i c = E z i 0 * exp ( − ( ( t e − t 0 − k d o t r e z ) / t a u ) . ˆ 2 ) ;
23 H x i c = H x i 0 * exp ( − ( ( tm − t 0 − k d o t r h x ) / t a u ) . ˆ 2 ) ;
H y i c = H y i 0 * exp ( − ( ( tm − t 0 − k d o t r h y ) / t a u ) . ˆ 2 ) ;
25 H z i c = H z i 0 * exp ( − ( ( tm − t 0 − k d o t r h z ) / t a u ) . ˆ 2 ) ;
end
27

% i f waveform i s d e r i v a t i v e o f G a u s s i a n
29 i f strcmp ( i n c i d e n t p l a n e w a v e . waveform type , ’ d e r i v a t i v e g a u s s i a n ’)
t a u = w a v e f o r m s . d e r i v a t i v e g a u s s i a n ( wi ) . t a u ;
31 t 0 = w a v e f o r m s . d e r i v a t i v e g a u s s i a n ( wi ) . t 0 ;
E x i c = E x i 0 * (− s q r t ( 2 * exp ( 1 ) ) / t a u ) * ( t e − t 0 − k d o t r e x ) ...
33 . * exp ( − ( ( t e − t 0 − k d o t r e x ) / t a u ) . ˆ 2 ) ;
E y i c = E y i 0 * (− s q r t ( 2 * exp ( 1 ) ) / t a u ) * ( t e − t 0 − k d o t r e y ) ...
35 . * exp ( − ( ( t e − t 0 − k d o t r e y ) / t a u ) . ˆ 2 ) ;
E z i c = E z i 0 * (− s q r t ( 2 * exp ( 1 ) ) / t a u ) * ( t e − t 0 − k d o t r e z ) ...
37 . * exp ( − ( ( t e − t 0 − k d o t r e z ) / t a u ) . ˆ 2 ) ;
H x i c = H x i 0 * (− s q r t ( 2 * exp ( 1 ) ) / t a u ) * ( tm − t 0 − k d o t r h x ) ...
39 . * exp ( − ( ( tm − t 0 − k d o t r h x ) / t a u ) . ˆ 2 ) ;
H y i c = H y i 0 * (− s q r t ( 2 * exp ( 1 ) ) / t a u ) * ( tm − t 0 − k d o t r h y ) ...
41 . * exp ( − ( ( tm − t 0 − k d o t r h y ) / t a u ) . ˆ 2 ) ;
H z i c = H z i 0 * (− s q r t ( 2 * exp ( 1 ) ) / t a u ) * ( tm − t 0 − k d o t r h z ) ...
43 . * exp ( − ( ( tm − t 0 − k d o t r h z ) / t a u ) . ˆ 2 ) ;
end
45

% i f waveform i s c o s i n e modulated G a u s s i a n
47 i f strcmp ( i n c i d e n t p l a n e w a v e . waveform type , . . .
’ cosine modulated gaussian ’ )
49 f = w a v e f o r m s . c o s i n e m o d u l a t e d g a u s s i a n ( wi ) . m o d u l a t i o n f r e q u e n c y ;
t a u = w a v e f o r m s . c o s i n e m o d u l a t e d g a u s s i a n ( wi ) . t a u ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

The Scattered Field Formulation 347

51 t 0 = waveforms . c o s i n e m o d u l a t e d g a u s s i a n ( wi ) . t 0 ;
E x i c = E x i 0 * cos ( 2 * pi * f * ( te − t 0 − k dot r ex ) ) . . .
53 . * exp ( − ( ( t e − t 0 − k d o t r e x ) / tau ) . ˆ 2 ) ;
E y i c = E y i 0 * cos ( 2 * pi * f * ( te − t 0 − k dot r ey ) ) . . .
55 . * exp ( − ( ( t e − t 0 − k d o t r e y ) / tau ) . ˆ 2 ) ;
E z i c = E z i 0 * cos ( 2 * pi * f * ( te − t 0 − k dot r ez ) ) . . .
57 . * exp ( − ( ( t e − t 0 − k d o t r e z ) / tau ) . ˆ 2 ) ;
H x i c = H x i 0 * c o s ( 2 * p i * f * ( tm − t 0 − k dot r hx ) ) . . .
59 . * exp ( − ( ( tm − t 0 − k d o t r h x ) / tau ) . ˆ 2 ) ;
H y i c = H y i 0 * c o s ( 2 * p i * f * ( tm − t 0 − k dot r hy ) ) . . .
61 . * exp ( − ( ( tm − t 0 − k d o t r h y ) / tau ) . ˆ 2 ) ;
H z i c = H y i 0 * c o s ( 2 * p i * f * ( tm − t 0 − k dot r hz ) ) . . .
63 . * exp ( − ( ( tm − t 0 − k d o t r h z ) / tau ) . ˆ 2 ) ;
end
 

After update incident fields is called in run fdtd time marching loop, the subroutine update -
magnetic fields is called in which the magnetic field components are updated for the current
time step. The implementation of update magnetic fields is modified as shown in Listing 11.5
to accommodate the scattered field formulation. Here the general updating equation is kept as
is; however, an additional section is added that will be executed if the mode of the simulation is
scattering. In this additional section the incident field arrays are multiplied by the corresponding
coefficients and are added to the magnetic field components, which in this case are assumed to
be scattered fields. Similarly, the implementation of update electric fields is modified as shown
in Listing 11.6 to accommodate the scattered field formulation for updating the scattered electric
field components.

Listing 11.5 update magnetic fields


% update magnetic f i e l d s
2

current time = current time + dt / 2 ;


4

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


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

8 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

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


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

14 if incident p l a n e w a v e . enabled
Hx = Hx + Chxhic . * Hxic + Chxhip . * Hxip ;
16 Hy = Hy + Chyhic . * Hyic + Chyhip . * Hyip ;
Hz = Hz + Chzhic . * Hzic + Chzhip . * Hzip ;
18 end
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

348 Scattered Field Formulation

Listing 11.6 update electric fields



% 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
2 % on t h e b o u n d a r i e s

4 current time = current time + dt / 2 ;

6 E x ( 1 : nx , 2 : ny , 2 : nz ) = C e x e ( 1 : nx , 2 : ny , 2 : nz ) . * E x ( 1 : nx , 2 : ny , 2 : nz ) . . .
+ C e x h z ( 1 : nx , 2 : ny , 2 : nz ) . * . . .
8 ( Hz ( 1 : nx , 2 : ny , 2 : nz )−Hz ( 1 : nx , 1 : ny −1 ,2: nz ) ) . . .
+ C e x h y ( 1 : nx , 2 : ny , 2 : nz ) . * . . .
10 ( Hy ( 1 : nx , 2 : ny , 2 : nz )−Hy ( 1 : nx , 2 : ny , 1 : nz − 1 ) ) ;

12 E y ( 2 : nx , 1 : ny , 2 : nz )= C e y e ( 2 : nx , 1 : ny , 2 : nz ) . * E y ( 2 : nx , 1 : ny , 2 : nz ) . . .
+ C e y h x ( 2 : nx , 1 : ny , 2 : nz ) . * ...
14 ( Hx ( 2 : nx , 1 : ny , 2 : nz )−Hx ( 2 : nx , 1 : ny , 1 : nz − 1 ) ) . . .
+ C e y h z ( 2 : nx , 1 : ny , 2 : nz ) . * ...
16 ( Hz ( 2 : nx , 1 : ny , 2 : nz )−Hz ( 1 : nx −1 ,1: ny , 2 : nz ) ) ;

18 E z ( 2 : nx , 2 : ny , 1 : nz )= C e z e ( 2 : nx , 2 : ny , 1 : nz ) . * E z ( 2 : nx , 2 : ny , 1 : nz ) . . .
+ C e z h y ( 2 : nx , 2 : ny , 1 : nz ) . * ...
20 ( Hy ( 2 : nx , 2 : ny , 1 : nz )−Hy ( 1 : nx −1 ,2: ny , 1 : nz ) ) . . .
+ C e z h x ( 2 : nx , 2 : ny , 1 : nz ) . * . . .
22 ( Hx ( 2 : nx , 2 : ny , 1 : nz )−Hx ( 2 : nx , 1 : ny −1 ,1: nz ) ) ;

24 if incident p l a n e w a v e . enabled
Ex = Ex + Cexeic .* Exic + Cexeip .* Exip ;
26 Ey = Ey + Ceyeic .* Eyic + Ceyeip .* Eyip ;
Ez = Ez + Cezeic .* Ezic + Cezeip .* Ezip ;
28 end
 

11.4.5 Postprocessing and Simulation Results


The scattered electric and magnetic field components at desired locations can be captured as the
FDTD simulation is running by defining 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 NF–FF transformation. Only a slight modification of the
code is required at the last stage of the NF–FF transformation. However, before discussing this
modification, it should be noted that if the calculation of the RCS is desired, the frequencies for
which the RCS calculation is sought must be defined in the subroutine define output parameters
as the parameter farfield.frequencies(i). Furthermore, the parameter farfield.number of cells -
from outer boundary must be defined as well.
The calculation of RCS from the captured NF–FF fictitious currents and display of results are
performed in the subroutine calculate and display farfields. The initial lines of this subroutine are
modified 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 field patterns. Another modification 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 field power. Hence, the
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

The Scattered Field Formulation 349

Listing 11.7 calculate and display farfields


i f n u m b e r o f f a r f i e l d f r e q u e n c i e s == 0
8 return ;
end
10

calculate radiated power ;


12 calculate incident plane wave power ;

14 j = sqrt ( −1);
number of angles = 360;
16

% p a r a m e t e r s u s e d by p o l a r p l o t t i n g f u n c t i o n s
18 s t e p s i z e = 10; % i n c r e m e n t between t h e r i n g s i n t h e p o l a r g r i d
Nrings = 4; % number o f r i n g s i n t h e p o l a r g r i d
20 l i n e s t y l e 1 = ’ b− ’ ; % l i n e s t y l e f o r t h e t a component
l i n e s t y l e 2 = ’ r−− ’ ; % l i n e s t y l e f o r p h i component
22 s c a l e t y p e = ’ dB ’ ; % l i n e a r o r dB

24 i f i n c i d e n t p l a n e w a v e . e n a b l e d == f a l s e
p l o t t y p e = ’D ’ ;
26 else
p l o t t y p e = ’ RCS ’ ;
28 end
 

subroutine calculate incident plane wave power, which is shown in Listing 11.8, is implemented
to calculate the power of the incident plane wave at the desired frequency or frequencies based
on (11.22).
The actual calculation of RCS is performed in the subroutine calculate farfields per plane.
The last part of this subroutine is modified as shown in Listing 11.9. If the mode of the simulation
is scattering then RCS is calculated using (11.21); otherwise, the directivity is calculated.

Listing 11.8 calculate incident plane wave power


% C a l c u l a t e t o t a l r a d i a t e d power
2 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 ;
4 end
x = i n c i d e n t p l a n e w a v e . waveform ;
6 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 ) ;
8 incident plane wave . frequency domain value = X ;
incident plane wave . frequencies = frequency array ;
10 E t = incident plane wave . E theta ;
E p = incident plane wave . E phi ;
12 e t a 0 = s q r t ( mu 0 / e p s 0 ) ;
incident plane wave . incident power = . . .
14 ( 0 . 5 / e t a 0 ) * ( E t ˆ 2 + E p ˆ 2 ) * abs ( X ) ˆ 2 ;
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

350 Scattered Field Formulation

Listing 11.9 calculate farfields per plane


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
152 % 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 ) ) ) . . .
154 . * ( 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 ) ) ) . . .
156 . * ( abs ( L t h e t a −e t a 0 * Nphi ) . ˆ 2 ) ;
else
158 % 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 , : ) = . . .
160 ( 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 ) ;
162 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 ) ) ) . . .
164 . * ( 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 field algorithm and demonstrated its implementa-
tion 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 % 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
103 figure ;
x l a b e l ( ’ time ( ns ) ’ , ’ f o n t s i z e ’ , 1 2 ) ;
105 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);
107 g r i d on ; hold on ;
sampled value theta = incident plane wave . E theta * . . .
109 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 * . . .
111 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 ;
113 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 ) ;
115 l e g e n d ( ’ E {\ t h e t a , i n c } ’ , ’ E {\ phi , i n c } ’ ) ; drawnow ;
end
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation Examples 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 definition of the problem space is shown in
Listing 11.11. The incident plane wave source is defined as shown in Listing 11.12. The waveform
of the plane wave is Gaussian. The output of the FDTD simulation is defined as far field at 1 GHz,
which indicates that the RCS will be calculated. Furthermore, the x component of the scattered
electric field at the origin is defined as the output as shown in Listing 11.13.

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 = [ ] ;
4 spheres = [ ] ;
thin wires = [ ] ;
6

% define a sphere
8 spheres ( 1 ) . radius = 100 e −3;
spheres ( 1 ) . center x = 0;
10 spheres ( 1 ) . center y = 0;
spheres ( 1 ) . center z = 0;
12 spheres ( 1 ) . material type = 4;
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

352 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 = [ ] ;
4 current sources = [ ] ;
diodes = [ ] ;
6 resistors = [];
inductors = [ ] ;
8 capacitors = [ ] ;
incident plane wave = [ ] ;
10

% d e f i n e s o u r c e waveform t y p e s and p a r a m e t e r s
12 waveforms . g a u s s i a n ( 1 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 0 ;
waveforms . g a u s s i a n ( 2 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 15;
14

% Define i n c i d e n t p l a n e wave , a n g l e s a r e i n d e g r e e s
16 incident plane wave . E theta = 1;
incident plane wave . E phi = 0;
18 incident plane wave . theta incident = 0;
incident plane wave . phi incident = 0;
20 incident plane wave . waveform type = ’ gaussian ’ ;
incident plane wave . waveform index = 1;
 

Listing 11.13 define output parameters.m


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

sampled electric fields = [];


4 sampled magnetic fields = [ ] ;
sampled voltages = [ ] ;
6 sampled currents = [ ] ;
ports = [ ] ;
8 fa r fi e ld . frequencies = [ ] ;

10 % figure refresh rate


p l o t t i n g s t e p = 10;
12

% mode o f o p e r a t i o n
14 run simulation = true ;
show material mesh = true ;
16 show problem space = true ;

18 % f a r f i e l d c a l c u l a t i o n parameters
f a r f i e l d . f r e q u e n c i e s ( 1 ) = 1 . 0 e9 ;
20 f a r f i e l d . number of cells from outer boundary = 13;

22 % f r e q u e n c y domain p a r a m e t e r s
f r e q u e n c y d o m a i n . s t a r t = 20 e6 ;
24 f r e q u e n c y d o m a i n . end = 4 e9 ;
f r e q u e n c y d o m a i n . s t e p = 20 e6 ;
26
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation Examples 353

28 % d e f i n e sampled e l e c t r i c f i e l d s
% component : v e c t o r component í x í , í y í , í z í , o r m a g n i t u d e í m í
30 % d i s p l a y plot = true , in order to plot f i e l d during simulation
s a m p l e d e l e c t r i c f i e l d s ( 1 ) . x = 0;
32 s a m p l e d e l e c t r i c f i e l d s ( 1 ) . y = 0;
s a m p l e d e l e c t r i c f i e l d s ( 1 ) . z = 0;
34 s a m p l e d e l e c t r i c f i e l d s ( 1 ) . component = ’ x ’ ;
sampled electric fields (1). display plot = false ;
36

% define animation
38 % f i e l d t y p e s h a l l be ’ e ’ o r ’ h ’
% p l a n e c u t s h a l l be ’ xy ’ , yz , o r z x
40 % component s h a l l be ’ x ’ , ’ y ’ , ’ z ’ , o r ’m;
animation ( 1 ) . f i e l d t y p e = ’ e ’ ;
42 a n i m a t i o n ( 1 ) . component = ’m ’ ;
animation ( 1 ) . p l a n e c u t ( 1 ) . t y pe = ’ zx ’ ;
44 animation ( 1 ) . plane cut ( 1 ) . p o s i t i o n = 0;
animation ( 1 ) . enable = true ;
46 animation ( 1 ) . d i s p l a y g r i d = f a l s e ;
animation ( 1 ) . d i s p l a y o b j e c t s = true ;
 
The simulation is run for 2,000 time steps, and the sampled electric field at the origin and the
RCS plots are obtained. Figure 11.5 shows the sampled scattered electric field captured at the
origin and shows the waveform of the incident plane wave. Figures 11.6, 11.7, and 11.8 show
the RCS of the dielectric sphere in the xy, xz, and y z planes, respectively.

1.5
Eθ,inc
Eφ,inc
1 Ex,scat
(volt/meter)

0.5

−0.5

−1
0 2 4 6 8 10
time (ns)

Figure 11.5 Scattered electric field captured at the origin and the incident field waveform.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

354 Scattered Field Formulation

↑y
90−10
120 60
−20 θ = 90o
xy plane
150 −30 30

−40
↑φ
x
180 0 →

210 330

240 300
dB 270 RCSθ, f=1 GHz
RCS , f=1 GHz
φ

Figure 11.6 Bistatic RCS at 1 GHz in the x y plane.

↑z
θ 00 θ
← →
30 30
−10 φ = 0o
xz plane
60 −20 60

−30

x
90 90 →

120 120

150 150
dB 180 RCS , f=1 GHz
θ

RCSφ, f=1 GHz

Figure 11.7 Bistatic RCS at 1 GHz in the x z plane.


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation Examples 355

↑z
θ 0 0 θ
← →
30 30
−10 φ = 90o
yz plane
60 −20 60

−30

y
90 90 →

120 1 20

1 50 150
dB 180 RCS , f=1 GHz
θ

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 defined as an output. The scattered electric field is
thus captured on the xz plane displayed during the simulation. Figure 11.11 shows the snapshots
of the animation captured at time steps 120, 140, 160, and 180.

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 figure 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 definition 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 defined
as shown in Listing 11.15. The incident plane wave illuminating the cube is θ polarized and
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

356 Scattered Field Formulation

0
exact
FDTD
−5

−10
σθθ [dB]

−15

−20

−25

−30
0 20 40 60 80 100 120 140 160 180
o o
θ , [φ =0]

Figure 11.9 Calculated RCS θ at 1 GHz in the x z plane compared with the analytical solution.

0
exact
FDTD
−5

−10
σφθ [dB]

−15

−20

−25

−30
0 20 40 60 80 100 120 140 160 180
o o
θ , [φ =90]

Figure 11.10 Calculated RCS φ at 1 GHz in the yz plane compared with the analytical solution.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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-field output is defined at 1 GHz as shown in Listing 11.16. Finally, a
sampled electric field is defined at the origin to observe whether the fields in the problem space
are sufficiently decayed.
After the FDTD time-marching loop is completed, the far-field patterns are obtained as shown
in Figs. 11.13, 11.14, and 11.15; for the RCS at 1 GHz in the xy, xz, and y z planes, respectively.
The same problem is simulated at 1 GHz using the MoM solver. Figure 11.16 shows the compared
RCSθ in the xz plane, whereas Figure 11.17 shows the compared RCSφ . The results show a good
agreement.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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 infinite 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 reflection and transmission coefficients
of the slab.

Listing 11.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 ’ ) ;

3 bricks = [ ] ;
spheres = [ ] ;
5 thin wires = [ ] ;

7 % define d i e l e c t r i c
b r i c k s ( 1 ) . m i n x = −80e −3;
9 b r i c k s ( 1 ) . mi n y = −80e −3;
b r i c k s ( 1 ) . m i n z = −80e −3;
11 b r i c k s ( 1 ) . max x = 80 e −3;
b r i c k s ( 1 ) . max y = 80 e −3;
13 b r i c k s ( 1 ) . max z = 80 e −3;
bricks ( 1 ) . material type = 4;
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation Examples 359

↑y
900
120 60
−10 θ = 90o
xy plane
150 −20 30

−30
↑φ
x
180 0 →

210 330

240 300
dB 270 RCSθ, f=1 GHz
RCSφ, f=1 GHz

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 = [ ] ;
4 current sources = [ ] ;
diodes = [ ] ;
6 resistors = [];
inductors = [ ] ;
8 capacitors = [ ] ;
incident plane wave = [ ] ;
10

% d e f i n e s o u r c e waveform t y p e s and p a r a m e t e r s
12 waveforms . g a u s s i a n ( 1 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 0 ;
waveforms . g a u s s i a n ( 2 ) . n u m b e r o f c e l l s p e r w a v e l e n g t h = 15;
14

% Define i n c i d e n t p l a n e wave , a n g l e s a r e i n d e g r e e s
16 incident plane wave . E theta = 1;
incident plane wave . E phi = 0;
18 incident plane wave . t h e t a i n c i d e n t = 45;
incident plane wave . phi incident = 30;
20 incident plane wave . waveform type = ’ gaussian ’ ;
incident plane wave . waveform index = 1;
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

360 Scattered Field Formulation

Listing 11.16 define output parameters.m


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

sampled electric fields = [];


4 sampled magnetic fields = [ ] ;
sampled voltages = [ ] ;
6 sampled currents = [ ] ;
ports = [ ] ;
8 fa r fi e ld . frequencies = [ ] ;

10 % figure refresh rate


p l o t t i n g s t e p = 10;
12

% mode o f o p e r a t i o n
14 run simulation = true ;
show material mesh = true ;
16 show problem space = true ;

18 % f a r f i e l d c a l c u l a t i o n parameters
f a r f i e l d . f r e q u e n c i e s ( 1 ) = 1 . 0 e9 ;
20 f a r f i e l d . number of cells from outer boundary = 13;

22 % f r e q u e n c y domain p a r a m e t e r s
f r e q u e n c y d o m a i n . s t a r t = 20 e6 ;
24 f r e q u e n c y d o m a i n . end = 4 e9 ;
f r e q u e n c y d o m a i n . s t e p = 20 e6 ;
26

28 % d e f i n e sampled e l e c t r i c f i e l d s
% component : v e c t o r component í x í , í y í , í z í , o r m a g n i t u d e í m í
30 % d i s p l a y plot = true , in order to plot f i e l d during simulation
s a m p l e d e l e c t r i c f i e l d s ( 1 ) . x = 0;
32 s a m p l e d e l e c t r i c f i e l d s ( 1 ) . y = 0;
s a m p l e d e l e c t r i c f i e l d s ( 1 ) . z = 0;
34 s a m p l e d e l e c t r i c f i e l d s ( 1 ) . component = ’ x ’ ;
sampled electric fields (1). display plot = false ;
 

The geometry of the problem in consideration is shown in Fig. 11.18. A dielectric slab, having
dielectric constant 4 and thickness 20 cm, penetrates into the CPML boundaries in xn, xp, yn, and
y p directions. The problem space is composed of cells having 0.5 cm size on a side. The source of
the simulation is an x-polarized incident field traveling in the positive z direction. Two sampled
electric fields are defined to capture the x component of the electric field at two points, each 5 cm
away from the slab—one below the slab and the other above the slab as illustrated in Fig. 11.18.
The definition of the problem space boundary conditions, incident field, the slab, and the sampled
electric fields are shown in Listings 11.17, 11.18, 11.19, and 11.20, respectively. Notice that the
CPML parameters has been modified for better performance.
In the previous sections scattered field formulation has been demonstrated for calculating the
scattered field when an incident field is used to excite the problem space. The sampled electric field
therefore is the one being captured while the simulation is running. The reflected field from the
slab is the scattered field, and the ratio of the reflected field to incident field is required to calculate
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation Examples 361

↑z
θ 0 0 θ
← →
30 30
−10 φ = 0o
xz plane
60 −20 60

−30

x
90 90 →

120 120

150 150
dB 180 RCSθ, f=1 GHz
RCSφ, f=1 GHz

Figure 11.14 Bistatic RCS at 1 GHz in the x z plane.


↑z
θ 00 θ
← →
30 30
o
−10 φ = 90
yz plane
60 −20 60

−30

y
90 90 →

120 120

150 150
dB 180 RCSθ, f=1 GHz
RCS , f=1 GHz
φ

Figure 11.15 Bistatic RCS at 1 GHz in the yz plane.


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

362 Scattered Field Formulation

0
MoM
−2 FDTD
−4

−6

−8
RCS [dB]

−10
θ

−12

−14

−16

−18

−20
0 20 40 60 80 100 120 140 160 180
o o
θ , [φ =0]

Figure 11.16 Calculated RCS θ at 1 GHz in the x z plane compared with the MoM solution.

0
MoM
FDTD
−5

−10
RCS [dB]

−15
φ

−20

−25

−30
0 20 40 60 80 100 120 140 160 180
θo , [φo=90]

Figure 11.17 Calculated RCS φ at 1 GHz in the x z plane compared with the MoM solution.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation Examples 363

Sample electric
field point 2

dielectric
slab

Sample electric
z field point 1
y
outer PEC boundaries
x
CPML inner boundaries
Einc

Figure 11.18 An FDTD problem space including a dielectric slab.

the reflection coefficient using

| Escat |
|| = , (11.23)
| Einc |

where  is the reflection coefficient. Here the scattered field is the one sampled at a point below
the slab, and the incident field shall be sampled at the same point as well. Therefore, the section
of code shown in Listing 11.21 is added to the subroutine capture sampled electric fields to
sample the incident electric field as the time-marching loop proceeds.
The ratio of the transmitted field to incident field is required to calculate the transmission
coefficient, where the transmitted field is the total field that is the sum of the incident and scattered
fields. Then the transmission coefficient can be calculated using

| Etot | | Escat + Einc |


|T| = = , (11.24)
| Einc | | Einc |

where T is the transmission coefficient. Here the scattered field is the one sampled at a point
above the slab, and the incident field is sampled at the same point as well.

Listing 11.17 define problem space parameters.m


18 % ==<b o u n d a r y c o n d i t i o n s >========
% Here we d e f i n e t h e b o u n d a r y c o n d i t i o n s p a r a m e t e r s
20 % ’ pec ’ : p e r f e c t e l e c t r i c c o n d u c t o r
% ’ cpml ’ : c o n l v o l u t i o n a l PML
22 % i f c p m l n u m b e r o f c e l l s i s l e s s than zero
% CPML e x t e n d s i n s i d e o f t h e domain r a t h e r t h a n o u t w a r d s
24

b o u n d a r y . t y p e x n = ’ cpml ’ ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

364 Scattered Field Formulation

26 boundary . a i r b u f f e r n u m b e r o f c e l l s x n = 0 ;
b o u n d a r y . c p m l n u m b e r o f c e l l s x n = −8;
28

b o u n d a r y . t y p e x p = ’ cpml ’ ;
30 boundary . a i r b u f f e r n u m b e r o f c e l l s x p = 0 ;
b o u n d a r y . c p m l n u m b e r o f c e l l s x p = −8;
32

b o u n d a r y . t y p e y n = ’ cpml ’ ;
34 boundary . a i r b u f f e r n u m b e r o f c e l l s y n = 0 ;
b o u n d a r y . c p m l n u m b e r o f c e l l s y n = −8;
36

b o u n d a r y . t y p e y p = ’ cpml ’ ;
38 boundary . a i r b u f f e r n u m b e r o f c e l l s y p = 0 ;
b o u n d a r y . c p m l n u m b e r o f c e l l s y p = −8;
40

b o u n d a r y . t y p e z n = ’ cpml ’ ;
42 boundary . a i r b u f f e r n u m b e r o f c e l l s z n = 10;
boundary . c p m l n u m b e r o f c e l l s z n = 8 ;
44

b o u n d a r y . t y p e z p = ’ cpml ’ ;
46 boundary . a i r b u f f e r n u m b e r o f c e l l s z p = 10;
boundary . c p m l n u m b e r o f c e l l s z p = 8 ;
48

boundary . cpml order = 4;


50 boundary . c p m l sigma factor = 1;
boundary . cpml kappa max = 1 ;
52 boundary . cpml alpha min = 0;
boundary . cpml alpha max = 0;
 

Listing 11.18 define geometry.m


% define d i e l e c t r i c
8 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;
10 b r i c k s ( 1 ) . min z = 0 ;
b r i c k s ( 1 ) . max x = 0 . 0 5 ;
12 b r i c k s ( 1 ) . max y = 0 . 0 5 ;
b r i c k s ( 1 ) . max z = 0 . 2 ;
14 bricks ( 1 ) . material type = 4;
 

Listing 11.19 define sources and lumped elements.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
12 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;

14 % Define i n c i d e n t p l a n e wave , a n g l e s a r e i n d e g r e e s
incident plane wave . E theta = 1;
16 incident plane wave . E phi = 0;
incident plane wave . theta incident = 0;
18 incident plane wave . phi incident = 0;
incident plane wave . waveform type = ’ d e r i v a t i v e g a u s s i a n ’ ;
20 incident plane wave . waveform index = 1;
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Simulation Examples 365

Listing 11.20 define output parameters.m


% f r e q u e n c y domain p a r a m e t e r s
19 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 ;
21 f r e q u e n c y d o m a i n . s t e p = 1 e6 ;

23 % d e f i n e sampled e l e c t r i c f i e l d s
% component : v e c t o r component í x í , í y í , í z í , o r m a g n i t u d e í m í
25 % d i s p l a y plot = true , in order to plot f i e l d during simulation
s a m p l e d e l e c t r i c f i e l d s ( 1 ) . x = 0;
27 s a m p l e d e l e c t r i c f i e l d s ( 1 ) . y = 0;
s a m p l e d e l e c t r i c f i e l d s ( 1 ) . z = −0.025;
29 s a m p l e d e l e c t r i c f i e l d s ( 1 ) . component = ’ x ’ ;
sampled electric fields (1). display plot = false ;
31

sampled electric fields (2). x = 0;


33 sampled electric fields (2). y = 0;
sampled electric fields (2). z = 0.225;
35 sampled electric fields (2). component = ’ x ’ ;
sampled electric fields (2). display plot = false ;
 
The simulation for this problem is executed, the incident and scattered fields are captured at
two points above and below the slab and transformed to frequency domain, and the reflection and
transmission coefficients 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
% Capturing the i n c i d e n t e l e c t r i c f i e l d s
25 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
27 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 ;
29 ks = s a m p l e d e l e c t r i c f i e l d s ( ind ) . ks ;

31 sw i t ch ( s a m p l e d e l e c t r i c f i e l d s ( i n d ) . component )
case ’ x ’
33 s a m p l e d v a l u e = 0 . 5 * sum ( E x i c ( i s −1: i s , j s , k s ) ) ;
case ’ y ’
35 s a m p l e d v a l u e = 0 . 5 * sum ( E y i c ( i s , j s −1: j s , k s ) ) ;
case ’ z ’
37 s a m p l e d v a l u e = 0 . 5 * sum ( E z i c ( i s , j s , ks −1: k s ) ) ;
c a s e ’m ’
39 s v x = 0 . 5 * sum ( E x i c ( i s −1: i s , j s , k s ) ) ;
s v y = 0 . 5 * sum ( E y i c ( i s , j s −1: j s , k s ) ) ;
41 s v z = 0 . 5 * sum ( E z i c ( i s , j s , ks −1: k s ) ) ;
sampled value = sqrt ( svx ˆ2 + svy ˆ2 + svz ˆ 2 ) ;
43 end
s a m p l e d e l e c t r i c f i e l d s ( ind ) . i n c i d e n t f i e l d v a l u e ( time step ) . . .
45 = sampled value ;
end
47 end
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

366 Scattered Field Formulation

0.8

0.6

0.4
|Γ| FDTD
|T| FDTD
0.2
|Γ| exact
|T| exact
0
0 0.2 0.4 0.6 0.8 1
frequency (GHz)

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 field traveling in the positive z direction. In the
given example the direction of incidence is defined as θ = 0◦ and φ = 0◦ . Change the
incident angle such that θ = 45◦ and φ = 0◦ , run the simulation, and obtain the RCS at 1
GHz. Examine the RCS plots, and verify that the RCS in the xz plane is the same as the
one shown in Fig. 11.7, except that it is rotated by 45◦ about the y axis.
11.2 Consider the scattering problem constructed for Exercise 11.1, where the RCS of a di-
electric sphere is calculated due to an incident field. The RCS calculations are based on
the scattered fields; the fictitious electric and magnetic current densities used for NF–FF
transformation are calculated using the scattered field electric and magnetic fields. The
total field in the problem space is the sum of the incident field and the scattered field.
Modify the program such that the RCS calculations are performed based on the total fields
rather than on the scattered fields. It is necessary to modify the code of the subroutine
calculate JandM. Run the simulation and obtain the RCS of the sphere. Verify that the
RCS data are the same as the ones obtained from Exercise 11.1. Notice that the incident
field does not contribute to far-field scattering at all.
11.3 Consider the dielectric slab problem demonstrated in Section 11.5.3. You can perform the
reflection and transmission coefficient calculation for stacked slabs composed of multiple
layers with different dielectric constants. For instance, create two slabs in the problem
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Exercises 367

space, each 10 cm thick. Then set the dielectric constant of the bottom slab as 4 and the
dielectric constant of the top slab as 2. Run the simulation, and then calculate the reflection
and transmission coefficients. Compare your result with the exact solution of the same
problem. For the exact solution you can refer to [43]. As an alternative, you can construct
a one-dimensional FDTD code similar to the one presented in Chapter 1 based on the
scattered field formulation to solve the same problem.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

12
Graphics Processing Unit
Acceleration of Finite-Difference
Time-Domain

Since the dawn of the computing age, research has relied on the power of the central processing
unit (CPU) to perform the variety of computational tasks needed. Over the years great progress has
been made in harnessing the power of the CPU by introducing faster clock speeds, larger caches,
faster memory, multiple processors, and even multiple cores in a single chip. This, however, has
also been accompanied by users ever expanding needs: from browsing the Internet to watching
videos and playing games. Due to these needs of the general computer user, the instruction set
of the average commercial processor has expanded well past 300 separate instructions in addition
to the core instructions of the processor. The CPU has been forced to be a jack-of-all-trades
for computing tasks, allowing it to do a great number of tasks but not specializing in any
particular area.
Conversely, the graphics processing unit (GPU) is designed to be very narrow in nature in
that it only needs to perform relatively few operations. The video card has been designed with
only one purpose: to process instructions and data necessary to provide graphics to the user.
Over the past few years, advancements in the design of GPUs has been occurring at a much
greater pace than with CPUs due to the narrow nature in which it was intended to be used. The
current generational rate for graphics processors has been on the order of 12 months, whereas
with CPUs it has been 18 months. This has led to the development of very powerful processing
units for computer graphics. As of the time of writing, current-generation GPUs are running at
approximately 600 MHz with a 384-bit data bus and memory bandwidth approaching 86 GB/sec.
While GPU clock speed seems slow compared with modern dual-core Pentium 4 CPUs, GPUs
are very specialized processors that incorporate many simultaneous instruction pipelines coupled
with a memory bandwidth an order of magnitude faster than modern system memory, as seen in
Table 12.1. In fact, the number of transistors in the latest GPUs almost match the number used in
a quad-core CPU. This leads to a GPUs ability to perform the specialized instructions for which
it was designed an order of magnitude or faster than just using a CPU, as seen in Fig. 12.1. While
the majority of silicon in CPUs is dedicated to performing noncomputational tasks like branch
prediction, out-of-order-execution, and cache operations, the majority of transistors on the GPU
is dedicated to its computational tasks. It must be noted that the GPU was designed specifically for
rendering graphics, not for doing computational electromagnetics. Luckily, the different processes
used in rendering graphics are analogous to many generic vector math operations. Here we look

369
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

370 Graphics Processing Unit Acceleration of Finite-Difference Time-Domain

Table 12.1 CPU versus GPU feature comparison.

Feature CPU GPU

Clock Speed Quad 3.4 GHz 600 MHz


Main Memory 4 GB 768 MB
Memory Bandwidth 41 GB/s 86 GB/s
Memory Width 64 Bit 384 Bit
Cache Type FIFO (Non-Streaming) 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 finite-difference time-domain (FDTD) have
been around for many years; however, the recent advances in computer technology are what
have made this method widely used. As computers become more powerful and systems with
larger memory are introduced, applications for FDTD grow as well. FDTD is increasingly used
to simulate larger and larger problems, which require more memory and faster processing to
complete the simulation in reasonable amounts of time. Even with current-generation computers,
the FDTD method is still limited in speed for practical simulations to be performed. Most
of the research on the FDTD method has been regarding introducing new formulations for

600

CPU Theoretical Max Performance


500 GPU Theoretical Max Performance

400
GFlops

300

200

100

0
2003 2004 2005 2006 2007
Year

Figure 12.1 Theoretical maximum processing power of CPUs and GPUs.


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Graphics Processors and General Math 371

solving problems and more efficient absorbing boundary conditions (ABCs). In the past few years
researchers have begun to explore different ways to implement FDTD solvers in alternative
methods to gain increases in speed. Work has been done recently in hardware-based solvers using
programmable gate arrays to essentially create chips specifically designed to solve FDTD. This
method, however, can be quite complex in its creation. As another alternative, graphics processors
have been shown to offer orders-of-magnitude speed increases in simple vector operations. In
the application of GPUs to solving FDTD operations, much detailed programming knowledge
has been required previously to implement the operations in the graphics card [44,45,46]. To
program a GPU to perform mathematical operations, the shader units inside each GPU must be
programmed. Sample FDTD applications on GPUs have required the programmer to understand
vast details about hardware functions in the graphics card as well as to learn custom register-level
programming languages for programming the shader units in these cards.
Even in the general use of graphics cards for scientific applications, these barriers have prevented
a wide adoption of these techniques since it requires a steep learning curve. Although most
programmers and engineers are adept at high-level programming languages such as MATLAB, C,
and FORTRAN, learning the intricacies of specialized low-level hardware languages can be quite
a daunting challenge for them. Currently several languages exist to allow GPU programming:
CUDA from nVidia, CTM from ATI, and an independent language called Brook [47]. Each
language offers its own advantages and disadvantages, mainly in its implementation. CUDA and
CTM are both highly tied into the hardware from their respective vendors, so a program written in
CUDA could only be run on certain nVidia boards, and the same goes for CTM. However, Brook
is not tied to any particular vendor and can operate on any compatible graphics card. Brook was
introduced for general programming environments as a subset of the C programming language.
This subset negates the need for detailed low-level programming knowledge by introducing
a few, relatively simple commands in the C language. By using these new commands in the
general high-level languages, Brook can then automatically generate the low-level code for the
programmer without any knowledge of the hardware systems of the target video card while
maintaining over 90% of the speed of the hand-coded low-level code. Therefore, instead of
having to manually program the shader units of the video cards, programmers can simply create a
standard C program with the added commands and have the compiler generate the necessary code
for them.

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 significant speed-up factor.
In the realm of graphics processing, two different types of data are operated upon: geometry
and texture maps. Geometry data usually relate the three-dimensional shapes (vertices) of various
objects to the GPU. Texture maps, on the other hand, are two-dimensional matrices that relate
surface characteristics of the object to the GPU (e.g., color, reflectivity, roughness). Geometry
objects may be composed of several texture maps combined (e.g., the ball may be red, highly
reflective, bumpy). To apply various texture maps to the geometries in many different ways, the
GPU must be able to perform a variety of arithmetic functions on the texture maps. For example,
it may need to add, subtract, multiply, or divide across the texture maps, which is performed
simply by using vector math on these textures. Because the graphics cards are designed to display
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

372 Graphics Processing Unit Acceleration of Finite-Difference Time-Domain

Streaming Non-streaming

Sequential Random Access


Figure 12.2 Streaming versus non-streaming operations.

high-quality graphics, the processing accompanying this must be able to provide high computa-
tional rates among many different data sets. This leads to a high order of parallelism inside the
GPU to process all the different objects that might be used, for example, in a game.
This math among texture maps occurs mainly in a section of the GPU called the fragment
processor, or pixel shader. In modern cards there are 4 to 64 of these fragment processors in par-
allel, depending on the video card type. Each one of these fragment processors currently has 4
or 5 subprocessors and is fully programmable and has separate and dedicated connections into
the main GPU cache. The purpose of the fragment processor in our case is to apply the math-
ematics across the texture maps to create a generalized vector processor. In the GPU many
fragment processors are running in parallel; each fragment processor usually runs the exact same
program as the others, with each operating on different points. Since there are many fragment
processors it is important for the cache to operate as efficiently as possible; otherwise, a fetch
stall will occur. A fetch stall happens when the cache does not contain the data necessary for
the operation and the fragment processor then stalls until the cache has been updated with the
necessary information. Mathematical operations with sequential elements (e.g., simple vector
addition) perform the fastest, as the methodology to retrieve the sequential elements of the pro-
gram is fairly straightforward. This is the basis of streaming processes that GPUs use. The GPU
is designed such that data are streamed into the separate processors where the operations are
performed and streamed back out to the memory. Operations such as vector or matrix multi-
plication suffer a larger performance penalty as the necessary matrix elements for the operation
are much more random in nature. This randomness causes the cache to replenish at a much
slower rate and therefore provides a greater chance of program stalls; this difference is shown
in Fig. 12.2.
For the majority of texture processes, the math involves only operations across the same
element of the various matrices. In this light, the shaders (the parts of the GPU that perform
vector operations on texture maps) operate on data that are streamed into them. In other words,
since the elements in the texture maps are only used once and in the same order across all maps,
the GPU can stream the entire matrix from memory instead of having to randomly access the
individual elements. When data are accessed in this sequential manner, as opposed to randomly
accessing elements, data can be processed at a maximal rate. As the number of random accesses
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Introduction to Brook 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 fit entirely inside the cache.
Texture maps inside the GPU are natively two-dimensional structures, which follows logically
since monitors are only capable of displaying two-dimensional images. While different video cards
may have varied limits on the size of the texture maps, currently the limits for the latest cards are on
the order of 8192×8192 (about 67 million elements). Because the matrices are two-dimensional,
problems containing three or more dimensions require a translation procedure to be performed
for these matrices to be stored inside the video card memory.
Before any discussion of FDTD programming implementations on GPUs, several terms need
to be introduced. These terms deal with the programming of general applications inside a video
card and should be understood before attempting any program.
1. Streams: Streams are how the matrices are fed into the GPU for processing. By default a
stream is simply sequential elements of a matrix or array that are “fed” into the processor.
If in processing, elements of a matrix are used more than once or in a random order, this is
reflected in the stream being of longer length or taking longer to stream.
2. iters: iters are the boundaries of the streams that are operated upon. For example, in a certain
application we might wish to perform an operation only on interior elements of the matrix,
so the iter would be defined as the interior limits of that stream (e.g., if the stream went
from (0)→(X) the interior iter would be (1)→(X-1).
3. Kernels: Kernels are the custom functions implemented inside the GPU that perform oper-
ations on the streams. These are usually cross-compiled into a shader language (depending
on the video card) to implement the function in the most efficient possible way.

It should be noted that the fragment processors programmed with the kernel are only capable of
straight mathematical operations. Logical- and program-flow-related operators (e.g., if/then/else,
bitwise operators) cannot be implemented inside a kernel.
To maximize efficiency of programs being run on the GPU it is necessary to understand how
these fragment processors were designed to operate. As was stated, each fragment processor has
four or five subproccesing units in them. The current NVidia chips have four identical full math
subprocessors per group, and the ATI chips have four subprocessors that can do simple math and
one subprocessor that can do advanced math per group. The reason for this grouping goes back
to the primary use of the GPU: to display images on the screen. When doing the calculations
for displaying images, the textures contain four pieces of data relating to how it will be applied.
Textures contain red, blue, green, and alpha (or transparency) information. In this model, having
the subprocessor grouped in four (or five) makes sense since each texture has four separate
parts. Care needs to be taken when formulating problems to achieve maximum utilization of the
processing power. For example, if two arrays are simply added to each other, only one subprocessor
per group is used as each data point only has one value. Conversly, if we consider doing equations
of electromagnetic fields we can utilize the nature of the field components (E and H having three
components x, y, and z) to better utilize more of the processing power of the GPU.

12.2 INTRODUCTION TO BROOK


The sample codes introduced in this chapter are implemented using the Brook program-
ming system for GPUs. Brook has been introduced as an extension to the many high-level
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

374 Graphics Processing Unit Acceleration of Finite-Difference Time-Domain

Table 12.2 Brook program flow.

Step Operation Performed

1 Constants are defined.


2 Arrays are created and initialized.
3 Arrays are passed to GPU streams.
4 Streams are processed through kernels.
5 Streams are passed back to arrays.
6 Data are passed to the output file.

languages such as C to facilitate the implementation of programs in the video card. Brook
is a free and open source system developed by Stanford University Graphics Lab (http://
graphics.stanford.edu/projects/brookgpu/), and current versions may be found on the open
source repository Sourceforge.net under the title Brook (http://sourceforge.net/-projects/
brook/). As Brook is not tied to any particular vendor, programs developed on it may be used on
many common graphics cards that are OpenGL and DirectX compliant. Using Brook the general
program flow for a GPU implementation varies only slightly from a standard C program as can
be seen in Table 12.2.
The Brook package includes installation instructions and details on where to locate the necessary
dependencies required to compile GPU programs necessary on PC-compatible systems. Brook
does require a few third-party tools to ensure interoperability among various graphics cards,
systems, and DirectX calls. While it is possible to integrate Brook into programming systems
such as Microsoft Visual Studio, the default installation and compilation of the system uses the
PC version of the GNU programming tools Cygwin (http://www.cygwin.com/). Cygwin acts just
as a UNIX shell would and provides the necessary programming tools to compile Brook and its
programs. The installation instructions in the Brook package also details what items in Cygwin are
needed beyond the default installation. Other items that are needed to include shader compilers
from nvidia, the free Microsoft C++ compiler (if Visual Studio is not installed), and the Microsoft
DirectX SDK. The details of each of these items are in the Brook documentation. The Brook
package also includes a wide variety of sample programs that can be examined to see how various
problems from fast Fourier transforms to simple matrix solvers can be implemented on the GPU.
Installation instructions and the Brook source code can be downloaded from their repository at
http://www.sourceforge.net/projects/brook, where all Brook files and additional examples can also
be found.
Compiling programs under Brook is very simple once it has been installed. Cygwin is a com-
mand line shell similar to what is found on most UNIX systems. Setting up new programs to
compile is fairly simple if the Makefile in each of the sample directories is examined. The Makefile
tells the Cygwin shell in what directories to look for source code and what the names of the source
code files are. A replacement folder for the “prog” directory in the Brook folder is included with
the sample codes to allow easier compilation. Once this “prog” folder has been replaced, all that
is necessary is to use the “make” command in the Brook directory to compile the provided sample
two-dimensional program. Brook compiles the program and places the executable in the “bin”
directory. Lastly, Brook programs require an environment variable to use DirectX, OpenGL,
or a GPU emulation to run the program. To use DirectX set the environment variable named
BRT RUNTIME to d x9 and for OpenGL use ogl.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Sample Two-Dimensional FDTD Implementation Using Brook 375

Listing 12.1 Example Brook code


1 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 <>)
3 {
c=a [ i t ]+ b [ i t ] ;
5 }

7 f l o a t a <100>;
f l o a t b<100>;
9 f l o a t c <100>;
i t e r f l o a t i t <1,98>
11 test ( a ,b , it , c ) ;
 

Brook operates by taking a source file written in a C style format with Brook extensions and
then replacing the Brook code with C and shader code. This is then compiled using a standard C
compiler. Thus, instead of having to write complicated shader and interfacing code, Brook uses
simple extensions to create this code automatically. Listing 12.1 shows a simple Brook code for
the addition of two matrices. This fragment of code is just to demonstrate the use of the different
parameters and cannot be compiled as such.
The code in Listing 12.1 adds each element of arrays “a” and “b”, bounded by the limits of
the iter “it”, and stores them in array “c”. In other words, this example performs the function
c[i]=a[i]+b[i] for elements 1 through 98 inside the GPU memory.
As can be seen in Listing 12.1, the kernel does not have any direct output back to the program.
Unlike a standard C function, the kernel operates on the streams and alters them directly; thereby,
it does not require the output to be sent back to the calling statement. In this particular kernel,
the “out” statement associated with the C stream identifies this particular stream as one that will
be modified by the kernel. The empty brackets “[ ]” after the declaration of “a” and “b” identify
these variables as incoming one-dimensional streams in which any element may be accessed by
the kernel. The “iter” statement identifies the variable “it” as containing the current location of
the output stream being operated on. The “<>” after the streams “it” and “c” identify the single
values at the location specified by the “iter”.

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 field updates. The major part of the program works exactly the same way as any stan-
dard C program might for this problem. Constants are initialized, and arrays are created and
filled, but when it comes time to iterate over the time steps the data are passed to the GPU.
This is first accomplished by creating the appropriately sized streams using commands such as
float 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 October 13, 2009 14:16

376 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 field component 10 cells back from the point source for every iteration the code
is run. Ezdata.txt, Hxdata.txt, and Hydata.txt export the final field states for each of the three fields
calculated in the code. It is possible to run the simulation for several different number of iterations
and to examine the field data, for example, after 100, 200, 500, and 1,000 iterations.
Once all the streams are copied into the GPU, the program can then iterate over time by calling
the kernels just as one would normally call a function or subroutine. Each of the kernels takes
the streams and the iter as the inputs and passes back the resulting updated field. The derivitives
are calculated by the use of an offset term such as float2 t0 = float2(0.0f, 1.0f). When this term is
added to the iter in the calculation such as in (Ez[it]–Ez[it+t0]), it provides the proper function
derivative. The kernel is applied to every element of the stream inside the boundaries of the iter.
The variable it contains the current location (in this case it will be a float2 type to specify the x and
y location such as Ez[54][60]). By adding another constant that is also a float2 type, it is possible
to specify the location offset for the calculations. In the given example, the calculation takes the
form of (Ez[X][Y]–Ez[X][Y+1]).
Once the streams have been iterated over the appropriate number of time steps, the streams
can be passed back to the C arrays using commands like streamWrite(Ez, outputEz). The C arrays
can then be outputted to data files for use elsewhere.
In part 1 of the sample two-dimensional transverse magnetic (TM) FDTD code the custom
GPU kernels are defined for the field computations needed to be performed. For this sample three
kernels are defined: one to do the calculations on the H fields, one for the E fields, and one to
facilitate the extraction of field points for postprocessing. The first part of each kernel defines the
variables that is passed to it and also the variables that are sent out of it. The dimensionality of
each variable is defined for the inputs (a single set of brackets to signify a one-dimensional array,
or a double set of brackets to signify two dimensions) and the output dimensionality is assumed.
In the two sections of the code, first the CPML portions are calculated and updated, and then the
actual field components with the CPML are calculated and updated. The last kernel is used to
copy one stream to another and to extract field points to be saved and examined later.
Part 2 starts the initialization section of the main C code. Like any other C code in this section
all the variables and constants needed for the program are defined. The constants are given their
values, and variables are cleared for use later. In this code all of the array structures are dynamically
allocated so that the domain size can be defined at runtime through command line arguments.
The values of many of the constants and variables are also written to a text file so that they may
be examined later.
Part 3 sets the initialization of all arrays to the initial (free space) values, including all the
CPML coefficients as well. In addition, a perfect electric conductor (PEC) boundary is defined
along the outer edges of the domain. It should be noted that all of the arrays in the C code are
one-dimensional regardless of their implied dimensionality. This has been done due to the way
the GPU portions transfer data back and forth with the CPU section. Even in a three-dimensional
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Extension to Three-Dimensional 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 coefficients so that the absorbing boundaries
may be applied. Each of these arrays are one-dimensional and span the length of either x or y
domains depending on their use. The assignments in this section are only applied within the
CPML boundaries of the domain. Finally, the source point for this sample code is assigned to the
approximate center of the domain.
Part 5 starts the initialization of the GPU section of the code. In this section all of the GPU
streams are defined to their proper sizes, and the arrays are passed from the CPU to the GPU. It
should be noted that while the sizes of the two-dimensional streams are defined in the order of
variable < ys i ze, xs i ze >, they are accessed in the kernel in the reverse order variable[x][y]. For
all the variables that are updated throughout the iterations there are two copies of each, because
certain video cards cannot update streams that are also passed as inputs. So duplicate streams are
created to "ping-pong" between the current and previous sets during the iterations.
Part 6 is the code that will iterate the fields over the requested number of time steps. Here it
can be seen how the two sets of streams are used to update each other in the various time steps.
For example, in the first time step the old fields are defined as Hx and Hy and the updated values
are placed in o Hx and o Hy. The copy kernel is also called to extract the value of a single Ez
point, which is then copied back to the CPU and written to a data file. The “.domain” operator
is used when calling the copy kernel to specify which point in the Ez data stream will be copied.
This operator requires two commands to tell it where to start and stop. In this example they are
the same values to indicate only a single value is needed. At the end the value of the input pulse is
written to a file for later examination.
The last section transfers the final values of the fields back to the CPU and then writes them to
files. This example shows how to transfer the values out of the GPU for processing at a later time.
It is also possible to transfer single points out of the GPU at each time step if required. Consult
the Brook documentation for more examples and deeper explanation of all the various functions
that are used.
Figures 12.3 and 12.4 show example data from the compiled and executed program showing Ez
values at certain time steps for a 200×200 domain as well as the value of a single Ez observation
point across 1,000 time steps. Figure 12.5 shows the speedup factors over an equivalent CPU
based code for a 1000×1000 domain for several different graphics cards. Listings 12.2 to 12.8 are
provided for the reader as one Brook program titled “tm2d.br.”

12.4 EXTENSION TO THREE-DIMENSIONAL

Efficient implementations of basic FDTD techniques on GPUs have been recently documented;
however, including absorbing boundary conditions can present a few challenges. Certain common
boundary types such as Mur [49] or Liao [50] may not have easy implementation due to the
nature of the time and spatial dependency of their updating equations, especially for higher-
order absorbing boundaries. Furthermore, this problem becomes more complicated for three-
dimensional problems where the three-dimensional to two-dimensional translation is necessary
for storage inside the GPU card, as seen in Fig. 12.6. Because of this translation, the various x,
y, and z boundaries inside the domain are scattered among the various tiles. Thus, applying the
boundary conditions on the individual boundaries becomes very complicated.
Figure 12.6 shows an example of how a three-dimensional domain can be translated into a
two-dimensional structure. The various levels along the z axis are sliced and tiled along the y
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

378 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 figure 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 fields must be calculated for the entire computational domain since the boundaries are
scattered. While no CPML field expressions normally exist within the internal portion of the
computational domain, they are still calculated to simplify the GPU implementation. Thus,
the CPML coefficients should be zero in the internal computational domain. This leads to no
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Three-Dimensional Parameter Exploration 379

20

10

0
Ez Value

-10

-20

-30

-40
0 100 200 300 400 500 600 700 800 900 1000
time steps

Figure 12.4 TM2D with CPML E z value at observation point.

significant difficulties 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 filters similar to those in [14] can be solved in a matter of seconds. In the
course of designing or teaching of many common devices, analytic methods can lead to a good
approximation for the final design. However, until the design has been simulated, the final results
can not be totally known. For example, while teaching these devices one might assign the design
of these sample cases as homework to achieve the desired result since the demonstration of it in
class can be prohibitive due to time constraints. Since the use of GPU can reduce the FDTD
simulation time to acceptable levels, one can now use this method inside the classroom given the
proper tools.
The first example of this application of the GPU-based FDTD method is the simulation of
the basic rectangular patch antenna. For this example, the configuration of this antenna is from
[14]. This is a simple offset fed patch antenna on a known dielectric substrate of r = 2.2 with a
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

380 Graphics Processing Unit Acceleration of Finite-Difference Time-Domain

70
DirectX 9.0c-ATI x1900
DirectX 9.0c-ATI x800
60 DirectX 9.0c-ATI 9550

50
speedup factor

40

30

20

10

0
0 500 1000 1500 2000 2500 3000 3500 4000
Iterations

Figure 12.5 TM2D with CPML speedup factors.

Listing 12.2 Brook code for two-dimensional TM simulation—part 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 [ ] [ ] ,
3 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 [ ] ,
5 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 [ ] [ ] ,
7 f l o a t dx , f l o a t dy ,
i t e r f l o a t 2 i t <>,
9 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

p x y = ( Bhy [ i t . y ] * p s i H x y [ i t ] ) + ( Chy [ i t . y ] * ( E z [ i t +t 0 ]− E z [ i t ] ) ) ;
19 p y x = ( Bhx [ i t . x ] * p s i H y x [ i t ] ) + ( Chx [ i t . x ] * ( E z [ i t +t 1 ]− E z [ i t ] ) ) ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Three-Dimensional Parameter Exploration 381

21 o p s i H x y =p x y ;
o p s i H y x =p y x ;
23

o Hx = ( Chxh [ i t ] * Hx [ i t ] ) + ( Khy [ it .y] * Chxe [ i t ] / dy *


25 ( E z [ i t +t 0 ]− E z [ i t ] ) ) + ( Chxe [ it ] * pxy ) ;
o Hy = ( Chyh [ i t ] * Hy [ i t ] ) + ( Khx [ it .x] * Chye [ i t ] / dx *
27 ( E z [ i t +t 1 ]− E z [ i t ] ) ) + ( Chye [ it ] * pyx ) ;

29 }

31

/ / GPU F u n c t i o n F o r E F i e l d s
33 k e r n e l void p r o c e s s f i e l d E z ( f l o a t Ez [ ] [ ] , f l o a t Ceze [ ] [ ] ,
f l o a t C e z h [ ] [ ] , f l o a t Hx [ ] [ ] , f l o a t Hy [ ] [ ] ,
35 f l o a t C s [ ] [ ] , f l o a t Kex [ ] , f l o a t Key [ ] ,
f l o a t Bex [ ] , f l o a t Bey [ ] ,
37 f l o a t Cex [ ] , f l o a t Cey [ ] ,
float psiEzx [ ] [ ] , float psiEzy [ ] [ ] ,
39 f l o a t dx , f l o a t dy ,
f l o a t g a u s s , i t e r f l o a t 2 i t <>,
41 o u t f l o a t o E z <>, o u t f l o a t o p s i E z x <>,
o u t f l o a t o p s i E z y <> )
43

{
45 f l o a t 2 t 0 = f l o a t 2 ( 0 . 0 f , −1.0 f ) ;
f l o a t 2 t1 = f l o a t 2 ( −1.0 f , 0 . 0 f ) ;
47

f l o a t pzx , p z y ;
49

p z x = ( Bex [ i t . x ] * p s i E z x [ i t ] ) + ( C e x [ i t . x ] * ( Hy [ i t ]−Hy [ i t +t 1 ] ) ) ;
51 p z y = ( Bey [ i t . y ] * p s i E z y [ i t ] ) + ( C e y [ i t . y ] * ( Hx [ i t ]−Hx [ i t +t 0 ] ) ) ;

53 o p s i E z x =p z x ;
o p s i E z y =p z y ;
55

o Ez = ( Ceze [ i t ] * Ez [ i t ] ) + ( Kex [ i t . x ] * ( C e z h [ i t ] / dx ) *
57 ( Hy [ i t ]−Hy [ i t +t 1 ] ) ) + ( Key [ i t . y ] * ( C e z h [ i t ] / dy ) *
( Hx [ i t ]−Hx [ i t +t 0 ] ) ) − ( Cs [ i t ]* gauss ) +
59 ( Cezh [ i t ] * pzx ) + ( Cezh [ i t ] * pzy ) ;

61 }

63

/ / Copy K e r n e l To E x t r a c t S i n g l e P o i n t s From a S t r e a m
65 k e r n e l v o i d Copy ( f l o a t i n p u t <>, o u t f l o a t o u t p u t <> )

67 {
output = input ;
69 }
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

382 Graphics Processing Unit Acceleration of Finite-Difference Time-Domain

Listing 12.3 Brook code for two-dimensional TM simulation—part 2.


i n t main ( i n t a r g c , c h a r * a r g v [ ] ) {
2

// I n i t i a l i z e Variables
4 i n t i , j , N , nx , ny , x s i z e , y s i z e , i n s i z e x , i n s i z e y ;
i n t iPML , kappa , m;
6 f l o a t s i g m a x , s i g m a y , amax ;
f l o a t s i g 1 , s i g 2 , a1 , a2 , k1 , k2 , i i ;
8 f l o a t eps0 , mu0 , c , pi , dx , dy , dx2 , dy2 , d f a c t o r ;
f l o a t dt , Nc , tau , t0 , fmax , c e ;
10 f l o a t * t =NULL ;
f l o a t * g a u s s=NULL ;
12 f l o a t * o u t p u t P o r t =NULL ;

14 float * aHx=NULL ;
float * aHy=NULL ;
16 float * a E z=NULL ;
float * a C e z e=NULL ;
18 float * aChxh=NULL ;
float * aChyh=NULL ;
20 float * a C e z h=NULL ;
float * a C h x e=NULL ;
22 float * a C h y e=NULL ;
float * a C s=NULL ;
24

f l o a t * o u t p u t E z = NULL ;
26 f l o a t * o u t p u t H x = NULL ;
f l o a t * o u t p u t H y = NULL ;
28

float * aKex=NULL ;
30 float * aKey=NULL ;
float * aKhx=NULL ;
32 float * aKhy=NULL ;

34 float * a b e x=NULL ;
float * abey=NULL ;
36 float * a c e x=NULL ;
float * a c e y=NULL ;
38

float * abhx=NULL ;
40 float * abhy=NULL ;
float * a c h x=NULL ;
42 float * a c h y=NULL ;

44 f l o a t * a p s i =NULL ;

46

FILE * pFile ;
48 FILE * pFile2 ;
FILE * pFile3 ;
50
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Three-Dimensional Parameter Exploration 383

/ / Define Constants
52 pi =3.14159265;
c = 2 . 9 9 8 e8 ;
54

/ / Br oken Down b e c a u s e o f f l o a t i n g p o i n t
56 / / problems with c e r t a i n c o m p l i e r s
eps0 =8.854;
58 e p s 0=e p s 0 * 1 e −6;
e p s 0=e p s 0 * 1 e −6;
60 mu0= 4 * p i ;
mu0= mu0 * 1 e −4;
62 mu0= mu0 * 1 e −3;

64 / / D e f i n e dx & dy
dx=1e −3;
66 dy=1e −3;
dx2 = ( 1 / dx ) * ( 1 / dx ) ;
68 dy2 = ( 1 / dy ) * ( 1 / dy ) ;

70 / / D e f i n e t i m e s t e p s and domain s i z e
/ / N, xsize , y s i z e are a l l defined
72 / / By r u n t i m e a r g u m e n t s
N = atoi ( argv [ 1 ] ) ;
74 x s i z e = atoi ( argv [ 2 ] ) ;
y s i z e = atoi ( argv [ 3 ] ) ;
76 nx =( i n t ) x s i z e ;
ny =( i n t ) y s i z e ;
78 dfactor =.9;
d t = ( 1 / ( c * s q r t ( dx2 + dy2 ) ) ) * d f a c t o r ;
80 c e=d t / ( 2 * e p s 0 ) ;

82 / / D e f i n e s o u r c e waveform c o n s t a n t s
Nc =25;
84 t a u =( Nc * d t ) / ( 2 * s q r t ( 2 . 0 ) ) ;
t0 =4.5* tau ;
86 fmax = 1 / ( t a u ) ;

88 / / D e f i n e PML C o n s t a n t s
iPML =10;
90 kappa =8;
m=4;
92 s i g m a x = ( 0 . 8 * m+ 1 ) / ( 1 5 0 * p i * dx ) ;
s i g m a y = ( 0 . 8 * m+ 1 ) / ( 1 5 0 * p i * dy ) ;
94 amax = ( fmax / 2 . 1 ) * 2 * p i * ( e p s 0 / 1 0 ) ;

96 / / 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 " ) ;
98 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 ) ;
100 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
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

384 Graphics Processing Unit Acceleration of Finite-Difference Time-Domain

/ / S e t a t Runtime
104 g a u s s= ( f l o a t * ) m a l l o c ( N* s i z e o f ( f l o a t ) ) ;
t= ( f l o a t * ) m a l l o c ( N* s i z e o f ( f l o a t ) ) ;
106 o u t p u t P o r t= ( f l o a t * ) malloc ( 1 * s i z e o f ( f l o a t ) ) ;

108 aHx= ( float * ) malloc ( xsize * ysize * sizeof ( float ));


aHy= ( float * ) malloc ( xsize * ysize * sizeof ( float ));
110 a E z= ( float * ) malloc ( xsize * ysize * sizeof ( float ));
a C e z e= ( float * ) malloc ( xsize * ysize * sizeof ( float ));
112 aChxh= ( float * ) malloc ( xsize * ysize * sizeof ( float ));
aChyh= ( float * ) malloc ( xsize * ysize * sizeof ( float ));
114 a C e z h= ( float * ) malloc ( xsize * ysize * sizeof ( float ));
a C h x e= ( float * ) malloc ( xsize * ysize * sizeof ( float ));
116 a C h y e= ( float * ) malloc ( xsize * ysize * sizeof ( float ));
a C s= ( float * ) malloc ( xsize * ysize * sizeof ( float ));
118 o u t p u t E z= ( float * ) malloc ( xsize * ysize * sizeof ( float ));
o u t p u t H x= ( float * ) malloc ( xsize * ysize * sizeof ( float ));
120 o u t p u t H y= ( float * ) malloc ( xsize * ysize * sizeof ( float ));

122 / / PML Arrays


aKex = ( float * ) malloc ( xsize * sizeof ( float ));
124 aKhx = ( float * ) malloc ( xsize * sizeof ( float ));
aKey = ( float * ) malloc ( ysize * sizeof ( float ));
126 aKhy = ( float * ) malloc ( ysize * sizeof ( float ));

128 abex = ( float * ) malloc ( xsize * sizeof ( float ));


abhx = ( float * ) malloc ( xsize * sizeof ( float ));
130 abey = ( float * ) malloc ( ysize * sizeof ( float ));
abhy = ( float * ) malloc ( ysize * sizeof ( float ));
132

acex = ( float * ) malloc ( xsize * sizeof ( float ));


134 achx = ( float * ) malloc ( xsize * sizeof ( float ));
acey = ( float * ) malloc ( ysize * sizeof ( float ));
136 achy = ( float * ) malloc ( ysize * sizeof ( float ));

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
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Three-Dimensional Parameter Exploration 385

Listing 12.4 Brook code for two-dimensional TM simulation—part 3.


1 / / P r e c a l c u t e input pulse

3 t [0]= dt ;
gauss [0]=0;
5

f o r ( i =1; i <N ; i ++) {


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

11

/ / Define E x t e r i o r Size
13 insizex = xsize ;
insizey = ysize ;
15

// I n i t i a l i z e o u r C f i e l d and c o n s t a n t a r r a y s
17

/ / 1D X A r r a y s
19 f o r ( i =0; i <nx ; i ++) {
aKex [ i ] = 1 ;
21 aKhx [ i ] = 1 ;
abex [ i ] = 0 ;
23 abhx [ i ] = 0 ;
acex [ i ]=0;
25 achx [ i ]=0;
}
27

/ / 1D Y A r r a y s
29 f o r ( i =0; i <ny ; i ++) {
aKey [ i ] = 1 ;
31 aKhy [ i ] = 1 ;
abey [ i ] = 0 ;
33 abhy [ i ] = 0 ;
acey [ i ]=0;
35 achy [ i ]=0;
}
37

/ / 2D A r r a y s
39 f o r ( j =0; j <ny ; j ++) {
f o r ( i =0; i <nx ; i ++) {
41 aHy [ nx * j + i ] = 0 ;
aHx [ nx * j + i ] = 0 ;
43 a E z [ nx * j + i ] = 0 ;
a C s [ nx * j + i ] = 0 ;
45 a C e z e [ nx * j + i ] = 1 . 0 ;
aChxh [ nx * j + i ] = 1 . 0 ;
47 aChyh [ nx * j + i ] = 1 . 0 ;
a C e z h [ nx * j + i ] = ( d t / e p s 0 ) ;
49 a C h x e [ nx * j + i ] = ( d t / mu0 ) ;
a C h y e [ nx * j + i ] = ( d t / mu0 ) ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

386 Graphics Processing Unit Acceleration of Finite-Difference Time-Domain

51 a p s i [ nx * j + i ] = 0 ;
}
53 }

55 / / S e t PEC Boundary
/ / ( E a s y way , f i l l w i t h PEC t h e n f i l l i n t e r n a l with a i r )
57

f o r ( j =0; j <ny ; j ++) {


59 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 ) ) ;
61 a C e z h [ nx * j + i ] = ( ( 2 * c e ) / ( 1 + ( c e * 1 e30 ) ) ) ;
}
63 }

65 f o r ( j =2; j <ny −2; j ++) {


f o r ( i =2; i <nx −2; i ++) {
67 a C e z e [ nx * j + i ] = 1 . 0 ;
a C e z h [ nx * j + i ] = ( d t / e p s 0 ) ;
69 }
}
 

Listing 12.5 Brook code for two-dimensional TM simulation—part 4.


/ / I n i t i a l i z e PML B o u n d a r i e s
2 f o r ( i =1; i <1+iPML ; i ++) {

4 i i =( f l o a t ) i ;
i i =(1+ iPML )− i i ;
6

s i g 1 =pow ( ( ( i i − 0 . 5 ) / iPML ) ,m) * s i g m a x ;


8 s i g 2 =(mu0 / e p s 0 ) * pow ( ( ( i i ) / iPML ) ,m) * s i g m a x ;

10 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

k1 =1+( kappa −1) * pow ( ( ( i i − 0 . 5 ) / iPML ) ,m ) ;


14 k2 =1+( kappa −1) * pow ( ( ( i i ) / iPML ) ,m ) ;

16 aKex [ i +1]=1/ k1 ;
aKhx [ i ] = 1 / k2 ;
18

aKex [ nx−i −1]=1/ k1 ;


20 aKhx [ nx−i −1]=1/ k2 ;

22 a b e x [ i +1]= exp ( ( − d t / e p s 0 ) * ( ( s i g 1 / k1 )+ a1 ) ) ;
a c e x [ i + 1 ] = ( ( s i g 1 / dx ) / ( ( s i g 1 * k1 ) + ( a1 * k1 * k1 ) ) ) *
24 ( exp ( ( − d t / e p s 0 ) * ( ( s i g 1 / k1 )+ a1 ) ) − 1 ) ;

26

a b e x [ nx−i −1]= exp ( ( − d t / e p s 0 ) * ( ( s i g 1 / k1 )+ a1 ) ) ;


28 a c e x [ nx−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 ) ;
30
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Three-Dimensional Parameter Exploration 387

abhx [ i ]= exp ( ( − d t / mu0 ) * ( ( s i g 2 / k2 )+ a2 ) ) ;


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

abhx [ nx−i −1]= exp ( ( − d t / mu0 ) * ( ( s i g 2 / k2 )+ a2 ) ) ;


36 a c h x [ nx−i − 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 ) ;
38

aKey [ i +1]=1/ k1 ;
40 aKhy [ i ] = 1 / k2 ;

42 aKey [ ny−i −1]=1/ k1 ;


aKhy [ ny−i −1]=1/ k2 ;
44

abey [ i +1]= exp ( ( − d t / e p s 0 ) * ( ( s i g 1 / k1 )+ a1 ) ) ;


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

50 abey [ ny−i −1]= exp ( ( − d t / e p s 0 ) * ( ( s i g 1 / k1 )+ a1 ) ) ;


a c e y [ ny−i − 1 ] = ( ( s i g 1 / dx ) / ( ( s i g 1 * k1 ) + ( a1 * k1 * k1 ) ) ) *
52 ( exp ( ( − d t / e p s 0 ) * ( ( s i g 1 / k1 )+ a1 ) ) − 1 ) ;

54 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 ) ) ) *
56 ( exp ( ( − d t / mu0 ) * ( ( s i g 2 / k2 )+ a2 ) ) − 1 ) ;

58 abhy [ ny−i −1]= exp ( ( − d t / mu0 ) * ( ( s i g 2 / k2 )+ a2 ) ) ;


a c h y [ ny−i − 1 ] = ( ( s i g 2 / dx ) / ( ( s i g 2 * k2 ) + ( a2 * k2 * k2 ) ) ) *
60 ( exp ( ( − d t / mu0 ) * ( ( s i g 2 / k2 )+ a2 ) ) − 1 ) ;
}
62

64

/ / P l a c e Our P o i n t S o u r c e ( P l a c e d i n t h e a p p r o x i m a t e c e n t e r )
66 a C s [ nx * ( y s i z e / 2 ) + ( x s i z e / 2 ) ] = 1 / dx ;

68 / / P l a c e Sample S c a t t e r i n g O b j e c t E r = 1 0 . 2

70 // 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
72 / / T h a t i s 16 c e l l s wide and 10 C e l l s Deep

74 f o r ( j = ( ( y s i z e / 2 ) − 8 ) ; j < ( ( y s i z e / 2 ) + 9 ) ; j ++) {
f o r ( i = ( ( x s i z e / 2 ) + 1 0 ) ; i < ( ( x s i z e / 2 ) + 2 0 ) ; i ++) {
76 a C e z e [ nx * j + i ] = 1 ;
a C e z h [ nx * j + i ] = ( 2 * c e ) / ( 1 0 . 2 ) ;
78 }
}
80

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 14:16

388 Graphics Processing Unit Acceleration of Finite-Difference Time-Domain

Listing 12.6 Brook code for two-dimensional TM simulation—part 5.


/ / B e g i n Code t o I n i t i a l i z e and Use GPU
2 {
/ / 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
4 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 ) ) ;
6

/ / I n i t i a l i z e the streams
8 f l o a t Obs <1 ,1 >;
f l o a t Hy<i n s i z e y , i n s i z e x >, Hx<i n s i z e y , i n s i z e x >;
10 f l o a t o E z <i n s i z e y , i n s i z e x >, o Hy<i n s i z e y , i n s i z e x >;
f l o a t o Hx<i n s i z e y , i n s i z e x >;
12 f l o a t Ceze<i n s i z e y , i n s i z e x >, Chxh<i n s i z e y , i n s i z e x >;
f l o a t Chyh<i n s i z e y , i n s i z e x >;
14 f l o a t Cezh<i n s i z e y , i n s i z e x >, Chxe<i n s i z e y , i n s i z e x >;
f l o a t Chye<i n s i z e y , i n s i z e x >, Cs<i n s i z e y , i n s i z e x >;
16 f l o a t Ez<i n s i z e y , i n s i z e x >;
f l o a t Kex<i n s i z e x >, Khx<i n s i z e x >;
18 f l o a t Bex<i n s i z e x >, Bhx<i n s i z e x >;
f l o a t Cex<i n s i z e x >, Chx<i n s i z e x >;
20 f l o a t Key<i n s i z e y >, Khy<i n s i z e y >;
f l o a t Bey<i n s i z e y >, Bhy<i n s i z e y >;
22 f l o a t Cey<i n s i z e y >, Chy<i n s i z e y >;
f l o a t p s i E z x <i n s i z e y , i n s i z e x >, o p s i E z x <i n s i z e y , i n s i z e x >;
24 f l o a t p s i E z y <i n s i z e y , i n s i z e x >, o p s i E z y <i n s i z e y , i n s i z e x >;
f l o a t p s i H x y <i n s i z e y , i n s i z e x >, o p s i H x y <i n s i z e y , i n s i z e x >;
26 f l o a t p s i H y x <i n s i z e y , i n s i z e x >, o p s i H y x <i n s i z e y , i n s i z e x >;

28

/ / Copy o u r C a r r a y s i n t o t h e S t r e a m s s o t h e GPU
30 / / can p r o c e s s them
s t r e a m R e a d ( Ez , a E z ) ;
32 s t r e a m R e a d ( Hy , aHy ) ;
s t r e a m R e a d ( Hx , aHx ) ;
34 streamRead ( o Ez , aEz ) ;
s t r e a m R e a d ( o Hy , aHy ) ;
36 s t r e a m R e a d ( o Hx , aHx ) ;
s t r e a m R e a d ( Ceze , a C e z e ) ;
38 s t r e a m R e a d ( Chxh , aChxh ) ;
s t r e a m R e a d ( Chyh , aChyh ) ;
40 s t r e a m R e a d ( Cezh , a C e z h ) ;
s t r e a m R e a d ( Chxe , a C h x e ) ;
42 s t r e a m R e a d ( Chye , a C h y e ) ;
s t r e a m R e a d ( Cs , a C s ) ;
44

s t r e a m R e a d ( Kex , aKex );
46 s t r e a m R e a d ( Khx , aKhx );
s t r e a m R e a d ( Bex , abex );
48 s t r e a m R e a d ( Bhx , abhx );
s t r e a m R e a d ( Cex , acex );
50 s t r e a m R e a d ( Chx , achx );
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Three-Dimensional Parameter Exploration 389

52 s t r e a m R e a d ( Key , aKey ) ;
s t r e a m R e a d ( Khy , aKhy ) ;
54 s t r e a m R e a d ( Bey , abey ) ;
s t r e a m R e a d ( Bhy , abhy ) ;
56 s t r e a m R e a d ( Cey , acey ) ;
s t r e a m R e a d ( Chy , achy ) ;
58

streamRead ( psiEzx , apsi ) ;


60 streamRead ( o psiEzx , apsi );
streamRead ( psiEzy , apsi ) ;
62 streamRead ( o psiEzy , apsi );
streamRead ( psiHxy , apsi ) ;
64 streamRead ( o psiHxy , apsi );
streamRead ( psiHyx , apsi ) ;
66 streamRead ( o psiHyx , apsi );
 

Listing 12.7 Brook code for two-dimensional TM simulation—part 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 " ) ;
3

/ / Do t h e r e q u e s t e d number o f i t e r a t i o n s
5 f o r ( i =0; i <N ; i ++){

7 / / We u s e t o 2 s e t s o f f i e l d s t r e a m s t o have
/ / a " New " and " Old " s e t
9 i f ( i %2==0) {

11 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 ,
13 dx , dy , i t , o Hx , o Hy , o p s i H x y , o p s i H y x ) ;

15 p r o c e s s f i e l d E z ( Ez , Ceze , Cezh , o Hx , o Hy , Cs ,
Kex , Key , Bex , Bey , Cex , Cey , p s i E z x , p s i E z y ,
17 dx , dy , g a u s s [ i ] , i t , o E z , o p s i E z x , o p s i E z y ) ;

19 / / 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
21 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

s t r e a m W r i t e ( Obs , o u t p u t P o r t ) ;
25 f p r i n t f ( p F i l e 2 , " %e \n " , o u t p u t P o r t [ 0 ] ) ;

27 } else {

29 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 ,
31 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 ,


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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


35 dy , g a u s s [ i ] , i t , Ez , p s i E z x , p s i E z y ) ;

37 / / 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
39

Copy ( E z . domain ( i n t 2 ( ( x s i z e /2) −10 , y s i z e / 2 ) ,


41 i n t 2 ( ( x s i z e /2) −10 , y s i z e / 2 ) ) , Obs ) ;

43 s t r e a m W r i t e ( Obs , o u t p u t P o r t ) ;
f p r i n t f ( p F i l e 2 , " %e \n " , o u t p u t P o r t [ 0 ] ) ;
45

}
47

f p r i n t f ( p F i l e , " %e %e \n " , g a u s s [ i ] , t [ i ] ) ;
49 }
 

Listing 12.8 Brook code for two-dimensional TM simulation—Part 7.


/ / 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
2 / / s o we can o u t p u t them

4 / / C h e c k which i s t h e l a s t s t r e a m s u p d a t e d

6 i f ( i %2==0) {
streamWrite ( Ez , o u t p u t E z ) ;
8 streamWrite ( Hx , o u t p u t H x ) ;
streamWrite ( Hy , o u t p u t H y ) ;
10 } else {
streamWrite ( o Ez , outputEz ) ;
12 streamWrite ( o Hx , o u t p u t H x ) ;
streamWrite ( o Hy , o u t p u t H y ) ;
14 }

16

/ / C l o s e The O b s e r v a t i o n and D a t a F i l e s
18 fclose ( pFile ) ;
fclose ( pFile2 ) ;
20

/ / Output the f i e l d s t a t e s i n t o a t e x t f i l e
22 p F i l e = fopen ( " E z d a t a . t x t " , " wt " ) ;
p F i l e 2 = fopen ( " H x d a t a . t x t " , " wt " ) ;
24 p F i l e 3 = fopen ( " H y d a t a . t x t " , " wt " ) ;

26 f o r ( j =0; j <ny ; j ++) {


f o r ( i =0; i <nx ; i ++) {
28 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 ] ) ;
30 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 ] ) ;
}
32 fprintf ( pFile ,"\ n " ) ;
fprintf ( pFile2 ,"\ n " ) ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Three-Dimensional Parameter Exploration 391

34 fprintf ( pFile3 ,"\ n " ) ;


}
36 }

38 // Close Field F il e s
fclose ( pFile ) ;
40 fclose ( pFile2 ) ;
fclose ( pFile3 ) ;
42 p r i n t f ( " Program c o m p l e t e \n " ) ;
return 0;
44 }
 

calls the GPU FDTD program and runs the simulation for the requested parameters and time
steps. After the simulation has finished, the GUI performs the postprocessing on the data and
displays the return loss for the selected configuration. In addition to the return loss, the tran-
sient input port voltage and current and the input impedance are also displayed as shown in
Figs. 12.10, 12.11, and 12.12, respectively. The graphical user interface (GUI) also includes a
calculator section that analyzes or synthesizes the proper antenna given the requested target
frequency or antenna size. By using this GUI, it is possible to vary any of the parameters inter-
actively and to have the results shown in a matter of seconds. Figure 12.13 shows the results for
return loss with the default input parameters. The entire simulation including the postprocess-
ing was accomplished very quickly, allowing for its use in a wide variety of teaching or research
situations.
As a second example for the three-dimensional GUI interface, a simple microstrip filter was
chosen from [14]. This is a simple offset microstrip filter placed on a known dielectric substrate of
r = 2.2 with a 10 cell air gap to the CMPL boundary as seen in Fig. 12.14. In this case we again
have seven parameters that can be adjusted: specifying the filter bar width, spacing of the left feed

Figure 12.6 Simple tiling from three-dimensional structure to two-dimensional texture.


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Three-Dimensional Parameter Exploration 393

Figure 12.9 MATLAB GUI for the microstrip patch antenna.

Figure 12.10 The transient voltage at the input port.


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Three-Dimensional Parameter Exploration 395

Figure 12.13 Return loss results for default microstrip patch antenna.

Figure 12.14 Example microstrip filter.


fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

396 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 filter bar, first feed line width, the spacing between the feed
arms, second feed line width, the spacing of the right feed arm from the edge of the filter bar, and
the height of the substrate.
A different GUI was created in MATLAB to handle this geometry as now there is both return
loss and transmission to be calculated and viewed. This interface can be seen in Fig. 12.15. This
interface is set up with the default parameters from [14] and shows the calculated results for
S11 and S21 . The parameters can be changed to specify different configurations, and the results
calculated show in seconds on personal computers with modest configuration. Figure 12.16 shows
the results for the default parameters of the microstrip filter. Both the microstrip patch antenna
and the microstrip filter examples executable codes and their corresponding MATLAB GUI are
provided on the CD for further experiments by the reader.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Three-Dimensional Parameter Exploration 397

Figure 12.16 Return loss and transmission results for default microstrip filter.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

A
One-Dimensional FDTD Code
Listing A.1 MATLAB code for one-dimensional FDTD

% T h i s program d e m o n s t r a t e s a one−d i m e n s i o n a l FDTD s i m u l a t i o n .
2 % The problem g e o m e t r y i s composed o f two PEC p l a t e s e x t e n d i n g t o
% i n f i n i t y i n y , and z d i m e n s i o n s , p a r a l l e l t o e a c h o t h e r w i t h 1 meter
4 % s e p a r a t i o n . The s p a c e between t h e PEC p l a t e s i s f i l l e d w i t h a i r .
% A s h e e t o f c u r r e n t s o u r c e p a r a l l e t o t h e PEC p l a t e s i s p l a c e d
6 % a t t h e c e n t e r o f t h e problem s p a c e . The c u r r e n t s o u r c e e x c i t e s f i e l d s
% i n t h e problem s p a c e due t o a z−d i r e c t e d c u r r e n t d e n s i t y J z ,
8 % which h a s a G a u s s i a n waveform i n t i m e .

10 % Define i n i t i a l constants
e p s 0 = 8 . 8 5 4 1 8 7 8 1 7 e −12; % p e r m i t t i v i t y of f r e e space
12 mu 0 = 4 * p i * 1 e −7; % permeability of f r e e space
c = 1 / s q r t ( mu 0 * e p s 0 ) ; % speed of l i g h t
14

% D e f i n e problem g e o m e t r y and p a r a m e t e r s
16 domain size = 1; % 1D problem s p a c e l e n g t h i n m e t e r s
dx = 1e −3; % c e l l s i z e in meters
18 d t = 3e −12; % d u r a t i o n of time s t e p in seconds
number of time steps = 2000; % number o f i t e r a t i o n s
20 nx = round ( d o m a i n s i z e / dx ) ; % number o f c e l l s i n 1D problem s p a c e
source position = 0.5; % p o s i t i o n of the current source J z
22

% Initialize f i e l d and m a t e r i a l a r r a y s
24 Ceze = z e r o s ( nx + 1 , 1 ) ;
Cezhy = z e r o s ( nx + 1 , 1 ) ;
26 Cezj = z e r o s ( nx + 1 , 1 ) ;
Ez = z e r o s ( nx + 1 , 1 ) ;
28 Jz = z e r o s ( nx + 1 , 1 ) ;
eps r z = o n e s ( nx + 1 , 1 ) ; % f r e e s p a c e
30 sigma e z = z e r o s ( nx + 1 , 1 ) ; % f r e e s p a c e

32 Chyh = zeros ( nx ,1);


Chyez = zeros ( nx ,1);
34 Chym = zeros ( nx ,1);
Hy = zeros ( nx ,1);
36 My = zeros ( nx ,1);
mu r y = ones ( nx , 1 ) ; % f r e e space
38 sigma m y = zeros ( nx , 1 ) ; % f r e e space

399
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

400 Appendix A One-Dimensional FDTD Code

40 % C a l c u l a t e FDTD u p d a t i n g c o e f f i c i e n t s
Ceze = ( 2 * e p s r z * eps 0 − dt * sigma e z ) . . .
42 . / ( 2 * e p s r z * eps 0 + dt * sigma e z ) ;

44 C e z h y = ( 2 * d t / dx ) . . .
. / ( 2 * e p s r z * eps 0 + dt * sigma e z ) ;
46

Cezj = ( −2 * d t ) . . .
48 . / ( 2 * e p s r z * eps 0 + dt * sigma e z ) ;

50 Chyh = ( 2 * m u r y * mu 0 − d t * s i g m a m y ) ...
. / ( 2 * m u r y * mu 0 + d t * s i g m a m y ) ;
52

C h y e z = ( 2 * d t / dx ) . . .
54 . / ( 2 * m u r y * mu 0 + d t * s i g m a m y ) ;

56 Chym = ( −2 * d t ) . . .
. / ( 2 * m u r y * mu 0 + d t * s i g m a m y ) ;
58

% D e f i n e t h e G a u s s i a n s o u r c e waveform
60 time = dt * [ 0 : number of time steps − 1 ] . ’ ;
J z w a v e f o r m = exp ( − ( ( time −2e − 1 0 ) / 5 e − 1 1 ) . ˆ 2 ) ;
62 s o u r c e p o s i t i o n i n d e x = round ( nx * s o u r c e p o s i t i o n / d o m a i n s i z e ) + 1 ;

64 % Subroutine to i n i t i a l i z e p l o t t i n g
initialize plotting parameters ;
66

% FDTD l o o p
68 for time step = 1: number of time steps

70 % Update J z f o r t h e c u r r e n t t i m e s t e p
J z ( s o u r c e p o s i t i o n i n d e x ) = Jz waveform ( time step ) ;
72

% Update m a g n e t i c f i e l d
74 Hy ( 1 : nx ) = Chyh ( 1 : nx ) . * Hy ( 1 : nx ) . . .
+ C h y e z ( 1 : nx ) . * ( E z ( 2 : nx + 1) − E z ( 1 : nx ) ) ...
76 + Chym ( 1 : nx ) . * My ( 1 : nx ) ;

78 % Update e l e c t r i c f i e l d
E z ( 2 : nx ) = C e z e ( 2 : nx ) . * E z ( 2 : nx ) . . .
80 + C e z h y ( 2 : nx ) . * ( Hy ( 2 : nx ) − Hy ( 1 : nx − 1 ) ) ...
+ C e z j ( 2 : nx ) .* J z ( 2 : nx ) ;
82

Ez ( 1 ) = 0 ; % A p p l y PEC b o u n d a r y c o n d i t i o n a t x = 0 m
84 E z ( nx + 1 ) = 0 ; % A p p l y PEC b o u n d a r y c o n d i t i o n a t x = 1 m

86 % Subroutine to p l o t the current s t a t e of the f i e l d s


plot fields ;
88 end
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Appendix A One-Dimensional FDTD Code 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

E z p o s i t i o n s = [ 0 : nx ] * dx ;
4 H y p o s i t i o n s = ( [ 0 : nx − 1 ] + 0 . 5 ) * dx ;
v = [ 0 −0.1 −0.1; 0 −0.1 0 . 1 ; 0 0 . 1 0 . 1 ; 0 0 . 1 −0.1; . . .
6 1 −0.1 −0.1; 1 −0.1 0 . 1 ; 1 0 . 1 0 . 1 ; 1 0 . 1 − 0 . 1 ] ;
f = [1 2 3 4; 5 6 7 8 ] ;
8 a x i s ( [ 0 1 −0.2 0 . 2 −0.2 0 . 2 ] ) ;
l e z = l i n e ( E z p o s i t i o n s , E z * 0 , Ez , ’ C o l o r ’ , ’ b ’ , ’ L i n e W i d t h ’ , 1 . 5 ) ;
10 l h y = l i n e ( H y p o s i t i o n s , 3 7 7 * Hy , Hy * 0 , ’ C o l o r ’ , ’ r ’ , . . .
’ L i n e W i d t h ’ , 1 . 5 , ’ l i n e s t y l e ’ , ’ −. ’ ) ;
12 s e t ( gca , ’ f o n t s i z e ’ , 1 2 , ’ F o n t W e i g h t ’ , ’ b o l d ’ ) ;
axis square ;
14 l e g e n d ( ’ E { z } ’ , ’ H { y } \ t i m e s 377 ’ , ’ L o c a t i o n ’ , ’ N o r t h E a s t ’ ) ;
x l a b e l ( ’ x [m] ’ ) ;
16 y l a b e l ( ’ [ A /m] ’ ) ;
z l a b e l ( ’ [ V /m] ’ ) ;
18 g r i d on ;
p = patch ( ’ v e r t i c e s ’ , v , ’ f a c e s ’ , f , ’ f a c e c o l o r ’ , ’ g ’ , ’ f a c e a l p h a ’ , 0 . 2 ) ;
20 t e x t ( 0 , 1 , 1 . 1 , ’ PEC ’ , ’ h o r i z o n t a l a l i g n m e n t ’ , ’ c e n t e r ’ , ’ f o n t w e i g h t ’ , ’ b o l d ’ ) ;
t e x t ( 1 , 1 , 1 . 1 , ’ PEC ’ , ’ h o r i z o n t a l a l i g n m e n t ’ , ’ c e n t e r ’ , ’ f o n t w e i g h t ’ , ’ b o l d ’ ) ;
 

Listing A.3 plot fields


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

3 delete ( lez ) ;
delete ( lhy ) ;
5 l e z = l i n e ( E z p o s i t i o n s , E z * 0 , Ez , ’ C o l o r ’ , ’ b ’ , ’ L i n e W i d t h ’ , 1 . 5 ) ;
l h y = l i n e ( H y p o s i t i o n s , 3 7 7 * Hy , Hy * 0 , ’ C o l o r ’ , ’ r ’ , . . .
7 ’ L i n e W i d t h ’ , 1 . 5 , ’ l i n e s t y l e ’ , ’ −. ’ ) ;
t s = num2str ( t i m e s t e p ) ;
9 t i = num2str ( d t * t i m e s t e p * 1 e9 ) ;
t i t l e ( [ ’ time s t e p = ’ t s ’ , time = ’ t i ’ ns ’ ] ) ;
11 drawnow ;
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

B
Convolutional Perfectly
Matched Layer Regions and
Associated Field Updates for a
Three-Dimensional Domain

B.1 UPDATING E X AT CONVOLUTIONAL PERFECTLY MATCHED LAYER (CPML) REGIONS


Initialization
Create new coefficient arrays for Cψe xy and Cψe xz :

Cψe xy = yCe xhz Cψe xz = zCe xhy

Modify the coefficient arrays for Ce xhy and Ce xhz in the CPML regions:

 
Ce xhz = 1/κe y Ce xhz , in the yn and yp regions.
Ce xhy = (1/κe z ) Ce xhy , in the zn and zp regions.

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 n− 1 n+ 1
ψe xy 2 (i, j, k) = b e y ψe xy 2 (i, j, k) + a e y Hz 2 (i, j, k) − Hzn+ (i, j − 1, k) ,

403
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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
σ pe y  
ae y =   bey − 1 ,
y σ pe y κe y + αe y κe y
2

 
σ y
− κpe +α pe y t
bey = e ey ε
0 .

n+ 1
Calculate ψe xz 2 for the zn and zp regions:
 
n+ 1 n− 1 n+ 1 n+ 1
ψe xz 2 (i, j, k) = b e z ψe xz 2 (i, j, k) + a e z Hy 2 (i, j, k) − Hy 2 (i, j, k − 1) ,

where
σ pe z
ae z =   [b e z − 1] ,
z σ pe z κe z + αe z κe2z
 
σ z
− κpe +α pe z t
bez = e ez 0ε
.

Add the CPML auxiliary term to E x in the yn and y p regions:

n+ 1
E xn+1 = E xn+1 + Cψe 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 + Cψe xz × ψe xz 2 .
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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 coefficient arrays for Cψe y z and Cψe y x :

Cψe y z = zCe yhx Cψe y x = xCe yhz

Modify the coefficient arrays for Ce yhz and Ce yhx in the CPML regions:

Ce yhx = (1/κe z ) Ce yhx , in the zn and zp regions.


 
Ce yhz = 1/κe y Ce yhz , in the xn and xp 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) ,
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

406 Appendix B Convolutional Perfectly Matched Layer

where
σ pe z
ae z =   [b e z − 1] ,
z σ pe z κe z + αe z κe2z
 
σ z
− κpe +α pe z t
bez = e ez 0ε
.
n+ 1
Calculate ψe y x 2 for the xn and xp regions:
n+ 1 n− 1
 n+ 1 n+ 1

ψe y x 2 (i, j, k) = b e x ψe y x 2 (i, j, k) + a e x Hz 2 (i, j, k) − Hz 2 (i − 1, j, k) ,

where
σ pe x
ae x =   [b e x − 1] ,
x σ pe x κe x + αe x κe2x
σ t
− pe x +α
b e x = e ( κe x pe x ) ε0 .

Add the CPML auxiliary term to E y in the zn and zp regions:

n+ 1
E yn+1 = E yn+1 + Cψe 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 + Cψe y x × ψe y x 2 .

B.3 UPDATING E Z AT CPML REGIONS


Initialization
Create new coefficient arrays for Cψe zx and Cψe zy :

Cψe zx = xCe zhy Cψe zy = yCe zhx

Modify the coefficient 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) ,
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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
σ pe x
ae x =   [b e x − 1] ,
x σ pe x κe x + αe x κe2x
σ t
− pe x +α
b e x = e ( κe x pe x ) ε0 .

n+ 1
Calculate ψe zy 2 for the yn and y p regions:
 
n+ 1 n− 1 n+ 1 n+ 1
ψe zy 2 (i, j, k) = b e y ψe zy 2 (i, j, k) + a e y Hx 2 (i, j, k) − Hx 2 (i, j − 1, k) ,

where
σ pe y  
ae y =   bey − 1 ,
y σ pe y κe y + αe y κe y
2

 
σ y
− κpe +α pe y t
bey = e ey ε 0 .

Add the CPML auxiliary term to E z in the xn and xp regions:

n+ 1
E zn+1 = E zn+1 + Cψe 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 + Cψe zy × ψe zy 2 .
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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 coefficient arrays for Cψhxy and Cψhxz :

Cψhxy = yC hxe z Cψhxz = zC hxe y

Modify the coefficient arrays for C hxe y and C hxe z in the CPML regions:

 
C hxe z = 1/κmy C hxe z , in the yn and yp regions.
C hxe y = (1/κmz ) C hxe y , in the zn and zp regions.

FDTD Time-Marching Loop


Update Hx in the full domain using the regular updatingequation

n+ 12 n− 12
Hx (i, j, k) = C hxh (i, j, k) × Hx (i, j, k)
 
+ C hxe z (i, j, k) × E zn (i, j + 1, k) − E zn (i, j, k)
 
+ C hxe y (i, j, k) × E yn (i, j, k + 1) − E yn (i, j, k) .

Calculate ψhxy
n
for the yn and y p regions:

 
ψhxy
n
(i, j, k) = b my ψhxy
n−1
(i, j, k) + a my E zn (i, j + 1, k) − E zn (i, j, k) ,
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Appendix B Convolutional Perfectly Matched Layer 409

where
σ pmy  
a my =   b my − 1 ,
y σ pmy κmy + αmy κmy
2

 
σ
− κpmy +α pmy µt
b my = e my 0 .

Calculate ψhxz
n
for the zn and zp regions:
 
ψhxz
n
(i, j, k) = b mz ψhxz
n−1
(i, j, k) + a mz E yn (i, j, k + 1) − E yn (i, j, k) ,

where
σ pmz
a mz =   [b mz − 1] ,
z σ pmz κmz + αmz κmz
2
 
σ
− κpmz +α pmz µt
b mz = e mz 0 .

Add the CPML auxiliary term to Hx in the yn and y p regions:

n+ 12 n+ 12
Hx = Hx + Cψhxy × ψhxy
n
.

Add the CPML auxiliary term to Hx in the zn and zp regions:

n+ 12 n+ 12
Hx = Hx + Cψhxz × ψhxz
n
.

B.5 UPDATING H Y AT CPML REGIONS


Initialization
Create new coefficient arrays for Cψhy z and Cψhy x :

Cψhy z = zC hye x Cψhy x = xC hye z

Modify the coefficient 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 n− 12
Hy (i, j, k) = C hyh (i, j, k) × Hy (i, j, k)
 
+ C hye x (i, j, k) × E xn (i, j, k + 1) − E xn (i, j, k)
 
+ C hye z (i, j, k) × E zn (i + 1, j, k) − E zn (i, j, k) .
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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.

Calculate ψhy
n
z for the zn and zp regions:
 n 
ψhy
n
z (i, j, k) = b mz ψhy z (i, j, k) + a mz E x (i, j, k + 1) − E x (i, j, k) ,
n−1 n

where
σ pmz
a mz =   [b mz − 1] ,
z σ pmz κmz + αmz κmz
2
 
σ
− κpmz +α pmz µt
b mz = e mz 0 .

Calculate ψhy
n
x for the xn and xp regions:
 n 
ψhy
n
x (i, j, k) = b mx ψhy x (i, j, k) + a mx E z (i + 1, j, k) − E z (i, j, k) ,
n−1 n

where
σ pmx
a mx =   [b mx − 1] ,
x σ pmx κmx + αmx κmx
2

σ t
− pmx +α
b mx = e ( κmx pmx ) µ0 .

Add the CPML auxiliary term to Hy in the zn and zp regions:

n+ 12 n+ 12
Hy = Hy + Cψhy z × ψhy
n
z.

Add the CPML auxiliary term to Hy in the xn and xp regions:

n+ 12 n+ 12
Hy = Hy + Cψhy x × ψhy
n
x.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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 coefficient arrays for Cψhzx and Cψhzy :

Cψhzy = xC hze y Cψhzy = yC hze x

Modify the coefficient arrays for C hze x and C hze y in the CPML regions:

C hze y = (1/κmx ) C hze y , in the xn and xp regions.


 
C hze x = 1/κmy C hze x , in the yn and yp regions.

FDTD Time-Marching Loop


Update Hz in the full domain using the regular updating equation

n+ 12 n− 12
Hz (i, j, k) = C hzh (i, j, k) × Hz (i, j, k)
 
+ C hze y (i, j, k) × E yn (i + 1, j, k) − E yn (i, j, k)
 
+ C hze x (i, j, k) × E xn (i, j + 1, k) − E xn (i, j, k) .

Calculate ψhzx
n
for the xn and xp regions:

 
ψhzx
n
(i, j, k) = b mx ψhzx
n−1
(i, j, k) + a mx E yn (i + 1, j, k) − E yn (i, j, k) ,
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

412 Appendix B Convolutional Perfectly Matched Layer

where
σ pmx
a mx =   [b mx − 1] ,
x σ pmx κmx + αmx κmx
2

σ t
− pmx +α
b mx = e ( κmx pmx ) µ0 .

Calculate ψhzy
n
for the yn and y p regions:
 
ψhzy
n
(i, j, k) = b my ψhzy
n−1
(i, j, k) + a my E yn (i, j + 1, k) − E yn (i, j, k) ,

where
σ pmy  
a my =   b my − 1 ,
y σ pmy κmy + αmy κmy
2

 
σ
− κpmy +α pmy µt
b my = e my 0 .

Add the CPML auxiliary term to Hz in the xn and xp regions:

n+ 12 n+ 12
Hz = Hz + Cψhzx × ψhzx
n
.

Add the CPML auxiliary term to Hz in the yn and y p regions:

n+ 12 n+ 12
Hz = Hz + Cψhzy × ψhzy
n
.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

C
MATLAB Code for Plotting
Far-Field Patterns

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 , . . .
3 line style 1 , line style 2 , constant theta , . . .
legend 1 , legend 2 , s c a l e t y p e )
5

% t h i s f u n c t i o n p l o t s two p o l a r p l o t s i n t h e same f i g u r e
7 plot range = s t e p s i z e * number of rings ;
min val = max val − p l o t r a n g e ;
9

hold on ;
11 th = 0 : ( pi / 5 0 ) : 2 * pi ; c i r c l e x = cos ( th ) ; c i r c l e y = sin ( th ) ;
f o r mi = 1 : n u m b e r o f r i n g s
13 r = ( 1 / n u m b e r o f r i n g s ) * mi ;
plot ( r * c i r c l e x , r * c i r c l e y , ’ : ’ , ’ color ’ , ’ k ’ , ’ linewidth ’ ,1);
15 t e x t ( 0 . 0 4 , r , [ num2str ( m i n v a l + s t e p s i z e * mi ) ] ,...
’ v e r t i c a l a l i g n m e n t ’ , ’ bottom ’ , ’ c o l o r ’ , ’ k ’ ,...
17 ’ f o n t w e i g h t ’ , ’ demi ’ , ’ f o n t s i z e ’ , 1 0 ) ;
end
19

r =[0:0.1:1];
21 f o r mi = 0 : 1 1
t h=mi * p i / 6 ;
23 plot ( r * cos ( th ) , r * sin ( th ) , ’ : ’ , ’ c o l o r ’ , ’ k ’ , ’ l i n e w i d t h ’ , 1 ) ;
t e x t ( 1 . 1 * c o s ( t h ) , 1 . 1 * s i n ( t h ) , [ num2str ( 3 0 * mi ) ] , . . .
25 ’ horizontalalignment ’ , ’ center ’ , ’ color ’ , ’k ’ , . . .
’ f o n t w e i g h t ’ , ’ demi ’ , ’ f o n t s i z e ’ , 1 0 ) ;
27 end

29 pattern 1 ( find ( pattern 1 < min val ) ) = min val ;


pattern 1 = ( pattern 1 − min val ) / plot range ;
31 pattern 2 ( find ( pattern 2 < min val ) ) = min val ;
pattern 2 = ( pattern 2 − min val ) / plot range ;
33

% transform data to C a r t e s i a n coordinates

413
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

414 Appendix C MATLAB Code for Plotting Far-Field Patterns

35 x1 = p a t t e r n 1 . * c o s ( p h i ) ;
y1 = p a t t e r n 1 . * s i n ( p h i ) ;
37

x2 = p a t t e r n 2 . * c o s ( p h i ) ;
39 y2 = p a t t e r n 2 . * s i n ( p h i ) ;

41 % p l o t d a t a on t o p o f g r i d
p = p l o t ( x1 , y1 , l i n e s t y l e 1 , x2 , y2 , l i n e s t y l e 2 , ’ l i n e w i d t h ’ , 2 ) ;
43 t e x t ( 1 . 2 * cos ( pi / 4 ) , 1 . 2 * sin ( pi / 4 ) , . . .
[ ’ \ t h e t a = ’ num2str ( c o n s t a n t t h e t a ) ’ ˆ o ’ ] , . . .
45 ’ c o l o r ’ , ’ b ’ , ’ f o n t w e i g h t ’ , ’ demi ’ ) ;
legend ( p , legend 1 , legend 2 , ’ l o c a t i o n ’ , ’ s o u t h e a s t ’ ) ;
47 t e x t ( −1 , −1.1 , s c a l e t y p e , ’ f o n t s i z e ’ , 1 2 ) ;
t e x t ( 1 . 0 2 * 1 . 1 , 0 . 1 3 * 1 . 1 , ’ ¼ ’ , ’ fontname ’ , ’ s y m b o l ’ , . . .
49 ’ c o l o r ’ , ’ b ’ , ’ f o n t w e i g h t ’ , ’ demi ’ ) ;
t e x t ( 1 . 0 8 * 1.1 , 0.13 * 1.1 , ’ \ phi ’ , . . .
51 ’ fontname ’ , ’ a r i a l ’ , ’ c o l o r ’ , ’ b ’ , ’ f o n t w e i g h t ’ , ’ demi ’ , ’ f o n t s i z e ’ , 1 2 ) ;

53 i f c o n s t a n t t h e t a == 90
text (1.2 , 0 . 0 6 , ’ x ’ , ’ fontname ’ , ’ a r i a l ’ , . . .
55 ’ c o l o r ’ , ’ b ’ , ’ f o n t w e i g h t ’ , ’ demi ’ ) ;
t e x t ( 1 . 2 , 0 , ’ ¹ ’ , ’ fontname ’ , ’ s y m b o l ’ , . . .
57 ’ c o l o r ’ , ’ b ’ , ’ f o n t w e i g h t ’ , ’ demi ’ ) ;
t e x t ( 0 . 0 6 , 1 . 2 3 , ’ y ’ , ’ fontname ’ , ’ a r i a l ’ , . . .
59 ’ c o l o r ’ , ’ b ’ , ’ f o n t w e i g h t ’ , ’ demi ’ ) ;
t e x t ( 0 , 1 . 2 3 , ’ ¼ ’ , ’ fontname ’ , . . .
61 ’ s y m b o l ’ , ’ c o l o r ’ , ’ b ’ , ’ f o n t w e i g h t ’ , ’ demi ’ ) ;
t e x t ( 1 . 2 * cos ( pi / 4 ) , 1 . 1 8 * sin ( pi / 4 ) − 0 . 1 2 , . . .
63 ’ x y p l a n e ’ , ’ c o l o r ’ , ’ b ’ , ’ f o n t w e i g h t ’ , ’ demi ’ ) ;
end
65

a x i s ( [ − 1 . 2 1 . 2 −1.2 1 . 2 ] ) ;
67 a x i s ( ’ equal ’ ) ; a x i s ( ’ o f f ’ ) ;
hold o f f ;
69 s e t ( gcf , ’ PaperPositionMode ’ , ’ auto ’ ) ;
s e t ( gca , ’ f o n t s i z e ’ , 1 2 ) ;
 

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 , . . .
3 line style 1 , line style 2 , constant phi , . . .
legend 1 , legend 2 , s c a l e t y p e )
5

% t h i s f u n c t i o n p l o t s two p o l a r p l o t s i n t h e same f i g u r e
7 plot range = s t e p s i z e * number of rings ;
min val = max val − p l o t r a n g e ;
9

hold on ;
11 th = 0 : ( pi / 5 0 ) : 2 * pi ; c i r c l e x = cos ( th ) ; c i r c l e y = sin ( th ) ;
f o r mi = 1 : n u m b e r o f r i n g s
13 r = ( 1 / n u m b e r o f r i n g s ) * mi ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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


15 t e x t ( 0 . 0 4 , r , [ num2str ( m i n v a l + s t e p s i z e * mi ) ] , . . .
’ v e r t i c a l a l i g n m e n t ’ , ’ bottom ’ , ’ c o l o r ’ , ’ k ’ , . . .
17 ’ f o n t w e i g h t ’ , ’ demi ’ , ’ f o n t s i z e ’ , 1 0 ) ;
end
19

r =[ −1:0.1:1];
21 f o r mi = 3 : 8
t h=mi * p i / 6 ;
23 plot ( r * cos ( th ) , r * sin ( th ) , ’ : ’ , ’ c o l o r ’ , ’ k ’ , ’ l i n e w i d t h ’ , 1 ) ;
t e x t ( 1 . 1 * c o s ( t h ) , 1 . 1 * s i n ( t h ) , [ num2str ( 3 0 * ( mi − 3 ) ) ] , . . .
25 ’ horizontalalignment ’ , ’ center ’ , ’ color ’ , ’k ’ , . . .
’ f o n t w e i g h t ’ , ’ demi ’ , ’ f o n t s i z e ’ , 1 0 ) ;
27 t e x t ( − 1 . 1 * c o s ( t h ) , 1 . 1 * s i n ( t h ) , [ num2str ( 3 0 * ( mi − 3 ) ) ] , . . .
’ horizontalalignment ’ , ’ center ’ , ’ color ’ , ’k ’ , . . .
29 ’ f o n t w e i g h t ’ , ’ demi ’ , ’ f o n t s i z e ’ , 1 0 ) ;
end
31 t e x t ( 0 , − 1 . 1 , ’ 180 ’ , . . .
’ horizontalalignment ’ , ’ center ’ , ’ color ’ , ’k ’ , . . .
33 ’ f o n t w e i g h t ’ , ’ demi ’ , ’ f o n t s i z e ’ , 1 0 ) ;

35 pattern 1 ( find ( pattern 1 < min val ) ) = min val ;


pattern 1 = ( pattern 1 − min val ) / plot range ;
37 pattern 2 ( find ( pattern 2 < min val ) ) = min val ;
pattern 2 = ( pattern 2 − min val ) / plot range ;
39

% transform data to C a r t e s i a n coordinates


41 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

x2 = −p a t t e r n 2 . * c o s ( t h e t a +p i / 2 ) ;
45 y2 = p a t t e r n 2 . * s i n ( t h e t a +p i / 2 ) ;

47 % p l o t d a t a on t o p o f g r i d
p = p l o t ( x1 , y1 , l i n e s t y l e 1 , x2 , y2 , l i n e s t y l e 2 , ’ l i n e w i d t h ’ , 2 ) ;
49 t e x t ( 1 . 2 * cos ( pi / 4 ) , 1 . 2 * sin ( pi / 4 ) , . . .
[ ’ \ p h i = ’ num2str ( c o n s t a n t p h i ) ’ ˆ o ’ ] , . . .
51 ’ c o l o r ’ , ’ b ’ , ’ f o n t w e i g h t ’ , ’ demi ’ ) ;
legend ( p , legend 1 , legend 2 , ’ l o c a t i o n ’ , ’ s o u t h e a s t ’ ) ;
53 t e x t ( −1 , −1.1 , s c a l e t y p e , ’ f o n t s i z e ’ , 1 2 ) ;
t e x t ( 0 . 2 , 1 . 0 2 , ’ ¹ ’ , ’ fontname ’ , ’ s y m b o l ’ , ’ c o l o r ’ , ’ b ’ , ’ f o n t w e i g h t ’ , ’ demi ’ ) ;
55 t e x t ( 0 . 2 , 1 . 0 8 , ’ \ t h e t a ’ , ’ fontname ’ , ’ a r i a l ’ , ’ c o l o r ’ , ’ b ’ , . . .
’ f o n t w e i g h t ’ , ’ demi ’ , ’ f o n t s i z e ’ , 1 2 ) ;
57 t e x t ( − 0 . 2 1 , 1 . 0 2 , ’ \ l e f t a r r o w ’ , ’ c o l o r ’ , ’ b ’ , ’ f o n t w e i g h t ’ , ’ demi ’ ) ;
t e x t ( − 0 . 2 , 1 . 0 8 , ’ \ t h e t a ’ , ’ fontname ’ , ’ a r i a l ’ , ’ c o l o r ’ , ’ b ’ , . . .
59 ’ f o n t w e i g h t ’ , ’ demi ’ , ’ f o n t s i z e ’ , 1 2 ) ;

61 i f c o n s t a n t p h i == 0
t e x t ( 1 . 2 , 0 . 0 6 , ’ x ’ , ’ fontname ’ , ’ a r i a l ’ , ’ c o l o r ’ , ’ b ’ , ’ f o n t w e i g h t ’ , ’ demi ’ ) ;
63 t e x t ( 1 . 2 , 0 , ’ ¹ ’ , ’ fontname ’ , ’ s y m b o l ’ , ’ c o l o r ’ , ’ b ’ , ’ f o n t w e i g h t ’ , ’ demi ’ ) ;
t e x t ( 0 . 0 6 , 1 . 2 3 , ’ z ’ , ’ fontname ’ , ’ a r i a l ’ , ’ c o l o r ’ , ’ b ’ , ’ f o n t w e i g h t ’ , ’ demi ’ ) ;
65 t e x t ( 0 , 1 . 2 3 , ’ ¼ ’ , ’ fontname ’ , ’ s y m b o l ’ , ’ c o l o r ’ , ’ b ’ , ’ f o n t w e i g h t ’ , ’ demi ’ ) ;
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

416 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 ’ , . . .


67 ’ c o l o r ’ , ’ b ’ , ’ f o n t w e i g h t ’ , ’ demi ’ ) ;
end
69 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 ’ , ’ demi ’ ) ;
71 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 ’ ) ;
73 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.12 , ’ yz plane ’ , . . .
75 ’ c o l o r ’ , ’ b ’ , ’ f o n t w e i g h t ’ , ’ demi ’ ) ;
end
77

a x i s ( [ − 1 . 2 1 . 2 −1.2 1 . 2 ] ) ;
79 a x i s ( ’ equal ’ ) ; a x i s ( ’ o f f ’ ) ;
hold o f f ;
81 s e t ( gcf , ’ PaperPositionMode ’ , ’ auto ’ ) ;
s e t ( gca , ’ f o n t s i z e ’ , 1 2 ) ;
 
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Bibliography
[1] A. Taflove and S. C. Hagness, Computational Electrodynamics: The Finite Difference Time Domain Method,
3rd ed. Norwood, MA: Artech House Publishers, 2005.
[2] K. S. Yee, “Numerical solution of inital boundary value problems involving Maxwell’s equations in
isotropic media,” IEEE Transactions on Antennas and Propagation, vol. 14, pp. 302–307, 1966.
[3] R. Courant, K. Friedrichs, and H. Lewy, “On the Partial Difference Equations of Mathematical
Physics,” IBM Journal of Research and Development, vol. 11, no. 2, pp. 215–234, 1967.
[4] J. A. Kong, Electromagnetic Wave Theory. Cambridge, MA: EMW Publishing, 2000.
[5] S. Dey and R. Mittra, “Conformal finite-difference time-domain technique for modeling cylindrical
dielectric resonators,” IEEE Transactions on Microwave Theory and Techniques, vol. 47, no. 9, pp. 1737–
1739, September 1999.
[6] R. Schechter, M. Kragalott, M. Kluskens, and W. Pala, “Splitting of material cells and averaging prop-
erties to improve accuracy of the FDTD method at interfaces,” Applied Computational Electromagnetics
Society Journal, vol. 17, no. 3, pp. 198–208, 2002.
[7] D. E. Aspnes, “Bounds on allowed values of the effective dielectric function of two-component com-
posites at finite frequencies,” Physical Review B, vol. 25, no. 2, pp. 1358–1361, January 1982.
[8] N. Kaneda, B. Houshmand, and T. Itoh, “FDTD analysis of dielectric resonators with curved surfaces,”
IEEE Transactions on Microwave Theory and Techniques, vol. 45, no. 9, pp. 1645–1649, 1997.
[9] J.-Y. Lee and N.-H. Myung, “Locally tensor conformal FDTD method for modeling arbitrary dielectric
surfaces,” Microwave and Optical Technology Letters, vol. 23, no. 4, pp. 245–249, 1999.
[10] R. F. Harrington, Time-Harmonic Electromagnetic Fields. Hoboken, NJ: Wiley-IEEE Press, 2001.
[11] J. Fang and D. Xeu, “Numerical errors in the computation of impedances by the FDTD method and
ways to eliminate them,” IEEE Microwave and Guided Wave Letters, vol. 5, no. 1, pp. 6–8, January 1995.
[12] R. W. Anderson, “S-parameter techniques for faster, more accurate network design,” Hewlett-Packard
Company, Tech. Rep., November 1996.
[13] K. Kurokawa, “Power waves and the scattering matrix,” IEEE Transactions on Microwave Theory, vol. 13,
no. 2, pp. 194–202, 1965.
[14] D. Sheen, S. Ali, M. Abouzahra, and J. Kong, “Application of the three-dimensional finite-difference
time-domain method to the analysis of planar microstrip circuits,” IEEE Transactions on Microwave
Theory, vol. 38, no. 7, pp. 849–857, 1990.
[15] J.-P. Berenger, “A perfectly matched layer for the absorption of electromagnetic waves,” Journal of
Computational Physics, vol. 114, no. 2, pp. 185–200, October 1994.
[16] ——, “Three-dimensional perfectly matched layer for the absorption of electromagnetic waves,” Journal
of Computational Physics, vol. 127, no. 2, pp. 363–379, September 1996.
[17] W. V. Andrew, C. A. Balanis, and P. A. Tirkas, “Comparison of the Berenger perfectly matched layer
and the Lindman higher-order ABC’s for the FDTD method,” IEEE Microwave and Guided Wave
Letters, vol. 5, no. 6, pp. 192–194, 1995.
[18] J.-P. Berenger, “Perfectly matched layer for the FDTD solution of wave-structure interaction prob-
lems,” IEEE Transactions on Antennas and Propagation, vol. 44, no. 1, pp. 110–117, 1996.
[19] J. C. Veihl and R. Mittra, “Efficient implementation of Berenger’s perfectly matched layer (PML) for
finite-difference time-domain mesh truncation,” IEEE Microwave and Guided Wave Letters, vol. 6, no. 2,
pp. 94–96, 1996.
[20] S. D. Gedney, “An anisotropic perfectly matched layer-absorbing medium for the truncation of FDTD
lattices,” IEEE Transactions on Antennas and Propagation, vol. 44, no. 12, pp. 1630–1639, 1996.
[21] A. Taflove, Computational Electrodynamics: The Finite Difference Time Domain Method. Norwood, MA:
Artech House Publishers, 1995.

417
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

418 Bibliography

[22] A. Z. Elsherbeni, “A comparative study of two-dimensional multiple scattering techniques,” Radio


Science, vol. 29, no. 4, pp. 1023–1033, 1994.
[23] J. Roden and S. Gedney, “Convolution PML (CPML): an efficient FDTD implementation of the
CFS-PML for arbitrary media,” Microwave and Optical Technology Letters, vol. 27, no. 5, pp. 334–339,
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. 775–785, 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. 447–449,
1996.
[26] J.-P. B·erenger, Perfectly Matched Layer (PML) for Computational Electromagnetics. San Rafael, CA: Mor-
gan & Claypool Publishers, 2007.
[27] W. C. Chew and W. H. Weedon, “A 3D perfectly matched medium from modified Maxwell’s equations
with stretched coordinates,” Microwave and Optical Technology Letters, vol. 7, no. 13, pp. 590–604,
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 finite-difference time-domain near
zone to far zone transformation,” IEEE Transactions on Antennas and Propagation, vol. 39, no. 4, pp.
429–433, 1991.
[30] R. J. Luebbers, D. Ryan, and J. Beggs, “A two dimensional time domain near zone to far zone trans-
formation,” IEEE Transactions on Antennas and Propagation, vol. 40, no. 7, pp. 848–851, 1992.
[31] S. A. Schelkunoff, “Some equivalence theorem of electromagnetics and their application to radiation
problem,” Bell System Technical Journal, vol. 15, pp. 92–112, 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 Antennas—A Numerical Approach. Herts, UK: Research Studies Press Ltd.
[35] A. Z. Elsherbeni, C. G. Christodoulou, and J. Gomez-Tagle, Handbook of Antennas in Wireless Commu-
nications. 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 filter for 802.11 a/b/g WLAN radios in portable devices,” Microwave and Optical Technology
Letters, vol. 49, no. 8, pp. 1868–1872, 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. 2200–2207, 2005.
[38] K. Umashankar, A. Taflove, 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. 1248–1257, 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. 94–99, 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. 1077–1084, May 2003.
[43] V. Demir and A. Z. Elsherbeni, “A graphical user interface for calculation of the reflection and
transmission coefficients 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.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

Bibliography 419

[45] M. J. Inman and A. Z. Elsherbeni, “3D FDTD accelleration using graphical processing units,” Applied
Computational Electromagnetics Society (ACES) Conference, Miami, FL, 2006.
[46] ——, “Programming video cards for computational electromagnetics applications,” Antennas and Prop-
agation Magazine, IEEE, vol. 47, no. 6, pp. 71–78, December 2005.
[47] I. Buck, Brook Spec v0.2. Stanford, CA: Stanford University, 2003.
[48] M. Inman, A. Elsherbeni, B. N. Baker, and J. Maloney, “Practical implementation of a CPML absorbing
boundary for GPU accelerated FDTD technique,” IEEE APS Symposium, Honolulu, HI, 2006.
[49] G. Mur, “Absorbing boundary conditions for the finite difference approximation of the time domain
electromagnetic field equations,” IEEE Transactions on Electromagnetic Compatibility, vol. 23, no. 4, pp.
377–382, 1981.
[50] Z. P. Liao, H. L. Wong, B.-P. Yang, and Y.-F. Yuan, “A transmitting boundary for transient wave
analysis,” Scientia Sinica, Ser. A, vol. 27, no. 10, pp. 1063–1076, 1984.
[51] M. J. Inman and A. Z. Elsherbeni, “Interactive GPU based FDTD simulations for teaching applica-
tions,” Applied Computational Electromagnetics Society (ACES) Conference, Naigara Falls, Canada,
March 2008.
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

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 elec-
trical 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 Sys-
tem 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 assis-
tant 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 Com-
putational 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 1999–2001, 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, finite-difference time-domain analysis of passive and active microwave devices
including planar transmission lines, field visualization and software development for electro-
magnetics (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, reflector 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
fdtd_main SPIB005-Elsherbeni & Demir October 13, 2009 14:16

422 About the Authors

and Antenna Optimization Using Taguchi’s Method (Morgan & Claypool, 2007), and is the main au-
thor of the chapters “Handheld Antennas” and “The Finite Difference Time Domain Technique
for Microstrip Antennas” in Handbook of Antennas in Wireless Communications (CRC Press, 2001).
He has served as the main advisor for 31 M.S. and 8 Ph.D. students.
Dr. Elsherbeni is a fellow member of IEEE and of ACES. He is editor-in-chief of ACES Journal
and associate editor of the Radio Science Journal. He serves on the editorial board of the book series
on Progress in Electromagnetic Research, the Electromagnetic Waves and Applications Journal, and
the Computer Applications in Engineering Education Journal. He was chair of the engineering and
physics division of the Mississippi Academy of Science and was chair of the Educational Activity
Committee for the IEEE Region 3 Section.

Veysel Demir received his bachelor of science degree in electri-


cal engineering from Middle East Technical University, Ankara,
Turkey, in 1997. He received a scholarship award from the Renais-
sance Scholarship Program for graduate study in the United States
(2000–2004). 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 Soft-
ware, Inc., Liverpool, New York. He worked as a visiting research
scholar in the Department of Electrical Engineering at the Univer-
sity 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 numer-
ical analysis techniques—finite-difference time-domain (FDTD),
finite-difference frequency-domain (FDFD), and method of mo-
ments (MoM)—as well as microwave and radiofrequency (RF) cir-
cuit 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.
fdtd_ind SPIB005-Elsherbeni & Demir November 13, 2009 19:43

Index
A Courant-Friedrichs-Lewy (CFL), 33, 34, 36, 45
cputime, 119, 129, 249
absorbing boundary, 36, 187–229, 274 create bricks, 58, 61
absorbing boundary conditions (ABC), 36, 187, 371, create PEC plates, 65
377, 419 create spheres, 61
air buffer number of cells, 47, 201, 241 curl equation, 3, 13, 15, 23, 27, 71, 72, 331
Ampere’s law, 15, 52, 110 current source, 75–76, 81, 86, 90, 96, 101,
animation, 111, 114, 118, 128, 219, 222, 229, 355 122
anisotropic, 1, 43, 188, 236, 417, 418
axial ratio, 279
D
B define geometry, 48, 49, 61, 67, 69, 133, 137, 138,
163, 172, 181, 201, 222, 255, 264, 302, 308,
backward difference, 5–10 320, 322, 351, 358, 364
bandwidth, 151, 153, 164, 369 derivative of Gaussian waveform, 149–150, 151f
Berenger, 232 dielectric resonator antenna (DRA), 307
Berenger’s PML, 232 diode, 81–85–88, 104, 123, 124
bistatic RCS, 340, 350, 354f, 355f, 359f, 361 DirectX, 374, 380f
Blackman-Harris window, 143–144 discrete convolution, 234, 235
Boltzmann’s constant, 82 discrete Fourier transformation (DFT), 225, 229f,
boundary conditions, 47, 118, 187 272, 273f, 277, 284, 340
bricks, 48f, 58–59, 69, 312 dispersion relation, 38–40
Brook, 371, 373–374, 375–377 divergence equations, 3

C E
capacitor, 77, 81, 86, 104, 138–139, 139f, 141f, 161 electric charge, 2
central difference, 5f, 6, 7, 9f, 10, 12, 13, 16, 18, 23, electric conductivity, 3, 15, 47, 55, 56, 57
28, 38, 72, 78, 196, 233, 318 electric current, 2, 71, 125, 204, 276, 287
central processing unit (CPU), 369, 370, 376, 377 electric displacement, 2, 53
CFL condition, 34–37 electric field, 2, 3, 15, 17, 31
CFL limit, 36 evanescent modes, 240
characteristic impedance, 168, 261–267, 268f
circularly polarized (CP), 279
complex frequency-shifted PML (CFS-PML), 231, F
232, 240
constitutive relations, 2, 3 Faraday’s law, 15, 315
convolution, 233, 234, 235 far field, 271, 272, 273, 275, 277–280, 281, 307,
convolutional PML (CPML), 231, 232, 236–240, 322, 339, 351, 357, 366, 413
242–250, 269 far field calculation, 274, 276, 277, 278, 288, 291,
cosine modulated Gaussian, 151 296
cosine modulated Gaussian pulse, 143, 151 far field condition, 271, 272
cosine modulated Gaussian waveform, 151–152, far field pattern, 271, 279, 281, 288, 357,
152f, 153f, 161–166 413–416
courant factor, 46 far field radiation, 277, 281, 322

423
fdtd_ind SPIB005-Elsherbeni & Demir November 13, 2009 19:43

424 Index

far field radiation pattern, 277, 322 L


far sources, 143
far zone sources, 271, 272, 331 Laplace transform, 233
fast Fourier transform (FFT), 157, 374 late-time reflections, 231
FDTD program, 43, 201, 219, 225, 282 left hand circularly polarized (LHCP), 279, 280
field distribution, 219, 225, 229 linear indexing, 99
forward difference, 4f, 6, 7, 9f, 10 linearly polarized (LP), 279
Fourier spectrum, 46 local subcell models, 43
Fourier transform, 1, 108, 143, 144, 147, 150, 151, lumped circuit elements, 71
152f, 154, 157, 160, 161, 218, 225, 272, 280, lumped element component, 71, 86, 87, 90–97, 154,
286, 340 163, 257, 264, 303, 308, 323, 340, 352,
fragment processor, 372, 373 359
frequency dependent, 1 lumped elements, 71–139, 163f
frequency domain, 1, 108,143, 147, 150, 151, 154,
156–160, 225, 227, 232, 258, 277, 279, 284, 288

M
G magnetic charge, 2
magnetic conductivity, 3, 15, 47, 62, 67
Gaussian pulse, 41, 143, 147, 151 magnetic current, 2, 204, 276, 282, 284
Gaussian waveform, 29, 146–149, 149–151, magnetic field, 3, 4, 15, 18, 73, 108, 110f, 111, 114,
151–152, 153, 161–166 119, 125, 126f, 190, 193, 197, 207, 208,
graphical processing unit (GPU), 369, 370, 371, 210–215, 218, 234–236, 237f, 238, 247, 248f,
373, 372, 376, 377, 379 249, 287, 315, 316f, 318, 337, 345,
Green’s function, 1, 274 347, 348
magnetic flux, 2, 54
magnitude, 31, 36, 40, 41, 74, 114, 125, 148f, 225,
226f, 227f, 228f, 229f
H
matching condition, 192, 194, 233
material arrays, 55, 58
hard voltage source, 74–75
material cell, 50, 52f, 53f
material type, 47, 48, 55, 56, 59, 67, 69
Maxwell’s equations, 2, 4, 188, 189, 192, 193, 195,
I 199, 273
method of moments (MoM), 355
image theory, 276, 277f
impedance matching condition, 187, 192
impressed current, 71, 90, 98, 122, 204, 225
impressed current density, 3, 71, 79, 222
N
impressed electric current, 122, 204
near field, 271–310, 339
impressed magnetic current, 119, 204, 215
near sources, 143, 204
incident field, 72, 143, 331, 333, 336, 338, 341–344,
near zone sources, 331
345, 346, 347, 353, 360, 363, 366
negative direction, 47, 86
incident plane wave, 195, 336–341, 343, 349, 351
Newton-Raphson method, 83, 84, 124, 125
inductor, 71, 77f, 78–79, 90, 103, 122
nonlinear, 1, 71, 82, 83, 85, 150
ITERS, 373
number of cells per wavelength, 46, 146, 147,
153
number of time steps, 44, 46, 89, 117, 131, 161
K numerical dispersion, 37–41
numerical dispersion relation, 38, 39
Kernels, 373, 376 numerical stability, 33–37, 40
fdtd_ind SPIB005-Elsherbeni & Demir November 13, 2009 19:43

Index 425

O scattered field, 331, 332–336, 339, 340–350, 357f,


360, 363
one-dimensional, 26–31, 40, 41, 96, 117, 245, 376, scattered field formulation, 331–336, 340–350, 363,
399 364
OpenGL, 374 scattered field updating equation, 332–336, 344
output parameters, 111–118, 130, 158, 219, 225, scattering cross-section, 1
281, 307, 322 sinusoidal, 40, 89, 131–134, 144, 146
sinusoidal source, 131, 134
sinusoidal waveform, 89, 143–146, 152, 153, 222
P space increments, 34
space parameters, 44–48, 67, 180, 203
parallel computation, 1 S-parameters, 108, 169–178, 179f, 180, 252, 261
partial differential equation (PDE), 33 spheres, 48, 59, 61, 350–355, 357f
PEC boundaries, 31, 47, 118, 119, 121, 176, 187, stair-cased grid, 43, 55
217, 363f, 376 stair-cased gridding, 43, 55
perfect electric conductor (PEC) boundary, 31, 47, streams, 373, 375, 376, 377
118, 119, 121, 176, 187, 217, 363f, 376 stretched coordinate, 231–232
perfectly matched layer (PML), 187–229, 231, subcell modeling, 55, 56, 315
376 surface equivalence theorem, 272–276
perfectly matched layer (PML) absorbing boundary,
187–229, 376
permeability, 2, 15, 47, 54, 66f, 67, 89, 274 T
permittivity, 2, 15, 47, 50, 53, 54, 55, 56, 66f, 67,
240 tangential components, 53
phase, 147, 161, 189, 225, 254, 278, 280 Taylor series, 6, 7, 12
phase velocities, 37, 40 texture maps, 371, 372, 373
“pixel shaders,” 372 texture processes, 372
plane cuts, 66f, 114, 118, 128, 305f, 306f, 357 thin sheet, 56–57
plane wave, 37, 38, 187, 188f, 190f, 195, 336–341, thin wire, 57, 85, 315, 318, 319, 320, 321, 329
357 thin wire formulation, 315–322
positive direction, 47, 86 thin wire modelling, 57, 315, 318
three-dimensional, 3, 13–22, 39, 55, 62, 99, 113,
193–195, 240–250, 344, 377–379, 384, 391,
R 392
time domain, 2, 33, 34, 143, 147, 154–158, 161,
radar cross section (RCS), 108, 271, 339 165, 166f, 233, 277, 369
radiation efficiency, 280 time increment, 34, 36
recursive convolution, 235–236 time shift, 149, 150, 157, 161
resistor, 75f, 76–77, 79–81, 92, 104, 131–134, 180, time step, 15, 17, 30f, 31, 36, 46, 88, 89, 108, 111,
256 122, 124, 125, 128, 156, 176, 225, 235, 236,
right hand circularly polarized (RHCP), 279, 280 277, 345
total field, 331, 332, 343, 363
transistors, 71, 369
S two-dimensional, 22–26, 27, 39, 192, 196, 199, 201,
202, 249, 375–377, 380, 382, 388,
sampled current, 110, 125, 134, 135f, 170, 180, 392f
253f, 262
sampled electric field, 125, 131, 202, 225, 226f, 357,
360 U
sampled voltage, 108, 109f, 117, 128, 134, 135f,
136f, 138, 161, 170, 176, 177f, 178f, 180, 252, updating coefficient, 97, 98, 100, 101, 102, 103,
256, 262 104, 105, 106, 107, 121, 208, 321, 344
fdtd_ind SPIB005-Elsherbeni & Demir November 13, 2009 19:43

426 Index

updating equation, 13, 22, 23, 25, 26–31, 74, 76, 79, W
86, 90, 96, 97, 98, 101, 103, 196, 197, 199–201,
233, 236–238, 249, 315, 318, 332–336, 344, wave equation, 33, 37, 38
403, 405, 406, 409, 411 waveforms, 29, 40, 87, 143–166, 338
wavelength, 146, 147, 153, 271
V wavenumber, 271, 291

voltage, 71, 72–74, 80, 85, 86, 90, 95, 98, 101,
108–111, 121, 128, 131, 134, 135f, 136f, Y
138–139, 180, 252f
voltage source, 72–75, 80, 86, 89, 96, 98, 101, Yee cell, 13, 14, 16, 23, 55, 56f, 59, 62, 110, 121,
121–122, 131, 161, 180, 307 125
voltage source updating equation, 101 Yee grid, 43–67, 63f

You might also like