NEC-5 in Python: Numerical Electromagnetics Code (PyNEC-5)

Mike Markowski, mike.ab3ap@gmail.com

NOTE: These pages show completed work. The code itself cannot be shared publicly because it must be licensed from LLNL. However, NEC-81 is publicy available.

Complete Python/NumPy conversion of Lawrence Livermore National Laboratory's NEC-5 (NECMP) Method of Moments (MoM) electromagnetic simulator, replacing older point-matching with mixed-potential integral equations (MPIE), RWG/rooftop basis functions, and Sommerfeld potential tables (by Gerald J. Burke, LLNL-CODE-746721).

Installation

pip install pynec5-5.0.0-py3-none-any.whl
pip install "pynec5-5.0.0-py3-none-any.whl[plots]"
pip install "pynec5-5.0.0-py3-none-any.whl[full]"

1. Running NEC-5 (GUI by Default & CLI Options)

nec5                          # Open PySide6 GUI
nec5 -g antenna.nec           # Open .nec deck or .cfg file in GUI
nec5 antenna.nec              # Run deck and print report to stdout
nec5 antenna.nec -o out.txt   # Write ASCII report to file
nec5 antenna.nec -p           # Run solver + 3D/2D Matplotlib plots
nec5 -c antenna.cfg           # Run from configuration file
nec5 -t my_antenna.cfg        # Generate starter .cfg template
OptionDescription
[target] Input .nec deck or .cfg file.
-i / --input FILE Input NEC-5 deck path.
-o / --output FILE Write ASCII report to FILE.
-c / --config FILE Run from a .cfg file.
-t / --write-template FILE Generate starter .cfg template.
-g / --gui Launch the PySide6 desktop GUI.
-p / --plots3d Generate 3D geometry/pattern/field plots.
-n / --no-show Save plot files without opening windows.
-d / --plot-dir DIR Directory for saved plots (default: plots).
-f / --plot-format FMT Image format: png, svg, or pdf.
-s / --pattern-style 3D pattern style: wireframe or surface.

2. Desktop GUI & Visualization Suite

3. NEC-5 Card Reference

CodeNamePurpose
CM / CE Comment Header comment lines terminated by CE.
PA Parameter Defines named symbolic parameters for subsequent cards.
GW / GC Wire / Taper Straight or ratio-tapered wire segments.
GA / GH Arc / Helix Circular wire arc or uniform/tapered helix.
SP / SM / SC Patches Triangular RWG, quad, or CountX x CountY rectangular patches.
GM / GR / GS / GX Transforms Move/copy, Z-rotation symmetry, scaling, and plane reflection symmetry.
GE Geometry End Builds RWG/rooftop/wire/1/ρ junction basis functions.
FR Frequency Single frequency or linear/multiplicative sweep.
EX Excitation Voltage source (0), plane wave (1–3), or current source (4).
GN / GD Ground Free space (-1), reflection (0), PEC (1), Sommerfeld (2), and cliff/screen (GD).
LD / NT / TL Loads & Nets RLC/conductivity loads, two-port [Y] networks, and transmission lines.
NE / NH / RP Fields Near E/H grids, free-space/reflection far field (RP 0), and ground wave (RP 1).
XQ / EN Execute / End Solves MoM system and terminates deck.