Skip to content

Test Biot-Savart derivatives against an analytic circular loop - #71

Draft
rogeriojorge wants to merge 1 commit into
mainfrom
test/circular-loop-derivative-oracle
Draft

rogeriojorge wants to merge 1 commit into
mainfrom
test/circular-loop-derivative-oracle

Conversation

@rogeriojorge

Copy link
Copy Markdown
Member

Needs the project's external reviewer. ESSOS PRs are not self-merged.

Why

Free-boundary equilibrium workflows differentiate coil fields through third spatial order and with respect to coil parameters. The active field tests currently check construction and cylindrical/Cartesian self-consistency, but they do not compare these quantities with an independent physical oracle.

What this adds

A circular filament in the xy plane has the analytic on-axis field

Bz(z) = mu0 I R^2 / (2 (R^2 + z^2)^(3/2)).

The source-free axisymmetric expansion around the axis determines every Cartesian component through third spatial order:

Bz = F - (x^2 + y^2) F'' / 4 + ...
(Bx, By) = -(x, y) F' / 2
           + (x, y) (x^2 + y^2) F''' / 16 + ...

The test writes the first three derivatives of F explicitly, then compares all entries of B, dB/dX, d2B/dX2, and d3B/dX3 at a nonzero axial point. It also checks two selected Coils.with_dofs JVPs against analytic derivatives: one physical ampere through the normalized current coordinate and a common-radius direction through the circle's two Fourier coefficients.

Absolute tolerances scale with the largest analytic component at each derivative order or sensitivity. This keeps zero-component checks tied to the corresponding physical scale: T, T/m, T/m^2, T/m^3, T/A, or T/m. The relative tolerance is 2e-11.

Scope

This is a full Cartesian tensor check at one symmetry-axis point. It is not an off-axis or full-domain oracle. The parameter test covers two selected directions of the field value; it does not cover the full coil-parameter Jacobian or parameter sensitivities of the spatial derivative tensors.

The oracle found no numerical defect in this tested scope. The change adds regression coverage only and does not modify production code.

Validation

  • pytest -q tests/test_fields.py: 6 passed
  • Python 3.11, JAX/JAXlib 0.9.2, CPU with 64-bit mode enabled
  • git diff --check

Related qualification work: VMEX HINT comparison #302. This PR remains draft for manual review.

@codecov

codecov Bot commented Sep 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

@rogeriojorge
rogeriojorge force-pushed the test/circular-loop-derivative-oracle branch from 8f5e1ea to 7d98744 Compare September 27, 2026 04:53
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.

1 participant