HarmoLab
HarmoLab — a Python MoM/CMA electromagnetic solver.
HarmoLab computes the currents, input impedance and radiated fields of antennas and scatterers made of conducting surfaces, with the Method of Moments (MoM), and their characteristic modes (CMA). It works on triangular surface meshes, with RWG basis functions, in free space.
Why "HarmoLab"
HARrington + MOM + LAB. The name is a tribute to Roger F. Harrington, who gave electromagnetics the method of moments (Field Computation by Moment Methods, 1968) and, with Joseph R. Mautz, the theory of characteristic modes for conducting bodies (IEEE Trans. Antennas Propag., 1971). Both methods are the core of this solver.
What it does
Status as in feature-status.md:
stable features are covered by the test suite, experimental ones work but are not.
Method of Moments
- EFIE with RWG basis functions on arbitrary triangular surface meshes (Gmsh
.msh), including junctions. Singular integrals by Duffy transform and closed-form 1/R integrals. Stable. - Optional GPU assembly of the impedance matrix with CuPy, chosen automatically when a CUDA GPU is usable; otherwise NumPy on the CPU. Stable.
- Ports: enhanced gap source (Ding et al., 2013), delta gap on a cut, delta gap on one edge; one or several ports driven together. Stable.
- Radiation (transmitting) and plane-wave scattering (receiving). Stable.
- Frequency sweep of the port impedance and reflection coefficient (active values, all ports driven together, not the full S-matrix). Stable.
- Near and far fields, 3D patterns, polar cuts, RHCP/LHCP, RCS. Experimental.
- Lumped R, L, C loads and adaptive mesh refinement. Experimental.
Characteristic Mode Analysis (harmolab/cma/, stable)
- Generalised eigenproblem
X·Jₙ = λₙ·R·Jₙ(withZ = R + jX), with a regularised or a rank-truncated solver, at one frequency or over a sweep, with mode tracking across frequencies. - Eigenvalues, modal significance, characteristic angle, modal currents and modal far fields, plots and text reports.
Optimiser (harmolab/optim/, stable)
- Exact reduced multiport model for a fixed geometry with changing loads (parasitic elements, lumped loads): the MoM system is solved once, then every choice of generators and loads costs a small P×P problem.
- Inner loop on the loads (L-BFGS-B), outer Bayesian loop on the geometry, matching networks.
See
harmolab/optim/README.md.
Graphical interface (interface/, in progress)
- A Qt main window that creates and opens projects, imports a Gmsh
.mshmesh and shows it in a 3D view, with a light and a dark theme. Simulations cannot be run from it yet.
Known limitations: perfect conductors or surface-impedance conductors in free space (no
dielectric, no substrate); the radiation efficiency of lossy conductors is wrong; with several
enhanced-gap ports the radiated power is not yet checked against the input power. Details in
feature-status.md.
Installation
HarmoLab needs Python 3.12 or later. It is not on PyPI yet: install it from a clone.
git clone https://github.com/FahdilOuro/harmolab.git
cd harmolab
conda create --name harmolab python=3.12 # or any Python >= 3.12 environment
conda activate harmolab
python -m pip install -e .
The required dependencies (NumPy, SciPy, Matplotlib, Plotly, Gmsh, Pillow) are installed with it. Optional extras:
| Extra | Installs | Needed for |
|---|---|---|
export |
kaleido | saving figures as PDF or PNG |
optim |
scikit-learn, threadpoolctl | the Bayesian outer loop of the optimiser |
gpu |
cupy-cuda12x | GPU assembly (CUDA 12.x) |
test |
pytest | the test suite |
python -m pip install -e ".[export,optim,test]"
The graphical interface is not part of the package. From the clone:
python -m pip install PySide6 pyvista pyvistaqt
python -m interface.gui
A first simulation
A half-wave strip dipole at 300 MHz: mesh it with Gmsh, feed it at its centre, get its input
impedance. Run it from an empty folder: HarmoLab writes every intermediate result (mesh, impedance
matrix, currents) in a data/ folder under the working directory.
import gmsh
from harmolab.utils.file_path import setup_save_file_paths
from harmolab.utils.mesh.gmsh_function import (mesh_and_gap_parameters, setup_performance_config,
generate_and_save_mesh)
from harmolab.utils.ports import EnhancedGap
from harmolab.src.radiation_algorithm.radiation_algorithm import radiation_algorithm
path = setup_save_file_paths("strip_dipole") # file names under ./data/
frequency = 300e6 # Hz, wavelength 1 m
length, width = 0.47, 0.01 # m, a strip along y centred at the origin
# Element size lambda/60 and a feed gap of 0.05 lambda (3 elements across it).
mesh_size, gap_width, wavelength = mesh_and_gap_parameters(frequency, resolution=60, gap_fraction=0.05)
gmsh.initialize()
gmsh.model.add(path.name)
setup_performance_config(n_threads=1) # one thread: the same mesh at every run
strip = gmsh.model.occ.addRectangle(-width / 2, -length / 2, 0, width, length)
gap = gmsh.model.occ.addRectangle(-width / 2, -gap_width / 2, 0, width, gap_width)
gmsh.model.occ.fragment([(2, strip)], [(2, gap)]) # the gap edges become mesh lines
gmsh.model.occ.synchronize()
generate_and_save_mesh(path, mesh_size)
gmsh.finalize()
ports = [EnhancedGap("feed", feed_point=(0.0, 0.0, 0.0), axis="y", gap_width=gap_width)]
result = radiation_algorithm(path, frequency, ports, voltages=[1.0], show=False)
feed = result.port("feed")
print(f"Input impedance: {feed.impedance:.2f} Ohm") # 72.74+4.09j Ohm
radiation_algorithm assembles the impedance matrix, builds the excitation, solves Z·I = V and
returns the currents and, for each port, its voltage, current, impedance and power. With
show=True (the default) it also opens a 3D view of the surface current.
More examples, one notebook per antenna or topic (radiation, scattering, characteristic modes,
ports, frequency sweeps, mesh refinement, optimisation), are in
harmolab/antenna_simulation/.
Gallery
Figures from the example notebooks.
4-port circularly polarised CubeSat antenna
(Nice_Cube_radiation.ipynb):
surface current and RHCP gain pattern.
Characteristic modes of a 480 × 240 mm rectangular loop
(loop_antenna.ipynb):
current and far field of mode 1.
Some notebooks contain interactive Plotly figures that GitHub does not display; open them with nbviewer.
Repository layout
harmolab/— the solver package (harmolab.rwg,harmolab.efield,harmolab.cma,harmolab.optim,harmolab.utils,harmolab.src), and the example notebooks inharmolab/antenna_simulation/(not installed with the package).interface/— the graphical interface, in progress; seeinterface/README.md.test/— the test suite:python -m pytest test/ harmolab/utils/quadrature/tests/.documentation/— sources of the documentation website (theory, user guide, API), in progress.
Citing HarmoLab
If you use HarmoLab in your work, please cite it with the metadata in CITATION.cff
(GitHub shows it under "Cite this repository").
Origins and acknowledgments
HarmoLab started as a Python translation of the MATLAB code of Sergey N. Makarov's book Antenna and EM Modeling with MATLAB (Wiley, 2002), and has been extended well beyond it (exact port models, singular quadrature, GPU assembly, characteristic modes, optimisation).
Thanks to:
- Sergey N. Makarov, for the foundational work in antenna modelling with MATLAB;
- Nguyen Tran Quang Khai (@Khainguyen1349), whose Python MoM implementation inspired this project.
License
MIT License, © 2025 Fahdilou Ouro-Yendou. See LICENSE.
Metadata
Release files for harmolab 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| harmolab-0.0.1.tar.gz | 216.2 kB | With provenance | Details for harmolab-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| harmolab-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for harmolab-0.0.1-py3-none-any.whl |
Total release size: 461.4 kB
Release files / harmolab-0.0.1.tar.gz
| Download URL | harmolab-0.0.1.tar.gz |
|---|---|
| Size | 216.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2ad6e18f09915e6a80898180b5aea142af07f57317fc9631f3c0f27df08dc66f
|
|
BLAKE2b-256 checksum How to use checksums |
f0c7601299d3021143191b28ad78855e2bc1fb56f5e57d62f13c97b384eb3926
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logRelease files / harmolab-0.0.1-py3-none-any.whl
| Download URL | harmolab-0.0.1-py3-none-any.whl |
|---|---|
| Size | 245.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
030fec99a130283c7c2ce846252ad5596e9c28d4a5c1cd6b97d1e8799aa42410
|
|
BLAKE2b-256 checksum How to use checksums |
c30beceea83012cfbe283d60b730abafddd16c663f59f6116ca1b96db027f419
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logSecurity for harmolab 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for harmolab-0.0.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.