Skip to content

feat(rf): circuit fundamentals, radio-system math, and a circuit calculator - #13

Merged
leavesofgrass merged 3 commits into
mainfrom
claude/sleepy-edison-2492mm
Sep 25, 2026
Merged

leavesofgrass merged 3 commits into
mainfrom
claude/sleepy-edison-2492mm

Conversation

@leavesofgrass

Copy link
Copy Markdown
Owner

PR 1 of 3 in the radio-toolset series. Stacked PRs follow for RF exposure (MPE/SAR) and the Smith chart/accessibility upgrade.

Why

abax's RF layer did not cover the circuit math of the FCC Amateur Extra (Element 4) exam. The 2024–2028 pool is effective 2024-07-01 through 2028-06-30, and this PR works from the copy that includes the fourth errata (2026-02-04). The missing pieces:

  • time constants
  • phase angle and admittance
  • ERP chains
  • link margin
  • op-amp gain
  • modulation index
  • CW/FSK bandwidth
  • ADC bits
  • sideband band edges
  • stub reactance

I extracted the pool text and inventoried every question that needs arithmetic: 45 questions reducing to about 20 distinct relations. This PR covers all of them.

What

59 new formula functions (Radio & RF category):

Area Functions
Ohm's law & power OHMV OHMI OHMR POWERVI POWERIR POWERVR
Series / parallel RSERIES RPARALLEL LSERIES LPARALLEL CSERIES CPARALLEL (values or ranges)
Time constants TAURC TAURL TCCHARGE TCDECAY TCTIME
Impedance & power ZSERIESRLC ZPARALLELRLC ZMAG PHASEANGLE POWERFACTOR ADMITTANCE CONDUCTANCE SUSCEPTANCE POLAR2RECT REALPOWER REACTIVEPOWER APPARENTPOWER QSERIES QPARALLEL
Link & power chain ERPW EIRPW RXLEVEL LINKMARGIN BWNOISEDB
Op-amps, FM, bandwidth OPAMPINV OPAMPNONINV MODINDEX DEVRATIO CARSONBW CWBW FSKBW
Sampling ADCBITS ADCLEVELS ADCLSB ADCSNR NYQUIST
Band edges, lines, antennas USBMAXFREQ LSBMINFREQ LINELEN ELECDEG STUBX ANTEFF
Receiver IMD3LO IMD3HI IP3 SFDR IMAGEFREQ
  • Impedance arguments accept either an Excel complex string ("75+25j") or separate R, X numbers.
  • Complex results are complex strings that the existing IMREAL, IMAGINARY and IMABS functions read.
  • Backed by new pure-stdlib modules core.science.circuits and core.science.radio_calc.

Worked examples: docs/examples/radio/extra-class-formulas evaluates all 45 calculation questions as formulas. It exits non-zero if any result disagrees with the answer key, so tests/test_examples.py enforces it. I also checked the answer letters and wording in the script against the pool text programmatically.

Circuit calculator (Tools → Radio), with four tabs:

  • Ohm's law: enter any two of E, I, R and P.
  • RC/RL time constant, with a graph.
  • RLC resonance: f0, Q and −3 dB bandwidth, with a graph.
  • Impedance, phase and admittance.

Fields accept engineering notation (50u, 40 pF, 3.5 MHz).

Accessibility of the graphs:

  • The chart canvas is keyboard-focusable and draws a visible focus ring.
  • It has an accessible name, and an accessible description written from the plotted numbers. That description is the same text as the visible summary, and it fires DescriptionChanged when the values change.
  • Reference lines and points are labeled with text, never color alone.
  • Each graph is paired with the same data as a table, plus a Data → new sheet button.
  • Colors come from the theme palette, so the high-contrast themes apply.

Sources and caveats

  • CW/FSK necessary bandwidth follows 47 CFR § 2.202(g): Bn = B·K, and Bn = 2M + 2DK. The rule states no general WPM → baud conversion. CWBW uses 0.8 baud per WPM, the ratio in the rule's own worked example (25 WPM with B = 20), and the pool uses the same ratio (E8C05). This is documented.
  • Coverage gaps:
    • The pool asks no numeric Smith chart or MPE questions; PRs 2–3 address those tools.
    • A few functions here go beyond the pool as practical station tools: Carson's rule, IP3/SFDR and image frequency.

Verification

  • ruff check . passes.
  • pytest -n auto: 4647 passed, 196 skipped. The skip count was unchanged by this PR; none of the new tests skip.
  • mkdocs build --strict passes.
  • python make_pyz.py builds, and abax.pyz --version runs.
  • The coverage ratchet was run locally with the CI command: core 84.35% (floor 83), engine 63.26% (floor 62), both within slack.
  • The new tests were mutation-checked:
    • Breaking the FSK formula, the phase-angle argument order, the ADC floating-point guard, or the complex-result cleanup each turns tests red.
    • The ADC guard mutation first slipped through, so a real floating-point edge case was added.
  • Registry-size and description-coverage pins were raised (614 → 673 and 625 → 688) with comments.

🤖 Generated with Claude Code

https://claude.ai/code/session_0157FDmhHjtSvT3pWABUTvmX


Generated by Claude Code

…ulator

Covers every calculation question in the FCC Amateur Extra (Element 4)
2024-2028 question pool, plus the circuit and system arithmetic of
day-to-day advanced station work.

- 59 new formula functions in the Radio & RF category:
  - circuits: Ohm's law/power, series/parallel, RC/RL time constants,
    RLC impedance, phase angle, admittance, power factor, true/reactive/
    apparent power, circuit Q
  - radio systems: ERP/EIRP chains, received level and link margin,
    op-amp gain, FM index and Carson bandwidth, CW/FSK necessary bandwidth
    (47 CFR 2.202), ADC resolution and Nyquist rate, sideband band edges,
    line length, stub reactance, antenna efficiency, IMD3/IP3/SFDR, image
    frequency
  - impedance arguments take an Excel complex string or R, X numbers;
    complex results are complex strings IMREAL/IMAGINARY/IMABS read
- docs/examples/radio/extra-class-formulas works all 45 calculation
  questions and exits non-zero if any disagrees with the answer key
- Tools > Radio > Circuit calculator: Ohm's law wheel, time-constant and
  resonance graphs, and impedance. Graphs are keyboard-focusable, carry a
  screen-reader description that updates with the numbers, and are
  paired with a data table and "Data -> new sheet".
- core.science.engnum parses/formats engineering notation; the Qt compat
  layer exports QAccessible/QAccessibleEvent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0157FDmhHjtSvT3pWABUTvmX
Only rule text verified from primary sources is built in:
47 CFR 1.1310 Table 1 (MPE, both tiers, 6/30-minute averaging), the
1.1310(b)-(c) SAR limits, and the 1.1307(b)(3)(i)(C) exemption table
with its lambda/2pi applicability limit.

- 11 formula functions: MPELIMIT, MPEEFIELD, MPEHFIELD, PWRDENSITY,
  MPEDIST, MPEPERCENT, AVGPOWER, EXEMPTERP, EXEMPTMINDIST, SARLIMIT, SAR
  (frequencies in Hz, power density in the FCC's mW/cm2)
- Ground reflection is a power-density factor: 1 (free space), 4 (full
  in-phase reflection) or user-entered. The tests show the 1.1307
  exemption table is exactly the x4 model applied to ERP, and that the
  1.1310 E-field and power-density columns agree via E^2/377.
- Duty cycle and transmit time are inputs; OET-65's per-mode factors
  and reflection factor, the 1.1307(b)(3)(i)(B) P_th formula, and
  ICNIRP levels could not be verified and are documented as omitted.
- Tools > Radio > RF exposure estimate (MPE): whole-station evaluation,
  verdicts stated in words, an accessible log-log density-vs-distance
  graph with limits and compliance distances marked, data table, and
  "Data -> new sheet". The estimate caveat is shown on the dialog.
- GraphPanel/rows_to_new_sheet move into a shared dialogs module;
  vertical reference-line labels move to the plot bottom to avoid
  colliding with threshold labels.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0157FDmhHjtSvT3pWABUTvmX
…-exposure

feat(rf): FCC RF-exposure (MPE/SAR) estimates and an exposure dialog
@leavesofgrass
leavesofgrass merged commit 932ffd5 into main Sep 25, 2026
33 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