TExcelTAD
Home › Electromagnetic Theory: Maxwell's Equations to Waves › The FDTD Method in 1-D and 2-D

The FDTD Method in 1-D and 2-D

How does a radar pulse scatter off an aircraft, a phone's signal couple into a nearby trace, or a wideband antenna respond from 11 to 10 GHz10\ \text{GHz} in one run? For problems like these, the most direct numerical method is to step Maxwell's two curl equations forward in time on a grid: the finite-difference time-domain (FDTD) method, introduced by K. S. Yee in 1966. It needs no matrix solver, handles any material map, and gives a broadband answer from a single pulse via the Fourier transform. This lesson builds a 1-D FDTD solver, checks it against the reflection coefficient of a dielectric interface, demonstrates the Courant stability limit, and runs a tiny 2-D simulation. The finite-difference wave equation in Numerical Methods is the mathematical background; the static counterpart is Finite Differences for Laplace and Poisson.

The Yee grid

In one dimension, with E=Ezz^\mathbf{E} = E_z\hat{\mathbf{z}} and H=Hyy^\mathbf{H} = H_y\hat{\mathbf{y}} varying along xx, Maxwell's curl equations (Maxwell's Equations) reduce to two coupled first-order equations:

μ∂Hy∂t=∂Ez∂x,ε∂Ez∂t=∂Hy∂x\mu\frac{\partial H_y}{\partial t} = \frac{\partial E_z}{\partial x}, \qquad \varepsilon\frac{\partial E_z}{\partial t} = \frac{\partial H_y}{\partial x}

Yee's idea is to stagger the unknowns: EzE_z at whole cells i Δxi\,\Delta x and whole time steps n Δtn\,\Delta t, HyH_y half a cell and half a step away. Then every derivative is a centred difference over one cell or one step, accurate to second order, and the two fields leapfrog each other:

Ez[i-1]Ez[i]Ez[i+1] Hy[i-1/2]Hy[i+1/2]Hy[i+3/2] time nn + 1/2 Hy from its two Ez neighbours, then Ez from its two Hy dx
Hyn+1/2[i+12]=Hyn−1/2[i+12]+Δtμ Δx(Ezn[i+1]−Ezn[i])Ezn+1[i]=Ezn[i]+Δtε Δx(Hyn+1/2[i+12]−Hyn+1/2[i−12])\begin{aligned} H_y^{n+1/2}[i + \tfrac{1}{2}] &= H_y^{n-1/2}[i + \tfrac{1}{2}] + \frac{\Delta t}{\mu\,\Delta x}\left(E_z^n[i + 1] - E_z^n[i]\right) \\ E_z^{n+1}[i] &= E_z^n[i] + \frac{\Delta t}{\varepsilon\,\Delta x}\left(H_y^{n+1/2}[i + \tfrac{1}{2}] - H_y^{n+1/2}[i - \tfrac{1}{2}]\right) \end{aligned}

Storing H~=η0H\tilde{H} = \eta_0 H instead of HH makes both coefficients depend only on the Courant number S=c Δt/ΔxS = c\,\Delta t/\Delta x: H~\tilde{H} gains S ΔEzS\,\Delta E_z and EzE_z gains (S/εr) ΔH~(S/\varepsilon_r)\,\Delta\tilde{H}. Materials are simply a map of εr\varepsilon_r (and μr\mu_r, σ\sigma) over the cells. A perfect conductor is a cell where EzE_z is held at zero.

Stability and accuracy

An explicit scheme is stable only if information does not cross more than one cell per step. In dd dimensions with equal cells, the Courant–Friedrichs–Lewy (CFL) condition is

S=c ΔtΔx≤1dS = \frac{c\,\Delta t}{\Delta x} \le \frac{1}{\sqrt{d}}

so Δt≤Δx/c\Delta t \le \Delta x/c in 1-D and Δx/(c2)\Delta x/(c\sqrt{2}) in 2-D. Above the limit, errors grow exponentially. Within it, accuracy depends on resolution: a common rule is at least 1010 to 2020 cells per shortest wavelength in the densest material, since the grid slightly slows short waves (numerical dispersion). The cost: cells scale as (L/Δx)d(L/\Delta x)^d and steps as L/(c Δt)L/(c\,\Delta t), so halving Δx\Delta x in 3-D costs 16 times the work.

Boundaries. A grid must end somewhere. A PEC wall reflects everything; open problems need an absorbing boundary, from simple one-way-wave conditions (Mur's) to the perfectly matched layer (PML) of Bérenger (1994), a lossy layer whose impedance matches the grid at all angles. The scripts below avoid the issue by making the 1-D grid long enough that end reflections arrive after the measurement window.

Worked example: setting up a run

Given: a 1-D model of a wave hitting a dielectric slab of εr=4\varepsilon_r = 4, with the highest frequency of interest 10 GHz10\ \text{GHz}.

Find: a cell size giving 2020 cells per wavelength in the slab, the time step at S=0.5S = 0.5, and the expected reflection and transmission coefficients.

Solve:

λslab=cfεr=2.998×1081010⋅2=15.0 mm,Δx=15.0 mm20=0.75 mmΔt=S Δxc=0.5⋅0.75×10−32.998×108=1.25 psΓ=η2−η1η2+η1=1/2−11/2+1=−13,τ=1+Γ=23\begin{aligned} \lambda_\text{slab} &= \frac{c}{f\sqrt{\varepsilon_r}} = \frac{2.998 \times 10^8}{10^{10} \cdot 2} = 15.0\ \text{mm}, \qquad \Delta x = \frac{15.0\ \text{mm}}{20} = 0.75\ \text{mm} \\ \Delta t &= \frac{S\,\Delta x}{c} = \frac{0.5 \cdot 0.75 \times 10^{-3}}{2.998 \times 10^8} = 1.25\ \text{ps} \\ \Gamma &= \frac{\eta_2 - \eta_1}{\eta_2 + \eta_1} = \frac{1/2 - 1}{1/2 + 1} = -\frac{1}{3}, \qquad \tau = 1 + \Gamma = \frac{2}{3} \end{aligned}

Check: Δt\Delta t is well inside the 1-D limit of 2.50 ps2.50\ \text{ps}. Γ\Gamma and τ\tau are those of Reflection at Normal Incidence; the simulation must reproduce them.

In Python

The 1-D part launches a Gaussian pulse (width about 3030 cells, so well resolved) towards a dielectric half-space, records the field at a probe in front of it and one inside it, and compares the reflected and transmitted peaks with Γ\Gamma and τ\tau. Then it runs an empty grid at S=1.0S = 1.0 and S=1.05S = 1.05. The 2-D part is a TMz grid (EzE_z, HxH_x, HyH_y) with PEC walls and a sinusoidal point source.

python · try it yourself
import numpy as np
import matplotlib.pyplot as plt

# ---- 1-D Yee grid: Ez and Hy (Hy scaled by eta0), Courant number S = c dt / dx
def run_1d(S, eps_r, steps, src=500, probes=(700, 1300)):
    n = eps_r.size
    ez, hy = np.zeros(n), np.zeros(n - 1)
    rec = np.zeros((steps, len(probes)))
    for t in range(steps):
        hy += S * (ez[1:] - ez[:-1])
        ez[1:-1] += S / eps_r[1:-1] * (hy[1:] - hy[:-1])
        ez[src] += np.exp(-((t - 120) / 30.0)**2)          # soft Gaussian source
        rec[t] = ez[list(probes)]
    return rec, ez

eps = np.ones(1600)
eps[1100:] = 4.0                                            # dielectric half-space from cell 1100
rec, _ = run_1d(0.5, eps, 2200)
inc = rec[:1500, 0].max()                                   # incident pulse passes cell 700 first
refl = rec[1500:, 0][np.argmax(np.abs(rec[1500:, 0]))]      # the reflection returns later
trans = rec[:, 1].max()
print(f"incident peak {inc:.4f}; reflected/incident {refl/inc:+.4f} (theory {(1-2)/(1+2):+.4f}); "
      f"transmitted/incident {trans/inc:.4f} (theory {2/(1+2):.4f})")

# stability: the same vacuum grid at S = 1.0 and S = 1.05
for S in [1.0, 1.05]:
    _, ez = run_1d(S, np.ones(400), 600, src=200, probes=(100,))
    print(f"S = {S:.2f}: max |Ez| after 600 steps = {np.abs(ez).max():.3g}")

# ---- 2-D TMz: Ez, Hx, Hy on a 121 x 121 grid with PEC walls, point source, S = 0.5
n, S = 121, 0.5
ez = np.zeros((n, n)); hx = np.zeros((n, n - 1)); hy = np.zeros((n - 1, n))
for t in range(160):
    hx -= S * (ez[:, 1:] - ez[:, :-1])
    hy += S * (ez[1:, :] - ez[:-1, :])
    ez[1:-1, 1:-1] += S * ((hy[1:, 1:-1] - hy[:-1, 1:-1]) - (hx[1:-1, 1:] - hx[1:-1, :-1]))
    ez[40, 60] += np.sin(2 * np.pi * t / 20)               # 20 steps per period at S = 0.5: lambda = 10 cells
print(f"2-D: |Ez| max {np.abs(ez).max():.3f} after 160 steps; wavefront radius about {160 * S:.0f} cells")
plt.figure(figsize=(4.4, 4))
plt.imshow(ez.T, origin="lower", cmap="RdBu", vmin=-0.25, vmax=0.25)
plt.title("2-D FDTD (TMz): Ez after 160 steps"); plt.xlabel("x (cells)"); plt.ylabel("y (cells)")
plt.show()
incident peak 1.0010; reflected/incident -0.3342 (theory -0.3333); transmitted/incident 0.6590 (theory 0.6667)
S = 1.00: max |Ez| after 600 steps = 0.5
S = 1.05: max |Ez| after 600 steps = 1.28e+155
2-D: |Ez| max 0.396 after 160 steps; wavefront radius about 80 cells

The reflection comes out at −0.3342-0.3342 against −1/3-1/3: the grid reproduces the boundary condition to 0.3 %0.3\ \%. The transmitted peak is 1.2 %1.2\ \% low because the pulse is resolved by fewer cells per wavelength inside the denser medium, so numerical dispersion spreads it a little; a finer grid closes the gap. At S=1.0S = 1.0 the 1-D grid is exactly at its limit (in vacuum it is even exact, the "magic time step"), while S=1.05S = 1.05 blows up to 1015510^{155} within 600600 steps: no physics, just the CFL condition. The 2-D picture shows cylindrical waves from the source (10 cells per wavelength), already reflected by the PEC walls on the left: without an absorbing boundary, a closed metal box is what the grid simulates.

Where FDTD is used

  • Antennas, scattering and EMC over wide bands: one pulse, one run, then an FFT of the probe signals gives the response at every frequency (Signals & Fourier).
  • Signal integrity: via transitions and connectors in 3-D.
  • Optics and photonics: periodic structures, nanoantennas.
  • Bio-electromagnetics: specific absorption rate in voxel models of the body for exposure assessment, where ICNIRP-style limits are verified by simulation rather than by experiment on people.

Open-source codes include openEMS (FDTD, with a MATLAB/Octave and Python interface) and Meep (MIT, FDTD with Python scripting); commercial suites include FDTD and finite-integration solvers. (Both still actively developed as of November 2026; check the projects' sites for current versions.) Their core loop is the leapfrog in this lesson, plus PML boundaries, sub-cell material averaging, excitation ports and near-to-far-field transforms.

Guided lab: validate before you trust

Hand calculation. Γ\Gamma and τ\tau for your interface; the CFL limit for your grid.

Simulation. Change eps[1100:] to other values and compare with Γ=(1−εr)/(1+εr)\Gamma = (1 - \sqrt{\varepsilon_r})/(1 + \sqrt{\varepsilon_r}); halve the pulse width (to 1515 cells) and watch the transmitted error grow; refine the grid and watch it shrink.

What you would measure. The physical counterpart is a TDR or VNA measurement of a cable or PCB with a known dielectric step, as in Transients on Lines: the measured reflected step should match both the formula and the simulation within the measurement uncertainty (a few per cent). A solver you have validated on such a case can then be trusted, within its resolution, on geometries without formulas.

Hazards and safe setup. Computation only. The one hazard is thermal: 3-D FDTD runs are long and CPU- or GPU-heavy, so keep grids small on a laptop and watch its temperature.

Pitfalls

  • Violating the CFL limit. Use S≤1/dS \le 1/\sqrt{d}, with dd the number of dimensions.
  • Too few cells per wavelength. Below about 10, phase errors accumulate over long runs.
  • Reflections from the grid edge. Without PML or a long enough grid, edge reflections contaminate the result.
  • Soft versus hard sources. A hard source (assigning EzE_z) reflects incoming waves like a wall; a soft source (adding to EzE_z) does not.

Practice

  1. What is the largest stable time step for cubic cells of 0.5 mm0.5\ \text{mm} in 3-D?
  2. A 2-D run uses 1 mm1\ \text{mm} cells and must cover a 0.3×0.3 m0.3 \times 0.3\ \text{m} region for 5 ns5\ \text{ns} at S=0.5S = 0.5. How many cell updates is that?
  3. For a dielectric of εr=9\varepsilon_r = 9, what reflection should the 1-D script report?
Answer
  1. Δt≤Δx/(c3)=0.5×10−3/(2.998×108⋅1.732)=0.963 ps\Delta t \le \Delta x/(c\sqrt{3}) = 0.5 \times 10^{-3}/(2.998 \times 10^8 \cdot 1.732) = 0.963\ \text{ps}.
  2. Cells: 300×300=9×104300 \times 300 = 9 \times 10^4. Δt=0.5⋅10−3/c=1.67 ps\Delta t = 0.5 \cdot 10^{-3}/c = 1.67\ \text{ps}, so 5 ns5\ \text{ns} needs 30003000 steps: 2.7×1082.7 \times 10^8 cell updates (times three field components).
  3. Γ=(1−3)/(1+3)=−0.5\Gamma = (1 - 3)/(1 + 3) = -0.5.

Test yourself

In the Yee scheme, where are EzE_z and HyH_y stored in 1-D?

  1. at the same points and times
  2. staggered by half a cell in space and half a step in time
  3. only at the boundaries
  4. on two separate grids of different sizes

The Courant stability limit for a 2-D grid of square cells is…

  1. S≤1S \le 1
  2. S≤1/2S \le 1/\sqrt{2}
  3. S≤1/2S \le 1/2
  4. S≤1/3S \le 1/\sqrt{3}

The 1-D script measures a reflection of −0.334-0.334 from a dielectric with εr=4\varepsilon_r = 4. The theoretical value is…

  1. −0.5-0.5
  2. −1/3-1/3
  3. +1/3+1/3
  4. −0.25-0.25

Why is FDTD well suited to broadband problems?

  1. it solves one frequency at a time
  2. a single pulse excitation and a Fourier transform give the response at all frequencies
  3. it needs no grid
  4. it is always more accurate than FEM