FDTD in OghmaNano
1. Introduction
Finite-Difference Time-Domain (FDTD) is a full-wave numerical method for solving Maxwell’s equations directly in the time domain on a discrete spatial grid. In contrast to ray tracing, mode solvers, or transfer-matrix approaches, FDTD makes no geometric or modal assumptions. Instead, the electric and magnetic fields are advanced explicitly in time by discretising the curl equations—Ampère’s law and Faraday’s law—so that electromagnetic waves propagate, scatter, interfere, and diffract naturally through the simulation domain.
\[ \nabla \times \boldsymbol{H} = \sigma \boldsymbol{E} + \epsilon \frac{\partial \boldsymbol{E}}{\partial t}, \qquad \nabla \times \boldsymbol{E} = - \mu \frac{\partial \boldsymbol{H}}{\partial t}. \]
In the finite-difference time-domain (FDTD) method, Maxwell’s equations are solved directly in the time domain by replacing spatial derivatives with finite differences on a staggered grid (typically a Yee lattice) and advancing the fields in time. Because this approach makes essentially no assumptions about propagation direction, modal structure, or field behaviour, a single FDTD simulation can capture broadband response, diffraction and interference, near-field effects, sub-wavelength geometry, and transient electromagnetic phenomena within one framework. This lack of simplifying assumptions is what makes FDTD so general, but it is also what makes it computationally expensive: the spatial grid must resolve the smallest physical length scale, the time step is tightly constrained by numerical stability, and three-dimensional simulations quickly become memory- and time-intensive even for geometries that appear modest in size.
2. When to use FDTD and when not to use FDTD
In most practical optical problems, FDTD should not be the first method you reach for. For large-scale optical systems, long propagation distances, or situations dominated by geometric optics, FDTD is an extremely inefficient choice. Imaging systems, macroscopic lenses, apertures, and optical assemblies with millimetre- to centimetre-scale dimensions are far better treated using ray tracing, while planar multilayer structures such as thin-film solar cells, OLED stacks, and coatings are more accurately and efficiently modelled using transfer-matrix methods. In these regimes, FDTD acts like a computational sledgehammer: it dramatically increases runtime and memory usage while yielding little or no additional physical insight.
In practice, FDTD should be regarded as a method of last resort, reserved for cases where simpler models genuinely break down. Its strength lies in situations where the full electromagnetic field must be resolved explicitly, such as diffraction from sub-wavelength gratings, photonic crystals, metasurfaces, strongly disordered or rough interfaces, and near-field coupling effects that cannot be captured by ray optics or layered-media models. Even in these cases, FDTD should be applied narrowly and deliberately, with a clear understanding of its numerical cost, stability constraints, and memory requirements. The sections that follow therefore derive the discrete update equations used in OghmaNano directly from Ampère’s and Faraday’s laws, not to encourage indiscriminate use, but to make explicit both what FDTD can do and why it should be used sparingly.
3. Theoretical background
This section of the manual aims to describe the FDTD code in full with verbose derivations to help understanding/pick up errors.
Ampere’s law is given as \[\sigma \boldsymbol{E} + \epsilon \frac{\partial \boldsymbol{E}}{\partial t} = \nabla \times \boldsymbol{H} = \begin{vmatrix} \hat{\boldsymbol{x}} & \hat{\boldsymbol{y}} & \hat{\boldsymbol{z}} \\ \frac{\partial}{\partial x} & \frac{\partial}{\partial y} & \frac{\partial}{\partial z} \\ H_{x} & H_{y} & H_{z} \end{vmatrix}\]
which can be expanded as
\[\sigma E_{x} + \epsilon \frac{\partial E_{x}}{\partial t} = \frac{\partial H_{z}}{\partial y}-\frac{\partial H_{y}}{\partial z}\]
\[\sigma E_{y} + \epsilon \frac{\partial E_{y}}{\partial t} = -\frac{\partial H_{z}}{\partial x}+\frac{\partial H_{x}}{\partial z}\]
\[\sigma E_{z} + \epsilon \frac{\partial E_{z}}{\partial t} = \frac{\partial H_{y}}{\partial x}-\frac{\partial H_{x}}{\partial y}\]
For the case \(\frac{\partial}{\partial y}=0\)
\[\begin{split} &\sigma E_{x} + \epsilon \frac{\partial E_{x}}{\partial t} =-\frac{\partial H_{y}}{\partial z}\\ &\sigma E_{y} + \epsilon \frac{\partial E_{y}}{\partial t} = -\frac{\partial H_{z}}{\partial x}+\frac{\partial H_{x}}{\partial z}\\ &\sigma E_{z} + \epsilon \frac{\partial E_{z}}{\partial t} = \frac{\partial H_{y}}{\partial x} \end{split}\]
for \(E_{x}\) \[\begin{split} &\sigma E_{x} + \epsilon \frac{\partial E_{x}}{\partial t} =-\frac{\partial H_{y}}{\partial z}\\ &\sigma \frac{E_{x}^{t+1}[]+E_{x}^{t}[]}{2} + \epsilon \frac{E_{x}^{t+1}[]-E_{x}^{t}[]}{\Delta t} = -\frac{H_{y}^{t+\frac{1}{2}}[\frac{1}{2}]-H_{y}^{t+\frac{1}{2}}[-\frac{1}{2}]}{\Delta z}\\ &\sigma \frac{E_{x}^{t+1}[]}{2} + \epsilon \frac{E_{x}^{t+1}[]}{\Delta t} = -\frac{H_{y}^{t+\frac{1}{2}}[\frac{1}{2}]-H_{y}^{t+\frac{1}{2}}[-\frac{1}{2}]}{\Delta z}-\sigma \frac{E_{x}^{t}[]}{2}+\epsilon \frac{E_{x}^{t}[]}{\Delta t}\\ &\sigma \frac{E_{x}^{t+1}[]}{2} + \epsilon \frac{E_{x}^{t+1}[]}{\Delta t} = -\frac{H_{y}^{t+\frac{1}{2}}[\frac{1}{2}]-H_{y}^{t+\frac{1}{2}}[-\frac{1}{2}]}{\Delta z}-\sigma \frac{E_{x}^{t}[]}{2}+\epsilon \frac{E_{x}^{t}[]}{\Delta t}\\ & \frac{\sigma \Delta t + 2 \epsilon }{ 2 \Delta t}E_{x}^{t+1}[] = -\frac{H_{y}^{t+\frac{1}{2}}[\frac{1}{2}]-H_{y}^{t+\frac{1}{2}}[-\frac{1}{2}]}{\Delta z}-\sigma \frac{E_{x}^{t}[]}{2}+\epsilon \frac{E_{x}^{t}[]}{\Delta t}\\ & E_{x}^{t+1}[] = \left ( -\frac{H_{y}^{t+\frac{1}{2}}[\frac{1}{2}]-H_{y}^{t+\frac{1}{2}}[-\frac{1}{2}]}{\Delta z}-\sigma \frac{E_{x}^{t}[]}{2}+\epsilon \frac{E_{x}^{t}[]}{\Delta t} \right ) \frac{2 \Delta t}{\sigma \Delta t + 2 \epsilon} \end{split}\]
for \(E_{y}\) \[\begin{split} &\sigma E_{y} + \epsilon \frac{\partial E_{y}}{\partial t} = -\frac{\partial H_{z}}{\partial x}+\frac{\partial H_{x}}{\partial z}\\ &\sigma \frac{E_{y}^{t+1}[]+E_{y}^{t}[]}{2} + \epsilon \frac{E_{y}^{t+1}[]-E_{y}^{t}[]}{\Delta t} = -\frac{H_{z}^{t+\frac{1}{2}}[\frac{1}{2}]-H_{z}^{t+\frac{1}{2}}[-\frac{1}{2}]}{\Delta x}+\frac{H_{x}^{t+\frac{1}{2}}[\frac{1}{2}]-H_{x}^{t+\frac{1}{2}}[-\frac{1}{2}]}{\Delta z}\\ &\sigma \frac{E_{y}^{t+1}[]}{2} + \epsilon \frac{E_{y}^{t+1}[]}{\Delta t} = -\frac{H_{z}^{t+\frac{1}{2}}[\frac{1}{2}]-H_{z}^{t+\frac{1}{2}}[-\frac{1}{2}]}{\Delta x}+\frac{H_{x}^{t+\frac{1}{2}}[\frac{1}{2}]-H_{x}^{t+\frac{1}{2}}[-\frac{1}{2}]}{\Delta z}-\sigma \frac{E_{y}^{t}[]}{2} + \epsilon \frac{E_{y}^{t}[]}{\Delta t}\\ &E_{y}^{t+1}[] = \left ( -\frac{H_{z}^{t+\frac{1}{2}}[\frac{1}{2}]-H_{z}^{t+\frac{1}{2}}[-\frac{1}{2}]}{\Delta x}+\frac{H_{x}^{t+\frac{1}{2}}[\frac{1}{2}]-H_{x}^{t+\frac{1}{2}}[-\frac{1}{2}]}{\Delta z}-\sigma \frac{E_{y}^{t}[]}{2} + \epsilon \frac{E_{y}^{t}[]}{\Delta t} \right ) \frac{2 \Delta t}{\sigma \Delta t + 2 \epsilon} \end{split}\]
for \(E_{z}\) \[\begin{split} &\sigma E_{z} + \epsilon \frac{\partial E_{z}}{\partial t} = \frac{\partial H_{y}}{\partial x}\\ &\sigma \frac{E_{z}^{t+1}[]+E_{z}^{t}[]}{2} + \epsilon \frac{E_{z}^{t+1}[]-E_{z}^{t}[]}{\Delta t} = \frac{H_{y}^{t+\frac{1}{2}}[\frac{1}{2}]-H_{y}^{t+\frac{1}{2}}[-\frac{1}{2}]}{\Delta x}\\ &\sigma \frac{E_{z}^{t+1}[]}{2} + \epsilon \frac{E_{z}^{t+1}[]}{\Delta t} = \frac{H_{y}^{t+\frac{1}{2}}[\frac{1}{2}]-H_{y}^{t+\frac{1}{2}}[-\frac{1}{2}]}{\Delta x}-\sigma \frac{E_{z}^{t}[]}{2} + \epsilon \frac{E_{z}^{t}[]}{\Delta t}\\ &E_{z}^{t+1}[]= \left ( \frac{H_{y}^{t+\frac{1}{2}}[\frac{1}{2}]-H_{y}^{t+\frac{1}{2}}[-\frac{1}{2}]}{\Delta x}-\sigma \frac{E_{z}^{t}[]}{2} + \epsilon \frac{E_{z}^{t}[]}{\Delta t} \right ) \frac{2 \Delta t}{\sigma \Delta t + 2 \epsilon}\\ \end{split}\]
Faraday’s law is given as \[-\sigma_{m} \boldsymbol{H} - \mu \frac{\partial \boldsymbol{H}}{\partial t} = \nabla \times \boldsymbol{E} = \begin{vmatrix} \hat{\boldsymbol{x}} & \hat{\boldsymbol{y}} & \hat{\boldsymbol{z}} \\ \frac{\partial}{\partial x} & \frac{\partial}{\partial y} & \frac{\partial}{\partial z} \\ E_{x} & E_{y} & E_{z} \end{vmatrix}\]
which can be expanded to give:
\[-\sigma_{m} H_{x} - \mu \frac{\partial H_{x}}{\partial t} = \frac{\partial E_{z}}{\partial y}-\frac{\partial E_{y}}{\partial z}\]
\[-\sigma_{m} H_{y} - \mu \frac{\partial H_{y}}{\partial t} = -\frac{\partial E_{z}}{\partial x}+\frac{\partial E_{x}}{\partial z}\]
\[-\sigma_{m} H_{z} - \mu \frac{\partial H_{z}}{\partial t} = \frac{\partial E_{y}}{\partial x}-\frac{\partial E_{x}}{\partial y}\]
With \(\sigma_m=0\) and \(\frac{\partial}{\partial y}=0\)
\[\begin{split} &\frac{\partial H_{x}}{\partial t} = \frac{1}{\mu} \left ( \frac{\partial E_{y}}{\partial z} \right )\\ &\frac{\partial H_{y}}{\partial t} = \frac{1}{\mu} \left ( \frac{\partial E_{z}}{\partial x}-\frac{\partial E_{x}}{\partial z} \right )\\ &\frac{\partial H_{z}}{\partial t} = - \frac{1}{\mu} \left ( \frac{\partial E_{y}}{\partial x} \right ) \end{split}\]
which discretizing gives
\[\begin{split} & H_{x}^{t+1} = \frac{1}{\mu} \left ( \frac{E_{y}^{t+\frac{1}{2}}[\frac{1}{2}]-E_{y}^{t+\frac{1}{2}}[-\frac{1}{2}]}{\Delta z} \right ) \Delta t + H_{x}^{t}[]\\ & H_{y}^{t+1} = \frac{1}{\mu} \left ( \frac{E_{z}^{t+\frac{1}{2}}[\frac{1}{2}]-E_{z}^{t+\frac{1}{2}}[-\frac{1}{2}]}{\Delta x}-\frac{E_{x}^{t+\frac{1}{2}}[\frac{1}{2}]-E_{x}^{t+\frac{1}{2}}[-\frac{1}{2}]}{\Delta z} \right ) \Delta t+ H_{y}^{t}[]\\ & H_{z}^{t+1} = \frac{1}{\mu} \left ( - \frac{E_{y}^{t+\frac{1}{2}}[\frac{1}{2}]-E_{y}^{t+\frac{1}{2}}[-\frac{1}{2}]}{\Delta x} \right ) \Delta t + H_{x}^{z}[] \end{split}\]
4. Numerical solution on a computer
The equations derived above describe the continuous-time, continuous-space evolution of the electric and magnetic fields. To solve them on a computer, both space and time are discretised. The simulation domain is divided into a regular grid of cells, and the field components are stored at discrete spatial locations and discrete time steps. In the standard FDTD formulation, the electric and magnetic fields are staggered in both space and time, so that each field component is evaluated where it is naturally required by the curl equations.
In practice, this means that the electric field components are stored at integer time steps (\(t, t+\Delta t, t+2\Delta t\)), while the magnetic field components are stored at half-integer time steps (\(t+\tfrac{1}{2}\Delta t, t+\tfrac{3}{2}\Delta t\)). Spatial derivatives such as \(\partial / \partial x\) and \(\partial / \partial z\) are replaced by centred finite differences between neighbouring grid points. This staggering leads to a simple, explicit update scheme in which the fields leapfrog over one another in time.
At each time step, the magnetic field is updated first using the discretised form of Faraday’s law, with the curl of the electric field evaluated from the current electric-field values. Once the magnetic field has been advanced by half a time step, the electric field is then updated using the discretised form of Ampère’s law, including material parameters such as permittivity, permeability, and conductivity. No global matrix solve is required: each field component at each grid cell is updated using only its local neighbours from the previous time step.
This explicit time-stepping procedure is repeated until the desired simulation time is reached. Because the method is time-domain, a single simulation naturally contains information over a broad frequency range; frequency-domain quantities such as spectra or steady-state field distributions are typically obtained by recording field values as a function of time and post-processing them using Fourier transforms. Sources, boundaries, and absorbing layers (such as perfectly matched layers) are incorporated directly into the update equations at the appropriate grid locations.
The simplicity of the update equations makes FDTD conceptually straightforward and highly parallelisable, but it also imposes strict numerical constraints. The time step must satisfy a stability condition that depends on the spatial grid spacing and material properties, and the memory footprint scales directly with the number of grid cells and stored field components. These constraints ultimately limit the size and duration of simulations that can be performed in practice and motivate careful choice of grid resolution, domain size, and model complexity.