Repository navigation
ForcingTerms - FEATURE - Use the exact straight-segment field in the coil Biot-Savart sum - #590
Conversation
…coil Biot-Savart sum
|
@krystophny Hi, please see my comment on the fortran equivalent PR. How does this affect the convergence of non-straight coils? |
|
The convergence for round coils, with a plot, is answered on the Fortran pull request: PrincetonUniversity/GPEC#361 (comment). It applies unchanged here, since both versions use the same formula. Chris&AI |
|
Independent local coil-resolution study at PR head I evaluated both methods over the full DIII-D-like example plasma boundary, rather than at a single observation point. The exact-segment calculation uses this PR's Julia kernel; the midpoint calculation uses the previous midpoint expression. Setup
Error definitions
Full convergence table — all error columns are percentages
Both methods converge as N^-2 once sufficiently resolved, consistent with the curved-coil explanation in the Fortran PR discussion. Exact segment integration improves the error coefficient but leaves the geometric error from replacing a circle with straight chords. At 64 segments, the full poloidal-vector error is 0.951% with exact segments versus 1.500% with midpoint evaluation. At high resolution, exact segments reduce that error by about 36% at fixed segment count in this case. Checks and scope: The elliptic-integral reference agrees with independent direct numerical Biot–Savart integration at three sampled surface locations to relative errors below 8e-16. Doubling toroidal sampling from 128 to 256 for N = 32, 64, 128, 256 changes the n=1 field vector by less than 1.4e-7 of the reference vector norm; the analytic reference's n=1 vector changes by about 1.1e-13. The harmonic comparison includes every mode resolved by the 256-point poloidal grid; this is a coil-resolution scan on a fixed equilibrium/surface grid, not a poloidal-grid convergence study. This is one filament hoop without finite conductor cross-section or plasma response, so it supports the improvement for a representative PF-coil placement rather than establishing a universal resolution threshold. |
matt-pharr
left a comment
There was a problem hiding this comment.
This is a good contribution and is physically valid. It improves convergence moderately in number of coil points required for an accurate field. See my above comment with a table doing a PF error field study on the DIII-D-like plasma. This is to be merged after the stack including #584.
Closes #589.
src/ForcingTerms/BiotSavart.jlevaluated every straight segment of a coil polyline as a single current element at its midpoint, a one-point quadrature whose relative error is of order (L/d)^2. This change replaces it, in bothaccumulate_strand_field!and the threaded kernel behindcompute_biot_savart_boundary!, with the exact field of a straight filament segment (Hanson and Hirshman, Phys. Plasmas 9, 4410 (2002), Eq. 8), the same fix as GPEC#361 for the Fortran GPEC#360. Both kernels now call one@inlinehelper,_segment_field, andPrecomputedSegmentsstores the segment start points and lengths instead of the midpoints. The exported functions keep their signatures and units. The on-conductor guard still skips a segment whose distance to the observer is below 1 μm, now measured as the effective perpendicular distance ρ² = 2RᵢR_f(Rᵢ + R_f - L)/(Rᵢ + R_f) rather than as the distance to the midpoint.Release note
CoilSetpolylines are now exact for the given polygon; for coils whose straight segments are long compared with their distance to the plasma boundary, the forcing spectrum changes by up to the former midpoint error (tens of percent at d/L ≲ 1). The DIII-D C-coil case indiiid_error_fieldmoves by 0.01 %. (harness @ abd73d4)Coil fields were computed with a midpoint rule along each straight coil segment, which overestimated or underestimated the field by up to tens of percent near coils with long straight sides. They are now exact for the coil polygon.
Regression report
The baseline 81fb41d is
origin/developat the time of the run.Notes for reviewers
test/runtests_coils.jl: a single segment against the textbook finite-wire field at d = 0.05-2 m (rtol 1e-12),@inferredon the kernel, an observer on the conductor, and a rectangle whose sides are split into 1 or 16 collinear pieces (agreement to 1e-12). The new tests fail ondevelop(single segment off by up to a factor 10 at d = 0.05 m). FullPkg.test()passes on Julia 1.13.2 (8448 assertions); Julia 1.11/1.12 were not run locally.BiotSavart.jl, so some unchanged lines in that file are re-indented.Chris&AI