Repository navigation
Equilibrium - BUGFIX - Add a knot-density floor to the auto grid and set the rational bracket by resolution #525
Description
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 tighterpsi_accuracydoes 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_minfrom 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
- Floor the knot density
rhoat a fixed value (prototype: 200 per unit ψ_N) before equidistributing. - Bracket half-width = max(W₀, c ·
singfac_min/(n_min·|q′|)).singfac_minstays as the lower bound because the bracket must contain the Δ′ matching points (and, after ForceFreeStates - BUGFIX - Decouple the ideal-crossing jump width from singfac_min #481, the crossing legs). W₀ is likely ~1–2e-3.
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:
- base: develop + Equilibrium - BUGFIX! - Build F and P of g-file and IMAS equilibria from the tabulated FF′ and p′ #506 + Equilibrium - BUGFIX! - Sample all flux surfaces on common straight-fieldline abscissae and cap the coefficient-spline core knots #398 (+ Equilibrium - BUGFIX - Converge PEST Δ′ in the radial grid #524 if it has landed);
- cases: DIII-D-like n = 1 Riccati, q = 2..5 (references with Equilibrium - BUGFIX! - Build F and P of g-file and IMAS equilibria from the tabulated FF′ and p′ #506 profiles: 5.84 / −7.97 / −18.70 / −3830 ± 40), and Solovev α 0.9–1.5;
- scan W₀ ∈ {5e-4, 1e-3, 2e-3, 4e-3} and floor ∈ {100, 200, 400}; pick the smallest values where Δ′ is flat to ≤1e-3 and knot count/runtime is acceptable.
Acceptance
- Auto grid matches a fine fixed grid for Δ′ on the cases above to ≤1%.
- Δ′ unchanged (≤1e-5) when
singfac_minvaries 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
- Choose the numbers after Equilibrium - BUGFIX! - Build F and P of g-file and IMAS equilibria from the tabulated FF′ and p′ #506 and Equilibrium - BUGFIX! - Sample all flux surfaces on common straight-fieldline abscissae and cap the coefficient-spline core knots #398 land.
- Keep the bracket ≥ the matching distance; coordinate with ForceFreeStates - BUGFIX - Decouple the ideal-crossing jump width from singfac_min #481 (crossing legs must sit inside the bracket) and ForceFreeStates - BUGFIX! - ⚠️ Keep both crossings of a rational surface on reverse-shear profiles #492 (reverse-shear double rationals share bracket logic).
Activity