Function Reference: 7.1 Set Basic Parameters
Function Reference: 7.1 Set Basic Parameters
Function Reference
Note: This chapter is incomplete.
A complete list of all available FDTD functions shall be provided in this chapter.
In order to use these functions, just include pFDTD.h and pFDTDvar.h in the
header part of your c le. Note that this function reference is for FDTD-X2 version
0.510.
7.1 Set Basic Parameters
First, we must set up some basic parameters, such as the domain size and the grid
resolution. The FDTD domain is assumed to be a cube (a regular hexahedron).
Three-dimensional arrays will be created to store electric and magnetic elds and
various auxiliary quantities. The use of mirror symmetry as well as the periodic
boundary condition may be set here.
1. void structure size(oat x, oat y, oat z) :
Set the FDTD domain size as x(a) y(a) z(a). Here, a represents the unit
length in FDTD. For example, when dealing with photonic crystals, the lattice
constant associated with the photonic crystal in question will be a natural choice
for the FDTD unit length. The coordinate origin (0,0,0) of FDTD is assumed
to be located at the center of the block-shaped FDTD domain. Therefore, for
example, the FDTD coordinate x will vary from -x/2 to +x/2.
2. void lattice size(int lx, int ly, int lz) :
Set the resolution of space grids The higher number means the higher reso-
lution. The grid size in the x direction will be x = a/lx. You can set different
resolutions for different directions, x, y, z, which will be useful if the struc-
ture in question has much ner features in one or two dimensions but not in all
three dimensions (Anisotropic, uniform grid). Note that lx is the same term as
lattice
x
in Sec.(5.3). For the simulation of 2-D photonic crystal slab structures,
71
72 7 Function Reference
lx=ly=lz=20 are routinely used. Also note that at least 2 grids should be set in
each direction to perform FDTD time updates.
3. void non uniform grid(char *component, oat z i, oat z f, int nlz) :
Non-uniform space grids can now be set after version 8.60. However, as of June
28th, 2011, this function works only for z direction. Thus, *component is mean-
ingless and should be set only as z. One can redene the grid resolution for
the range [z = z i, z = z f] to be nlz. In order not to violate the central difference
approximation of FDTD, nlz shouldnt be changed too much from the original
grid resolution of lz - Generally, nlz should be chosen such that nlz/lz < 2 or
lz/nlz < 2. This function is still in the middle of upgrade.
4. void pml size(int il,int ir,int jl,int jr,int kl,int kr) :
Set the thickness of Perfectly Matched Layers (PMLs), which are articial ab-
sorbing boundary conditions. Here, for example, il and ir are applied for the side-
walls at x =(x/2)(a) and at x = +(x/2)(a), respectively. j- and k- are for the y
and z directions, respectively. The PML thickness takes grid as its unit, which
means, for example, if lattice
x
=20 and il=10, the thickness will be 10 grids or
0.5(a). In most cases, il=ir=jl=jr=kl=kr=10 are good numbers and you may take
them as default values.
5. void set default parameter(oat S) :
Set a number of basic parameters. A list of such parameters are shown in the
below.
a. =3.1415926
b.
0
= 8.854 10
12
c.
0
= 4 10
7
d. the speed of light, c = 1.0/
0
e. Numerical stability parameter, S, can be explicitly set, namely, S=S. Note
that S in our FDTD is reciprocal to the well-known Courant stability param-
eter (See Taove[9] and also Sec. 5.3).
f. One FDTD time step will be set by S through t = 1/(cS).
g. More parameters are needed to completely specify the properties of PMLs.
(Details shall be given in the forthcoming version.) As shown in the below,
these parameters will take the following values by default.
orderxl = 3.5; orderyl = 3.5; orderzl = 3.5;
orderxr = 3.5; orderyr = 3.5; orderzr = 3.5;
sig axl = 1.0; sig ayl = 1.0; sig azl = 1.0;
sig axr = 1.0; sig ayr = 1.0; sig azr = 1.0;
kx = 1.0; ky = 1.0; kz =1.0;
h. Set parameters needed for using the GSL
1
random number generator.
gsl rng env setup();
rng type = gsl rng default;
rng r = gsl rng alloc(rng type);
gsl rng set(rng r, 1234);
1
GNU Scientic Library. For more information, visit www.gnu.org/software/gsl/
7.1 Set Basic Parameters 73
Here, gsl rng set() initializes the GSL random number generator with the
seed value of 1234. You may alter the seed value through gsl rng set(rng r,).
6. void set sigma max(oat axl, oat axr, oat ayl, oat ayr, oat azl, oat
azr) :
This function may be called to ne tune a certain set of PML parameters. sig axl
sig azr can be rened by this function. If you do not call this, these values
will take the default values as dened by set default parameters().
7. void set sigma order(oat oxl, oat oxr, oat oyl, oat oyr, oat ozl, oat
ozr) :
This function may be called to ne tune a certain set of PML parameters. orderxl
orderzr can be rened by this function. If you do not call this, these values
will take the default values as dened by set default parameters().
8. void set kappa(oat kappa x, oat kappa y, oat kappa z) :
This function may be called to ne tune a certain set of PML parameters. kx, ky,
kz can be rened by this function. If you do not call this, these values will take
the default values as dened by set default parameters().
9. void Hz parity(int x,int y,int z) :
Set mirror symmetry conditions if the structure under consideration retains cer-
tain mirror symmetries. Possible input values will be one of the three, {-1,0,+1}
0 turns off the symmetry condition while 1 or -1 sets even or odd symme-
try with respect to the associated symmetry plane (For example, x applies to the
x =0 plane). Note, however, the denitions of even and odd are completely oppo-
site to the physical denitions. Our denitions are based on how magnetic elds
are changed under mirror operations (Thus, the name H
z
comes out here). This is
because we will mostly deal with photonic-crystal cavity modes with TE like
symmetry, where H
z
act like pseudoscalar.
(Important to remember) There are two things you should keep in mind when
using this symmetry condition.
(1) The total number of grids should be even integer for the direction to
which one wants to set the mirror symmetry condition. For example, x(xsize)
lx(lattice x) = even number, for the mirror symmetry condition with respect
to the x = 0 plane.
(2) The location of a point dipole source should be within the third quad-
rant (where both coordinates are minus values including zeros). For exam-
ple, the location of the dipole source should be x 0, when the mirror
symmetry condition is to be applied for the x = 0 plane. This rule also ap-
plies for other source functions, such as Gaussian dipole source(), Gaus-
sian line source(), random Gaussian dipole(), and incoherent point dipole().
10. void periodic boundary(int x on, int y on, oat k x, oat k y) :
Set the Bloch-Floquet periodic boundary conditions. If the structure under con-
sideration retains discrete or continuous translational symmetry in either x or y
direction, the periodic boundary conditions can be set on(=1) or off(=0) through
74 7 Function Reference
x on and y on variables. Examples where this function might be useful include
photonic-crystal waveguides and 2-D square-lattice photonic-crystals. k x and
k y are Bloch wavevectors in the x and y directions, respectively. The range of
these wavevectors will lie between 0 and 0.5, as a result of the normalization
by 2/L, where L denotes the FDTD domain size in the x direction or in the y
direction.
One may redene these wavevectors through the following reserved variables,
wave vector x, wave vector y. In the case when one does not call out this
function, by default, FDTD does not invoke the use of the periodic boundary
condition, i.e., x on=y on=0.
In general, when both k x and k y are not simultaneously zero at the same time,
FDTD requires double sized memory, one for real elds and one for imaginary
elds. However, when both k x and k y are zero (Gamma point), FDTD can use
much simpler time update equations where only real elds are involved. In this
case, in the subsequent memory() function, memory arrays for imaginary elds
will not be created. Therefore, do not set both k x and k y to be zero, if you are to
redene Bloch wavevectors through wave vector x, wave vector y variables.
11. void material complexity(int input) :
From FDTD version-X, three types of dispersive media can be handled; single-
pole Drude media (SD), single-pole Lorentz media (SL), and double-pole Lorentz
media (DL). Using this function, you have to tell the compiler what level of com-
plexity your FDTD code would require with regard to the material type. For ex-
ample, if you do not call this function, the complier will assume that the structure
in question does not have any dispersive media and therefore, it will assume input
= 0 as a default. If your structure involves only SD along with normal dielectric
media (ND), the level of the complexity number will take input = 1. The higher
input number means your structure involves more complex dispersive media
In the case of DL, input = 4, which will be the highest input value.
It is true that any medium can be categorized into DL. However, the dielectric
function for DL requires seven tting parameters with more additional auxiliary
arrays than the other lower level material types. Certainly, DL contains SL, and
SL contains SD, and nally, SD contains ND. Mathematically, this relationship
can be rewritten as
DL SL SD ND
Several representative cases are described and corresponding input values are
given in the below.
a. input = 0 : No dispersive medium anywhere in the structure. Only ND are
included.
b. input = 1 : SD or SL are included along with ND.
c. input = 4 : DL is included along with other lower level material types,
{SD, SL, ND}.
Currently, this function is in the middle of upgrade to minimize the use of mem-
ory. The idea came out of MIT MEEP[26], where the entire computational do-
main is divided into a number of chunks and each chunk will contain a dif-
7.1 Set Basic Parameters 75
ferent level of the material complexity. This is one of the many things being
upgraded here at Caltech.
12. void Gaussian planewave TF SF(oat position, oat eps bg, oat fre-
quency, long to, long tdecay) :
13. void memory() :
Declare and initialize all 3-D/2-D variables for E and H elds and etc. Some
elds arrays may not be created depending on the settings in the above functions.
Therefore, this function cannot proceed any of the functions described ahead
of this.
14. void real space param(oat a nm, oat w n) :
Print out an ASCII text le, Real Space Param.dat, which contains certain
useful information on some physical quantities in terms of real space unit(See
Sec. 5.3) a nm is the FDTD unit length a in unit of nanometer (10
9
meter) and
w n is the normalized frequency of a resonance in question.
Note that this w n will be used in the calculation of the effective susceptibility,
e f f
.
2
2
See, for instance, total EM energy block()
76 7 Function Reference
7.2 Set up dielectric/metallic/dispersive media
Here we provide a list of functions that are related to the denitions of various di-
electric/metallic/dispersive media. An object will have both exterior and interior
properties. Examples of exterior properties are shape and size. A variety of
simple geometrical shapes such as sphere and block can be set by using these
functions and then combined to create a more complex object. One must dene its
interior properties as well so that the FDTD can determine how light should prop-
agate within such objects. In the case of a simple dielectric medium, an example of
such interior properties will be a dielectric constant, . An object can take more
complex interior properties in the case of dispersive media. Currently (as of July
17th, 2011), a single-pole Drude medium (SD), a single-pole Lorentz medium (SL),
and a double-pole Lorentz medium (DL) can be handled along with a normal di-
electric medium (ND). For each material type, there exist functions related to it. To
show this relationship, functions are grouped depending on their material types in
the below.
ND:
background(),
input object(),
input object Euler rotation(),
random object(),
make epsilon()
SD:
input Drude medium(),
input Drude medium2(),
make Lorentz structure()
SL:
input Lorentz medium(),
make Lorentz structure()
DL:
input double Lorentz medium(),
make double Lorentz structure()
One can dene objects by using input functions while actual 3-D memories
related to those objects will be created by using make functions. Note that SD and
SL are unied into the same single-pole Lorentz medium form, which means that
these two material types will be handled equally in actual internal processes. This
is the reason why SD and SL have the same material complexity number, 1, for
using material complexity().
There are several rules one must keep in mind dening complex structures in-
volving both ND and dispersive media. Now let us assume that the FDTD domain
consists of a mixture of ND, SD, SL, and DL. Therefore, in general, a certain grid
point specied by (i, j, k) may have multiply dened internal properties.
7.2 Set up dielectric/metallic/dispersive media 77
(1) The priority of the material type or internal property is such that {DL} >
{SD = SL} > {ND}. For example, any dispersive medium will take over any
ND.
(2) Among ND, the latter input object will take over the former input object.
Here, the sequence of input objects is determined by the order of appearance
in an actual c code. One of the useful tips to create a complex normal dielectric
structure is to apply this rule For example, one can drill a hole by dening a
cylinder object with = 1.0 (air).
(3) Among dispersive media (SD, SL, and DL), there is no such sequential rule
as the rule (2) for ND. The resulting geometrical shape will be a union of all
input functions subjected to the rule (1).
(4) To dene a certain truncated geometrical shape in a predened dispersive
medium shape, input functions can be set as removers, usually by having all
zero parameters related to their internal properties. This rule can be used to
dene a certain ND structure (that will occupy the region A) inside a dispersive
medium First, remove the region A of the dispersive medium. Then, use an
input object function to dene for the region A.
1. void background(oat epsilon) :
The entire FDTD domain will be lled with a uniform dielectric medium with
a dielectric constant of epsilon. For example, to dene a background as silica,
epsilon can be set as 1.45*1.45.
2. void input object(char *shape, char *matrix le, oat centerx, oat cen-
tery, oat centerz, oat size1, oat size2, oat size3, oat epsilon) :
One can dene normal dielectric media (ND) with simple geometric shapes,
where materials are assumed to be linear, isotropic, and non-dispersive.
*shape can take one of the geometric shapes (See Fig.(7.1) ) to be described
in the below. Note that unused input parameters are denoted by EMP (Empty
variable, which is dened to be 0 in pFDTD.h). size1, size2, size3 should be
represented in unit of a.
a. rod : A cylinder aligned in the z direction.
*matrix le : EMP
centerx, centery, centerz : The center of mass coordinate
size1 : Radius of the cylinder as is seen in the x y plane
size2 : Height of the cylinder along the z direction
size3 : EMP
epsilon : A dielectric constant () of the material
b. rodX : A cylinder aligned in the x direction.
*matrix le : EMP
centerx, centery, centerz : The center of mass coordinate
size1 : Radius of the cylinder as is seen in the y z plane
size2 : Height of the cylinder along the x direction
size3 : EMP
epsilon : A dielectric constant () of the material
78 7 Function Reference
c. rodY : A cylinder aligned in the y direction.
*matrix le : EMP
centerx, centery, centerz : The center of mass coordinate
size1 : Radius of the cylinder as is seen in the z x plane
size2 : Height of the cylinder along the y direction
size3 : EMP
epsilon : A dielectric constant () of the material
d. donut : A cylinder with a donut cross-section lying in the z direction.
*matrix le : EMP
centerx, centery, centerz : The center of mass coordinate
size1 : Inner radius as is seen in the x y plane
size2 : Outer radius as is seen in the x y plane
size3 : Height of the cylinder in the z direction
epsilon : A dielectric constant () of the material
e. sphere : A sphere.
*matrix le : EMP
centerx, centery, centerz : The center of mass coordinate
size1 : Radius
size2 : EMP
size3 : EMP
epsilon : A dielectric constant () of the material
f. shell : A spherical shell (crust).
*matrix le : EMP
centerx, centery, centerz : The center of mass coordinate
size1 : Inner radius
size2 : Outer radius
size3 : EMP
epsilon : A dielectric constant () of the material
g. ellipse : Acylinder with an ellipse cross-section lying in the z direction. The
two principal axes of the ellipse are assumed to lie in the x and y directions,
respectively.
*matrix le : EMP
centerx, centery, centerz : The center of mass coordinate
size1 : Radius of the ellipse measured in the x direction (=Rx)
size2 : Height of the cylinder in the z direction
size3 : Ratio of Rx/Ry, where Ry is the radius measured in the y direction.
epsilon : A dielectric constant () of the material
h. ellipsoidal : A 3-D ellipsoidal. The three principal axes are assumed to lie
in the x, y, and z directions, respectively.
*matrix le : EMP
centerx, centery, centerz : The center of mass coordinate
size1 : Radius x (=Rx)
size2 : Radius y (=Ry)
size3 : Radius z (=Rz)
epsilon : A dielectric constant () of the material
7.2 Set up dielectric/metallic/dispersive media 79
i. cone : A conical cylinder whose axis of the rotation lie in the z direction.
*matrix le : EMP
centerx, centery : The center of mass coordinate
centerz : The center of the height (=size3)
size1 : Radius of the circle on the top (=R1)
size2 : radius of the circle at the bottom (=R2)
size3 : Height of the cylinder (=H)
epsilon : A dielectric constant () of the material
j. block : Acube or a regular hexahedron. The three principal axes are assumed
to lie along the x, y, and z directions, respectively.
*matrix le : EMP
centerx, centery, centerz : The center of mass coordinate
size1, size2, size3 : Side lengths along the x, y, and z directions, respectively.
epsilon : A dielectric constant () of the material
k. hexapillar : A cylinder with a hexagon cross-section lying in the z direc-
tion. The six vertex points of the hexagon are determined by the well-known
complex equation, (x +iy)
6
= R.
*matrix le : EMP
centerx, centery, centerz : The center of mass coordinate
size1 : Radius of the circumscribed circle of the hexagon as is seen in the
x y plane
size2 : Height of the cylinder along the z direction
size3 : EMP
epsilon : A dielectric constant () of the material
l. hexapillarY : A cylinder with a hexagon cross-section lying in the y direc-
tion. The six vertex points of the hexagon are determined by the well-known
complex equation, (x +iz)
6
= R.
*matrix le : EMP
centerx, centery, centerz : The center of mass coordinate
size1 : Radius of the circumscribed circle of the hexagon as is seen in the
z x plane
size2 : Height of the cylinder along the y direction
size3 : EMP
epsilon : A dielectric constant () of the material
m. hexapillarR : A cylinder with a hexagon cross-section lying in the z direc-
tion. The six vertex points of the hexagon are determined by the well-known
complex equation, (y +ix)
6
= R.
*matrix le : EMP
centerx, centery, centerz : The center of mass coordinate
size1 : Radius of the circumscribed circle of the hexagon as is seen in the
x y plane
size2 : Height of the cylinder along the z direction
size3 : EMP
epsilon : A dielectric constant () of the material
80 7 Function Reference
n. contour : A 3-D region of space swept by the parallel transport of a cer-
tain contour diagram lying in the x y plane along the z direction. For more
information, see Sec. 5.3.1 about contour FDTD.
*matrix le : 2-D ASCII text matrix (MN) from which the contour infor-
mation will be extracted.
centerx, centery : The center coordinate of the contour image in the unit of
the grid of the matrix le. This point will be brought to the center (x = y =
0.0a) of the FDTD domain.
centerz : The vertical center of the 3-D contour structure in the unit of the
FDTD unit length, a.
size1 : Discrimination level. The 2-D matrix le contains scalar values of
(x, y). The contour lines are dened by the discrimination level such that
(x, y) = size1. By default, we select the area (x
0
, y
0
) that satises the in-
equality, (x
0
, y
0
) size1.
size2 : Height (or thickness) of the 3-D contour structure in the unit of the
FDTD unit length, a.
size3 : Compression factor (or magnication). The matrix data (x, y) usually
contains a higher-resolution image than what is to be drawn for the FDTD
computation. Thus, one must shrink its size to t into the FDTD scale. For
example, let us assume that N
m
grids in (x, y) correspond to N
F
grids in the
FDTD space. Then, size3 should be set as N
F
/N
m
.
epsilon : A dielectric constant () of the material
3. void input object Euler rotation(char *shape, char *matrix le, oat cen-
terx, oat centery, oat centerz, oat size1, oat size2, oat size3, oat
alpha, oat beta, oat gamma, oat epsilon) :
One can perform 3-D Euler rotations dened by the three Euler angles of , ,
on a few selected object shapes. As of July 17th, 2011, *shape can take only
rod, ellipse, ellipsoidal, and block.
The Euler rotation is dened by the following matrix form, [R].
[R] =
_
_
cos sin 0
sin cos 0
0 0 1
_
_
_
_
1 0 0
0 cos sin
0 sin cos
_
_
_
_
cos sin 0
sin cos 0
0 0 1
_
_
Other input parameters have the same meanings as in void input object(). For
more information, see Note Euler.pdf on the web.
4. void input Drude medium(char *shape, char *matrix le, oat centerx,
oat centery, oat centerz, oat size1, oat size2, oat size3, oat ep-
silon b, oat omega p, oat gamma 0, oat lattice n) :
One can dene single-pole Drude media (SD) with simple geometric shapes,
where materials are assumed to be linear, isotropic, and dispersive. The Auxiliary
Differential Equation (ADE) method (See Taove Chap. 9[9] and Sec. 4.2) has
been adopted to implement the following form of a single-pole Drude dielectric
function.
7.2 Set up dielectric/metallic/dispersive media 81
Fig. 7.1 List of geometrical shapes that can be used in various input object functions.
() =
2
p
2
+ j
A proper set of
,
p
, should be chosen depending on the material type and
the valid range of the frequency. Some of useful Drude parameters are given in
the below.
lattice n is the FDTD unit length, a, in the unit of meter.
82 7 Function Reference
a. Gold
600nm - 2000nm (n, k data from Johnson and Christy
3
)
= 10.48449
p
= 1.37555 10
16
rad/s
= 1.1774510
14
rad/s
b. Silver
340nm - 1240nm (n, k data from Palik
4
)
= 4.08598
p
= 1.331610
16
rad/s
= 1.130810
14
rad/s
330nm - 660nm (n, k data from Palik)
= 4.39211
p
= 1.349910
16
rad/s
= 2.021810
14
rad/s
330nm - 660nm (n, k data from Johnson and Christy)
= 5.25729
p
= 1.452510
16
rad/s
= 7.065610
13
rad/s
*shape can take all the geometric shapes that can be used in input object() ex-
cept for hexapillarY, and hexapillarR (As of July 19th, 2011). Note that unused
input parameters can be set as EMP.
Important note on how to set up a metal remover: Both epsilon b and
omega p should be set to be zeros.
On the other hand, one can set up a perfect conductor by having epsilon b=1000.
Both the electric eld and the magnetic eld will be forced to zeros within such
a medium during the FDTD time stepping.
5
5. void input Lorentz medium(char *shape, char *matrix le, oat centerx,
oat centery, oat centerz, oat size1, oat size2, oat size3, oat ep-
silon b, oat omega p, oat gamma 0, oat omega 0, oat lattice n) :
One can dene single-pole Lorentz media (SL) with simple geometric shapes,
where materials are assumed to be linear, isotropic, and dispersive. The Auxiliary
Differential Equation (ADE) method (See Taove Chap. 9[9] and Sec. 4.3) has
been adopted to implement the following form of a single-pole Lorentz dielectric
function.
() =
2
p
2
0
2
j
3
P. B. Johnson and R. W. Christy, Optical Constants of the Noble Metals, Phys. Rev. B, Vol. 6,
4370 (1972).
4
E. D. Palik Handbook of Optical Constants of Solids
5
Note that this is a kind of unphysical boundaryconditions, which can often cause the numerical
instability.
7.2 Set up dielectric/metallic/dispersive media 83
Aproper set of
,
0
,
p
, should be chosen depending on the material type and
the valid range of the frequency. Note that this model is indeed a generalization
of the single-pole Drude model by adding the natural oscillation frequency,
0
.
6. void input double Lorentz medium(char *shape, oat centerx, oat cen-
tery, oat centerz, oat size1, oat size2, oat size3, oat epsilon b,
oat omega p 1, oat gamma 0 1, oat omega 0 1,oat omega p 2, oat
gamma 0 2, oat omega 0 2, oat lattice n) :
One can dene double-pole Lorentz media (DL) with simple geometric shapes,
where materials are assumed to be linear, isotropic, and dispersive. The Auxiliary
Differential Equation (ADE) method (See Taove Chap. 9[9] and Sec. 4.4) has
been adopted to implement the following form of a double-pole Lorentz dielec-
tric function.
() =
2
p1
2
01
2
j
1
+
(1)
S
2
p2
2
02
2
j
2
A proper set of
,
01
,
p1
,
1
,
02
,
p2
,
2
, should be chosen depending on the
material type and the valid range of the frequency. An integer S can be used to
set a sign of the second pole. By default, S is xed to 2. To reverse this polarity,
one must simply put a minus sign ahead of
p2
. Some of useful DL parameters
are given in the below.
a. Silicon
400nm - 900nm (n, k data from Palik)
= 3.0766
p1
= 1.68955 10
16
rad/s
01
= 5.7298 10
15
rad/s
1
= 1.14527 10
14
rad/s
p2
= 6.7512 10
14
rad/s
6
02
= 2.49448 10
15
rad/s
2
= 2.78064 10
15
rad/s
b. Gold
500nm - 1500nm (n, k data from Johnson and Christy
7
)
= 5.9673
p1
= 1.328 10
16
rad/s
01
= 0
1
= 1.0 10
14
rad/s
p2
= 4.26435 10
15
rad/s
02
= 4.0845 10
15
rad/s
2
= 6.58855 10
14
rad/s
6
Here, the use of a minus sign is to set S to be 1.
7
Fitting parameters are obtained from A. Vial, et al..[27]
84 7 Function Reference
7. void random object(char *shape, oat radius, oat height, oat epsilon,
oat x min, oat x max, oat y min, oat y max, oat z min, oat z max,
int gen number, int seed) :
gen number number of *shape objects will be randomly located within a cube
region bounded by { [x min, x max], [y min, y max], [z min, z max] }. We
have used rand() to generate random numbers. A different set of random num-
bers can be obtained by varying seed. Currently, (as of July 19th, 2011) only
rod and sphere are two possible inputs for *shape.
8. void make epsilon() :
Create ND structures in the actual memory.
9. void make Lorentz structure() :
Create SD and SL structures in the actual memory.
10. void make double Lorentz structure() :
Create DL structures in the actual memory.
11. void coefcient() :
Some of useful variables are set, which will be used in the FDTD time update
equations. This function should appear after make epsilon(), make Lorentz structure(),
make double Lorentz structure().
7.3 Functions needed during the FDTD time loop 85
7.3 Functions needed during the FDTD time loop
Functions listed in this section may be inserted in the FDTD time-loop mainly for
the purpose of 1) updating and manipulating eld arrays and 2) detecting and pro-
cessing the resulting eld data. The FDTD time loop consists of a forloop in
which t (reserved variable to represent the FDTD time step) is increasing one-step
at a time. An exemplary forloop may look as shown in the below.
for(t=0;t<10000;t++)
{
Gaussian_dipole_source(. . .);
propagate();
out_point(. . .);
if(t>1000 && t<2000 && t\%100==0)
out_plane(. . . );
. . .
}
1. void propagate() :
This is the part where actual FDTD time updates are performed based on the
Maxwells curl equations. (For instance, see Eq 5.29.) Everytime when it is
called, one FDTD time-step will elapse.
2. void propagate tri() :
3. void Gaussian dipole source(char *component,oat x,oat y,oat z,oat
frequency,oat phase,long to,long tdecay) :
An electric current density J or a magnetic current density M at a particular point
of space (x, y, z) can be set (For more information, read Sec. 5.3.2). The Gaussian
dipole source adopts the following functional form for the current vector.
G(t) = sin(2 f t +
0
) exp
_
(t t
0
)
t
_
2
G(t) will vanish unless t
0
3t <t <t
0
+3t.
a. *component : One of the current vector components. To set up J, one of {
Ex, Ey, Ez } should be used, while M can be set through { Hx, Hy, Hz }.
Though the initial phase can be rigorously set through phase, phase shift
can be quickly set by putting signs in front of *component, such as -Ex,
-Ey, -Ez, -Hx, -Hy, -Hz.
86 7 Function Reference
b. x,y,z : 3-D coordinates of the point dipole source in the unit of a.
c. frequency : The carrier frequency, f , in the unit of the normalized frequency
(
n
= a/).
d. phase : The initial phase,
0
.
e. to : = t
0
. Normally, to is set equal to 3 t.
f. tdecay : =t. Roughly speaking, three times tdecay corresponds to FWHM
of a given Gaussian envelope function.
4. void Lorentzian dipole source(char *component,oat x,oat y,oat z,oat
frequency,oat phase,long to,long tdecay) :
An electric current density J or a magnetic current density M at a particular
point of space (x, y, z) can be set (For more information, read Sec. 5.3.2). The
Lorentzian dipole source adopts the following functional form for the current
vector.
L(t) = sin(2 f (t t
0
) +
0
) exp
_
(t t
0
)
t
_
L(t) will vanish unless t
0
< t < t
0
+8t.
a. to : = t
0
. The time at which the Lorentzian source starts.
b. tdecay : = t in the unit of the FDTD time step. However, with the setting
of tdecay = 0, one can set up a continuous-wave dipole source, where the
amplitude does not change in time.
c. Other input parameters are the same as in Gaussian dipole source().
5. oat Gaussian phase(oat Wn, long t peak) :
Returns a proper initial phase for the Gaussian dipole source. This initial phase
makes the following time integral of the current density zero, which also mini-
mizes remnant static charges at the source point.
_
0
J(x, t)dt = 0 (7.1)
Here, Wn is the central frequency of the dipole source (
n
) and t peak is the
time at which the Gaussian envelope reaches its peak value (t
0
).
For the following form of a Gaussian dipole source,
J(x, t) =
de
_
tt
0
t
_
2
sin(t +
G
)(xx
0
) (7.2)
the proper initial phase should satisfy
G
= t
0
.
6. oat Lorentzian phase(oat Wn, long tdecay) :
Returns a proper initial phase for the Lorentzian dipole source, with which the
time integral of the current density will be vanishingly small. Wn is the central
frequency of the dipole source (
n
) and tdecay is the lifetime of the exponential
decay.
7.3 Functions needed during the FDTD time loop 87
For the following form of a Lorentzian dipole source,
J(x, t) =
de
t
cos(t +
L
)(x x
0
) (7.3)
the proper initial phase should satisfy both sin
L
=/
2
+
2
and cos
L
=
/
2
+
2
.
7. void Gaussian planewave(char *Ecomp, char *Hcomp, oat position, oat
frequency, long to,long tdecay) :
This function creates a planewave source propagating downward (z) or upward
(+z). A plane array of point Gaussian dipole sources is used to create this source.
The lateral extension of this array will automatically t to the FDTD domain
size. The direction of the propagation will be determined by EcompHcomp,
where *Ecomp and *Hcomp are Cartesian components of an electric eld and a
magnetic eld, respectively, where a minus sign may be used to represent the
phase shift. The vertical location (z) of the planewave source is given by position
in the unit of a. Other parameters are the same as in the Gaussian dipole source
function.
When used along with periodic boundary(), ideal, diffractionless planewaves
can be generated. Obliquely incident planewaves may be generated with a proper
set of non-zero Bloch wavevectors of k x and k y.
8. void Lorentzian planewave(char *Ecomp, char *Hcomp, oat position,
oat frequency, long to,long tdecay) :
This function creates a planewave source based on a plane array of point Lorentzian
dipole sources. Other parameters are the same as in the Lorentzian dipole source
function.
9. void Gaussian line source(char *component, oat position x, oat posi-
tion z, oat frequency, oat phase, long to,long tdecay) :
This function creates a linear array of point Gaussian dipole sources, which may
be used in ideal 2-D simulation (where x and z are assumed to be the two orthog-
onal coordinates). The line source lies in the y direction. Thus, its 2-D location
is given by (position x and position z). Other parameters are the same as in the
Gaussian dipole source function.
For ideal 2-D simulation, one must set up a periodic boundary condition for y
with wave vector y = 0. Then, for example, to excite a TE mode (where electric
elds point vertically, or in the y direction), one may use this line source with
*component = Ez.
10. void Lorentzian line source(char *component, oat position x, oat posi-
tion z, oat frequency, oat phase, long to,long tdecay) :
This function creates a linear array of point Lorentzian dipole sources. Other
parameters are the same as in the Lorentzian dipole source function.
11. void random Gaussian dipole(char *component, oat frequency, oat tde-
cay, oat x min, oat x max, oat y min, oat y max, oat z min, oat
z max, int gen number, int seed) :
gen number number of point Gaussian dipole sources will be randomly scat-
tered within a volume of space dened by { [x min, x max], [y min, y max],
88 7 Function Reference
[z min, z max] }. We have used one of the standard C libraries, rand(), as a ran-
dom number generator. A different sequence of random numbers can be chosen
by varying seed.
Note that all those dipole sources will have the same polarization determined by
*component. However, initial phases of such dipoles are assigned randomly.
Other parameters are the same as in the Gaussian dipole source function.
12. void incoherent point dipole(char *function, oat x, oat y, oat z, oat
frequency, long to, long tdecay, oat t mu, oat sd) :
This function creates a point dipole source (either Gaussian or Lorentzian) at a
specic point of space, (x,y,z). But its polarization and initial phase will uctuate
with a mean coherence time, < t >= t mu, whose statistical distribution obeys
the Gaussian distribution with the standard deviation of sd. The two types of an
envelope function can be specied through *function, either Gauss (Gaussian
function) or Lorentz (Lorentzian function).
13. void eld initialization() :
Initialize all the eld variables such as (Ex,Bx,Hx,Dx,Jx, ).
14. void Poynting block(oat centerx, oat centery, oat centerz, oat size1,
oat size2, oat size3) :
This function performs Poynting ux summation over the closed block-shaped
surfaces, whose center and side lengths are dened by centerx, centery, cen-
terz, size1, size2, size3, as in input object().
Specically, it performs the following form of recursive summation, whenever it
is called upon within the t-loop.
E
block
(t +t) = E
block
(t) +
_
block
EH dS (7.4)
Here, E
block
(t) denotes the accumulated Poynting energy at time t and initially,
E
block
(t = 0) = 0.
The result of E
block
(t) will be stored in Sumx, Sumy, Sumz, which are pre-
dened variables in pFDTDvar.h. For example, Sumx contains the accumulated
Poynting energy only over the two parallel surfaces positioned at x = size1/2
and x = +size1/2. Thus, E
block
(t) =Sumx + Sumy + Sumz.
This function may be used together with print energy(), which will be explained
in the next section.
Note that this function may not be used at the time along with Poynt-
ing total().
15. void Poynting total() :
This function is very similar to Poynting block() except for the fact that the
binding box is automatically set as the entire FDTD domain. The function will
remove the regions of PML, if there is any. Thus, this function is equivalent to
Poynting block() with the following set of parameters:
size1=L
x
x
+
x
2 centerx=
x
/2
x
+/2
size2=L
y
y
+
y
2 centery=
y
/2
y
+/2
size3=L
z
z
+
z
2 centerz=
z
/2
z
+/2
7.3 Functions needed during the FDTD time loop 89
,where, for example, L
x
is the FDTD domain size in the x direction, {
x
and
x
+} are the PML thicknesses on the left and right, respectively, and is a small
positive value equal to two space grids.
8
When we denote the above closed surface to be (), this function performs the
following form of recursive summation, whenever it is called upon within the
t-loop.
E
tot
(t +t) = E
tot
(t) +
_
EH dS (7.5)
The result of E
tot
(t) will be stored in Sumx, Sumy, Sumz, which are pre-dened
variables in pFDTDvar.h. Thus, E
tot
(t) =Sumx + Sumy + Sumz.
This function may be used together with print energy(), which will be explained
in the next section.
Note that this function may not be used at the time along with Poynt-
ing block().
16. void Poynting UpDown(oat value, oat zposition) :
This function assumes the same binding box, , as in Poynting total(), excluding
a certain strip region, .
The region of is dened by the following inequality.
( ) & {zpositionvalue z zposition+value} (7.6)
,where value and zposition are in the unit of a.
Specically, it performs the following form of recursive summation,
E
UnD
(t +t) =E
UnD
(t) +
_
EH dS (7.7)
whenever it is called upon within the t-loop.
The result of E
UnD
(t) will be stored in SumUpper, SumLower, which are pre-
dened variables in pFDTDvar.h. For example, SumUpper contains the accu-
mulated Poynting energy only over the upper surface above the strip position.
Thus, E
UnD
(t) =SumUpper + SumLower.
If value is set to be 0.0, then this function becomes equivalent to Poynt-
ing block().
This function may be used together with print energy(), which will be explained
in the next section.
17. void Poynting side(oat value, oat zposition) :
This function performs Poynting ux summation over the strip region, , dened
in the above.
Specically, it performs the following form of recursive summation, whenever it
is called upon within the t-loop.
E
side
(t +t) = E
side
(t) +
_
EH dS (7.8)
8
In order to avoid direct touching with PML layers
90 7 Function Reference
The result of E
side
(t) will be stored in SideSumx, SideSumy, which are
pre-dened variables in pFDTDvar.h. For example, SideSumx gives the ac-
cumulated Poynting energy only over the two parallel surfaces positioned at
x = L
x
/2 +
x
+ and x = L
x
/2
x
+ . Thus, E
side
() =SideSumx
+ SideSumy.
This function may be used together with print energy(), which will be explained
in the next section.
18. oat Poynting half sphere point(char *component, oat z0, oat R, oat
theta, oat phi) :
In the spherical coordinate, a Poynting vector can be decomposed as P =
P
r
r +P
+P
. This function returns one component of the Poynting vec-
tor in the spherical coordinate, where component can take either r (P
r
),theta
(P
), phi (P
0
|E|
2
dxdydz (7.9)
Note that automatically takes the following formof
e f f
when it meets a single-
pole Drude medium:
9
e f f
() Re
_
d()
d
_
=
2
p
(
2
2
)
(
2
+
2
)
2
(7.10)
Here, is the frequency at which the effective susceptibility (
e f f
) is being cal-
culated and can only be set through real space param() function.
The result will be printed out as a text le, total eEE b.en. Called upon repeat-
edly in the FDTD for-loop, E
Eb
(t) will be appended in the same total eEE b.en
le together with t.
9
See Jackson Chap. 6.8. and Changs papers[28, 29].
7.3 Functions needed during the FDTD time loop 91
Note that currently (as of June 1st, 2012) this effective dielectric function cannot
be used for Lorentz media (but it is very straightforward to upgrade for Lorentz
media).
20. void total M energy block(oat centerx, oat centery, oat centerz, oat
size1, oat size2, oat size3) :
This function is essentially same as total E energy block() except for the fact
that it takes a different effective dielectric constant when it meets a Drude
medium. (For magnetic energy)
Specically, it performs the following volume integration over the block, when-
ever it is called upon within the t-loop.
E
Mb
(t) =
_ _ _
block
1
2
M
|E|
2
dxdydz (7.11)
Here,
M
takes
M
= (x, y, z) in a normal dielectric medium.
M
= Re[()] = 2
2
p
2
+
2
in a Drude medium.
The result will be printed out as a text le, total Mb.en. Called upon repeatedly
in the FDTD for-loop, E
Mb
(t) will be appended in the same total E Mb.en le
together with t.
21. void total M energy block2(oat centerx, oat centery, oat centerz, oat
size1, oat size2, oat size3) :
This function is essentially same as total E energy block() except for the fact
that it takes a different effective dielectric constant when it meets a Drude
medium. (For magnetic energy)
Specically, it performs the following volume integration over the block, when-
ever it is called upon within the t-loop.
E
Mb2
(t) =
_ _ _
block
1
2
0
|H|
2
dxdydz (7.12)
The result will be printed out as a text le, total Mb2.en. Called upon repeatedly
in the FDTD for-loop, E
Mb2
(t) will be appended in the same total E Mb2.en le
together with t.
22. void total K energy block(oat centerx, oat centery, oat centerz, oat
size1, oat size2, oat size3) :
This function is essentially same as total E energy block() except for the fact
that it takes a different effective dielectric constant when it meets a Drude
medium. (For kinetic energy of electrons in metal)
Specically, it performs the following volume integration over the block, when-
ever it is called upon within the t-loop.
E
K
(t) =
_ _ _
block
1
2
K
|E|
2
dxdydz (7.13)
Here,
K
takes
92 7 Function Reference
K
= 0 in a normal dielectric medium.
K
=
2
p
2
+
2
in a Drude medium.
The result will be printed out as a text le, total K b.en. Called upon repeat-
edly in the FDTD for-loop, E
K
(t) will be appended in the same total K b.en le
together with t.
One is often encountered a situation where the following form of volume in-
tegration need to be calculated.
I
EM
(t) =
_
V
d
3
r (u
E
(r, t) +u
M
(r, t)) (7.14)
,where u
E
and u
M
are the electric-eld energy density and the magnetic-eld
energy density, respectively.
Obviously, in normal dielectrics, u
E
(r) = (1/2)
0
(r)|E(r, t)|
2
and
u
M
(r) = (1/2)
0
(r)|H(r, t)|
2
, respectively. Furthermore, for a harmonic
mode oscillating at a frequency of , it is well known that the time-averaged
total electric-eld energy should be equal to the time-averaged total magnetic-
eld energy.
_
_
V
d
3
ru
E
(r, t)
_
T
=
_
_
V
d
3
ru
M
(r, t)
_
T
(7.15)
Here, < >
T
denotes time average over one optical period.
Therefore, when there are only normal dielectric media, one can simply
double the electric-eld energy such that
I
EM
T
= 2 I
E
T
= 2
_
_
V
d
3
ru
E
(r, t)
_
T
(7.16)
The volume integral like Eq. 7.16 can be simply done with the help of
total E energy block().
However, in the case of mixed media consisting of normal dielectrics
and Drude metal, the electric energy density and the magnetic energy density
are given by[3]
u
E
(r, t) =
0
2
Re
_
d()
d
_
|E(r, t)|
2
=
0
2
_
2
p
(
2
2
)
(
2
+
2
)
2
_
|E(r, t)|
2
(7.17)
u
M
(r, t) =
0
2
|H(r, t)|
2
(7.18)
7.3 Functions needed during the FDTD time loop 93
The volume integral like Eq. 7.18 and 7.18 can be simply done with the
help of total E energy block() and total M energy block2().
A further simplication of Eq. 7.18 can be made by using the following
relation.[28]
_
_
V
d
3
r
0
2
Re[(r, )]|E(r, t)|
2
_
T
=
_
_
V
d
3
r
0
2
|H(r, t)|
2
_
T
(7.19)
One must remember that the above equality holds true after integrating over
V. Also note that this is a generalized version of Eq. 7.15 for the equality
between the magnetic energy and the electric energy of the harmonic mode.
Therefore, I
EM
T
can be written as
I
EM
T
=
_
_
V
d
3
r
0
2
_
Re
_
d()
d
_
+Re[(r, )]
_
|E(r, t)|
2
_
T
(7.20)
The volume integral like this can be simply done with the help of to-
tal E energy block() and total M energy block().
23. void total EM energy thin block z(oat centerx, oat centery, oat cen-
terz, oat size1, oat size2, oat size3, oat eps L, oat eps H, char
*name) :
24. void total EM energy thick block z(oat centerx, oat centery, oat cen-
terz, oat size1, oat size2, oat size3, oat eps L, oat eps H, char
*name) :
25. void Drude energy loss in block(oat centerx, oat centery, oat centerz,
oat size1, oat size2, oat size3, oat WC) :
This function calculates how much energy will be absorbed in Drude media for a
harmonic mode oscillating at a frequency of WC (represented in unit of normal-
ized frequency). According to the Poynting theorem for dispersive media,
10
the
absorbed energy density is given by
u
abs
(r) =
0
Im[()] |E(r)|
2
(7.21)
Specically, it performs the following volume integration, whenever it is called
upon within the t-loop.
P
SD
(t) =
_ _ _
block
u
abs
dxdydz (7.22)
10
See Eq.6.127 in Jackson.
94 7 Function Reference
Here, the block-shaped volume is dened by centerx, centery, centerz, size1,
size2, size3, respectively. This function automatically excludes the region of
non-SD media for the above integration.
The integration result is printed out as a text le, Drude E loss.en. Every
time called upon in the FDTD for-loop, P
SD
(t) will be appended in the same
Drude E loss.en le together with t.
26. void Dlorentz energy loss in block(oat centerx, oat centery, oat cen-
terz, oat size1, oat size2, oat size3, oat WC) :
This function calculates how much energy will be absorbed in double Lorentz
media for a harmonic mode oscillating at a frequency of WC (represented in unit
of normalized frequency).
Specically, it performs the following volume integration, whenever it is called
upon within the t-loop.
P
DL
(t) =
_ _ _
block
u
abs
dxdydz (7.23)
Here, u
abs
is the same as dened in Drude energy loss in block() except for
the fact that now () takes the double Lorentz dielectric function. The block-
shaped volume is dened by centerx, centery, centerz, size1, size2, size3,
respectively. This function automatically excludes the region of non-DL media
for the above integration.
The integration result is printed out as a text le, Dlorentz E loss.en. Every
time called upon in the FDTD for-loop, P
DL
(t) will be appended in the same
Dlorentz eEE.en le together with t.
27. void max EM Energy detector(oat centerx, oat centery, oat centerz,
oat size1, oat size2, oat size3) :
This function nds out the maximum of the electromagnetic energy (I
EM
=
_
V
d
3
r
0
2
_
Re
_
d()
d
_
+Re[(r, )]
_
|E(r, t)|
2
) at the present FDTDtime, t, within
the volume dened by a block whose center and side lengths are denoted as
centerx, centery, centerz, size1, size2, size3, respectively.
The result is printed in a text le, max detect.dat, along with t and (max i,
max j, max k), the FDTD time step and the space coordinate where the max-
imum has been obtained, respectively. Called repeatedly in the FDTD for-loop,
the results will be appended in the same max detect.dat le
7.4 Functions needed to print out results 95
7.4 Functions needed to print out results
1. int get period in update(oat w n) :
Returns one optical cycle (period) in the unit of the FDTD time stepping, where
the period corresponds to the normalized frequency of w n. This function may be
used when one needs to perform time-average of some eld data over one optical
cycle.
2. void out epsilon(char *plane, oat value, char *name) :
Print out a 2-D text matrix containing one of cross sections of the whole FDTD
structure. *plane can take one of the followings, x,y, and z. value deter-
mines the location of the plane on which a cross sectional image of the FDTD
epsilon structure is to be obtained. For example, a structure image on the z = 0
plane will be obtained with parameter settings of *plane=z and value=0. The
unit of value is the FDTD unit length, a. *name requires the output le name
including the le extension.
3. void out epsilon periodic(char *plane, oat value, char *name, int m h, int
m v) :
This function performs basically the same tasks as out epsilon() except for the
fact that the epsilon image can be expanded to include multiple periods. m h
and m v (both are nonnegative integers) specify the number of periods for the
horizontal and vertical directions, respectively.
4. void out epsilon periodic tri(char *plane, oat value, char *name, int m h,
int m v) :
5. void out epsilon projection(char *dirc, char *name) :
This function generates a 2-D text matrix data for the epsilon structure as is
seen from the top (In the present FDTD version, only *dirc = +z can be used).
*name requires the output le name including the le extension.
6. void out plane(char *component,char *plane,oat value,char *lastname) :
This function takes a snap shot of one of eld components or their manipulations
in a plane dened by *plane = value. The result will be printed out as a 2-D text
matrix.
a. *component can be one of the followings :
Ex : x component of the electric eld E
Ey : y component of the electric eld E
Ez : z component of the electric eld E
Hx : x component of the magnetic eld H
Hy : y component of the magnetic eld H
Hz : z component of the magnetic eld H
Jx : x component of the current density J
11
Jy : y component of the current density J
Jz : z component of the current density J
11
J is dened by the Maxwell-Ampere equation, J = HD/t
96 7 Function Reference
J.E :
12
J E
E2 : |E|
2
=|E
x
|
2
+|E
y
|
2
+|E
z
|
2
H2 : |H|
2
=|H
x
|
2
+|H
y
|
2
+|H
z
|
2
Sx : x component of Poynting vector. E
y
H
z
E
z
H
y
Sy : x component of Poynting vector. E
z
H
x
E
x
H
z
Sz : x component of Poynting vector. E
x
H
y
E
y
H
x
LogE2 : log
10
|E|
2
LogH2 : log
10
|H|
2
EM Energy :
13 1
2
_
|E|
2
+|H|
2
E Energy :
1
2
|E|
2
Ex2Ey2 : |E
x
|
2
+|E
y
|
2
Ey2Ez2 : |E
y
|
2
+|E
z
|
2
Ez2Ex2 : |E
z
|
2
+|E
x
|
2
LogEx2Ey2 : log
10
(|E
x
|
2
+|E
y
|
2
)
LogEy2Ez2 : log
10
(|E
y
|
2
+|E
z
|
2
)
LogEz2Ex2 : log
10
(|E
z
|
2
+|E
x
|
2
)
Hx2Hy2 : |H
x
|
2
+|H
y
|
2
Hy2Hz2 : |H
y
|
2
+|H
z
|
2
Hz2Hx2 : |H
z
|
2
+|H
x
|
2
LogHx2Hy2 : log
10
(|H
x
|
2
+|H
y
|
2
)
LogHy2Hz2 : log
10
(|H
y
|
2
+|H
z
|
2
)
LogHz2Hx2 : log
10
(|H
z
|
2
+|H
x
|
2
)
b. *plane and value : determines the location of the plane on which you want to
look at the FDTD result.
c. *lastname : requires the le extension for the output. The le name is auto-
matically written using the FDTD time step.
7. void out plane periodic(char *component, char *plane, oat value, char
*lastname, int m h, int m v) :
This function performs basically the same tasks as out plane() except for the
fact that the *component image can be expanded to include multiple periods.
m h and m v (both are nonnegative integers) specify the number of periods for
the horizontal and vertical directions, respectively.
When you are using the periodic boundary condition with the normalized wavevec-
tor setting of (
k
x
,
k
y
), this function actually performs the following operations to
obtain the eld data *component lying outside the original calculation domain.
A(x +m hR
x
+m vR
y
) = exp[2i(m h
k
x
+m v
k
y
)]A(x) (7.24)
where A is one of *component and R
x
(R
y
) is the lattice vector along the x (y)
axis.
8. void out plane periodic tri(char *component, char *plane, oat value, char
*lastname, int m h, int m v) :
12
The work done per unit time per unit volume by the eld. See Jackson Chap. 6.7.
13
For the Drude metal, becomes the effective susceptibility, see total EM energy block().
7.4 Functions needed to print out results 97
9. void out plane time average(char *component,char *plane,oat value, long
start, long end, oat ***eld avg, char *lastname) :
This function performs time average (from start to end) of 2-D matrix data of
*component. In the upper part of the main function, at each use of this
function, you have to declare one 2-D array variable, to which the eld data is
being added during [start, end] and at t =end the summed result will be divided
by (end - start) to get the time average. For example, you can declare a 2-D
array by
oat **2deld;
Then, you have to link this 2-D array into the input argument, ***eld avg, as
follows.
out plane time average( . . . ,&2deld, .)
An output le name is determined by combining start time and the le extension,
*lastname.
10. void out plane projection(char *component,char *dirc, char *lastname, int
k shift) :
This function generates a 2-D text matrix data for the eld computation result
(*component) as is seen from the top (In the present FDTD version, only *dirc
= +z can be used). *lastname requires the le extension for the output. The
le name is automatically written using the FDTD time step.
One another feature that differs from out epsilon projection() function is that
one can control the vertical distance from the genuine surface of the structure;
k shift (in the unit of the FDTD grid) measures the constant distance between the
surface and the imaging plane. So, what we do here is more like real NSOM
14
measurement. With k shift =0, the eld image is obtained as the NSOM tip
moves on the sample surface in contact.
11. void out plane time average projection(char *component,char *dirc, long
start, long end, oat ***eld avg, char *lastname, int k shift) :
This function combines two features of out plane time average() and out plane projection()
functions. So, you can perform time average (from start to end) of 2-D projec-
tion data of *component, which has been obtained at a distance of k shift from
the structure surface.
12. void out point(char *component,oat x,oat y,oat z,long ti,long tf,char
*name) :
This function detects a eld component (*component) at a certain point of (x,
y, z) during [ti, tf]. The result will be printed out as a one-column text matrix
having a le name of *name.
a. *component : All the eld manipulations that can be used in void out plane()
function are available.
b. x,y,z : space coordinates in the unit of a.
c. ti, tf : ti is an initial time and tf a nal time in the unit of the FDTD time
stepping.
d. *name : output le name
14
Near-eld Scanning Optical Microscope
98 7 Function Reference
13. void out several points(char *component,oat zposition, oat xside, oat
yside, int pNx, int pNy, long ti,long tf,char *name) :
This function detects a eld component (*component) at several points of
{x, y, z} during [ti, tf]. Here, {x, y, z} are dened by
x = x
i
= xside/2 +i(xside/pN
x
) where i = 0, , pN
x
(7.25)
y = y
j
=yside/2 + j(yside/pN
y
) where j = 0, , pN
y
z = zposition
The result will be printed out as a multi-column text matrix having a le name of
*name, in which each column corresponds to the data for each space position of
(x
i
, y
j
).
a. *component : All the eld manipulations that can be used in void out plane()
function are available.
b. zposition : z coordinate of the detection plane on which (x
i
, y
j
) are located, in
the unit of a.
c. xside, yside : the size of the detection plane, xside yside
d. pNx, pNy : Total number of detection points will be (pNx+1)(pNy+1).
e. ti, tf : ti is an initial time and tf a nal time in the unit of the FDTD time
stepping.
f. *name : output le name
14. oat grid value(char *component,int i,int j,int k) :
This function returns *component at a certain space position of (i,j,k) where
input values should be in the unit of the FDTD grid. This enables lower level
manipulation of the eld data.
15. void print energy() :
After nishing the whole FDTD time update, this function can be used to print
out VQSQ.en le, which includes several Poynting integration results, such as
Sumx, Sumy, Sumz, SideSumx, SideSumy, SumUpper, and SumLower.
7.5 Functions needed for far-eld simulation 99
7.5 Functions needed for far-eld simulation
All the functions below have been introduced for efcient simulation of far-eld
radiation from 2-D photonic crystal nanocavities.[17] However, the same algorithm
can also be applied to a number of different structures including microdisks. For
further details, see Sec. 5.4 and the following paper:
Se-Heon Kim, Sun-Kyung Kim, and Yong-Hee Lee, Vertical beaming of wavelength-scale
photonic crystal resonators, Phys. Rev. B, Vol.73, 235117 (2006).
1. void far eld param(oat *OMEGA, oat DETECT) :
This function performs the recursive discrete Fourier transformation (DFT) con-
currently with the FDTD time stepping to get the exact phasor data of the in-
plane near-eld data.
Therefore, this function should be used within the FDTD t-loop.
The near-eld data is obtained from a plane at z=DETECT. This function calcu-
lates n number of phasor data for n number of frequency components dened in
a 1-D array of *OMEGA.
This function should be included inside the FDTD for-loop. A typical time length
for one complete DFT is about 100 200 optical cycles, but it is also dependent
on the Q factor of a possible resonant mode.
This function will create, for example, a 2-D array of Ex cos[i][j][m] to perform
the DFT.
15
Here, [i],[j] indices are related to (x, y) positions and [m] refers to the
frequency component.
Other functions listed in the below should be used outside of the FDTD t-
loop.
2. void print amp and phase(int mm) :
Print out amplitude data and phase data from the extracted near-eld phasor data.
2-D text matrix les will be printed out with the le names, such as jEx amp
and jEx phase, and the le extensions, such as .ap(mm), where mm means the
(mm+1)-th frequency component.
Note that the output occurs directly from the internal memories, such as
Ex cos[i][j][m].
3. void print real and imag(int mm) :
Print out real components and imaginary components of the extracted near-
eld phasor data. 2-D text matrix les will be printed out with the le names,
such as tEx real and tEx imag, and the le extensions, such as .ri(mm), where
mm means the (mm+1)-th frequency component.
Note that the output occurs directly from the internal memories, such as
Ex cos[i][j][m].
4. void print real and imag 2n size(int NROW, int mm) :
This function performs nearly the same tasks as print real and imag() function
does, except for the fact that the output matrix le will have NROW NROW
size with the null values
16
, where NROW should be in the form of 2
n
.
15
See Eq. 5.74
16
See Sec. 5.4.3
100 7 Function Reference
For example, output le names will be Ex real and Ex imag with a le exten-
sion of .ri(mm), where mm means the (mm+1)-th frequency component. These
output les will be used as input les for far eld FFT() function.
Note that the output occurs directly from the internal memories, such as
Ex cos[i][j][m].
5. void make 2n size(int NROW, int mm) :
This function reads t-les such as tEx real and tEx imag to create Ex real,
Ex imag les with NROW NROWsize as in the same way print real and imag 2n size()
does.
6. void far eld FFT(int NROW, oat NA, oat Nfree, oat *OMEGA, int mm):
After reading NROW NROW sized near-eld data (such as Ex real and
Ex imag), this function performs actual far-eld simulations based on the near-
to far-eld transformation algorithm. Here, NA is the numerical aperture of an
assumed collection lens and Nfree, refractive index of the free space. A num-
ber of output les will be created, such as rad Ex .ri(mm), rad Ey .ri(mm),
rad Et .ri(mm), rad Ep .ri(mm), and rad tot .ri(mm).
Output les with extensions like .ri(mm) will contain data in the following coor-
dinate system.
x = sin() cos() (7.26)
y = sin() sin()
= sin()
Here, we give a brief description on some of output le names.
rad tot .ri(mm) : total intensity of the far-eld, |E
x
|
2
+|E
y
|
2
=|E
|
2
+|E
|
2
rad Ex .ri mm : x-polarized far-eld, |E
x
|
2
rad Ey .ri mm : y-polarized far-eld, |E
y
|
2
rad Et .ri mm : -polarized far-eld, |E
|
2
rad Ep .ri mm : -polarized far-eld, |E
|
2
7. void transform fareld(int NROW, int tnum, char *name, int mm) :
This function performs the following coordinate transformation to an output le,
{*name}.ri mm, which is tnum tnum.
From (with les having the extension of .ri mm)
x = sin() cos() (7.27)
y = sin() sin()
= sin()
To (with les having the extension of .sas mm)
x = cos() (7.28)
y = sin()
7.5 Functions needed for far-eld simulation 101
=
Note that the output le size can be adjusted by tnum which should be in the
form of 2n +1.
8. void add fareld(int tnum, char *name) :
Add all output les having the extension of .sas mm. The result will be printed
in sum.sas mm.
102 7 Function Reference
7.6 List of global variables
All the variables listed below are reserved for specic purposes.
1. Dened in main.c
oat shift
int SpecN
long t : The FDTD time step
oat Sumx, Sumy, Sumz, SideSumx, SideSumy
oat SumUpper, SumLower
const gsl rng type * rng type
gsl rng * rng r
oat TF SF pos
oat TF SF freq
long TF SF to
oat TF SF eps bg
2. Dened in parameter.c
int isize, jsize, ksize
int pmlil, pmlir, pmljl, pmljr, pmlkl, pmlkr
int lattice x, lattice y, lattice z
int lattice nz
oat xsize, ysize, zsize
oat nz start, nz end
oat xcenter, ycenter, zcenter
oat kx, ky, kz
oat orderxl, orderyl, orderzl
oat orderxr, orderyr, orderzr
oat sig axl, sig ayl, sig azl
oat sig axr, sig ayr, sig azr
oat ds x, ds y, ds z, dt
oat *ds nz
oat S factor : Numerical stability factor
oat pi, eo, uo, ups, light speed
int misize, mjsize, mksize
int pisize, pjsize, pksize
int cisize, cjsize, cksize
int xparity, yparity, zparity
oat wave vector x, wave vector y
int use periodic x, use periodic y
int metal type : used for material complexity()
3. Dened memory.c
char ***position
oat ***epsilonx,***epsilony,***epsilonz
oat ***Lepsilon,***Lomega,***Lgamma
7.6 List of global variables 103
oat ***DLepsilon,***DLomega 1,***DLgamma 1, ***DLomega0 1, ***DLomega 2,***DLgamma 2,
***DLomega0 2
oat ***Ex,***Ey,***Ez
oat ***Jx,***Jy,***Jz : used for metal update
oat ***Hx,***Hy,***Hz
oat ***Dx,***Dy,***Dz : used for PML
oat ***Bx,***By,***Bz
oat ***pEx,***pEy,***pEz
oat ***pJx,***pJy,***pJz
oat ***iEx,***iEy,***iEz
oat ***iJx,***iJy,***iJz
oat ***iHx,***iHy,***iHz
oat ***iDx,***iDy,***iDz
oat ***iBx,***iBy,***iBz
oat ***piEx,***piEy,***piEz
oat ***piJx,***piJy,***piJz
oat ***Qx 1, ***Qy 1, ***Qz 1
oat ***Qx 2, ***Qy 2, ***Qz 2
oat ***iQx 1, ***iQy 1, ***iQz 1
oat ***iQx 2, ***iQy 2, ***iQz 2
oat ***pQx 1, ***pQy 1, ***pQz 1
oat ***pQx 2, ***pQy 2, ***pQz 2
oat ***piQx 1, ***piQy 1, ***piQz 1
oat ***piQx 2, ***piQy 2, ***piQz 2
oat *Ex inc, *Hy inc for TF-SF
oat *aax,*aay,*aaz
oat *bbx,*bby,*bbz
oat *ccx,*ccy,*ccz
oat ***ddx,***ddy,***ddz
oat *eex,*eey,*eez
oat *ffx,*ffy,*ffz
oat *ggx,*ggy,*ggz
oat *hhx,*hhy,*hhz
oat *iix,*iiy,*iiz
oat *jjx,*jjy,*jjz
oat *kkx,*kky,*kkz
oat *llx,*lly,*llz
oat ***Ex cos, ***Ex sin
oat ***Ey cos, ***Ey sin
oat ***Hx cos, ***Hx sin
oat ***Hy cos, ***Hy sin
4. Dened in input.c
oat back epsilon
104 7 Function Reference
5. Dened in output.c
oat global W : the normalized frequency to be used in the effective suscepti-
bility,
e f f
.
References 105
References
1. D. Hestenes, Oersted medal lecture 2002: Reforming the mathematical language of physics,
Am. J. Phys., vol. 71, no. 2, pp. 104121, Feb 2003.
2. G. B. Arfken and H. J. Weber, Mathematical methods for physicists. London: Academic
Press, 1995.
3. J. D. Jackson, Classical Electrodynamics. New York: Wiley, 1974.
4. N. C. Frateschi and A. F. J. Levi, The spectrum of microdisk lasers, J. Appl. Phys., vol. 80,
p. 644, 1996.
5. J. M. G erard, D. Barrier, J. Y. Marzin, R. Kuszelewicz, L. Manin, E. Costard, V. Thierry-
Mieg, and T. Rivera, Quantumboxes as active probes for photonic microstructures: The pillar
microcavity case, Appl. Phys. Lett., vol. 69, p. 499, 1996.
6. H. Y. Ryu, M. Notomi, and Y. H. Lee, High-quality-factor and small-mode-volume hexapole
modes in photonic-crystal-slab nanocavities, Appl. Phys. Lett., vol. 83, p. 4294, 2003.
7. Y. Akahane, T. Asano, B. S. Song, and S. Noda, Nature, vol. 425, p. 944, 2003.
8. P. R. Villeneuve, S. Fan, and J. D. Joannopoulos, Microcavities in photonic crystals: Mode
symmetry, tunability, and coupling efciency, Phys. Rev. B, vol. 54, p. 7837, 1996.
9. A. Taove and S. C. Hagness, Computational Electrodynamics: the nite-difference time-
domain method, 2nd ed. Norwood, MA: Artech House, 2000.
10. K. Yee, Numerical solution of initial boundaryvalue problems involvingmaxwells equations
in isotropic media, IEEE Trans. Antennas and Propagation, vol. 14, p. 302, 1966.
11. Y. Xu, J. V ukovi c, R. K. Lee, O. J. Painter, A. Scherer, and A. Yariv, Finite-difference time-
domain calculation of spontaneous emission lifetime in a microcavity, J. Opt. Soc. Am. B,
vol. 16, p. 465, 1999.
12. S. H. Kim and Y. H. Lee, Symmetry relations of two-dimensional photonic cyrstal cavity
modes, IEEE J. Quantum Electron., vol. 39, p. 1081, 2003.
13. O. Painter and K. Srinivasan, Polarization properties of dipolelike defect modes in photonic
crystal nanocavities, Opt. Lett., vol. 27, p. 339, 2002.
14. R. B. Laughlin, A Different Universe: Reinventing Physics from the Bottom Down. New
York: A Member of the Perseus Books Group, 2005.
15. J. V ukovi c, M. Lon car, H. Mabuchi, and A. Scherer, IEEE J. Quantum Electron., vol. 38, p.
850, 2002.
16. W. H. Press, B. P. Flannery, S. A. Teukolsky, and W. T. Vetterling, Numerical Recipes in C:
The Art of Scientic Computing, 2nd ed. Cambridge University Press, 1992.
17. S. H. Kim, S. K. Kim, and Y. H. Lee, Vertical beaming of wavelength-scale photonic crystal
resonators, Phys. Rev. B, vol. 73, p. 235117, 2006.
18. J. W. Goodman, Introduction to Fourier Optics. Singapore: McGraw Hill, 1996, chap. 6.
19. S. L. McCall, A. F. J. Levi, R. E. Slusher, S. J. Pearton, and R. A. Logan, Appl. Phys. Lett.,
vol. 60, p. 289, 1992.
20. J. K. Hwang, H. Y. Ryu, and Y. H. Lee, Spontaneous emission rate of an electric dipole in a
general microcavity, Phys. Rev. B, vol. 60, p. 4688, 1999.
21. S. G. Johnson, S. Fan, P. R. Vileneuve, J. D. Joannopoulos, and L. A. Kolodziejski, Phys. Rev.
B, vol. 60, p. 5751, 1999.
22. S. Fan, P. R. Villeneuve, J. D. Joannopoulos, and E. F. Schubert, High extraction efciency
of spontaneous emission from slabs of photonic crystals, Phys. Rev. Lett., vol. 78, p. 3294,
1997.
23. H. G. Park, J. K. Hwang, J. Huh, H. Y. Ryu, Y. H. Lee, and J. S. Kim, Nondegenerate
monopole-mode two-dimensional photonic bandgap laser, Appl. Phys. Lett., vol. 79, p. 3032,
2001.
24. H. G. Park, S. H. Kim, S. H. Kwon, Y. G. Ju, J. K. Yang, J. H. Baek, S. B. Kim, and Y. H. Lee,
Electrically driven single-cell photonic crystal laser, Science, vol. 305, p. 1444, 2004.
25. J. D. Joannopoulos, R. D. Meade, and J. N. Winn, Photonic Crystals. Princeton Univ. Press,
1995.
106 7 Function Reference
26. A. F. Oskooi, D. Roundy, M. Ibanescu, P. Bermel, J. D. Joannopoulos, and S. G. John-
son, MEEP: A exible free-software package for electromagnetic simulations by the FDTD
method, Computer Physics Communications, vol. 181, pp. 687702, January 2010.
27. A. Vial, A.-S. Grimault, D. Macas, D. Barchiesi, and M. L. de la Chapelle, Improved ana-
lytical t of gold dispersion: application to the modeling of extinction spectra with a nite-
difference time-domain method, Phys. Rev. B, vol. 71, p. 085416, Feb 2005. [Online]. Avail-
able: http://link.aps.org/doi/10.1103/PhysRevB.71.085416
28. S.-W. Chang and S. L. Chuang, Normal modes for plasmonic nanolasers with dispersive and
inhomogeneous media, Opt. Lett., vol. 34, no. 1, pp. 9193, Jan 2009. [Online]. Available:
http://ol.osa.org/abstract.cfm?URI=ol-34-1-91
29. , Fundamental formulationfor plasmonic nanolasers,QuantumElectronics, IEEEJour-
nal of, vol. 45, no. 8, pp. 1014 1023, aug. 2009.