AntennaSim
Web-based antenna simulator powered by NEC2. Design, simulate, and analyze antennas with real-time 3D visualization, radiation patterns, SWR, and impedance charts.
Install / Use
/learn @EA1FUO/AntennaSimREADME
Design antennas from built-in templates or build your own from scratch in the wire editor. Run NEC2 simulations and instantly visualize SWR, impedance, Smith chart, 3D radiation patterns, current distribution, and near-field heatmaps -- all in your browser.
Two deployment modes: self-hosted with Docker (backend + Redis) or fully static via WebAssembly on GitHub Pages -- zero server required.
Table of Contents
- Features
- Antenna Templates
- Quick Start
- GitHub Pages (WebAssembly)
- Development Setup
- Production Deployment
- Architecture
- Project Structure
- API Reference
- Configuration
- Keyboard Shortcuts
- Tech Stack
- Contributing
- License
- Acknowledgments
Features
<details open> <summary><strong>Simulation Engine</strong></summary> <br>- Full NEC2 pipeline -- geometry definition to card deck generation to
nec2cexecution to parsed results, all automated - Frequency sweep -- simulate across any frequency range with configurable step size
- 10 ground models -- free space, perfect ground, salt water, fresh water, pastoral, average, rocky, city, dry/sandy, and custom (user-defined dielectric constant and conductivity)
- Lumped loads -- series RLC, parallel RLC, fixed impedance, and wire conductivity (copper, aluminum, steel, stainless steel)
- Transmission lines -- characteristic impedance, length, velocity factor, and shunt admittance
- GA/GM/GR cards -- wire arcs, coordinate transformations, and cylindrical symmetry for complex geometries
- Redis caching -- simulation results cached with SHA-256 keys and zlib compression (1h TTL)
- Rate limiting -- opt-in, configurable (default: 30/hour, 5 concurrent per IP when enabled)
- Sandboxed execution --
subprocess.run(shell=False, timeout=180), isolated temp dirs, non-root container
- Real-time 3D rendering -- pan, rotate, zoom with orbit controls
- Radiation pattern -- 3D surface mesh with perceptually uniform colormap (gain in dBi)
- Volumetric shells -- alternative multi-shell pattern visualization
- Current distribution -- wire segments colored by current magnitude with hot colormap
- Animated current flow -- luminous particles traveling along wires proportional to current
- Near-field heatmap -- E-field magnitude as a semi-transparent plane in 3D
- Pattern slice -- animated cutting plane sweeping through the radiation pattern
- Ground reflection -- ghost mirror showing antenna image below ground plane
- Hover measurements -- tooltip follows cursor over any 3D object showing gain, wire dimensions, current magnitude, or field strength
- Auto-framing -- camera automatically fits to antenna bounding box on load and template change
- 3D orientation gizmo -- interactive axis cube in the viewport corner; click any face/edge/corner to snap to that camera angle
- Compass rose for spatial orientation
- SWR vs. Frequency -- color-coded zones (green/amber/red), ham band markers, resonance annotation, crosshair tooltips
- Impedance (R + jX) -- resistance and reactance curves, reference impedance line, resonance crossings where jX=0
- Smith Chart -- impedance locus with frequency markers, constant SWR circles (1.5, 2.0, 3.0), click-to-inspect tooltip showing Z, SWR, and reflection coefficient
- Polar Radiation Pattern -- azimuth (H-plane) and elevation (E-plane) cuts, -3dB beamwidth arc, max gain marker, concentric dBi grid
- Chart popups -- click any chart to expand to a full-screen modal for detailed analysis
- Legends -- every chart includes a clear legend explaining all colors, lines, and markers
- Balun/Unun matching -- client-side impedance transformation with 10 presets (1:1 to 49:1) for viewing SWR relative to transformed impedance
- .s1p overlay -- import NanoVNA measurement data and overlay on simulation SWR for comparison
- Build from scratch -- click-to-add wires, drag endpoints, snap grid
- Move mode -- drag endpoints or entire wires; Shift+drag for vertical-only movement
- Undo/Redo -- full history with Ctrl+Z / Ctrl+Shift+Z
- Wire properties -- edit coordinates, radius, segments per wire
- Excitations -- set feed points with magnitude and phase
- Loads & transmission lines -- add lumped RLC loads and TL models to any segment
- Templates -- load any built-in template into the editor and modify it
- Import/Export -- open and save
.nec(NEC2 card deck) and.maa(MMANA-GAL) files
- Nelder-Mead algorithm (scipy, adaptive mode)
- 5 objective functions -- minimize SWR (single freq), minimize SWR (band average), maximize gain, maximize front-to-back ratio, weighted combined
- Up to 10 variables with min/max bounds
- Real-time progress -- WebSocket streaming of iteration count, current best SWR, convergence chart
- Cancel -- abort optimization mid-run
- 17 antenna templates spanning wire, vertical, multiband, loop, and directional categories
- Template library page -- browse and compare all templates with descriptions and difficulty ratings
- Learn page -- educational content on NEC2, SWR, impedance, radiation patterns, and simulation tips
- Mobile responsive -- usable on phones and tablets with touch-friendly controls
- Dark/Light theme -- system-aware with manual toggle
- Keyboard shortcuts -- 17 bindings for fast workflow (press
?to see them all)
Antenna Templates
AntennaSim ships with 17 ready-to-simulate templates organized by category:
| Category | Templates | |---|---| | Wire | Half-Wave Dipole, Inverted V, End-Fed Half-Wave | | Vertical | Ground Plane Vertical, J-Pole, Slim Jim | | Multiband | Off-Center Fed Dipole, G5RV, Fan Dipole | | Loop | Delta Loop, Horizontal Delta Loop, Cubical Quad, Small Magnetic Loop | | Directional | Yagi-Uda (2-6 el.), Moxon Rectangle, Hex Beam, Log-Periodic Dipole Array |
Every template includes configurable parameters (frequency, height, element lengths, spacing, wire diameter, etc.) with sensible defaults and validation ranges.
Quick Start
Prerequisites
- Docker and Docker Compose (v2+)
- That's it. No Python, Node.js, or nec2c installation needed.
One-liner (Docker Hub)
docker run -p 80:80 ea1fuo/antennasim
Open http://localhost in your browser. Done. This pulls the all-in-one image from Docker Hub with everything bundled (frontend, backend, Redis, nginx).
From source
git clone https://github.com/EA1FUO/AntennaSim.git
cd AntennaSim
cp .env.example .env
docker compose up --build
The first build takes a few minutes (downloading base images, compiling nec2c, installing dependencies). Subsequent starts are fast.
GitHub Pages (WebAssembly)
AntennaSim can run entirely in the browser -- no backend server needed. The NEC2 engine (nec2c) is compiled to WebAssembly and executes locally in a Web Worker.
Live demo: https://EA1FUO.github.io/AntennaSim/
This mode is enabled by setting VITE_ENGINE=wasm at build time. The GitHub Pages deployment is fully automated via the deploy-pages.yml workflow, which:
- Checks out the repo with the
nec2cgit submodule - Compiles nec2c to WebAssembly using Emscripten
- Builds the frontend with
VITE_ENGINE=wasm - Deploys to GitHub Pages
Both deployment modes (Docker and WASM) are functionally equivalent -- same simulation engine, same UI, same results.
| | Docker | WebAssembly | |---|---|---| | Server required | Yes | No | | Simulation runs on | Backend (Pyt
