EdgeFEM
3D Finite-Element Electromagnetics Simulator for RF and mmWave

EdgeFEM is an open-source full-wave frequency-domain FEM solver for RF and microwave structures: hollow waveguides and probe-fed patch antennas, with experimental support for periodic unit cells. It computes S-parameters, electromagnetic fields, and radiation patterns using lowest-order Nédélec (edge) tetrahedral elements. Validated so far: WR-90 and WR-42 wave-port S-parameters (7–12 and 20–26 GHz) against analytic TE10 results, and a 2.45 GHz probe-fed patch against openEMS (see Validation). Unit-cell reflection is not validated (no Floquet port yet).
Features
| Feature |
Description |
| S-parameters |
Wave ports with 2D discrete port modes and assembled surface-mass ABC; lumped ports for antenna feeds |
| Radiation Patterns |
3D far-field via Stratton-Chu integration over a Huygens surface |
| Periodic Structures |
Phase-shifted (Bloch) periodic BCs along one lattice axis; unit-cell S-parameters experimental (see Limitations) |
| Open Boundaries |
First-order ABC; an experimental isotropic graded absorbing layer (see Limitations) |
| Dispersive Materials |
Debye, Lorentz, Drude, and DrudeLorentz models |
| Python SDK |
Full scriptable API with NumPy integration |
| Design Classes |
RectWaveguideDesign, PatchAntennaDesign, UnitCellDesign |
| Plotting Module |
14 visualization functions |
| Standard Exports |
Touchstone (.sNp), VTK, CSV |
Quick Start
Installation
From PyPI:
pip install edgefem==1.1.1
Wheels cover CPython 3.9-3.13 on Linux x86_64 (glibc 2.27+) and macOS 14+
(arm64 and x86_64). On other platforms pip builds from the sdist, which
needs CMake, Eigen 3.4+ and a C++20 compiler. Mesh generation requires gmsh
(installed automatically as a dependency). Version 1.0.0 predates the fixes
in CHANGELOG.md; pin 1.1.0 or later.
From source (for development):
Eigen 3.4.x and 5.x both work (Homebrew installs 5.0.1; Ubuntu 24.04
libeigen3-dev is 3.4.0).
# macOS
brew install cmake ninja eigen gmsh
# Clone and build
git clone https://github.com/jman4162/EdgeFEM.git
cd EdgeFEM
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DEDGEFEM_PYTHON=ON
cmake --build build -j
# Set Python path
export PYTHONPATH="$PWD/build/python:$PWD/python:$PYTHONPATH"
10-Line Example: Waveguide S-Parameters
from edgefem.designs import RectWaveguideDesign
import numpy as np
# Create WR-90 waveguide (X-band)
wg = RectWaveguideDesign(a=22.86e-3, b=10.16e-3, length=50e-3)
wg.generate_mesh(density=10)
# Compute S-parameters at 10 GHz
S = wg.sparams_at_freq(10e9)
print(f"|S11| = {abs(S[0,0]):.4f}") # ~0.01 (see validation report)
print(f"|S21| = {abs(S[1,0]):.4f}") # ~0.99 (matched transmission)
Patch Antenna Example
import numpy as np
from edgefem.designs import PatchAntennaDesign
# 2.4 GHz WiFi patch on FR-4
patch = PatchAntennaDesign(
patch_length=29e-3, patch_width=38e-3,
substrate_height=1.6e-3, substrate_eps_r=4.4
)
patch.set_probe_feed(y_offset=-5e-3)
# Quick analytical estimates (transmission-line / cavity model)
Z_in = patch.input_impedance(2.4e9)
D = patch.directivity(2.4e9)
print(f"Directivity: {10*np.log10(D):.1f} dBi")
# Full-wave FEM (lumped port, requires gmsh)
patch.generate_mesh(density=12)
s11, _ = patch.simulate(2.4e9)
print(f"|S11| at 2.4 GHz: {abs(s11):.3f}")
input_impedance(), radiation_pattern() and directivity() use the
full-wave FEM once a mesh exists (generate_mesh() or load_mesh()), and
the analytical models (with a warning) before that. The FEM model has
probe feeds only. A full sweep example is in
examples/run_patch_fullwave.py.
UnitCellDesign has no validated Floquet port yet. Its port uses the 1.0.0
modal terms: on a bare grounded slab |R| = 1 but arg® is 30–106 deg off
the analytic value. The periodic BC is applied on the x faces only, and
patches, slots and vias are not meshed (add_patch and friends raise).
reflection_transmission() and the methods built on it raise
NotImplementedError unless you opt in:
from edgefem.designs import UnitCellDesign
cell = UnitCellDesign(period_x=5e-3, period_y=5e-3,
substrate_height=0.5e-3, substrate_eps_r=3.5,
experimental=True)
cell.generate_mesh(density=20)
R, T = cell.reflection_transmission(10e9) # not validated
Documentation
Jupyter Notebook Tutorials
Example Scripts
Runnable scripts in examples/ (all perform real FEM solves
unless noted):
Architecture
┌─────────────────────────────────────────────────────────────────┐
│ Python SDK (pyedgefem) │
│ ┌─────────────────────┐ ┌────────────────┐ ┌──────────────┐ │
│ │ Design Classes │ │ Plots Module │ │ Core API │ │
│ │ RectWaveguideDesign │ │ plot_pattern │ │ load_gmsh │ │
│ │ PatchAntennaDesign │ │ plot_sparams │ │ assemble │ │
│ │ UnitCellDesign │ │ plot_coupling │ │ solve │ │
│ └─────────────────────┘ └────────────────┘ └──────────────┘ │
└─────────────────────────────┬───────────────────────────────────┘
│ pybind11
┌─────────────────────────────┴───────────────────────────────────┐
│ C++ Core │
│ ┌──────────┐ ┌──────────┐ ┌────────┐ ┌──────────┐ ┌─────────┐ │
│ │ Mesh │ │ Maxwell │ │ Ports │ │ Solver │ │ Post │ │
│ │ (Gmsh) │ │ Assembly │ │ (Wave/ │ │(BiCGSTAB)│ │ (NTF, │ │
│ │ │ │(ABC/absr)│ │ Lumped)│ │ │ │ VTK) │ │
│ └──────────┘ └──────────┘ └────────┘ └──────────┘ └─────────┘ │
└─────────────────────────────────────────────────────────────────┘
Validation
Validated against analytical benchmarks (WR-90/WR-42 waveguide dispersion, cavity eigenmodes, lossy-dielectric attenuation). Representative WR-90 results on the 3 mm benchmark mesh (examples/rect_waveguide.geo, 4,227 tets):
| Metric |
Typical (WR-90, 7-12 GHz) |
Test pass criterion |
| |S21| |
0.997-0.9997 |
> 0.99 |
| |S11| |
0.003-0.053 |
< 0.08 |
| Phase error vs. -βL |
3-13° |
< 15° |
| Passivity |S11|² + |S21|² |
≈ 1.0 |
≤ 1.01 |
Numbers are from tests/benchmark_wr90.cpp, run in CI. A measured mesh-convergence study (scripts/run_convergence_study.py) shows all quantities converging with refinement — phase error at ~O(h²), and |S11| down to 5×10⁻⁴ at 18 elements/wavelength — see the Validation Report for the full tables and limitations.
Ecosystem Integration
EdgeFEM is the full-wave FEM engine in a multi-package RF modeling ecosystem:
┌───────────────────────────────────────────────────────────────┐
│ Application Layer │
│ ┌─────────────────────┐ ┌─────────────────────────────────┐ │
│ │ Phased-Array- │ │ RF Metasurface Package │ │
│ │ Antenna-Model │ │ (planned) │ │
│ └──────────┬──────────┘ └────────────────┬────────────────┘ │
└─────────────┼──────────────────────────────┼──────────────────┘
│ │
▼ ▼
┌─────────────────────────────────────────────────────────────────┐
│ EdgeFEM │
│ Full-wave 3D FEM providing: S-params, patterns, coupling │
└─────────────────────────────────────────────────────────────────┘
Build Options
cmake -S . -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DEDGEFEM_PYTHON=ON # Python bindings
| Option |
Default |
Description |
EDGEFEM_BUILD_SCALAR |
ON |
Scalar Helmholtz solver |
EDGEFEM_BUILD_VECTOR |
ON |
Maxwell vector solver |
EDGEFEM_PYTHON |
OFF |
Python bindings (pybind11) |
EDGEFEM_USE_SUITESPARSE |
OFF |
Direct solves with SuiteSparse UMFPACK instead of Eigen SparseLU |
By default the direct solver is Eigen SparseLU and the build links no
SuiteSparse library. -DEDGEFEM_USE_SUITESPARSE=ON links SuiteSparse
UMFPACK (brew install suite-sparse, or libsuitesparse-dev on
Debian/Ubuntu; configure stops if it is not found), which factored the
10 GHz patch example about 12x (density 6) and 30x (density 12) faster
in our tests. UMFPACK is licensed GPL-2.0-or-later: a binary or wheel
built with the option on links GPL code (UMFPACK and the SuiteSparse
libraries it depends on), so distributing it carries the GPL’s
conditions. EdgeFEM’s source remains MIT-licensed, and binaries from the
default build contain no SuiteSparse code.
Run Tests
ctest --test-dir build -j # All tests (what CI runs)
ctest --test-dir build -L smoke # Quick smoke tests
ctest --test-dir build -L pml # PML absorption tests
Tests labelled known_issue document open defects; they carry WILL_FAIL,
so they pass while the defect is open and fail once it is fixed.
Plotting Module
import edgefem.plots as vp
# S-parameters vs frequency
vp.plot_sparams_vs_freq(freqs, S_list, params=['S11', 'S21'])
# Radiation patterns
vp.plot_pattern_3d(pattern, interactive=True)
vp.plot_pattern_3d_cuts(pattern, title="E/H-plane")
# Coupling analysis
vp.plot_coupling_matrix(S, title="4×4 Array")
vp.plot_active_impedance_scan(angles, Z_active)
| Format |
Function |
Use Case |
| Touchstone (.sNp) |
export_touchstone() |
RF circuit simulators |
| VTK (.vtu) |
export_fields_vtk() |
ParaView visualization |
| CSV |
export_pattern_csv() |
Custom post-processing |
Citation
If you use EdgeFEM in your research, please cite:
@software{hodge2026edgefem,
author = {Hodge, John},
title = {{EdgeFEM}: A 3D Finite-Element Electromagnetics Simulator for RF and mmWave},
year = {2026},
month = dec,
version = {1.1.1},
publisher = {GitHub},
url = {https://github.com/jman4162/EdgeFEM},
license = {MIT}
}
Current Limitations
EdgeFEM targets small-to-medium waveguide and patch antenna problems; unit cells are experimental. Know these limits before relying on results:
| Feature |
Status |
Notes |
| True tensor (coordinate-stretched) PML |
Planned |
Current absorber (experimental) is an isotropic graded layer, eps = mu = 1 - j sigma/omega: matched only at normal plane-wave incidence. Terminating WR-90 at 10 GHz it gives |S11| about 0.07-0.10 (test_pml_waveguide) |
| Wave port formulation |
First-order single-mode ABC |
Assembled surface-mass operator with 2D discrete port modes (no tuned constants); mesh-convergent S-parameters; higher-order port modes not mode-matched; accuracy degrades near cutoff |
| Floquet ports / harmonic expansion |
Planned |
No validated unit-cell port: UnitCellDesign results need experimental=True. Periodic BC applies a Bloch phase along one lattice axis (sparse elimination, checked by test_periodic_constraint) |
| Embedded element patterns |
Not implemented |
compute_embedded_patterns raises; use calculate_sparams_with_fields + extract_huygens_surface + stratton_chu_3d |
| Inhomogeneous / TEM ports (coax, microstrip) |
Not supported |
2D port eigensolver is scalar (hollow homogeneous guides only) |
| Higher-order elements (Tet10) |
Planned |
Lowest-order Whitney elements; use finer mesh |
| Adaptive mesh refinement |
Planned |
Manual mesh refinement in Gmsh |
| Higher-order modes (TE20, TM) |
Planned |
Single TE mode; the port operator j beta M_s is the TE form |
| Plane wave excitation (RCS) |
Planned |
— |
| Anisotropic materials |
Not planned |
Isotropic (complex scalar) only |
| Parallelism (threads/MPI/GPU) |
Planned |
Single-threaded execution; direct-solver memory limits apply |
| Low-frequency stabilization |
Not implemented |
Expect conditioning problems well below ~1 GHz |
| Time-domain solver |
Not planned |
Frequency-domain only |
| Gmsh mesh input |
v2 ASCII only |
Export with gmsh -format msh2; v4 files are not readable |
For large problems (>1M DOF), adaptive refinement, or reference-plane modal ports, use commercial tools like HFSS or CST.
Roadmap
Current (1.1.x)
- Wave ports: assembled surface-mass port operator with 2D discrete port
modes (WR-90 |S11| 0.003–0.053, |S21| >= 0.997 over 7–12 GHz)
- Lumped (gap) ports with a physical load and source; probe-fed patch
validated against openEMS at 2.45 GHz
- Sparse direct solves (SuiteSparse UMFPACK optional), one factorization
per S-matrix
- Dispersive materials (Debye, Lorentz, Drude, DrudeLorentz)
- pip-installable Python package, GitHub Actions CI
Next
- Validated Floquet port for unit cells (TE and TM, oblique incidence),
checked against Fresnel results; dual-axis periodicity
- Eigenmode-port frequency sweep with K/M separation
- True tensor (coordinate-stretched) PML
- Higher-order waveguide modes (TE20, TE01, TM)
Later
- Higher-order Nédélec elements (Tet10)
- Adaptive mesh refinement
- OpenMP parallelization
- Plane wave excitation for RCS; surface impedance BC
v2.0 (Future)
- MPI distributed solving
- GPU acceleration
- Optimization framework
- GUI application
Contributing
- Use feature branches; PRs require green CI and updated docs
- clang-tidy, formatting, and unit tests are mandatory
- Large features require an ADR (architecture decision record)
See CONTRIBUTING.md for details.
License
MIT License. See LICENSE for details.
Acknowledgments
EdgeFEM builds on excellent open-source projects:
评论