Skip to content

Fix large-model segment/patch collisions and EX source resolution - #21

Merged
maurymarkowitz merged 2 commits into
maurymarkowitz:mainfrom
torinwalker:fix-opennec-large-model-correctness
Sep 15, 2026
Merged

maurymarkowitz merged 2 commits into
maurymarkowitz:mainfrom
torinwalker:fix-opennec-large-model-correctness

Conversation

@torinwalker

Copy link
Copy Markdown
Contributor

This PR fixes two correctness issues encountered while testing OpenNEC with a large NEC-2 model containing approximately 10,248 generated wire segments.

  1. Segment/patch namespace collision

PCHCON was set to 10000 and is used to distinguish patch connections from ordinary wire-segment connections. Once the generated segment count exceeds that value, valid segment numbers can collide with the patch-connection encoding.

In testing, this caused the results of an otherwise identical model to depend strongly on the ordering of its GW cards, including implausible impedances, broken geometric symmetry, and incorrect radiation patterns. PCHCON is moved to 1000000000, well above the segment counts encountered in practical testing.

  1. EX source segment resolution

An EX card specifies a segment relative to its tag, but the sequential reporting path queued that relative segment number in a field subsequently interpreted as an absolute/global segment number. The fix resolves the tag-relative segment through segment_number() before queueing the source.

For example, in the model that exposed the problem, EX 0 902 1 ... was intended to excite the first segment of tag 902, whose global segment number was 358, but the queued source instead referred to global segment 1.

With both fixes applied, seven different orderings of the same geometry produced identical impedance and 360-degree radiation patterns. The corrected result also agreed with nec2c: approximately Z = 159.18 - j51.18 ohms, gain 12.21 dBi, and F/B 18.28 dB, with no pattern asymmetry to printed precision.

Both changes have been rebuilt successfully against the current main branch.

@maurymarkowitz
maurymarkowitz merged commit 96575bf into maurymarkowitz:main Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants