Skip to content

0.9.0: pin conductivity (LD 5) load behaviour and report out-of-range targets - #13

Merged
andrekuehne merged 2 commits into
masterfrom
ccr-21b2c228-a4dust
Oct 16, 2026
Merged

andrekuehne merged 2 commits into
masterfrom
ccr-21b2c228-a4dust

Conversation

@andrekuehne

@andrekuehne andrekuehne commented Oct 16, 2026 •

Copy link
Copy Markdown
Owner

This PR adds the necpp side of WP0 for andrekuehne/PhasedArrayVisualizer-NG#159 (wire conductor material). The app computes conductor loss itself from NECQ currents, so it needs necpp's LD 5 behaviour pinned and documented exactly. It also bumps the WASM package to 0.9.0; after merge, release is the wasm-v0.9.0 tag on master.

Engine behaviour is unchanged. 0.8.0 already does everything the app relies on, including recomputing LD 5 on prepare() at a new frequency. This PR adds regression coverage, a normative contract, and one clearer error message.

Changes

  • Tests: new src/nec_stateful_model_conductivity_tb.cpp (Catch2 [conductivity], runs under necpp_unit) and packages/necpp-wasm/test/conductivity-load.test.mjs. Together they pin:
    • structureLossW = Σ ½·Re Z′ᵢ·Lᵢ·|Aᵢ+Cᵢ|². This is the segment-centre rule with NEC ZINT, checked in all three branches (x ≤ 8, 8 < x ≤ 110, x > 110). It uses each segment's own radius, and feed segments are loaded too.
    • The app's GL-4 NECQ samples reproduce structureLossW to 1e-12 once each segment's exact centre current is rebuilt from the samples.
    • prepare(f1) → prepare(f2) is bitwise equal to a fresh prepare(f2). This holds for the stateful model and for NecArraySolver with symmetry off and auto.
    • With a perfect ground, loss counts physical segments only.
    • FORTRAN NEC-2 reference. testharness/FORTRAN/nec2dx.f was built with gfortran using the same c0. It agrees with necpp to every printed digit: Z to 6 significant figures, loss to 5. The decks are copper, stainless and σ = 1e3 dipoles and a copper monopole, each at 1000 and 1100 MHz.
    • The ring evaluator accepts loaded wires.
    • Validation happens at addLoad.
  • Error message: a tag-relative load range that runs past the tag's last segment used to fail with "NO SEGMENT HAS AN ITAG OF 1", for a tag that exists. It now fails with "SEGMENT TARGET IS OUT OF RANGE FOR THE TAG". The error class (NecGeometryError) and the absent-tag message are unchanged.
  • Docs: docs/wasm-api.md gains a normative "Conductivity loads (LD 5)" section: the formula and its branches, NEC's constants, the accounting rule, recompute on frequency change, and validation.
  • Version: 0.9.0 in the same places the 0.8.0 bump touched: package.json, the lockfile, versions.ts, the fixture manifest, the README CDN example, and the two version-asserting tests.
  • CHANGELOG: new 0.9.0 section. The GE -1 entries that sat under "Unreleased" are in the commit tagged wasm-v0.8.0, so they now sit under 0.8.0.

Note for anyone using nec2c as a golden

nec2c 1.3.1 does not match NEC-2 for x ≤ 110. On the same decks it is 2 % off for stainless and 19 % off for σ = 1e3. necpp, the original FORTRAN and the exact J0/J1 form all agree with each other.

nec2c agrees only in the x > 110 branch (copper at x ≈ 203: 1 GHz, a = 0.3 mm). The visualizer's product metals at 10 GHz (copper x ≈ 64) all sit in the series branch, where nec2c is wrong.

Validation

Run locally with the Emscripten SDK 4.0.7 build of this branch:

  • native ctest: 8/8 pass;
  • npm --prefix packages/necpp-wasm test: 166/166 pass, typecheck clean;
  • pack manifest test passes at 0.9.0.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LEzEibjCJrRrYxMm1uke1N

Downstream consumers compute conductor loss themselves from exported
segment currents, so the LD 5 contract has to be exact and stable.

Tests (native Catch2 [conductivity] and package conductivity-load.test.mjs):
- structureLossW equals sum 0.5 Re(Z'_i) L_i |A_i + C_i|^2 with NEC ZINT
  in all three branches (x <= 8, 8 < x <= 110, x > 110), per-segment
  radius, feed segments included; GL-4 NECQ samples reproduce it via the
  exact centre current.
- prepare() at a new frequency recomputes the load: a swept stateful
  model or NecArraySolver (explicit and symmetric) is bitwise identical
  to a fresh one.
- Perfect-ground loss counts physical segments only.
- FORTRAN NEC-2 (testharness nec2dx.f, same c0) reference values for
  copper, stainless and sigma = 1e3 dipoles and a copper monopole.
- The ring evaluator accepts loaded wires.

A tag-relative load range past the tag's last segment now fails with
"SEGMENT TARGET IS OUT OF RANGE FOR THE TAG" instead of "NO SEGMENT HAS
AN ITAG OF n" for a tag that exists. Error class and absent-tag message
are unchanged.

docs/wasm-api.md gains a normative "Conductivity loads (LD 5)" section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LEzEibjCJrRrYxMm1uke1N
Move the GE -1 entries that shipped in the wasm-v0.8.0 tag under 0.8.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LEzEibjCJrRrYxMm1uke1N
@andrekuehne andrekuehne changed the title Pin conductivity (LD 5) load behaviour and report out-of-range targets 0.9.0: pin conductivity (LD 5) load behaviour and report out-of-range targets Oct 16, 2026
@andrekuehne
andrekuehne merged commit 702bcab into master Oct 16, 2026
12 checks passed
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