Testing Ourselves
Levent Sevgi Doğuş University Electronics and Communications Eng. Dept. Zeamet Sokak, No 21, Acibadem — Kadiköy Istanbul  Turkey Email: lsevgi@dogus.edu.tr, levent.sevgi@ieee.org
http://www3.dogus.edu.tr/lsevgi
W e have introduced many computer codes and virtual tools for electromagnetic modeling and simulation in
the Magazine for nearly a decade. I’m very glad to see that those tools are used in several universities and institutions, even in national research centers, from USA to Japan, Europe to Australia and Africa. Most of those tools can be downloaded from http://modsim.dogus.edu.tr (and may also be requested from the authors), and be used in teaching/training in virtual undergraduate labs as well in graduatelevel research. Now, we’re happy to announce they can also be downloaded from my new Web site (http://leventsevgi.net). The list of the tutorials we have introduced since February 2007 may also be found there.
We have received several requests and questions on some of our FiniteDifference TimeDomain (FDTD)based virtual tools from our readers, who have experienced MATLABbased coding/compiling/version problems. I have assigned Miss Gizem Toroglu, the youngest research and teaching assistant in our department at Doğuş University, to reshape (as well as redevelop) a collection of MATLABbased core FDTD codes in two dimensions (2D), without the need for any toolbox and/or special command/macro, and to present them in her interdepartmental seminar this semester. I liked the way she tailored and presented these codes. Although there were a number of FDTD codes and packages, I therefore decided to share them with our readers, through the tutorial we prepared for this purpose in this issue (by the way, the tutorial on novel RCS measurement approaches by B. Fisher is on the way). Those codes mentioned in this issue’s tutorial are already there, under EM Virtual Tools, at leventsevgi.net. I hope the readers
will enjoy having them and find them useful.
We have already discussed “Statistical Decision Making” [1] and “Biostatistics” with hypothetical tests on cellphone users using statistical decision making [2]. What about “Strategic Decision Making?” The study of strategic decision making is called “Game Theory.” We, engineers, have mostly been familiar with game theory after a wonderful movie, A Beautiful Mind, a 2001 American biographical drama film based on the life of John Nash, a Nobel Laureate in Econom ics. John Nash, who introduced the Nash equilibrium concept, was played by Russell Crowe. I’m glad to announce that I have finally convinced Prof. Benan Zeki Orbay, former Dean of the Faculty of Economics and Administrative Sciences, and current Chair of the Department of Economics and Finance at Doğuş University, to prepare a tutorial on game theory. She is going to give a presentation entitled “Game Theory and Engineering Applications” in one of our interdepartmental seminars in April 2014. Hopefully, we’ll extend it to an interesting tutorial.
References
1. L. Sevgi, “Hypothesis Testing and Decision Making: Con
stantFalseAlarm Rate,” IEEE Antennas and Propagation Magazine, 51, 3, June 2009, pp. 218224.
2. L. Sevgi, “Biostatistics and Epidemiology: Hypothetical
Tests on Cell Phone Users,” IEEE Antennas and Propagation Magazine, 52, 1, February 2010, pp. 267273.
220
IEEE Antennas and Propagation Magazine, Vol. 56, No. 2, April 2014
FiniteDifference TimeDomain (FDTD) MATLAB Codes for First and SecondOrder EM Differential Equations
Gizem Toroğlu, Levent Sevgi
Electronics and Communications Engineering Department Doğuş University Zeamet Sokak 21, Acıbadem – Kadıköy, 34722 Istanbul – Turkey Email: lsevgi@dogus.edu.tr
Abstract
A set of twodimensional (2D) electromagnetic (EM) MATLAB codes, using both ﬁrstorder coupled differential (Maxwell) equations and secondorder decoupled (wave) equations, are developed for both transversemagnetic (TM) and transverseelectric (TE) polarizations. Secondorder MUR type absorbing boundary conditions are used to simulate free space. Metamaterial (MTM) modeling is also included. Performance tests in terms of computational times, memory requirements, and accuracies were done for simple EM scenarios with magnetic ﬁeld, current, and voltage comparisons. The codes may be used for teaching and research purposes.
Keywords: Maxwell equations; ﬁnitedifference timedomain; FDTD; wave equation; absorbing boundary conditions; MUR conditions; transverse electric; TE; transverse magnetic; TM; metamaterials; MTM; MATLAB
1. Introduction
T he FiniteDifference TimeDomain (FDTD) method is one of the most powerful numerical approaches widely used in
solving a broad range of electromagnetic (EM) problems since its first introduction [1] (a quick Internet search will list tens of thousands of FDTD studies). A few of the many useful books written on the FDTD are [28]. Information related to the FDTD may also be found in Wikipedia [9]. The books on the parallel FDTD [10] and FDTDbased metamaterial (MTM) modeling [11] are also worth mentioning. We have also presented many useful tutorials, and have shared our codes and virtual tools for a long time [1219]. Table 1 lists these free FDTDbased virtual tools, with short explanations. These and many more can be found in the IEEE Press/John Wiley book recently published within the Press series on EM Wave Theory [20].
The MATLABbased codes and virtual tools in [12] use the onedimensional FDTD for the planewave propagation modeling and simulation through inhomogeneous media, and in [13] for voltage/current wave transmission and reflection along a transmission line (TL) under different termination and impedancemismatch conditions. The TDRMeter virtual tool
IEEE Antennas and Propagation Magazine, Vol. 56, No. 2, April 2014
in [13] can be used for the visualization of both transmission/ reflections and fault identification.
A generalpurpose twodimensional FDTD virtual tool, MGL2D [14], and its modified version, MTMFDTD [15], can be used in the modeling and simulation of EM waves in two dimensions. A variety of electromagnetic problems, from indoor/outdoor radiowave urban/rural propagation to electro magnetic compatibility (EMC), from resonators to closed/open periodic structures, linear and planar arrays of radiators can be simulated easily with MGL2D. The beauty of MGL2D comes from its visualization power, as well as its easytouse design steps. Similarly, MTMFDTD may be used for the visualiza tion of EM waves interacting with different metamaterials. Snapshots during these interactions may be taken. Scenarios with normal and oblique incidences, demonstrating focusing beams in planar metamaterials and the existence of a negative refractive angle, respectively, may be observed in the time domain. In addition, video clips of wave metamaterial inter actions may easily be recorded.
The MATLABbased virtual tool WedgeFDTD was devel oped to investigate EM scattering on the canonical nonpene
221
Table 1. Free FDTDbased EM Virtual Tools presented in the IEEE Antennas and Propagation Magazine.
Virtual Tool 
Explanation 

1DFDTD 
A 
MATLABbased 1D FDTD simulation of plane wave propagation in time domain through single, double 
or threelayer media. EM parameters are supplied by the user [12]. 

TDRMeter 
A virtual timedomain reflectometer virtual tool. It is used to locate and identify faults in all types of metallic paired cable. Fourier and Laplace analyzes are also possible [13]. 

MGL2D 
A 
general purpose 2D FDTD package for both TE and TM type problems. Any 2D scenario may be created 
by the user by just using the mouse [14]. 

MTMFDTD 
Modified version of MGL2D to simulate cylindrical wave propagation through MeTaMaterials (MTM) 

[15]. 

WedgeFDTD ^{*} 
A 
2D MATLABbased simulator for the modeling of EM diffraction from a semiinfinite nonpenetrable 
wedge using high frequency asymptotics and FDTD [16] ( ^{*} published in ACES). 

A 
3D FDTDbased EM simulator for the broadband investigation of microstrip circuits. The user only needs 

MSTRIP 
to 
picture the microstrip circuit via computer mouse on a rectangular grid, to specify basic dimensions and 
operational needs such as the frequency band, simulation length [18]. 

MGLRCS 
A 3D FDTDbased EM simulator for RCS prediction. The user only needs to locate a 3D image file of the target in 3DS graphics format, specify dimensions and supply other user parameters. The simulator predicts RCS vs. angle and/or RCS vs. frequency [19]. 
trable wedge problem with the FDTD method [16]. Diffracted fields may easily be extracted and compared with the results of highfrequency asymptotic (HFA) models. Some interesting applications of the twodimensional FDTD method were also discussed in one of our tutorials [17]. There, FDTDbased path planning and segmentation were modeled and implemented.
Finally, fullwave, 3DFDTD EM virtual tools have been prepared and reviewed in tutorials [18] and [19] for realistic problem modeling and simulations. In [18], MSTRIP was introduced for the investigation of a variety of microstrip cir cuits. MSTRIP is a 3DFDTD EM simulator that uses the pow erful perfectly matched layer terminations (PML) [21]. The user needs only to render the microstrip circuit via a computer mouse on a rectangular grid, and to specify basic dimensions and supply operational requirements, such as the frequency band and simulation length. The rest is handled by MSTRIP. It is easytouse, strengthened with visualization and videoclip capabilities, and can handle very complex single and double layer microstrip structures. Timedomain visualization is pos sible during the simulations and video clips may be recorded. The S parameters are automatically calculated, and may be displayed online.
In [19], a threedimensional FDTDbased RCS prediction virtual analysis tool (MGLRCS) was introduced. It can be used to design any kind of a PEC target using basic blocks, such as a rectangular prism, cone, cylinder, sphere, etc. A collection of predesigned surface and air targets stored in 3DS format files, are also supplied. Timedomain near scattered fields can be simulated around the object under investigation, and transients can be recorded as video clips. Far fields are then extrapolated, and RCS as a function of frequency and RCS as a function of angle plots can be produced (FORTRAN source codes of this package may also be found in [4]).
222
2. The TwoDimensional FDTD Models
The FDTD method [1] discretizes Maxwell equations by replacing derivatives with their finitedifference approxima tions, directly in the time domain. It is simple, easy to code, but has the openform (iterative) solution. It is therefore con ditionally stable: one needs to satisfy a stability condition. The FDTD volume is finite, and therefore may model only closed regions. Freespace simulation is an important task in FDTD, and various effective boundary terminations have been devel oped for the last two decades (see [22] for the secondorder MURtype terminations used here). Broadband (pulse) excita tion is possible in the FDTD, but inherits the numericaldisper sion problem. Finally, only near fields can be simulated around the object under investigation; far fields can be extrapolated using the Equivalence Principle (e.g., the StrattonChu equa tions) [4].
2.1 FirstOrder Coupled Equations
The assumption of a continuous translational symmetry along z lets us reduce the threedimensional problem into two dimensions on the xy plane. Maxwell equations in such an environment are characterized with three parameters (the per mittivity, ε , permeability, µ , and conductivity, σ ):
∇×
∇×
E
H
= −
H
µ ^{∂}
t
∂
=
ε
E
∂
∂ t
+
,
σ
E .
(1)
(2)
IEEE Antennas and Propagation Magazine, Vol. 56, No. 2, April 2014
These reduce to two sets of scalar equations (i.e., TM _{z} and TE _{z} ) in two dimensions under the assumption ∂∂z ≡ 0 , and can be given as [23]
SET #1: TM _{z} (
H
z
≡
0
)
−
µ
∂
H
x
∂
t
=
∂
E
z
∂ y
,
(3a)
µ
∂
H
y
∂
t
=
∂
E
z
∂
x
,
(3b)
ε
∂
E
z
∂
H
y
∂
H
x
=−−
∂∂∂ t xy
σ
E
z
,
(3c)
SET #2: TE _{z} (
E
z
ε
∂
E
x
∂
t
=
∂
H
z
∂
y
≡
−
0
)
σ
E
x
,
ε
−
∂
E
y
∂
t
=−
∂
H
z
∂ x
−
σ
E
y
,
∂
H
z
∂
E
y
∂
E
x
µ .
∂
t
=−
∂∂ xy
(4a)
(4b)
(4c)
As observed, knowing the
derive all the other field components for the TM _{z} ( TE _{z} ) prob lem. The discretized FDTD iteration equations then reduce to
( H ) component is enough to
E
z
z
SET #1: TM _{z} (
H
z
≡
0
)
H
n n
x
x
(
ij
H
, ,
)
−
1
(
= −
ij
)
∆
t
∆
µ
y
E
nn
ij ,
E
(
)
(
−−
ij ,1
zz
(5a)
H
n n
y
y
(
ij
H
, ,
)
= +
1
−
(
ij
)
∆
t
∆
µ
x
E
nn
ij ,
−−
E
i
(
)
(
zz
(5b)
n
z
E
+ 1
(
ij ,
)
2 ^{=}
2
ε
−
σ
∆ t
t
∆
ε
+
σ
2
∆ t
+
2
ε
+∆
σ
t
−
2 ∆ t
2
ε
+∆
σ
t
n
z
E
n
y
H
(
ij ,
)
(
ij
,
)
−
n
y
H
(
i
− 1,
j
)
n
x
H
(
ij
,
)
∆
x
−
n
x
H
(
ij
−
,1)
∆
y
(5c)
SET #2: TE _{z} (
E
z
≡
0
)
1,
j
,
)
)
,
,
IEEE Antennas and Propagation Magazine, Vol. 56, No. 2, April 2014
n
x
E
( ij ,
)
E ij
z
,
n
(
)
n
z
H
(
ij
,
)
=
2
ε
−
∆ t
σ
2
ε
+
∆ t
σ
E
n − 1
x
−
2 ∆ t
(
2
ε
+∆
σ
t )
∆ y
(
ij ,
)
)
n
H
z
(
ij
,
−
n
z
H
(
,1
ij
−
(6a)
=
2
ε
−
∆ t
σ
2
ε
+
∆ t
σ
E
n − 1
z
(
+
2
∆ t
(
2
ε
+∆
σ
t
)
∆ x
ij ,
)
n
z
H
(
ij
,
(6b)
)
−
n
z
H
(
i
=
n − 1 z
H
+
∆
t
µ
0
(
ij
,
n
y
E
)
(
ij
,
)
−
n
y
E
(
i
−
1,
j
)
∆
x
−
∆
t
µ
0
n
x
E
(
ij
,
)
−
n
x
E
(
,1
ij
−
)
∆
y
.
(6c)
−
1,
j
)
)
,
2.2 SecondOrder Decoupled Equations
Two of the three field components in Equations (3) and (4)
can be eliminated, and a secondorder differential (wave)
equation with a single field component can be obtained. For example, the following wave equation for the TM _{z} problem can be directly obtained from Equation (3c) using Equa tions (3a) and (3b):
∂∂ xy
∂∂ +−
22
22
1
εµ
∂
2
∂
t
2
−
µσ
∂
∂
t
E
z
= 0 .
This equation, defined for
t ≥
0;
0
≤≤x
X
max
, 0
≤≤yY
max
,
(7)
(8)
together with the boundary conditions
E
z
E
z
E
z
E
z
(
(
(
(
0,
yt
,
x
,0,
t
X
max
)
= g
1
)
= g
2
yt
,,
)
(
(
yt
,
xt
,
= g
3
)
)
(
for
for
yt
,
)
xY
,,
max
t
)
= g
4
(
xt
,
)
and, the initial conditions
x =
y =
0, 0
0, 0
≤≤yY
max
≤≤xX
max
,
,
(9a)
(9c)
for
x = X
max
, 0
≤≤yY
max
(9b)
for
yY=
max
, 0
≤≤xX
max
(9d)
,
223
E
z
(
xy
,
,0
)
= f
1
(
xy
,
)
,
∂ E
z
(
xy
,
,0
)
∂ t
= f
2
(
xy
,
)
,
(10a)
(10b)
are enough to solve for
Equation (7) can therefore also be used in the FDTD modeling and simulations. The FDTD discretized form of Equation (7) is
and the other field components.
E
z
n +
z
E
1
(
ij
,
)
=
+
+
4
(
1 −
p
−
q
)
g
n
z
E
(
ij
,
)
−
t
g
n
z
E
−
1
2 p
g
2 q
g
(
n
Ei
z
−+
1,
j
)
n (
E
z
,1
ij
−+
)
(
n
Ei
z
+
1,
j
)
n
z
E
(
,1
ij
+
)
(11)
(
ij
,
)
where
p
q
v
∆ t
∆ x
2
v
∆ t
∆ y
2
,
(12a)
g
2
2 + µσ vt∆ ,
t
−+2
2
µσ vt∆
(12b)
v =
1
(12c)
Note that the dispersion and stability conditions, as well as the source injection in time, are handled just like the firstorder coupled FDTD equations. On the other hand, the values at the
) must
be supplied for the spatial source injection.
first two time instants of E (i.e.,
z
0
E
z
(
ij
,
)
1
and E
z
(
ij
,
)
2.3 Basic Features of the FDTD Equations
The observations listed below are important for the numerical implementation of the firstorder coupled (FOC) FDTD model:
• There are three field components ( H
x
TM _{z} and
E
x
,
E
y
, and
H
z
^{,}
for
for TE _{z} ) in each cell,
and they are distinguished by the _{(}_{i}_{,} j) label for the firstorder coupled FDTD model.
H
y ^{,}
E
z
• The discretization steps are ∆x, ∆y , and ∆t , and the
,
physical quantities are calculated from
x = ix∆
y = jy∆
, and t = nt∆
.
224
• Since the FDTD equations are iterative (i.e., open form solutions), they are conditionally stable. The Courant stability condition, which states that the time step cannot be arbitrarily specified once the spatial discretization is done, must be satisfied.
• Although
n
H
z
(
ij
,
and
) , are used, their locations are different in
the classical Yee cell [1] (see Figure 1), and there is
a halftimestep difference between the E and H field computation times. That is, the magneticfield components are calculated at time steps t = ∆t 2 ,
the
same
notations,
n
E
x
(
ij
,
)
, but the electric fields are calcu
lated at time steps t =∆ttt, 2∆ ,3∆ ,
.
Figure 1. The Yee cells for the (a) TM _{z} and (b) TE _{z} prob lems.
IEEE Antennas and Propagation Magazine, Vol. 56, No. 2, April 2014
• Only
E
n − 1
z
larly,
H
n − 1
x
(
neighboring
magneticfield
ij
,
)
are required to update
n
z
E
(
neighboring
electricfield
ij
,
)
are required to update
n
x
H
values
(
)
ij
values
.
,
(
ij
,
)
and
. Simi
and
•
Both magnetic and electricfield components in any cell may be moved to the origin by just cell averaging. This is accomplished via
for mag
netic fields, but four electricfield components are required for this purpose:
H
x
(
ij
,
)
= 0.5 H
(
ij ++H
,
i
)
(
1,
j
)
_{}
xx
E
z
(
ij
,
)
= 0.25 E
(
ij ++E
,
i
)
(
zz
+E
z
(
1)
ij ++ E
,
z
(
i +
1,
1,
j +
)
j
1) ^{.}
• Any object may be modeled by giving ε , µ , and σ . Two of these, ε and σ , appear in the electric field components, and the third, µ , appears in the magneticfield components.
• Three different ε and σ values may be assigned for three electricfield components, so that different objects may be located within the Yee cell. Simi larly, different µ values may be given for Hfield components for the same purpose.
The important aspects of the secondorder decoupled (SOD) FDTD model are as follows:
• There is only one field component, and its location may be anywhere in the unit cell.
• The models and discrete equations are identical for the TM _{z} and TE _{z} problems.
• The past two values are needed in every cell.
• FDTD iterations yield only
E
z
( TM _{z} )
or
H
z
( TE _{z} ). One therefore needs to write down another discrete (Maxwell) equation for the other two com
ponents, i.e.,
H
x
,
H
y
( TM _{z} ) or
E
x
,
E
y
( TE _{z} ).
2.4 Absorbing Boundary Conditions
To make it simple in this tutorial, the secondorder MUR terminations [22] are used. Table 2 lists equations that must be satisfied along the boundaries (see Figure 2). The discrete iteration equations will then be
IEEE Antennas and Propagation Magazine, Vol. 56, No. 2, April 2014
At
+
_{+}
At
_{+}
x = 0
( N = N
x
)
n
z
E
+
1
(
1,
jE
= −
)
n
z
−
1
(
2,
j
)
(
∆
ct
)
2
∆
x
+
+
2
∆
y
(
2
(
∆ +∆
ct
x
∆
ct
)
2
∆
x
)
2
∆
y
2
(
∆ +∆
ct
x
)
ct
ct
∆
−∆ x
+∆ x
ct
∆
2
∆ x
∆ +∆
x
n
z
E
n
z
E
+
1
(
(
2,
2,
+
jE
)
n
z
−
jE +
)
n
z
(
1,
1
(
1,
j
)
j
n
z
E
n
z
E
(
(
2,
1,
j
j
)
+− 1
)
+− 1
2
E
nn
2,
+
jE
(
)
zz
2
E
nn
1,
jE +
(
)
zz
(
(
2,
1,
j
)
j
−
−
1
(13)
x = X
max
( N = N
x
)
1
)
)
n
z
E
+
1
(
Nj
,
)
1
=−
+
+
+
∆
ct
n
z
−
(
N
E
−∆ x
−
1,
j
n +
z
E
1
)
(
N
1,
j
)
ct
∆
2
+∆ x
∆ x
n
z
E
(
N
ct
(
∆ +∆
∆
ct
x
)
2
∆
x
2 ∆ y
2
(
∆ +∆
ct
x
)
−
−
1,
j
)
+
(
EN
z
n
+
n
z
E
−
1
(
Nj ,
n
z
E
(
Nj
,
)
−
1,
j
+
1
)
)
(
∆
ct
)
2
∆
x
−
2 ∆ y
2
(
∆ +∆
ct
x
)
2 EN
n
z
(
−
1,
n
z
E
(
Nj ,
j
)
+
(
EN
z
n
1,
j
−−
1)
)
+− 12
E
nn
Nj ,
+
E
(
)
zz
(
Nj ,
−
1
(14)
)
Table 2. Differential equations for the secondorder MUR terminations.
x 
= 0 

0 
≤ 
y 
≤ Y max 
x = 
X max 

0 
≤ 
y 
≤ Y max 
y 
= 0 

0 
≤ 
x 
≤ X max 
y 
= 
Y max 

0 
≤ 
x 
≤ X max 
∂∂∂
1
c
2
22
=
0
→
E
z
(
0,
,
yt
)
=
0
→
∂
∂
xt
+−
∂
c
t
2
2 ∂
y
2
E
z
(
X
max
,, yt
)
→
(
Ex
z
,0,
t
)
=
0
→
E
z
(
xY ,
max
)
,0 t =
225
Figure 2. The boundary cells used in MUR terminations.
At
_{+}
+
At
+
226
y = 0 ( N = N
y
)
1
+
Ei
z
n
(
,1
)
= −
1
Ei
z
n
−
(
,2
)
(
∆
ct
)
2 ∆
y
+
+
2 ∆
x
(
2 (
∆ +∆
ct
y
∆
ct
)
2 ∆
y
)
2 ∆
x
2 (
∆ +∆
ct
y
)
ct
ct
2
∆
∆
−∆ y
+∆ y
∆ y



∆ +∆
ct
y
1
+
Ei
z
n
(
,2
)
(
n
Ei
z
,2
)
+
+
1
Ei
z
n
−
(
(
n
Ei
z
,1
)
,1
)
(
n
Ei
z
(
n
Ei
z
)
+− 1, 2
)
+− 1,1
2
nn
Ei
, 2
+
Ei
(
)
(
zz
−
1, 2
)
2
nn
Ei
,1
+
Ei
(
)
(
zz
−
1,1
)
(15)
y = Y
max
( N = N
y
)
n
z
E
+
1
(
iN
,
)
=−
n
z
E
−
1
(
,1
iN
−
)
+
+
ct
∆
−∆ y
ct
∆
+∆ y
2 ∆ y
ct
∆
+∆ y
^{}
n +
z
E
1
(
iN ,1
−
)
n
z
E
(
,1
iN
−
)
+
+
n
z
E
−
1
(
n
z
E
(
iN
,
iN ,
)
_{+}
(
∆
ct
)
2
∆
y
2 ∆ x
2
(
∆ +∆
ct
y
)
(
n
Ei
z
+
1,
N
−
1
)
)
(
∆
ct
)
2
∆
y
−
2 ∆ x
2
(
∆ +∆
ct
y
)
2 E
n
z
(
n
z
E
Гораздо больше, чем просто документы.
Откройте для себя все, что может предложить Scribd, включая книги и аудиокниги от крупных издательств.
Отменить можно в любой момент.