An Interactive 1D Matlab FDTD Code
An Interactive 1D Matlab FDTD Code
ABSTRACT: This paper describes a 1D Matlab finite difference time-domain (FDTD) code
with a graphical user interface for visualization of the time-domain electromagnetic response.
The program animates time-domain reflection and transmission of a Gaussian plane wave
through one or two homogeneous material slabs. 2001 John Wiley & Sons, Inc. Comput Appl Eng
Educ 9: 136147, 2001
Keywords:
INTRODUCTION
The finite difference time-domain (FDTD) method
[1] has become widely used for the simulation of
electromagnetic radiation and scattering problems.
The method is relatively simple to understand and
implement, yet it is capable of modeling very complex
geometrical configurations comprising many different
types of materials and it can provide wide frequency
response data from a single calculation.
This paper describes a simple 1D Matlab [2] FDTD
formulation and an interactive computer program, and
illustrates the use of the developed code. The program
has been developed primarily for educational use to
model the time-domain reflection and transmission of
a Gaussian plane wave through one or two homogeneous material slabs. It has a graphical user
interface (GUI) for setting the parameters of the
FDTD simulation that provides the user with the ability to quickly change parameters and see the effects
of the new parameters on the simulation results. The
program presents the results of the FDTD simulation
Correspondence to A. W. Glisson ([email protected]).
2001 John Wiley & Sons, Inc.
136
1D FDTD
Total Field Formulation
For the 1D simulation we consider the case of a
Gaussian plane wave propagating in the x-direction,
and having only a y-component of electric field and a
z-component of magnetic field. In the total field
formulation, the time-domain Maxwells equations
for this special case reduce to
@Ey 1
@Hz
e
Ey ;
@t
@x
"
@Hz 1
@Ey
m H z ;
@t
@x
where ", , e , and m are the permittivity, permeability, electric conductivity, and magnetic conductivity of the medium, respectively, and Ey and Hz
represent the total electromagnetic fields. These
constitutive parameters may be functions of x in the
general 1D case, but for this work we assume they are
constants within each of the material slabs and in the
surrounding space.
Using central finite differences in time and space
for the derivatives in (1), one can obtain the secondorder accurate FDTD update equations for a total field
formulation as [3]
Eyn1 i Ceye iEyn i Ceyh i
"
#
Hzn1=2 i 12 Hzn1=2 i 12
;
x
1
n1=2
i
2
Hz
2
1
1
Chzh i Hzn1=2 i
2
2
n
1 Ey i 1 Eyn i
;
Chze i
2
x
where the notation F n i represents F evaluated
at time t nt and spatial position x ix,
with t being the simulation time step and x the
space increment. The coefficients C in (2) are defined
by
"r i Ce e i
;
"r i Ce e i
2Ce
;
Ceyh i
"r i Ce e i
r i Ch m i
;
Chzh i
r i Ch m i
2Ch
;
Chze i
r i Ch m i
Ceye i
Ey Eys Eyinc ;
Hz Hzs Hzinc ;
137
Ey " "0
Ey ;
"
@t
@x
@t
@Eys
@Hzs 1
@H inc
m Hzs 0 z m Hzinc :
@t
@x
@t
5
@t
"i
e i inc;n1=2
E
i;
"i y
1
Hzs;n1=2 i
2
1
1
1
s;n1=2
i
Chze i
Chzh i Hz
2
2
2
s;n
s;n
Ey i 1 Ey i
x
n
i 12 0 @Hzinc i 12
@t
i 12
m
1
i 2 inc;n
1
H
6
i :
2
i 12 z
where "r and r are the relative permittivity and permeability, Ce t=2"0 ; and Ch t=20 : It should
also be noted that field averaging has been used
for the undifferentiated field components in (1) to
obtain (2).
138
Excitation Waveform
A Gaussian pulse waveform is used as the excitation
for the FDTD simulation. The expression for the
Gaussian pulse is defined as
x xp ct2
inc
;
Ey x; t exp
SYSTEM REQUIREMENTS
The user must have access to Matlab to run the 1D
FDTD simulation program. The program was developed and tested under Matlab version 5.3. The program consists of two preparsed pseudocode (pcode)
Matlab files:
gui_fdtd_1d.p
gui_fdtd_dataentry.p
These files are available at the Applied Computational Electromagnetics Society (ACES) web site,
http://aces.ee.olemiss.edu. Both files must be in the
Matlab search path.
PROGRAM USAGE
Termination of the Computational Domain
The program allows for the termination of the
computational domain on either side by a perfect
electric conductor (PEC) or a first-order Mur absorbing boundary condition [4]. The PEC boundary
condition is enforced in the total field formulation
by setting Ey 0 at the boundary for all values of
the time index n. In the scattered field formulation,
the PEC boundary condition is enforced by setting
Eys Eyinc at the boundary.
The first-order Mur absorbing boundary is based on
the use of a one-way wave equation at each boundary,
which permits only outward propagation from the
computational domain. The FDTD update equations
for the electric field at the boundary in the total field
formulation can then be written as
ct x
ct x
Eyn1 ib 1 Eyn ib ;
Eyn1 ib Eyn ib 1
Figure 2 The incident pulse after one time step and the material region boundaries in the main
simulation window using the default parameters.
139
140
change the plot range to avoid clipping the timedomain response in the graph window. Conversely,
reducing the plot range value also allows one to view
lower amplitude details in the plot.
141
electric field and the total electric field are equal, the
curve appears in green in the simulation window.
EXAMPLE SIMULATIONS
Computation Boundaries
The properties of both the left and right boundaries of
the computation domain can be chosen in this section.
The first-order Mur absorbing boundary condition is
used when absorbing is chosen. Since the incident
pulse starts within the computation domain, it is
possible to choose both the left and right boundaries
as PEC if desired.
Formulation Type
In this section the user can choose to use a total field
formulation, a scattered field formulation in which the
time derivative of the incident field is computed
exactly, or a scattered field formulation in which the
time derivative of the incident field is computed
numerically. When a scattered field formulation is
chosen, the simulation window shows plots of both the
scattered electric field (as a blue curve) and the total
electric field (as a red curve). When the scattered
Figure 4 Simulation using scattered field formulation with the default parameters, and with exact
differentiation of the excitation term.
142
Numerical Dispersion
The next example illustrates the problem of numerical
dispersion. For this example, the total field formulation is used and the default simulation parameters are
Figure 5 Simulation using scattered field formulation with the default parameters, and with
numerical differentiation of the excitation term.
143
Figure 6 Simulation using scattered field formulation with ct=x 0:5, and with exact
differentiation of the excitation term.
Media Averaging
The final example illustrates the effect of changes in
the manner in which the medium parameters are
modeled at an interface. For this example, the total
field formulation is used and the default simulation
parameters are used except that the dielectric constant
of the slab has been set to "r 4, the relative permeability has been set to r 4, and the pulse width
has been set to 600 ps to reduce numerical dispersion.
With these parameters, the impedance of the slab is
the same as that of free space, so there should be no
reflection of the incident pulse at either slab interface.
For the case in which media averaging has been set
to off, Figure 9 shows the simulation result just after
the pulse has completely penetrated the left boundary
of the slab. When media averaging is off and a
medium parameter at the interface is required by an
FDTD update equation, the program simply uses the
value of the medium parameter immediately to the
right of the interface. This introduces an additional
error into one of the update equations and the result is
a significant reflection from the interface as shown in
Figure 9.
144
Figure 7 Simulation using total field formulation with the default parameters, except that the
dielectric constant of the slab is "r 80.
Figure 8 Simulation using total field formulation with an incident pulse of width 1000 ps for the
slab with dielectric constant "r 80.
Figure 9 Simulation showing computed reflection from the interface of a slab with parameters
"r 4 and r 4 when media averaging is off.
Figure 10 Simulation showing computed reflection from the interface of a slab with parameters
"r 4 and r 4 when media averaging is on.
145
146
REFERENCES
CONCLUSION
In this paper, we have described a simple 1D Matlab
FDTD code that has been developed primarily for
educational use and have provided examples of its
use. The program models the time-domain reflection
and transmission of a Gaussian plane wave through
one or two homogeneous material slabs. The program
allows the user to choose between several different
models for the same situation, such as using either a
total field formulation or a scattered field formulation.
It has a GUI for setting the parameters of the FDTD
BIOGRAPHIES
Allen W. Glisson received the BS, MS,
and PhD degrees in electrical engineering
from the University of Mississippi, in
1973, 1975, and 1978, respectively. In
1978, he joined the faculty of the
University of Mississippi, where he is
currently a professor of electrical engineering. He was selected as the Outstanding Engineering Faculty Member in
1986 and again in 1996. He received a Ralph R. Teetor Educational
Award in 1989. His current research interests include the
development and application of numerical techniques for treating
electromagnetic radiation and scattering problems, and modeling of
dielectric resonators and dielectric resonator antennas. Dr. Glisson
has been actively involved in the areas of numerical modeling of
arbitrarily shaped bodies and bodies of revolution with surface
integral equation formulations. He has also served as a consultant to
several different industrial organizations in the area of numerical
modeling in electromagnetics.
147
Copyright of Computer Applications in Engineering Education is the property of John Wiley & Sons, Inc. and
its content may not be copied or emailed to multiple sites or posted to a listserv without the copyright holder's
express written permission. However, users may print, download, or email articles for individual use.