# Antenna Simulator: NEC-2 Antenna Analysis, SWR & Pattern (`jumblemog/antenna-simulator`) Actor

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.

- **URL**: https://apify.com/jumblemog/antenna-simulator.md
- **Developed by:** [Jumble Mog](https://apify.com/jumblemog) (community)
- **Categories:** Developer tools, AI, Automation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Antenna Simulator: NEC-2 Antenna Analysis, SWR & Pattern

**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 `.s1p` file for circuit simulators and VNA software, and the deck as simulated, for 4nec2 or xnec2c.

![Radiation pattern of a Moxon rectangle for 28.5 MHz in free space: 5.92 dBi toward the front, a front-to-back ratio of 36.5 dB, azimuth and elevation cuts on the ARRL log scale](https://api.apify.com/v2/key-value-stores/Km5b4PG3kYHdZSb1E/records/antenna-simulator-pattern.png?signature=1i7JpBDO5IVJhNV0i9qNq)

*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.*

![SWR, feed impedance, gain and front-to-back ratio of the 28.5 MHz Moxon from 27.6 to 30.1 MHz: SWR under 2 from 28.05 to 29.55 MHz, front-to-back peaking at 38 dB near 28.47 MHz](https://api.apify.com/v2/key-value-stores/Km5b4PG3kYHdZSb1E/records/antenna-simulator-sweep.png?signature=1A0hctSk6vxypVKeG8lR7)

*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.*

![A wire-grid model of a car with a 20 m whip on its roof, its 423 segments coloured by the current on them at 14 MHz](https://api.apify.com/v2/key-value-stores/Km5b4PG3kYHdZSb1E/records/antenna-simulator-geometry.png?signature=AsE1tv3TQf9vL8sviMtj)

*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](https://www.qsl.net/5b4az/pages/nec2.html) 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

1. Give **Antennas**: a link to a `.nec` file (or a ZIP or GitHub folder of them), or a design in words with its frequency. Uploads and pasted decks work too.
2. If you like, set the **design frequency**, the **sweep**, the **feed line impedance**, the **ground** and the **height**.
3. 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 `OUTPUT` sums up the run.

### How-to examples

The result lines come from runs of these inputs. The `.nec` files are examples from [xnec2c](https://github.com/KJ7LNW/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`.

```json
{
  "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.

```json
{
  "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.

```json
{
  "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.

```json
{
  "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.

```json
{
  "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: `.nec` files, 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**: `SY` symbols 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 `Z0` card (the line impedance SWR refers to), and `GS` cards that scale only a range of tags, which NEC-2 itself doesn't have (it scales everything); for decks of `GW` wires and `GM` copies 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` (`file` or `design`), `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`, `bandwidthSwr2OpenEnded` and 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 in `sweep`, the file links, `seconds` and `events`.
- Each finding has `severity` (`critical`, `warning` or `info`), `check`, `message` and the `segments` it's about.
- **Key-value store**: `pattern.png`, `sweep.png`, `smith.png`, `geometry.png`, `sweep.csv`, `pattern.csv`, `currents.csv`, `antenna.s1p`, `antenna.nec` and `nec-output.txt`. With several antennas, the second one's files start with `ant2-`, the third's with `ant3-`, 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

1. Links are downloaded and uploads fetched; ZIPs and GitHub folders are unpacked, and NEC decks are told apart from other files by their content.
2. 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.
3. 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 1` to 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 an `NX` card is listed in `notes`.
- Not read: `GF` (a precomputed structure file), plane-wave and elementary-current sources (`EX 1` to `EX 4`; the voltage sources `EX 0` and `EX 5` work), 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 more `timeLimitSeconds`.

### For AI agents and developers

- **Input**: `antennas` (links or designs in words), and optionally `frequencyMHz`, `ground`, `heightM` and `impedanceOhms`.
- **Output**: in the dataset, each antenna's `verdict`, `headline`, `findings` and the numbers behind them; `OUTPUT` has every antenna with its file links.
- **Errors**: an antenna that can't be read or simulated gets `status: "failed"` and an `error` that 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:

```bash
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](https://www.qsl.net/5b4az/pages/nec2.html), 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.

# Actor input Schema

## `antennas` (type: `array`):

One antenna per line. A link to a NEC-2 deck: a .nec file (4nec2's symbols, traps and coatings work), a ZIP archive or a GitHub folder of decks (add #yagi to take only the files whose path holds yagi), a GitHub or GitLab file page, Google Drive or Dropbox. Or a design in words, built and tuned for you: dipole, inverted V, vertical or ground plane, Yagi (2 to 17 elements), Moxon, quad, loop or delta loop, with the frequency, and optionally height, ground, wire size and material, such as '5 element yagi 432 MHz 4 mm' or 'inverted V 3.65 MHz apex 15 m over poor ground'.

## `upload` (type: `string`):

A .nec file (or a ZIP of them) from your computer, simulated together with the antennas above.

## `necText` (type: `string`):

The text of a NEC-2 deck: CM comments, then GW wires, GE, EX source, FR frequency and EN, as 4nec2, xnec2c and nec2c use.

## `frequencyMHz` (type: `number`):

Where the pattern, gain and feed impedance are reported. Empty: the deck's FR card (the middle of its range), or the design's frequency. For a design without a frequency in its words, this is its frequency.

## `sweepStartMHz` (type: `number`):

Empty: the amateur or radio band holding the design frequency with a margin on both sides (the deck's own range when its FR card sweeps), else 5% either side.

## `sweepStopMHz` (type: `number`):

The top of the sweep. Give one end only and the sweep is centred on the design frequency.

## `sweepPoints` (type: `integer`):

Frequencies in the sweep, evenly spaced. Empty: 21. Each one costs one NEC run: large models take a while per frequency.

## `impedanceOhms` (type: `number`):

SWR, return loss, the Touchstone file and the matching networks refer to this: 50 for coax, 75 for TV coax, 450 or 600 for ladder line. Empty: the deck's Z0 card (xnec2c) if it has one, else 50.

## `ground` (type: `string`):

Real soils use NEC's exact Sommerfeld ground. Over a ground the pattern is the half above it and the takeoff angle is reported.

## `groundConductivity` (type: `number`):

For a custom ground, or to change a soil type's value. Giving it with the deck's ground uses custom soil.

## `groundPermittivity` (type: `number`):

For a custom ground, or to change a soil type's value (dielectric constant).

## `heightM` (type: `number`):

Moves the whole antenna up or down to put its (first) feed point this high above the ground. For designs it's the height of the antenna (the apex of an inverted V, the base of a ground plane). Empty: as the deck has it; designs over ground go half a wavelength up.

## `symbols` (type: `object`):

Values for the deck's SY symbols, which win over the deck's own, to try a change without editing the file: {"len": 10.35, "h": 15}. Expressions in the deck use them.

## `wireDiameterMm` (type: `number`):

For designs whose words give no size. Empty: 2 mm wire below 30 MHz, 6 mm tube for beams and 4 mm for others above.

## `material` (type: `string`):

The wires' losses (LD 5). For a deck, every wire, unless the deck sets its own conductivity. Empty: decks as they are; designs copper below 30 MHz, aluminium above.

## `outputs` (type: `array`):

The dataset row with every number is always made.

## `timeLimitSeconds` (type: `integer`):

Downloading and simulating stop after this long; what was done is kept. A sweep that wouldn't fit is cut to fewer frequencies. Each antenna is billed for its own time.

## Actor input object example

```json
{
  "antennas": [
    "3 element yagi 144.2 MHz 10 mm aluminium",
    "dipole 7.1 MHz at 12 m over average ground"
  ],
  "ground": "deck",
  "outputs": [
    "pictures",
    "tables",
    "nec",
    "touchstone"
  ],
  "timeLimitSeconds": 300
}
```

# Actor output Schema

## `antennas` (type: `string`):

A row per antenna: verdict, headline, feed impedance, SWR, gain and front-to-back.

## `pattern` (type: `string`):

Gain and its direction, front-to-back, beamwidths, polarization and efficiency.

## `impedance` (type: `string`):

Feed point, resonance, SWR bandwidth and matching networks.

## `findings` (type: `string`):

Every finding of the geometry checks and the notes.

## `patternPicture` (type: `string`):

Azimuth and elevation patterns of the first antenna.

## `sweepPicture` (type: `string`):

SWR, impedance, gain and front-to-back across the sweep.

## `smith` (type: `string`):

The feed impedance across the sweep.

## `geometry` (type: `string`):

The wires in 3D, coloured by current.

## `sweepCsv` (type: `string`):

The sweep as a table.

## `touchstone` (type: `string`):

The feed point's S11 in Touchstone format.

## `deck` (type: `string`):

The deck as simulated, for 4nec2, xnec2c or nec2c.

## `output` (type: `string`):

The run's summary: every antenna, its numbers, findings and file links in one JSON object.

## `store` (type: `string`):

Every file in the run's key-value store (with several antennas, the second one's files start with ant2-, and so on).

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "antennas": [
        "3 element yagi 144.2 MHz 10 mm aluminium",
        "dipole 7.1 MHz at 12 m over average ground"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("jumblemog/antenna-simulator").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "antennas": [
        "3 element yagi 144.2 MHz 10 mm aluminium",
        "dipole 7.1 MHz at 12 m over average ground",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("jumblemog/antenna-simulator").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "antennas": [
    "3 element yagi 144.2 MHz 10 mm aluminium",
    "dipole 7.1 MHz at 12 m over average ground"
  ]
}' |
apify call jumblemog/antenna-simulator --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,jumblemog/antenna-simulator"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/oFhNj3XkvDkwV2m54/builds/sgPGiOpfEmaw7rf5H/openapi.json
