FEM, MoM and BEM: Meshes, Convergence and Validation
Finite differences (Finite Differences for Laplace and Poisson) and FDTD (The FDTD Method) put a regular grid over all of space. Real devices have curved surfaces, thin layers and fine features next to large empty regions, and a regular grid either staircases them or wastes millions of cells. The two other workhorses of computational electromagnetics fix this in different ways. The finite element method (FEM) fills the region with an unstructured mesh of triangles or tetrahedra that follow the geometry and grow where nothing happens. The method of moments (MoM), a boundary element method (BEM), does not mesh space at all: it puts unknowns only on the conductors' surfaces. This lesson builds a tiny example of each, measures their convergence, and sets out the validation habits that every field simulation needs.
The finite element method
FEM starts from a weak (integral) form of the equation. For Poisson's equation (Poisson's and Laplace's Equations), multiply by a test function that vanishes where is prescribed and integrate by parts:
Now approximate with simple basis functions (in 1-D, the "hat" that is 1 at node , 0 at the other nodes and linear in between), and use the same functions as tests (Galerkin's method). The result is a sparse linear system , assembled element by element: each element adds a small "stiffness" matrix to and a load to . Physically, solving it minimises the stored energy minus the work of the charges, which is why FEM capacitance from energy converges from one side.
Properties. Elements follow curved boundaries and interfaces exactly (or to second order with curved elements); material changes sit on element faces, where FEM automatically satisfies the natural boundary condition of continuous normal . With linear elements, the error in falls as and in as , where is the element size. For high-frequency problems, FEM uses edge (Nédélec) elements, whose unknowns are tangential field components along element edges, so tangential is continuous and no spurious modes appear. FEM is the standard for magnetostatics with nonlinear iron (motors, transformers: Magnetic Circuits), electrostatics of insulators, eddy currents and frequency-domain RF structures.
The method of moments and boundary elements
For conductors in a homogeneous medium, the potential anywhere is an integral over the unknown surface charge, using the free-space Green's function (Charge Distributions):
Divide the surface into patches with a constant (pulse) charge density on each, and require the equation at the patch centres (point matching): an dense system . Off-diagonal entries are approximately for patches of side ; the diagonal needs the exact potential of a uniformly charged square at its own centre, per unit density. Then .
Properties. Only surfaces are meshed, and the radiation condition at infinity is built into the Green's function, so open problems (antennas, scattering, capacitance of a component in free space) need no absorbing boundary. The price is a dense matrix: storage and direct solution, so large problems use fast multipole or compressed-matrix methods. Wire-antenna MoM codes (NEC is the classic) use the same idea with currents on thin wires. Inhomogeneous materials are hard for pure MoM, which is why hybrids (FEM inside, BEM outside) exist.
Worked example: what to expect from the two solvers
Given: (a) a 1-D FEM model of on with (exact ), linear elements; (b) a MoM model of a thin plate at with pulse basis.
Find: the expected order of convergence for each, and how to extrapolate.
Solve: (a) linear interpolation of a smooth function has error about : with and , that is , and it should fall by each time halves (order 2). (b) The charge density on a plate edge is singular (it grows like towards an edge), which constant patches resolve poorly, so expect a slower, about first-order convergence; then Richardson extrapolation with , , removes most of the error, as in the mini project.
Check: the script's coarsest FEM error, , matches the estimate; the MoM differences between successive meshes (, , ) halve each time: first order, as predicted.
In Python
import numpy as np
# ---- 1. FEM, 1-D: -V'' = rho(x)/eps with V(0) = V(1) = 0; take rho/eps = pi^2 sin(pi x), exact V = sin(pi x)
def fem_1d(n):
x = np.linspace(0, 1, n + 1)
h = np.diff(x)
K = np.zeros((n + 1, n + 1)); F = np.zeros(n + 1)
gp, gw = np.array([-1, 1]) / np.sqrt(3), np.array([1.0, 1.0]) # 2-point Gauss rule
for e in range(n):
K[e:e + 2, e:e + 2] += np.array([[1, -1], [-1, 1]]) / h[e] # element stiffness
xm, xr = (x[e] + x[e + 1]) / 2, h[e] / 2
for g, w in zip(gp, gw):
xg = xm + xr * g
f = np.pi**2 * np.sin(np.pi * xg)
F[e:e + 2] += w * xr * f * np.array([(1 - g) / 2, (1 + g) / 2]) # load against the hat functions
V = np.zeros(n + 1)
V[1:-1] = np.linalg.solve(K[1:-1, 1:-1], F[1:-1]) # Dirichlet: V = 0 at both ends
xs = np.linspace(0, 1, 2001)
return np.max(np.abs(np.interp(xs, x, V) - np.sin(np.pi * xs)))
print("1-D FEM, linear elements:")
prev = None
for n in [4, 8, 16, 32]:
err = fem_1d(n)
rate = "" if prev is None else f", order {np.log2(prev / err):.2f}"
print(f" {n:2d} elements: max error {err:.2e}{rate}")
prev = err
# ---- 2. MoM: capacitance of a 1 m x 1 m thin square plate, pulse basis, point matching
EPS0 = 8.854e-12
def plate_capacitance(n, side=1.0):
a = side / n
c = (np.arange(n) + 0.5) * a - side / 2
X, Y = np.meshgrid(c, c)
pts = np.column_stack([X.ravel(), Y.ravel()])
R = np.hypot(pts[:, None, 0] - pts[None, :, 0], pts[:, None, 1] - pts[None, :, 1])
np.fill_diagonal(R, 1.0)
P = a**2 / (4 * np.pi * EPS0 * R) # far patches: point charges
np.fill_diagonal(P, a * np.log(1 + np.sqrt(2)) / (np.pi * EPS0)) # self term: exact for a square patch
sigma = np.linalg.solve(P, np.ones(n * n)) # plate held at 1 V
return np.sum(sigma) * a**2 # C = Q / V
print("MoM, square plate 1 m x 1 m:")
res = {}
for n in [4, 8, 16, 32]:
res[n] = plate_capacitance(n)
print(f" {n:2d} x {n:2d} patches: C = {res[n]*1e12:.3f} pF")
rich = 2 * res[32] - res[16] # error roughly proportional to h
print(f" Richardson (first order) from 16 and 32: C = {rich*1e12:.2f} pF")1-D FEM, linear elements:
4 elements: max error 7.01e-02
8 elements: max error 1.88e-02, order 1.90
16 elements: max error 4.79e-03, order 1.97
32 elements: max error 1.20e-03, order 1.99
MoM, square plate 1 m x 1 m:
4 x 4 patches: C = 38.240 pF
8 x 8 patches: C = 39.567 pF
16 x 16 patches: C = 40.225 pF
32 x 32 patches: C = 40.541 pF
Richardson (first order) from 16 and 32: C = 40.86 pF
The FEM error falls by four at each refinement (observed order ). The MoM capacitance rises towards a limit from below and the Richardson value, , agrees with published high-accuracy computations for the unit square plate (; F. H. Read, arXiv math-ph/0603051) to about . Grading the patches finer towards the edges, where the charge crowds, would converge much faster than uniform refinement: that is what adaptive meshing does automatically.
Validation: how to trust a field solver
Every numerical result in this course was checked the same way, and so should yours be:
- Reproduce an exact case. A coaxial line, a sphere, a parallel-plate capacitor, a dielectric interface: the solver must match the formula. This catches modelling mistakes (wrong boundary condition, wrong units).
- Converge the mesh. Refine (globally or adaptively) until the quantity you need changes less than your tolerance; check that it converges at the expected order. A result that has not been refined is a guess.
- Check conservation and symmetry. Total charge equal and opposite on two conductors, a symmetric structure giving a symmetric field, power in equal to power out plus losses (Poynting's Theorem).
- Compare with a different method or a measurement. FEM against MoM, a simulation against a measured capacitance or , within the measurement uncertainty.
- Know the model's limits. A 2-D solver ignores end effects; a lossless model ignores skin effect; a mesh that staircases a curve converges only at first order.
Meshing in practice. Unstructured meshes are built by Delaunay triangulation or advancing-front algorithms (Gmsh and Triangle are common open-source mesh generators). Good meshes have well-shaped elements (no slivers), are fine where fields change fast (corners, edges, thin gaps, within a skin depth of conductors) and coarse elsewhere. Adaptive solvers estimate the error per element and refine where it is largest.
Tools (as of November 2026, all still maintained; check current versions). FEMM (2-D magnetostatics, electrostatics and current flow, Windows, free), Elmer FEM (multiphysics, open source), FreeFEM and FEniCS (now FEniCSx; FEM toolkits), openEMS and Meep (FDTD), NEC-2 (wire MoM, public domain), plus commercial suites from several vendors. The roadmap's suggested exercise, a coil and magnetic circuit in FEMM, follows directly from Magnetic Circuits: build it, refine the mesh until the inductance stops changing, and compare with the reluctance estimate.
Guided lab: validate a capacitance
Hand calculation. For two square plates of side and gap , without fringing.
Simulation. Extend the MoM script to two plates (two sets of patches, one at , one at , ) and converge it; expect several per cent above the parallel-plate value from fringing (Palmer's formula, , gives about here).
What you would measure. With an LCR meter at , measure the plates spaced by four small nylon spacers, connecting with short leads and subtracting the open-lead reading. Expect agreement within about to , limited by plate flatness and the spacer thickness tolerance (a error in a gap is ).
Hazards and safe setup. LCR-meter levels only. Keep the plates away from any high-voltage source.
Pitfalls
- Trusting a single mesh. Always show a refinement study.
- Point matching too close to singularities. Self terms must be integrated analytically or with special quadrature; a naive with is infinite.
- Wrong order of convergence. If the observed order is lower than expected, something (a corner, a staircase, a bug) is limiting it.
- Forgetting the open boundary in FEM. FEM needs a truncation boundary far enough away, or an infinite-element or absorbing condition.
Practice
- Linear FEM gives a max error of with elements. Estimate the error with elements.
- MoM gives with and with , converging at first order. Extrapolate.
- Why does MoM need no absorbing boundary for an antenna problem, while FDTD and FEM do?
Answer
- Order 2: two halvings divide it by , about .
- .
- The free-space Green's function already satisfies the radiation condition at infinity; FDTD and FEM discretise space itself and must truncate it.
Test yourself
Which method meshes only the surfaces of conductors?
- FDTD
- FEM
- MoM (a boundary element method)
- finite differences
Linear finite elements for a smooth potential converge at order…
- for
- for
- for
- they do not converge
Why does the MoM plate capacitance converge only at first order?
- the Green's function is wrong
- the charge density is singular at the plate edges, poorly captured by constant patches
- point matching is exact
- the matrix is sparse
Which step should come first when validating a new field solver?
- run the full product geometry
- reproduce a case with an exact solution
- buy a faster computer
- skip mesh refinement