Repository navigation
0.9.0: pin conductivity (LD 5) load behaviour and report out-of-range targets - #13
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.0tag 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
src/nec_stateful_model_conductivity_tb.cpp(Catch2[conductivity], runs undernecpp_unit) andpackages/necpp-wasm/test/conductivity-load.test.mjs. Together they pin:structureLossW= Σ ½·Re Z′ᵢ·Lᵢ·|Aᵢ+Cᵢ|². This is the segment-centre rule with NECZINT, 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.structureLossWto 1e-12 once each segment's exact centre current is rebuilt from the samples.prepare(f1)→prepare(f2)is bitwise equal to a freshprepare(f2). This holds for the stateful model and forNecArraySolverwith symmetry off and auto.testharness/FORTRAN/nec2dx.fwas 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.addLoad.NecGeometryError) and the absent-tag message are unchanged.docs/wasm-api.mdgains a normative "Conductivity loads (LD 5)" section: the formula and its branches, NEC's constants, the accounting rule, recompute on frequency change, and validation.package.json, the lockfile,versions.ts, the fixture manifest, the README CDN example, and the two version-asserting tests.GE -1entries that sat under "Unreleased" are in the commit taggedwasm-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:
ctest: 8/8 pass;npm --prefix packages/necpp-wasm test: 166/166 pass, typecheck clean;🤖 Generated with Claude Code
https://claude.ai/code/session_01LEzEibjCJrRrYxMm1uke1N