Pass 2 of the implementation plan. Adds magnetic-field synthesis at
arbitrary sensor locations, all in f64 for near-field stability per
plan §7-1.
Public API (re-exported from lib.rs):
- dipole_field(&DipoleSource, sensor_pos) -> ([f64; 3], near_field_flag)
Closed-form analytic dipole: B = (μ₀ / 4π r³)[3(m·r̂)r̂ − m]
(Jackson 3e §5.6).
- current_loop_field(&CurrentLoop, sensor_pos) -> (Vec3, flag)
Numerical Biot–Savart over n_segments straight chords (default 64);
flag fires if any chord midpoint < R_MIN_M (1 mm) of sensor.
- ferrous_field(&FerrousObject, ambient_b, sensor_pos) -> (Vec3, flag)
Linear induced moment m = χ·V·H_ambient (Cullity & Graham 2e §2),
re-radiates as a dipole.
- scene_field_at(&Scene, sensor_pos) -> (Vec3, flag) — aggregate.
- scene_field_at_sensors(&Scene) -> Vec<(Vec3, flag)> — for every sensor.
- R_MIN_M = 1 mm — near-field clamp constant.
Pass 2 acceptance per plan §3 — n=8 RMS gate ≤ 0.5%. Test
`dipole_n8_directions_within_half_percent_rms` independently
recomputes the formula in-test rather than calling the implementation
twice, so the gate guards against an implementation that
accidentally agrees with a buggy reference.
7 new tests:
- on-axis dipole matches B_z = μ₀ m / (2π z³)
- equatorial dipole matches B_z = -μ₀ m / (4π r³)
- n=8 directions RMS ≤ 0.5% — Pass 2 acceptance gate
- on-axis current loop matches μ₀ I a² / [2(a²+z²)^(3/2)]
- near-field r < 1 mm clamps to (0, flag=true)
- zero-ambient ferrous object emits zero field
- two opposite dipoles aggregate to zero at colocated sensor
Validated:
- cargo test -p nvsim → 19 passed (was 12; +7).
- cargo test --workspace --no-default-features → 1,594 passed,
0 failed, 8 ignored (was 1,587; +7).
- ESP32-S3 on COM7 streaming live CSI (cb #8900).
Co-Authored-By: claude-flow <ruv@ruv.net>