Computational Electromagnetics

Open-Source Electromagnetic Simulation: FDTD, FEM, MoM

by Martin D. Maas, Ph.D

Last updated: 2021-08-24

This is a review of the most up-to-date open-source projects in Computational Electromagnetics, encompassing the three major techniques in this area: FDTD, FEM and BEM/MoM.

Method of Moments (equivalenty, BEM) simulation via the open-source Bempp package. Source: bempp.com

Computational Electromagnetics encompasses a wide range of application areas, including antennas, nano-photonics, solar cells, metamaterials, lasers, and many more. There are also many ways to approach the computations required in these various areas.

There are three major family of numerical methods for Electromagnetic simulations: FDTD, FEM and MoM. Each of these approaches is best suited for certain cases, and has advantages and disadvantages.

In this post we discuss the basic trade-offs between these families of methods, and we give some references to some of the best open-source implementations out there.

Difference between FDTD, FEM and MoM.

There are three basic numerical approaches for electromagnetic simulation, namely:

Before digging deeper into each one of these options, lets give a short summary of this three alternatives:

Method Solver type Discretization Material type
FDTD Differential equation Volumetric domain Non-linear, anisotropic
FEM Variational form Volumetric domain Non-linear, anisotropic, multi-physics
MoM/BEM Integral equations Surface currents Linear, piecewise homogeneous

What is the FDTD method?

FDTD is the application of finite differences to Maxwell’s equations, in a second order, stable, staggered-grid approach for electric and magnetic fields. The method was first proposed in a seminal 1966 paper by Kane Yee. The FDTD acronym, in turn, was coined later by Taflove in the 1980’s.

Some of the main advantages of the FDTD is that, being based on the time domain, the FDTD method supports a wide range of frequencies, and additionally, the incorporation of non-linear materials is straightforward.

Disadvantages of FDTD

The flexibility of time-domain discretization comes at a certain price, tough. As with any finite difference method, the propagation of a wave in the discrete grid doesn’t obey the exact dispersion relations of Maxwell’s equations, but rather an approximate version of them. This is called numerical dispersion error, and it can quickly become one of the main accuracy limitations of the FDTD.

Consequently, in FDTD the error accumulates over time, especially for high frequencies. This can make long-time simulations and high frequency propagation challenging to compute with FDTD, as the initial error (and thus the grid size) have to be really small to compensate the effect of this error accumulation. See for example, this paper by Taflove where they report to have used a discretization finer than 1/100th wavelengths for a 1.5 dB accuracy.

Another drawback of FDTD is related to the treatment of the unbounded domains which we frequently encounter in Computational Electromagnetics. In such cases, radiation boundary conditions need to be implemented by means of numerically absorbing boundary conditions (ABC). One of the most popular methods to do so is the Perfectly matched layer (PML). This solution comes at the cost of requiring large computational domains surrounding the geometry of interest, which further slows down computations.

Best open-source FDTD codes

Software License Written in Interface Parallelization
Meep GPL C++ Python, Scheme, C++ MPI
gprMax GPL Python+Cython Python CUDA, MPI
OpenEMS GPL C++ Matlab/Octave MPI

FEM for Computational Eletromagnetics

The Finite Element Method (FEM) is a popular approach for solving PDEs in general, in view of the ease to accommodate a given triangulated geometry. For this reason, in Electromagnetism, the FEM is typically employed for static or time-harmonic problems with complex geometries.

The FEM is also very well suited for multi-physics problems (i.e. where electromagnetism is coupled with elasticity, heat transfer, fluid dynamics), as substantial existing software can be reused.

The method is based on a weak integral formulations obtained via multiplication of the PDE by test functions and integration-by-parts arguments. The unknowns and the test functions are then restricted into suitable discrete spaces, which usually leads to sparse linear algebra problems.

Volumetric Discretization

The FEM, as it is usually employed on the frequency domain, doesn’t suffer from dispersion error as the FDTD. It is also possible to use the FEM as a part of a time-stepping algorithm, in which case the same concerns about numerical dispersion will apply.

An important feature of the FEM is that it is a volumetric discretization method. This can be considered either as a feature or as a limitation. For example, the FEM will accommodate anisotropic materials with ease. However, this becomes a limitation in the case of homogeneous materials, where the FEM is not using that property to simplify calculations. This also means that the FEM will require a volumetric mesh, which can be more complicated to obtain with respect to a surface mesh (as required by MoM/BEM).

One particular are where the volumetric nature of the FEM is certainly a limitation, is on the treatment of the air around a geometry of interest. This air has to be discretized as well, leading to large computational domains, just like in the FDTD. Unlike the FDTD where this limitation is rather fundamental, in the case of the FEM it can be circumvented by means of a coupled FEM/BEM approach. This leads us a step closer to the Method of Moments (or BEM), which is the third method under consideration in this post.

Best open-source FEM codes for electromagnetism

Software License Written in Interface Parallelization
FEniCS LGPL C++ Python, C++ MPI
Elmer FEM LGPL Fortran MPI
FreeFEM LGPL C++ Own language MPI

The Method of Moments (MOM) or BEM in Electromagnetics

The method of moments (or boundary element method) is a frequency-domain method for performing electromagnetic simulations. The MoM also enforces radiation boundary conditions automatically, without requiring to discretize a large volume of air around a given geometry of interest.

The main advantage of the MoM is that only surfaces need to meshed, giving the MoM a big computational advantage over the FDTD and the FEM. As a frequency domain method, it does not suffer from numerical dispersion. Its main drawback is that is mainly suited to deal with linear problems and piecewise homogeneous materials.

For anisotropic materials, there is the possibility of resorting to a volumetric version of the BEM, or to a coupled FEM/BEM approach.

Best open-source MOM codes

Software License Written in Interface Input meshes Parallelization
Bempp MIT Python+OpenCL/Numba Python, C++ Gmsh, meshio Shared memory
PumaEM GPLv3 Python/C++ Python Gmsh, GiD, Ansys, VRML MPI
NEC-2 GPLv2 C++ C/C++/Python/Ruby Antenna parameters Single-threaded?


There are many numerical methods to choose from for solving Maxwells equations. The choice of method/packages can depend on multiple factors, such as the required generality in terms of materials, geometries, and the computational efficiency and available computer equipment.

Ask me a question or send me your comments!

Don't hesitate to ask me any question about the topics I cover on this blog!

Click here to reach out!

Selected Posts