TExcelTAD
Home › Electromagnetic Theory: Maxwell's Equations to Waves › FEM, MoM and BEM: Meshes, Convergence and Validation

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 −∇⋅(ε∇V)=ρv-\nabla \cdot (\varepsilon\nabla V) = \rho_v (Poisson's and Laplace's Equations), multiply by a test function ww that vanishes where VV is prescribed and integrate by parts:

∫Ωε ∇w⋅∇V dv=∫Ωw ρv dvfor every admissible w\int_\Omega \varepsilon\,\nabla w \cdot \nabla V\,dv = \int_\Omega w\,\rho_v\,dv \quad \text{for every admissible } w

Now approximate V≈∑jVjNj(r)V \approx \sum_j V_j N_j(\mathbf{r}) with simple basis functions NjN_j (in 1-D, the "hat" that is 1 at node jj, 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 KV=F\mathbf{K}\mathbf{V} = \mathbf{F}, assembled element by element: each element adds a small "stiffness" matrix to K\mathbf{K} and a load to F\mathbf{F}. Physically, solving it minimises the stored energy 12∫ε∣∇V∣2dv\frac{1}{2}\int\varepsilon\lvert\nabla V\rvert^2 dv minus the work of the charges, which is why FEM capacitance from energy converges from one side.

nodes and hat functions exact (dashed)FEM (linear) MoM: patches, match V at centres plate at 1 V

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 D\mathbf{D}. With linear elements, the error in VV falls as h2h^2 and in E\mathbf{E} as hh, where hh 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 E\mathbf{E} 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):

V(r)=14πε0∫Sρs(r′)∣r−r′∣ dS′=V0on the conductorV(\mathbf{r}) = \frac{1}{4\pi\varepsilon_0}\int_S \frac{\rho_s(\mathbf{r}')}{\lvert\mathbf{r} - \mathbf{r}'\rvert}\,dS' = V_0 \quad \text{on the conductor}

Divide the surface into NN patches with a constant (pulse) charge density on each, and require the equation at the NN patch centres (point matching): an N×NN \times N dense system Pσ=V01\mathbf{P}\boldsymbol{\sigma} = V_0\mathbf{1}. Off-diagonal entries are approximately a2/(4πε0Rij)a^2/(4\pi\varepsilon_0 R_{ij}) for patches of side aa; the diagonal needs the exact potential of a uniformly charged square at its own centre, aln⁡(1+2)/(πε0)a\ln(1 + \sqrt{2})/(\pi\varepsilon_0) per unit density. Then C=Q/V0=∑σia2/V0C = Q/V_0 = \sum\sigma_i a^2/V_0.

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: N2N^2 storage and N3N^3 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 −V′′=π2sin⁡(πx)-V'' = \pi^2\sin(\pi x) on [0,1][0, 1] with V(0)=V(1)=0V(0) = V(1) = 0 (exact V=sin⁡πxV = \sin\pi x), linear elements; (b) a MoM model of a 1×1 m1 \times 1\ \text{m} thin plate at 1 V1\ \text{V} 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 h28max⁡∣V′′∣\frac{h^2}{8}\max\lvert V''\rvert: with h=1/4h = 1/4 and max⁡∣V′′∣=π2\max\lvert V''\rvert = \pi^2, that is 116⋅8⋅9.87=0.077\frac{1}{16 \cdot 8} \cdot 9.87 = 0.077, and it should fall by 44 each time hh halves (order 2). (b) The charge density on a plate edge is singular (it grows like d−1/2d^{-1/2} towards an edge), which constant patches resolve poorly, so expect a slower, about first-order convergence; then Richardson extrapolation with p=1p = 1, C≈2Ch/2−ChC \approx 2C_{h/2} - C_h, removes most of the error, as in the mini project.

Check: the script's coarsest FEM error, 0.0700.070, matches the 0.0770.077 estimate; the MoM differences between successive meshes (1.331.33, 0.660.66, 0.32 pF0.32\ \text{pF}) halve each time: first order, as predicted.

In Python

python · try it yourself
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 1.991.99). The MoM capacitance rises towards a limit from below and the Richardson value, 40.86 pF40.86\ \text{pF}, agrees with published high-accuracy computations for the unit square plate (C=0.36679⋅4πε0⋅1 m=40.81 pFC = 0.36679 \cdot 4\pi\varepsilon_0 \cdot 1\ \text{m} = 40.81\ \text{pF}; F. H. Read, arXiv math-ph/0603051) to about 0.1 %0.1\ \%. 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:

  1. 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).
  2. 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.
  3. 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).
  4. Compare with a different method or a measurement. FEM against MoM, a simulation against a measured capacitance or S11S_{11}, within the measurement uncertainty.
  5. 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 10 cm10\ \text{cm} and gap 2 mm2\ \text{mm}, C=ε0A/d=44.3 pFC = \varepsilon_0 A/d = 44.3\ \text{pF} without fringing.

Simulation. Extend the MoM script to two plates (two sets of patches, one at +0.5 V+0.5\ \text{V}, one at −0.5 V-0.5\ \text{V}, C=Q/1 VC = Q/1\ \text{V}) and converge it; expect several per cent above the parallel-plate value from fringing (Palmer's formula, C≈ε0w2d[1+dπw(1+ln⁡2πwd)]2C \approx \frac{\varepsilon_0 w^2}{d}\bigl[1 + \frac{d}{\pi w}\bigl(1 + \ln\frac{2\pi w}{d}\bigr)\bigr]^2, gives about 9 %9\ \% here).

What you would measure. With an LCR meter at 100 kHz100\ \text{kHz}, measure the plates spaced by four small nylon spacers, connecting with short leads and subtracting the open-lead reading. Expect agreement within about 33 to 5 %5\ \%, limited by plate flatness and the spacer thickness tolerance (a 0.05 mm0.05\ \text{mm} error in a 2 mm2\ \text{mm} gap is 2.5 %2.5\ \%).

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 1/R1/R with R=0R = 0 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

  1. Linear FEM gives a max error of 1.2×10−31.2 \times 10^{-3} with 3232 elements. Estimate the error with 128128 elements.
  2. MoM gives 40.225 pF40.225\ \text{pF} with hh and 40.541 pF40.541\ \text{pF} with h/2h/2, converging at first order. Extrapolate.
  3. Why does MoM need no absorbing boundary for an antenna problem, while FDTD and FEM do?
Answer
  1. Order 2: two halvings divide it by 1616, about 7.5×10−57.5 \times 10^{-5}.
  2. 2⋅40.541−40.225=40.857 pF2 \cdot 40.541 - 40.225 = 40.857\ \text{pF}.
  3. 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?

  1. FDTD
  2. FEM
  3. MoM (a boundary element method)
  4. finite differences

Linear finite elements for a smooth potential converge at order…

  1. hh for VV
  2. h2h^2 for VV
  3. h3h^3 for VV
  4. they do not converge

Why does the MoM plate capacitance converge only at first order?

  1. the Green's function is wrong
  2. the charge density is singular at the plate edges, poorly captured by constant patches
  3. point matching is exact
  4. the matrix is sparse

Which step should come first when validating a new field solver?

  1. run the full product geometry
  2. reproduce a case with an exact solution
  3. buy a faster computer
  4. skip mesh refinement