From 52a39132447d14642e20aac0c79260fde7be7add Mon Sep 17 00:00:00 2001 From: adrianaghiozzi <67669644+adrianaghiozzi@users.noreply.github.com> Date: Tue, 1 Sep 2026 14:54:38 -0400 Subject: [PATCH 1/2] ForceFreeStates - BUGFIX! - Snap the periodic theta endpoint before integrating GGJ geometry --- src/ForceFreeStates/Surfaces/Resist.jl | 4 ++++ src/ForceFreeStates/Surfaces/ResistEval.jl | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/ForceFreeStates/Surfaces/Resist.jl b/src/ForceFreeStates/Surfaces/Resist.jl index ecfbcd0f8..24a56fc7b 100644 --- a/src/ForceFreeStates/Surfaces/Resist.jl +++ b/src/ForceFreeStates/Surfaces/Resist.jl @@ -94,6 +94,10 @@ function resist_eval(sing::SingType, equil::Equilibrium.PlasmaEquilibrium, ff[itheta, 6] = dpsisq / bsq @views ff[itheta, :] .*= jac / v1 end + # Snap the repeated endpoint exactly equal to the start (see Equilibrium.jl's + # GS-residual integrator and issue #240 -- independent spline evaluations at + # theta=0/1 can differ by machine epsilon and trip PeriodicBC's check) + @views ff[end, :] .= ff[1, :] itp = cubic_interp(equil.rzphi_ys, Series(ff); bc=PeriodicBC()) avg = FastInterpolations.integrate(itp) diff --git a/src/ForceFreeStates/Surfaces/ResistEval.jl b/src/ForceFreeStates/Surfaces/ResistEval.jl index 04953b6c0..acadf1979 100644 --- a/src/ForceFreeStates/Surfaces/ResistEval.jl +++ b/src/ForceFreeStates/Surfaces/ResistEval.jl @@ -165,6 +165,10 @@ function resist_geometry(equil::Equilibrium.PlasmaEquilibrium, ff[itheta, 7] = B_here @views ff[itheta, :] .*= jac / v1 end + # Snap the repeated endpoint exactly equal to the start (see Equilibrium.jl's + # GS-residual integrator and issue #240 -- independent spline evaluations at + # theta=0/1 can differ by machine epsilon and trip PeriodicBC's check) + @views ff[end, :] .= ff[1, :] # Integrate each column around θ using the same periodic cubic-spline # integrator Mercier.jl uses From cefa01003f59a0cc34e20b77681428b2efe54788 Mon Sep 17 00:00:00 2001 From: adrianaghiozzi <67669644+adrianaghiozzi@users.noreply.github.com> Date: Wed, 2 Sep 2026 10:44:01 -0400 Subject: [PATCH 2/2] Shorten overly verbose comments --- src/ForceFreeStates/Surfaces/Resist.jl | 4 +--- src/ForceFreeStates/Surfaces/ResistEval.jl | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/ForceFreeStates/Surfaces/Resist.jl b/src/ForceFreeStates/Surfaces/Resist.jl index 24a56fc7b..fd4a4b46a 100644 --- a/src/ForceFreeStates/Surfaces/Resist.jl +++ b/src/ForceFreeStates/Surfaces/Resist.jl @@ -94,9 +94,7 @@ function resist_eval(sing::SingType, equil::Equilibrium.PlasmaEquilibrium, ff[itheta, 6] = dpsisq / bsq @views ff[itheta, :] .*= jac / v1 end - # Snap the repeated endpoint exactly equal to the start (see Equilibrium.jl's - # GS-residual integrator and issue #240 -- independent spline evaluations at - # theta=0/1 can differ by machine epsilon and trip PeriodicBC's check) + # Snap the repeated endpoint exactly equal to the start @views ff[end, :] .= ff[1, :] itp = cubic_interp(equil.rzphi_ys, Series(ff); bc=PeriodicBC()) avg = FastInterpolations.integrate(itp) diff --git a/src/ForceFreeStates/Surfaces/ResistEval.jl b/src/ForceFreeStates/Surfaces/ResistEval.jl index acadf1979..09bd6dd80 100644 --- a/src/ForceFreeStates/Surfaces/ResistEval.jl +++ b/src/ForceFreeStates/Surfaces/ResistEval.jl @@ -165,9 +165,7 @@ function resist_geometry(equil::Equilibrium.PlasmaEquilibrium, ff[itheta, 7] = B_here @views ff[itheta, :] .*= jac / v1 end - # Snap the repeated endpoint exactly equal to the start (see Equilibrium.jl's - # GS-residual integrator and issue #240 -- independent spline evaluations at - # theta=0/1 can differ by machine epsilon and trip PeriodicBC's check) + # Snap the repeated endpoint exactly equal to the start @views ff[end, :] .= ff[1, :] # Integrate each column around θ using the same periodic cubic-spline