Skip to content

Add differentiable physical section flux and filament potential - #148

Open
rogeriojorge wants to merge 10 commits into
mainfrom
research/magnetic-turnstiles
Open

rogeriojorge wants to merge 10 commits into
mainfrom
research/magnetic-turnstiles

Conversation

@rogeriojorge

@rogeriojorge rogeriojorge commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Adds two physical-flux primitives in the existing field module: section_flux integrates B_phi dR dZ over a supplied section polygon, and BiotSavart.A evaluates the filament vector potential using the existing coil quadrature. Field and vertex derivatives are retained. The section measure has no extra radius factor; the equivalent circulation for the positive toroidal normal traverses the boundary clockwise in (R,Z).

The caller must supply a simple, resolved polygon and a field regular over its signed triangle fan. These functions do not locate turnstiles, identify manifold branches or qualify a coil-design objective. There is no new dependency, tracer or topology package.

Independent tests cover the analytic B_phi=C/R rectangle, field reversal, polygon orientation, concave geometry, field and shape derivatives, JIT/VMAP/JVP/VJP, curl(A)=B, closed-loop Stokes and gauge invariance. Inserting an extra radius deliberately makes the analytic oracle fail. All 57 field/coil tests pass; coverage reaches 22/22 changed executable lines and 4/4 new validation branches. The upstream fatal flake8 selectors pass.

The full local suite reports 323 passed, 1 xfailed, 2 failed (535.55 s). Both failures are bitwise adaptive8 survivor-compaction comparisons and reproduce on unchanged baseline 043047f6f0ccfe51ec85c655497c73af855a39bb in the same environment, with maximum absolute array mismatch 6.94e-18. Those failures are preserved; the suite is not claimed green. Environment: Apple M4 CPU, Python 3.13.7, JAX/JAXlib 0.11.0, x64, one BLAS/OpenMP thread. At revision 74afb895f2e1fe91263175898c6ccffb2b59beff, the Python 3.10, 3.11 and 3.12 CI suites and patch-coverage check all pass.

The patch adds 50 source lines, 65 test lines and 10 README lines. It has no performance or new physical-result claim. Related open #99 owns the cylindrical return map, #139 changes coil conversion, and #146 changes broader field algebra/tracing; this patch leaves those implementations alone. Review this bounded diagnostic independently of any future lobe or optimization work.

Current-main integration: merge ed6d61772048a2bc98f41b9125f6a3c46c6b1c66 includes upstream 0d1f9b6267af404c5a8585c1c36335ade385b797 (#147). The flux/coil source, tests and README are byte-identical to the previously qualified patch. All 74 field, coil and augmented-Lagrangian tests pass on the integrated revision (181.40 s, same shared CPU environment), and fatal flake8 selectors report zero. Python 3.10/3.11/3.12 CI and patch coverage all pass on this integrated revision.

@rogeriojorge
rogeriojorge marked this pull request as ready for review October 7, 2026 20:11
@rogeriojorge

Copy link
Copy Markdown
Member Author

Merged main. surfaces.toroidal_flux/poloidal_flux were dead before (BiotSavart had no A); with field.A they now run, and a short test checks toroidal_flux against section_flux on a circular section (orientation is opposite, as documented).

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