Antenna Simulator: NEC-2 Antenna Analysis, SWR & Pattern
Pricing
Pay per event
Antenna Simulator: NEC-2 Antenna Analysis, SWR & Pattern
Simulate antennas with NEC-2 (nec2c): upload 4nec2 .nec decks or describe a Yagi, dipole, vertical, Moxon, quad or loop in words. Get SWR, impedance, gain, front-to-back, takeoff angle, pattern plots, Smith chart, Touchstone and CSV. For hams, RF engineers and AI agents.
Pricing
Pay per event
Rating
0.0
(0)
Developer
Jumble Mog
Maintained by CommunityActor stats
0
Bookmarked
2
Total users
1
Monthly active users
8 hours ago
Last modified
Categories
Features
Share
Simulate an antenna in one API call. Give a NEC-2 deck (a .nec file from 4nec2, xnec2c or nec2c, or a ZIP or GitHub folder of them), paste one, or describe the antenna in words such as 5 element yagi 144.2 MHz 6 mm aluminium. The tool runs NEC-2 at the design frequency and across a frequency sweep, and for each antenna you get back:
- The feed point: impedance (R + jX), SWR on your feed line (50 ohms unless you say otherwise), return loss and mismatch loss, the resonant frequency, and the SWR 2:1 and 1.5:1 bandwidths. When SWR is over 1.1, the two L-networks that match the antenna to the line, with the inductor and capacitor values.
- The radiation pattern: maximum gain in dBi and dBd and its direction, the takeoff angle over ground, front-to-back and front-to-rear ratios, azimuth and elevation beamwidths, polarization and efficiency.
- Model checks, the ones 4nec2's geometry check makes and more: segments too long or too short for the wavelength, too thick for NEC's thin-wire model, junctions of very different segments, wires that cross or touch without a junction, wire ends that nearly meet, the same wire given twice, sources on open wire ends, wires under or flat on the ground, and the average gain test. Each finding names the segments and what to change, and a verdict (ok, warning or critical) sums them up.
- Designs from words: dipole, inverted V, vertical or ground plane, Yagi (2 to 17 elements, from NBS Technical Note 688), Moxon rectangle (W4RNL's formulas), two-element quad, loops and delta loops, built at your frequency, wire size, height and ground, and tuned to resonance with NEC. The row gives the dimensions.
- Files: pictures (the pattern, the sweep, a Smith chart and the wires coloured by current), CSV tables (the sweep, the full pattern and the current on every segment), a Touchstone
.s1pfile for circuit simulators and VNA software, and the deck as simulated, for 4nec2 or xnec2c.

A Moxon rectangle for 28.5 MHz, from the words moxon 28.5 MHz 2 mm copper wire: 5.92 dBi and a front-to-back ratio of 36.5 dB.

The same Moxon across the band: SWR under 2 from 28.05 to 29.55 MHz on 50 ohms, and the front-to-back ratio at its best on the design frequency.

xnec2c's example of a whip on a car, coloured by current. The model check finds 412 places where the body's grid wires meet without NEC joining them.
The simulations are NEC-2's: the Numerical Electromagnetics Code that Lawrence Livermore National Laboratory wrote for the US Navy, in its C translation nec2c by Neoklis Kyriazis (5B4AZ), the engine behind xnec2c. 4nec2's additions to the deck format (symbols and expressions, units, traps and coated wires) are read too, and so are xnec2c's (the Z0 card and GS scaling of chosen tags). You install nothing: no Windows, no 4nec2, EZNEC or MMANA.
It's made for:
- Radio amateurs checking an antenna before cutting wire: SWR across the band, gain and takeoff angle at their height over their soil, and what matches it to the coax.
- Antenna designers and RF engineers who want decks simulated in bulk or in a pipeline: a ZIP or a GitHub folder of variants in one run, with tables, Touchstone files and model checks for each.
- Students and teachers: the pattern, currents and Smith chart of a textbook antenna from one sentence.
- Developers of antenna calculators, ham radio apps and RF dashboards who need NEC by API.
- AI agents asked "what's the SWR of this dipole?" or "design me a 2 m Yagi". A language model can't solve the antenna's equations; this tool hands it the numbers, findings and pictures as JSON and PNG.
How to use it
- Give Antennas: a link to a
.necfile (or a ZIP or GitHub folder of them), or a design in words with its frequency. Uploads and pasted decks work too. - If you like, set the design frequency, the sweep, the feed line impedance, the ground and the height.
- Click Start. The dataset has a row per antenna with the verdict, a headline, every number and the findings. The pictures and files are in the run's key-value store, and
OUTPUTsums up the run.
How-to examples
The result lines come from runs of these inputs. The .nec files are examples from xnec2c's repository on GitHub; the tool downloads them from their links and they aren't part of it.
How to simulate a NEC file online (4nec2, xnec2c or nec2c)
Put the link to the .nec file in antennas. A GitHub file page works, and so do raw links, Google Drive and Dropbox. To simulate a file from your computer, use upload; to paste a deck, necText.
{"antennas": ["https://github.com/KJ7LNW/xnec2c/blob/master/examples/2m_yagi.nec"]}
Result: at 145 MHz, the middle of the deck's own 140 to 150 MHz sweep, the feed point is 44.5 + j14.3 ohms, SWR 1.38 on 50 ohms, and SWR stays under 2 from the start of the sweep to 149.07 MHz. The Yagi gives 11.18 dBi (9.03 dBd) with a front-to-back ratio of 14.1 dB and an azimuth beamwidth of 48.5 degrees. The verdict is a warning: 25 segments are shorter than 8 times their radius, where NEC is less exact and the extended kernel (an EK card) helps. 3 seconds, 1 event.
How to design a Yagi for your frequency
Describe it in words: the number of elements, the frequency, the element size and metal, and the height and ground if you want them.
{"antennas": ["5 element yagi 144.2 MHz 6 mm aluminium at 10 m over average ground"]}
Result: dimensions gives a 1.663 m boom (0.80 wavelength), a 1.023 m reflector, a 0.9656 m driven element and directors from 0.9087 to 0.9002 m, from NBS Technical Note 688 scaled for 6 mm elements. NEC tunes the driven element to resonance at 144.198 MHz, where it's 26.8 ohms (SWR 1.86 on 50 ohms). Over average ground at 10 m it gives 15.37 dBi at 2 degrees elevation, with a front-to-back ratio of 22.2 dB, and the first of the two matching networks is a 27.5 nH inductor in series at the antenna, then a 20.5 pF capacitor across the line. 3 seconds, 1 event.
How to see what height does to a dipole
Give the same antenna at several heights, one per line.
{"antennas": ["dipole 7.1 MHz at 7 m over average ground","dipole 7.1 MHz at 12 m over average ground","dipole 7.1 MHz at 20 m over average ground"]}
Result: each dipole is cut to resonance at 7.1 MHz for its height (2 mm copper wire, as none was given):
| Height | Length | Feed point | SWR on 50 ohms | Gain | Elevation of the maximum |
|---|---|---|---|---|---|
| 7 m (0.17 wavelength) | 20.25 m | 64.7 ohms | 1.29 | 6.00 dBi | 90 degrees (straight up) |
| 12 m (0.28 wavelength) | 20.42 m | 87.3 ohms | 1.75 | 5.88 dBi | 52 degrees |
| 20 m (0.47 wavelength) | 20.68 m | 72.8 ohms | 1.46 | 7.26 dBi | 30 degrees |
Low, the dipole sends its power straight up, which suits short-range (NVIS) contacts. Raised to half a wavelength, its lobe comes down to 30 degrees for longer distances. 3 to 10 seconds each, 1 event each.
How to check a NEC model before you trust it
Every antenna gets the model checks; the verdict and findings say what they found.
{"antennas": ["https://github.com/KJ7LNW/xnec2c/blob/master/examples/20m_car_ant.nec"]}
Result: the verdict is critical. The car body is a grid of thick wires, and at 412 places their ends meet without NEC joining them: they're up to 94.5 mm apart, and NEC joins ends only when they're within about a thousandth of a segment length, so current can't cross from one wire to the next there. 410 segments are also shorter than 8 times their radius, a junction joins wires whose radii differ more than five times, and the segments next to the source differ in length from it by more than 25%. As modelled, the whip is 35.3 - j6.4 ohms at 14 MHz (SWR 1.46 on 50 ohms). 15 seconds, 1 event.
How to simulate a folder of antennas at once
Link to a GitHub folder (or a ZIP), and add #text to take only the files whose path holds the text.
{"antennas": ["https://github.com/KJ7LNW/xnec2c/tree/master/examples#yagi"]}
Result: the 11 Yagi decks of the folder's 82 files, in 102 seconds at 2 GB, 1 event each. The two stacked 2 m Yagis give 14.07 dBi, 2.9 dB more than one alone (11.18 dBi). The 13 cm Yagi is critical: its 227 segments are shorter than twice their radius, where NEC's thin-wire model fails. The extended double Zepp Yagis, whose driven element is about 1.25 wavelengths long, give 8.9 to 9.2 dBi and are far from 50 ohms at their centre feed (down to -j309 ohms), as such an element is.
How to let an AI agent design or check an antenna
Add the tool to the agent through Apify's MCP server at https://mcp.apify.com/?tools=jumblemog/antenna-simulator. Asked for a 10 m beam, the agent sends {"antennas": ["moxon 28.5 MHz 2 mm copper wire"]} and reads headline, dimensions and the numbers. The headline is a sentence it can pass on as it is: "At 28.5 MHz: 53.7 + j1.7 ohms, SWR 1.08 on 50 ohms; 5.92 dBi, front-to-back 36.5 dB; resonant at 28.4589 MHz; SWR under 2 from 28.0517 MHz to 29.5485 MHz." The dimensions are the ones to cut: "A 3.825 m wide, B 0.5719, C (gap) 0.1097, D 0.716, E (depth) 1.398 m; 2 mm copper, free space", and patternPngUrl is a picture it can show.
FAQ
Which antenna files can it read?
- NEC-2 decks as NEC-2, nec2c, xnec2c and 4nec2 write them:
.necfiles, or any text file that holds a deck, in free format (or in the old fixed columns when the numbers have spaces between them). Decks are told apart from other files by their content, so ZIPs and folders with other files in them work. - 4nec2's additions:
SYsymbols and expressions, units (2mm,10ft), positions in percent (EX 0 1 50% ...), LC traps (LD 6) and insulated wire (LD 7). - xnec2c's additions: the
Z0card (the line impedance SWR refers to), andGScards that scale only a range of tags, which NEC-2 itself doesn't have (it scales everything); for decks ofGWwires andGMcopies the tool works out the scaled wires as xnec2c does. - EZNEC (
.ez) and AO (.ant) files open in 4nec2, which saves them as.nec. MMANA-GAL files (.maa) aren't read.
How accurate is it? It's NEC-2, in nec2c, the engine inside xnec2c: a deck gives the results xnec2c gives, and those of 4nec2's NEC-2 engine to within the small differences between builds. A half-wave dipole of 2 mm copper in free space comes out at 72.8 ohms and 2.09 dBi (textbook values for an infinitely thin, lossless one: 73 ohms and 2.15 dBi), and a quarter-wave vertical over perfect ground at 5.13 dBi (5.16 in theory). NEC-2 is less exact where wires of very different thickness meet, where parallel wires are very close and with stepped-diameter tubing; the model checks point those places out.
At which frequency are the numbers?
At frequencyMHz when you give it. Otherwise at the deck's FR frequency, or the middle of its sweep; for a deck that sweeps a range wider than 1.5:1 (a multiband antenna), at the frequency of lowest SWR, with a note. Designs use the frequency in their words. The sweep covers the radio band holding that frequency with a margin, or the deck's own sweep, and its every frequency is in sweep and sweep.csv.
Which ground does it use?
The deck's own (GN card) unless you choose one in ground: free space, perfect ground, or a real soil from very poor to salt water. Real soils use NEC-2's Sommerfeld method, its most exact. NEC-2 can't model wires under the ground or lying on it: a dense radial field on or in the ground is usually modelled as perfect ground (GN 1), and elevated radials as wires.
Does it optimize an antenna?
No, it simulates the antenna you give. To compare variants, give each one as its own line (words or links), or set symbols to change a parametric deck's SY values without editing it.
Is my antenna file kept? Each antenna is read and simulated by a separate process with no access to your Apify token, in a temporary folder that's deleted when the run ends. The results and files stay in your own Apify storage.
Input
| Field | What it does |
|---|---|
antennas | One per line: a link to a NEC deck (a .nec file, a ZIP, a GitHub or GitLab file page or folder, Google Drive or Dropbox), or a design in words. #text after a ZIP or folder link takes only the files whose path holds the text (several, comma-separated; *.nec patterns work). Up to 100. |
upload | A .nec file (or a ZIP of them) from your computer. |
necText | A NEC deck pasted in. |
frequencyMHz | Where the pattern and feed numbers are taken (the deck's FR card, the middle of its range, or for a deck that sweeps more than 1.5:1, the frequency of lowest SWR; for designs, the frequency in the words). |
sweepStartMHz, sweepStopMHz, sweepPoints | The frequency sweep (the band holding the design frequency, with a margin; the deck's own range when its FR card sweeps; 21 frequencies, up to 201). |
impedanceOhms | The feed line impedance SWR refers to (the deck's xnec2c Z0 card, else 50). |
ground | deck (as the deck says), freeSpace, perfect, a soil (average, good, veryGood, poor, veryPoor, sandy, city, extremelyPoor), saltWater, freshWater, or custom. Real soils use NEC's exact Sommerfeld ground. |
groundConductivity, groundPermittivity | Your own soil (S/m and relative permittivity). |
heightM | Moves the antenna to put its feed point this high above the ground; for designs, the antenna's height (the apex of an inverted V, the base of a ground plane). |
symbols | Values for the deck's SY symbols, which win over the deck's own: {"h": 15, "len": 10.35}. |
wireDiameterMm, material | For designs, the wire size; for every antenna, the wire's metal (copper, aluminium, brass, steel, stainless, silver, bronze, perfect). A deck's own LD 5 card wins. |
outputs | pictures, tables, nec, touchstone (all four). |
timeLimitSeconds | Downloading and simulating stop after this long (300 s). A sweep that wouldn't fit is cut to fewer frequencies. |
Output
- Dataset: one row per antenna, with
antenna,source,kind(fileordesign),status,error,verdict,headline,description,design,dimensions, the feed point (frequencyMHz,band,wavelengthM,impedanceReferenceOhms,resistanceOhms,reactanceOhms,impedanceMagnitudeOhms,swr,returnLossDb,mismatchLossDb,reflectionCoefficient,feeds,matchingNetworks), resonance and bandwidth (resonantMHz,resonanceResistanceOhms,resonances,minSwr,minSwrMHz,bandwidthSwr2MHz,bandwidthSwr2FromMHz,bandwidthSwr2ToMHz,bandwidthSwr2OpenEndedand the same for SWR 1.5), the pattern (maxGainDbi,maxGainDbd,maxGainElevationDeg,maxGainAzimuthDeg,takeoffAngleDeg,frontToBackDb,frontToRearDb,azimuthBeamwidthDeg,elevationBeamwidthDeg,omnidirectional,polarization,efficiencyPercent,averageGainTest,averageGainTestDb), the ground (ground,groundConductivity,groundPermittivity), the model (segments,tags,sources,symbols),findings,notes, every sweep frequency insweep, the file links,secondsandevents. - Each finding has
severity(critical,warningorinfo),check,messageand thesegmentsit's about. - Key-value store:
pattern.png,sweep.png,smith.png,geometry.png,sweep.csv,pattern.csv,currents.csv,antenna.s1p,antenna.necandnec-output.txt. With several antennas, the second one's files start withant2-, the third's withant3-, and so on. - OUTPUT: the run as one JSON object, with every antenna's row (without the sweep rows when there are more than 10) and, for a single antenna, its file links at the top.
How it works
- Links are downloaded and uploads fetched; ZIPs and GitHub folders are unpacked, and NEC decks are told apart from other files by their content.
- Each antenna is read and simulated by a separate process, as an unprivileged user, in a throwaway folder. Designs are built first: their element lengths come from published designs (NBS Technical Note 688, W4RNL's Moxon formulas) or from the textbook shape, then NEC tunes them to resonance at your frequency.
- NEC reads the structure first, and the checks look at every segment and junction it found. Then NEC runs at the design frequency with the full pattern (every 2 degrees) and the currents, and across the sweep with a cut through the main lobe at each frequency.
Pricing
You pay per antenna simulated, at the price shown on this page. One event covers an antenna simulated within 30 seconds at the default 2 GB memory (15 seconds at 4 GB, since the platform's cost follows memory); a longer one costs an event for each further started 30 seconds.
Each antenna's events says what it counted for. In the runs above every antenna counted 1 event. The largest of xnec2c's examples took more at 4 GB: the 10 to 20 m Moxon (540 segments, 86 frequencies) 3 events, and a 6 to 40 m dipole over Sommerfeld ground swept at 221 frequencies 4. Antennas that can't be downloaded, read or simulated are never charged.
Speed
Times at the default 2 GB memory, which has half a CPU core, from the runs above:
| Antenna | Time |
|---|---|
| 5-element Yagi for 144.2 MHz, 10 m over average ground (design) | 3 s |
| xnec2c's 2 m Yagi (137 segments) | 3 to 10 s |
| Half-wave dipole for 7.1 MHz over average ground (design) | 3 to 10 s |
| Moxon rectangle for 28.5 MHz (design) | 3 to 9 s |
| xnec2c's car with a 20 m whip (423 segments) | 15 s |
| The 11 Yagis of xnec2c's examples folder | 102 s |
Half a core runs faster when the server is quiet, so the same antenna can take 3 seconds in one run and 10 in another. A design is built and tuned before it's simulated, which takes a few NEC runs. Real grounds take longer than free space, and time grows with the segments and the frequencies in the sweep: give big models more memory (a CPU core per 4 GB) or fewer sweepPoints.
Tips and limits
- Real grounds use the Sommerfeld method, NEC-2's exact one. NEC-2 can't model wires below the ground or lying on it, and a vertical's base needs
GE 1to join the ground; the checks say so when a deck breaks these rules. - The average gain test is shown in free space and over perfect ground, where it means something: a sound, lossless model scores 1 (0 dB). Over a real ground the ground absorbs power and the test doesn't apply.
- NEC-2's known limits hold: wires of very different thickness meeting at a junction, closely spaced parallel wires and stepped-diameter tubing (as in many HF Yagis) are less exact than in NEC-4. Designs use one diameter per element.
- A deck is read the way xnec2c reads it: cards after a run card (
RP,XQ) count too, with NEC's rules for what replaces what. Only the first structure is simulated; one after anNXcard is listed innotes. - Not read:
GF(a precomputed structure file), plane-wave and elementary-current sources (EX 1toEX 4; the voltage sourcesEX 0andEX 5work), and 4nec2's MiniNEC ground (GN 3). EZNEC (.ez) and AO (.ant) files open in 4nec2, which saves them as.nec; MMANA-GAL files (.maa) aren't read. - Up to 6,000 segments an antenna. A large model takes seconds to minutes per frequency: give the run more memory (a CPU core per 4 GB), fewer
sweepPoints, or moretimeLimitSeconds.
For AI agents and developers
- Input:
antennas(links or designs in words), and optionallyfrequencyMHz,ground,heightMandimpedanceOhms. - Output: in the dataset, each antenna's
verdict,headline,findingsand the numbers behind them;OUTPUThas every antenna with its file links. - Errors: an antenna that can't be read or simulated gets
status: "failed"and anerrorthat says why, with the line and card for deck errors (a missing GE card, a source on a tag that doesn't exist, a wire under the ground, NEC's own stop). Failed antennas cost nothing.
Add the tool to an agent through Apify's MCP server at https://mcp.apify.com/?tools=jumblemog/antenna-simulator. Or get the results from one HTTP call:
curl -X POST "https://api.apify.com/v2/acts/jumblemog~antenna-simulator/run-sync-get-dataset-items?token=YOUR_TOKEN" \-H "Content-Type: application/json" \-d '{"antennas": ["moxon 28.5 MHz 2 mm copper wire"]}'
Credits
- nec2c, Neoklis Kyriazis's (5B4AZ) translation to C of NEC-2, the Numerical Electromagnetics Code by G. J. Burke and A. J. Poggio of Lawrence Livermore National Laboratory, which is in the public domain. Installed from Debian.
- Yagi element lengths from NBS Technical Note 688, Yagi Antenna Design (P. P. Viezbicke, 1976); Moxon rectangle dimensions from L. B. Cebik's (W4RNL) formulas; the model-check thresholds follow 4nec2's geometry check by Arie Voors.
- NumPy, SciPy and Matplotlib.