feat(math): classify resonances high-Z/low-Z; avoid only high-Z#128
Merged
Conversation
Adds the physically-nuanced refinement previously deferred. A wire is resonant at every quarter-wave multiple, but the feed sees very different impedances: odd multiples (lambda/4, 3lambda/4, ...) are current-fed low-Z (~35-50 ohm, easy to match) while even multiples (half-wave multiples) are voltage-fed high-Z (hundreds to thousands of ohm, genuinely hard to match). - new ImpedanceClass (Low/High) derived from harmonic parity - the non-resonant optimizer now avoids ONLY the high-Z (half-wave) resonances; the desirable low-Z lengths are left available. Per-band the avoid-set is padded by one half-wave so the nearest high-Z point just outside the window is still counted (honest edge clearance) - every on-screen and exported resonant point is tagged low-Z/high-Z, with a legend, so a recommended length that sits near a low-Z resonance is clearly reconcilable against the listed points (resolves the old clearance-vs-points confusion without a second resonance definition) - ResonantPoint gains an impedance_class field; JSON export gains "impedance_class"; text/CSV points are tagged inline - docs/math.md §5 updated; tests for classification, high-Z-only avoidance, and the tagged display/legend Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Addresses the #128 code-review findings: - [1][3] Since the non-resonant optimizer now avoids only high-Z resonances, min_resonance_clearance_pct measures distance to high-Z points only. Relabel it "high-Z clearance" in the non-resonant view and the advise notes, and add a one-line explanation, so the figure is no longer read as a generic "resonance clearance" (a recommendation may intentionally sit on an easy-match low-Z resonance). - [2] Revert the resonant_points_in_window CSV/text value format to the stable `{h}x={len}{unit}` contract (no inline "(low-Z)"); the class stays a first-class field in the JSON export and tagged in the on-screen view. Added a contract guard test. - [4] Fix stale docs/math.md wording that still said "within 1 m outside the window" (padding is now one half-wave per band). - [5] Move the ImpedanceClass enum out from between band_resonant_points_m's doc comment and its fn, so each doc heads its own item. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Owner
Author
|
Applied the high-effort review findings:
All 461 tests pass; clippy + fmt clean. |
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.
Summary
Adds the physically-nuanced resonance handling deferred from #127. A wire is resonant at every quarter-wave multiple, but the feedpoint impedance alternates:
The non-resonant optimizer now avoids only the high-Z resonances, leaving the desirable low-Z lengths available, and every resonant point is tagged in the display and exports so the recommendation stays reconcilable against the list.
Why this is the consistent version of the earlier idea
#127 deliberately did not split resonances into high/low-Z, because doing so partially would create a second, conflicting definition of "resonance" versus the display/export. This PR does it fully: the tags appear everywhere, so recommending a length near a low-Z point (e.g. 30.15 m near the low-Z 3× = 30.14 m) is self-explanatory rather than contradictory.
Changes
ImpedanceClass(Low/High) from harmonic paritybuild_non_resonant_resonance_pointskeeps only even (half-wave) harmonics, padded by one half-wave per band so near-edge clearance stays honest and the set is never spuriously emptyResonantPointgainsimpedance_class; display lines are tagged[low-Z]/[high-Z]with a legend; JSON export gains"impedance_class"; text/CSV points tagged inlineTest plan
impedance_class_follows_harmonic_parity,non_resonant_avoids_only_high_z_resonances(asserts even harmonics avoided, odd left available, first beyond-edge high-Z included),resonant_points_display_lines_tag_impedance_class_and_legendcargo testall pass (370 lib + integration), clippy + fmt clean🤖 Generated with Claude Code
https://claude.ai/code/session_01Jf8uBU8AYxkrG8fa8yo6tC