Skip to content

Equilibrium - BUGFIX - Add a knot-density floor to the auto grid and set the rational bracket by resolution #525

Closed

Description

@jhalpern30

Problem

Two defects in the two-pass auto ψ grid (refined_psi_grid, src/Equilibrium/GridRefinement.jl) make Δ′ wrong or setting-dependent.

(a) No knot-density floor. Knots are placed only where measured curvature is high, so smooth equilibria get too few knots away from the rationals. Δ′ needs the coefficients resolved well beyond what the energies need.

  • Solovev α 1.09 on the default auto grid: Δ′ = +48 against a converged −90.
  • With a floor of 200 knots per unit ψ_N (rho .= max.(rho, 200)): −90.3 ± 0.3% from 257 to 1012 knots, and et₁ returns to the converged 14.3009.
  • In a calibration over Solovev α 0.9–2.3, the auto grid without the floor gives a bad Δ′ (>10% error) at every α ≥ 1.05.
  • A wider rational patch (RATIONAL_RES_RADIUS) or a tighter psi_accuracy does not fix it.

(b) Bracket width tied to singfac_min. The knot-free bracket around each rational has half-width BRACKET_COEF · singfac_min / (n_min·|q′|) (BRACKET_COEF = 4), so the radial grid changes when the crossing/matching setting singfac_min changes.

  • With singfac_min ≥ 1e-3 the 4× bracket is wide enough to under-resolve the coefficients next to the rational, and Solovev Δ′ goes wrong.
  • With a fixed bracket, Δ′ is flat in singfac_min from 1e-4 to 3e-3 to ≤1e-5.
  • But too narrow a cell is also bad at high α: grid-point noise is amplified by w^(−2α). Solovev α 1.37: −702 at half-width 2.5e-4, −930 at 2e-3, −932 at 4e-3.

Proposed fix

Both are a few lines in refined_psi_grid.

What to do first: choose the numbers

The floor and W₀ above were measured on inputs that later turned out to be contaminated (DIII-D profiles before #506; field lines before #398). Re-choose both by scan on the corrected base:

Acceptance

  • Auto grid matches a fine fixed grid for Δ′ on the cases above to ≤1%.
  • Δ′ unchanged (≤1e-5) when singfac_min varies over 1e-4–1e-3.
  • Report knot count and runtime change on the harness cases. Auto-grid results move, so the PR takes ! and re-pins the harness.

Dependencies

Activity

  1. self-assigned this
    on Oct 23, 2026
  2. logan-nc commented on Oct 23, 2026

    @logan-nc
    Collaborator

    Closing. I tested the proposed fixes on current develop (with #398) and neither makes a difference that the data can support.

    (a) Knot-density floor. The auto grid already had a floor of 5 knots per unit ψ_N. Raising it to 64 or 200, with Riccati Δ′ in hamada coordinates:

    case knots (5 / 64 / 200) Δ′
    DIII-D-like n=1 279 / 283 / — q=2–5 move ≤ 0.5%, inside the scatter between fixed core_edge_packed grids at 1024 and 2048 intervals
    Solovev q0 = 1.2 (α = 0.886) 175 / 193 / 319 +217 / +422 / +394

    On Solovev, the fixed-grid "references" don't converge either: −66 at 512 intervals, −100 at 1024, +789 at 2048 (flux_surface_rtol = 1e-7). What shows up there is field-line tracing noise amplified at the surface, which is #524, not knot density. The original floor evidence was measured on inputs later found to be contaminated (before #506 and #398), and I could not reproduce a case where a floor helps. (p0fac adds a constant to the pressure, so it does not change α; I did not reach the α ≥ 1.05 cases.)

    (b) Bracket tied to singfac_min. In practice it isn't. The bracket half-width is the largest of 4·singfac_min/(n|q′|), MIN_KNOT_SPACING, and half the local spacing. Within ±5e-3 of every rational, the near-rational patch holds the local spacing at 5e-4, so the half-width settles near 2.5e-4. That is the resolution-set W₀ proposed here.

    • DIII-D: the grid at singfac_min = 1e-6 is identical to the one at 1e-4.
    • Solovev (|q′| = 1.42): the half-width moves from 2.5e-4 to 2.8e-4.
    • At 1e-3: the bracket widens because the matching stencil really is that wide, which is the intended behaviour.

    Widening W₀ to 1–2e-3 would put each surface in a cell 4–8× wider than its neighbours. It would also run into the overlap check in #492 on dense edge rationals. The structural decoupling belongs to #481.

    Follow-up for Solovev Δ′ convergence is #524.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions