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:
- Finite-differences-time domain (FDTD)
- Finite Element Method (FEM)
- Method of Moments (MoM), or equivalently, Boundary Element Method (BEM)
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
|Meep||GPL||C++||Python, Scheme, C++||MPI|
- Meep. Developed at MIT, Meep is a highly efficient FDTD package, scriptable in Python, Scheme or callable from C++ APIs. It is parallelized with MPI, and it includes a library with support for a variety of material types.
- gprMax. Developed at the University of Edinburgh, gprMax was designed for modelling Ground Penetrating Radar (GPR) but can also be used to model electromagnetic wave propagation for many other applications. gprMax is command-line driven software written in Python, with performance-critical parts written in Cython/OpenMP.
- OpenEMS. Developed at the University of Duisburg-Essen, and parallelized with MPI. Matlab or Octave are mainly used as a scripting interfaces. The related project pyEMS provides a high-level Python interface.
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.
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
|Elmer FEM||LGPL||Fortran||GUI, Python||MPI|
- FEniCS. FEniCS is a popular open-source LGPLv3-licenced software package for solving partial differential equations (PDEs). It features high-level Python and C++ interfaces, and can be run in high-performance clusters. To get started, visit the FEniCS Tutorial which includes an example in magnetostatics, or check out the official Discourse forum.
- Elmer FEM. An open-source Finite Element Solver, dealing with multiphysical simulations. Built-in Electromagnetics Solvers include magnetostatic, electrostatic and wave-equation solvers. See the Elmer Models Manual for more information. Elmer has a GUI, a command-line interface, and a Python wrapper pyelmer.
- FreeFEM. FreeFEM is an open-source LGPLv3-licenced PDE solver relying on its own programming language. FreeFEM offers a large list of finite elements. Pre-built physics for Electromagnetic simulations include Magnetostatics and Electrostatics only.
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||Python, C++||Gmsh, meshio||Shared memory|
|PumaEM||GPLv3||Python/C++||Python||Gmsh, GiD, Ansys, VRML||MPI|
- Bempp. Bempp is an open-source, MIT licenced, computational boundary element platform to solve electrostatic, acoustic and electromagnetic problems. Bempp uses just-in-time compiled OpenCL or Numba kernels to assemble BEM operators in CPUs or GPUs. Features include a Python interface, Fast Multipole Method acceleration via Exafmm-t, and coupled FEM/BEM computations via interfaces to FEniCS.
- PumaEM is an open-source (GPL v3 licensed) Method of Moments implementation for Electromagnetics, accelerated with the Multilevel Fast Multipole Method, and parallelized via MPI.
- NEC-2. A classical code by LLNL rewritten in C++, targeted at wire and surface antenna simulation.
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.