The Finite-Difference Time-Domain (FDTD) Algorithm: James R. Nagel

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

ECE3300

The Finite-Dierence Time-Domain (FDTD) Algorithm


James R. Nagel
Overview: It is dicult to overstate the importance of simulation to the world of engineering. Simulation is useful because it allows us to test our designs without going through all the hassle of physically constructing any devices. In fact, the market for quality simulation is quite rich, and one could easily make an entire career out of developing cheap, ecient, and accurate tools for simulation. The nite-dierence time-domain (FDTD) algorithm is an especially popular tool because it is simple, robust, and easy to understand. Basically, the algorithm works by taking the telegraphers equations and approximating all of the derivatives as nite-dierences. The system is then incremented by little time steps, and the solution eectively plays itself out in time. In fact, virtually any physical system that is governed by a time-dependent partial dierential equation (PDE) can be readily simulated through the use of FDTD. Engineers routinely test their designs through FDTD simulations of the heat equation, Maxwells equations, and even the Schrdinger equation. o

1. THE TELEGRAPHERS EQUATIONS


The telegraphers equations are basically nothing more than a pair of coupled partial dierential equations (PDEs) in space and time. Together, they represent the fundamental governing equations of all transmission line theory, and are given as v(z, t) z i(z, t) z i(z, t) , t v(z, t) = G v(z, t) + C , t = R i(z, t) + L (1) (2)

where v(z, t) and i(z, t) represent the instantaneous voltage and current at position z and time t. The R , L , G , and C terms represent the resistance, inductance, conductance, and capacitance per unit length. Because computers only have a nite capacity for memory storage, the rst step in applying FDTD is to dene a mesh, which is a set of discrete points in space and time that will sample our functions. Shown in gure 1, this is done by xing a grid spacing of z in space and t in time. The points that lie on the mesh are then dened as zk = kz , tn = nt . where k and n are integers conned by sets 1 k K, and 1 n N . (3) (4)

UNIVERSITY OF UTAH DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING

50 S. Central Campus Dr | Salt Lake City, UT 84112-9206 | Phone: (801) 581-6941 | www.ece.utah.edu

ECE3300

Figure 1. A simple FDTD mesh dened in space and time.

Now that the voltage and current functions have been sampled on a discrete, nite grid, we are ready to dene a stencil, which is simply a numerical approximation for the derivative that uses neighboring points along the mesh. For example, the spatial derivative acting on the voltage function can be approximated through the use of a forward nite-dierence: v(z, t) v(z + z, t) v(z, t) . z z (5)

At this point, it is convenient to introduce a more compact notation for the function v(zk , tn ) by simply n shortening it to vk . In other words, the subscript index represents the spatial grid point, while the superscript index represents the temporal grid point. Using this notation, the numerical derivative is rewritten as n n n vk+1 vk vk . (6) z z Note that as long as the dierence length z is very small, this approximation can provide us with reasonably accurate results. Nevertheless, we still would like to minimize the error from this approximation. It is therefore best to approximate all of our derivatives by using the central-dierence method because it is more accurate than either forward- or backwards-dierences. We shall therefore impose the approximation v(z, t) v(z + z, t) v(z z, t) , (7) z 2z or equivalently,
n n n vk+1 vk1 vk . z 2z

(8)

Similarly, we can apply the same approximation to the time-derivatives. For example, the timederivative on the current function i(z, t) can be rewritten as n in+1 in1 k i k . t k 2t
UNIVERSITY OF UTAH DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING

(9)

50 S. Central Campus Dr | Salt Lake City, UT 84112-9206 | Phone: (801) 581-6941 | www.ece.utah.edu

ECE3300

Figure 2. Revised FDTD mesh using the staggered grid. The red Xs represent voltage samples while the black circles represent current samples.

Using these new expressions, we are now ready to transform the telegraphers equations into a pair of coupled, nite-dierence equations. In terms of our new stencil notation, this is written as
n n vk+1 vk1 2z n i in k1 k+1 2z n1 in+1 ik k , 2t n1 v n+1 vk = G in + C k . k 2t

= R in + L k

(10) (11)

Comparing with equations (1) and (2), it is easy to see that all we have done so far is approximate the continuous derivatives of the telegraphers equations with discrete nite-dierences. Although this is a perfectly acceptable approximation, there is still one nal trick we can use to improve the algorithm. Mathematically, there is no reason why the voltage and currents must be dened along the same grid points in space and time. This may seem a little counter-intuitive at rst, but we can exploit it to improve accuracy without sacricing any computational eciency. To see how this works, suppose that we redene all of our samples to exist at half-step increments away from the each other. Shown in gure 2, the voltage mesh is staggered from the current mesh in both space and time by the convention
n n vk vk+1/2

in ik k

n+1/2

The reason for redening the meshes this way is so that we can approximate the spatial derivative on v as n n n vk+1/2 vk1/2 vk . (12) z z In other words, the spatial derivative on v, centered around the point k, is dened in terms of the spatial points k + 1/2 and k 1/2. Notice however, that the central-dierence approximation only spans a
UNIVERSITY OF UTAH DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING

50 S. Central Campus Dr | Salt Lake City, UT 84112-9206 | Phone: (801) 581-6941 | www.ece.utah.edu

ECE3300 length of z instead of 2z. Similarly, the temporal derivative on the current is approximated by centering around the nth time step using n ik i t k
n+1/2

ik t

n1/2

(13)

Putting these ideas together and applying them to equations (1) and (2) then gives a new set of nite-dierence equations given by
n n vk+1/2 vk1/2

z n+1/2 n+1/2 i ik k+1 z

= R

in k

+L

ik

n+1/2

ik t

n1/2

, .
n+1/2

(14) (15)

= G vk+1/2 + C

n+1/2

n+1 n vk+1/2 vk+1/2

This is almost the expression we are after. However, the terms in and vk+1/2 do not t in with k their proper grid points. To correct this, we simply redene these terms by the average value between the two nearest temporal points along the stencil. That is,
n+1/2 vk+1/2

n+1 n vk+1/2 + vk+1/2

in k

, 2 n+1/2 n1/2 ik + ik . 2

(16) (17)

Finally, plug these expressions back into the telegraphers equations to nd a pair of coupled, nitedierence equations, with all points dened along a staggered mesh. This represents a direct numerical approximation to the telegraphers equations that can be worked out by a computer:
n n vk+1/2 vk1/2

z n+1/2 n+1/2 ik+1 ik z

= =

1 R 2 1 G 2

n+1/2 ik

n1/2 ik

+L

ik

n+1 n vk+1/2 + vk+1/2 + C

ik , t n+1 n vk+1/2 vk+1/2 t

n+1/2

n1/2

(18) . (19)

2. UPDATE EQUATIONS
The key concept behind the FDTD algorithm is to begin with some given present state for a system and then solve for the nearest future state. This is accomplished by taking the numerical telegraphers n+1/2 equations and solving for the future terms. For example, the future term in equation (18) is ik n+1 because it exists at the latest point in time. Similarly, the future term in equation (19) is vk+1/2 . Solving for these two terms therefore gives the update equations of the FDTD algorithm, which are ik and
n+1 vk+1/2 = c3 ik+1 n+1/2 n+1/2 n n = c1 vk+1/2 vk1/2 + c2 ik n1/2

(20)

ik

n+1/2

n + c4 vk+1/2 ,

(21)

UNIVERSITY OF UTAH DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING

50 S. Central Campus Dr | Salt Lake City, UT 84112-9206 | Phone: (801) 581-6941 | www.ece.utah.edu

ECE3300

Figure 3. Schematic representation of how a current sample at ik n and vk+1/2 .

n+1/2

is solved for in terms of ik

n1/2

n , vk1/2 ,

where the constant coecients are given by 2t tzR + 2zL 2L tR c2 = 2L + tR 2t c3 = tzG + 2zC 2C tG c4 = . 2C + tG c1 = (22) (23) (24) (25)

The importance of equations (20) and (21) is that they provide a way to solve for the future state of the system in terms of surrounding points in space and time. This is illustrated in gure 3, which indicates the points that determine how a value is updated. The system then leap frogs between voltage and current as it is updated in half-step time increments. A summary of the algorithm is provided below: 1. Instantiate the samples of voltage and current over the simulation domain to their initial values. 2. Loop over all values of k and solve for the future state of the current, ik
n+1/2

n+1 3. Loop over all values of k and solve for future state of the voltage, vk+1/2 .

4. Increment n. 5. Process the new state of the system (ie, plot a graph, compute power ow, etc). 6. If n is greater than the desired simulation time N , terminate the loop. Else, return to step 2.

UNIVERSITY OF UTAH DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING

50 S. Central Campus Dr | Salt Lake City, UT 84112-9206 | Phone: (801) 581-6941 | www.ece.utah.edu

ECE3300

3. STABILITY
If one were to attempt the algorithm dened above for FDTD, one would quickly discover that certain congurations of the physical constants are unstable, and the simulated system rapidly increases without bound. To gain insight into this phenomenon, it helps to study the physical solutions to the telegraphers equations and see how they behave under the FDTD scheme. To illustrate, consider a lossless transmission line where R = G = 0. The general solutions for the voltage and current take on the form of forward- and reverse-traveling waves, given by v(z, t) = V0+ cos(t z + + ) + V0 cos(t + z + ) , i(z, t) = V0+ Z0 cos(t z + + ) V0 Z0 cos(t + z + ) . (26) (27)

where Z0 = L /C . For simplicity, let us only consider the case of a basic, forward-traveling wave, such that V0+ = 1.0 V, and V0 = 0. Also, we may neglect the phase term so that + = 0, leaving v(z, t) = cos(t z) , 1 i(z, t) = cos(t z) . Z0 (28) (29)

In terms of our FDTD stencil, the solutions to the telegraphers equations can now be expressed as
n vk = cos(nt kz) , 1 in = cos(nt kz) . k Z0

(30) (31)

For convenience, it helps to dene the constants A, B, and C such that A = nt kz B = t C = z . This allows us to rewrite the stencils within the update equations as
n vk+1/2 = cos(A C/2) , n+1 vk+1/2 = cos(A + B C/2) ,

(32) (33) (34)

(35) (36) (37) (38)

ik

n+1/2

= cos(A + B/2) , = cos(A B/2) ,

n1/2 ik

and so on. If these expressions are plugged back into an update equation such as (21), we nd cos(A + B C/2) = c3 [cos(A + B/2) cos(A B/2)] + cos(A C/2) , Z0 (39)

where c4 = 1 under the lossless condition.

UNIVERSITY OF UTAH DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING

50 S. Central Campus Dr | Salt Lake City, UT 84112-9206 | Phone: (801) 581-6941 | www.ece.utah.edu

ECE3300 The importance of equation (39) is that it places constraints on the available choices for c3 . As long as A, B, and C are real numbers, the left side of the expression is bounded by the interval [1, 1]. However, the constant c3 is arbitrary, and could easily be chosen such that the amplitude of the cosine terms on the right side exceeds the natural bounds on the left. When this happens, error quickly accumulates in the simulation, and the system is said to be unstable or blow up. To prevent the simulation from being unstable, all we need to do is dene the system parameters in such a way that equation (39) never exceeds its natural bounds. This is usually accomplished by solving for a value of t that guarantees stability under the maximum possible extremes for the cosine terms. To illustrate, suppose that cos(A + B C/2) = 1 and cos(A C/2) = 1. We are then left with c3 2 [cos(A + B/2) cos(A B/2)] (40) Z0 t zC C [cos(A + B/2) cos(A B/2)] . L (41)

Next, we suppose the cosine terms in the brackets sum together at an extreme value of 2, and we are left with t C 1 . (42) zC L Finally, substitute the propagation velocity vp = 1/ L C and solve for t to nd t z . vp (43)

The upper limit on t is called the critical time step tc , and represents the maximum allowable time increment for a stable simulation. It also provides an intuitive physical picture because we cannot increment the simulation any more than the time required for a wave to travel one grid step in space.

4. BOUNDARY CONDITIONS
The nal step to implementing any FDTD algorithm is guring out how to handle the boundaries. The simplest boundary condition (BC) is called the Dirichlet boundary, and works by xing the end points of a simulation to some specied value. For example, the short-circuit load on a transmission line can easily be simulated by enforcing a voltage of zero at the far-right boundary. For a simulation domain of size K, this implies
n+1 vK+1/2 = 0

(Short-Circuit Boundary) .

(44)

Another special BC is called the Neumann boundary, which only xes the derivative of a function to some specied value. This can be used to simulate the open-circuit load by enforcing the condition
n+1 n+1 vK+1/2 = vK1/2

(Open-Circuit Boundary) .

(45)

In other words, the boundary point is assigned the same value as the rst inner point, giving a slope of zero between them. It should nally be noted that these conditions are complementary between voltage and current. That is, a Dirichlet condition on the voltage acts the same as a Neumann condition on the current, and vice versa.
UNIVERSITY OF UTAH DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING

50 S. Central Campus Dr | Salt Lake City, UT 84112-9206 | Phone: (801) 581-6941 | www.ece.utah.edu

You might also like