Auto psi-grid: the accuracy-driven density is grid-dependent — pursue a self-consistent / one-pass construction
Summary
The two-pass auto grid (grid_type = "auto", src/Equilibrium/GridRefinement.jl) sizes knot
density from an accuracy requirement: place knots so the cubic-spline derivative error of the
profile/geometry channels meets psi_accuracy. The premise is that this density is a property of
the equilibrium. It is not — the measured curvature that drives the density grows with the
grid it is measured on, so the grid the generator produces depends on the pass-1 grid rather than
converging to a unique accuracy-defined grid.
This does not affect the ideal Δ′ convergence (fixed separately by rational-surface bracketing —
see the accompanying PR), but it undermines the auto grid's stated guarantee and couples pass-1
resolution to pass-2 grid size (hence ODE cost).
Evidence
Forming the equilibrium on uniform grids of increasing resolution and evaluating
implied_knot_count (the density integral ∫ρ) at a fixed tau on each (DIII-D-like example):
| mpsi |
implied(τ=1e‑3) |
implied(τ=1e‑4) |
| 128 |
418 |
900 |
| 256 |
436 |
939 |
| 512 |
709 |
1508 |
| 1024 |
1551 |
3310 |
| 2048 |
2643 |
5649 |
A grid-invariant density would saturate; instead ∫ρ grows ~monotonically with the measurement
grid. The same effect makes implied/used ≈ 2 (and climbing) in two-pass runs — long read as
"underpacking," it is actually this non-convergence of the measurement.
Root cause
Near the separatrix the flux geometry is genuinely near-singular (q → ∞ ~ −A·ln(1−ψ_N); the r²,
jacobian and ν channels compress at the X-point). Each finer equilibrium solve resolves sharper
edge curvature, so the divided-difference |f''''| estimate diverges as resolution increases. Two
regularizations were tried and both fail (documented so they are not re-attempted):
- Fixed-ψ-width stencil for
_fourth_derivative_nodes (anchor the 4th-difference to a fixed
width instead of the 5 adjacent nodes): ∫ρ still grew 418→2643. The dominant edge growth is the
2D geometry channels, whose singularity a wider window cannot bound.
- ι = 1/q spline (regular, → 0 at ψ_N = 1, anchored at (1,0), recover q'''' analytically):
∫ρ still grew (464→3713). ι → 0 but ι′ itself diverges (~1/[(1−ψ)ln²(1−ψ)]), so the
singularity order only drops; and q is not the dominant channel anyway.
The only grid-invariant treatment of a real singularity is an a-priori model, not measurement.
Proposed directions (any one is a big enough change to warrant its own PR)
- A-priori edge-region density. Near ψ_N → 1 (past the pedestal), replace measured curvature
with the analytic edge model 1/(dlog·(1−ψ)) (already present but only used as a max floor),
as the core region already does. Needs a principled pedestal↔edge threshold so real pedestal
(kinetic) curvature is still measured.
- Self-consistent / fixed-point construction. Iterate refine→re-measure until the density
integral stabilizes (implied ≈ used), with a convergence criterion instead of a hard-coded
PASS1_INTERVALS. Removes the pass-1 dependence — but only converges once (1) bounds the edge.
- One-pass / curvature-from-input. Estimate the target ψ_N grid from input-data curvature
(q, p, F, geometry from the geqdsk/first solve) or via an r-adaptive equidistribution monitor
during the solve, so the equilibrium is formed once on the accuracy-defined grid.
Impact / severity
- Bounded, not catastrophic:
N_cap and MIN_KNOT_SPACING cap the grid; ideal Δ′ converges via
the rational-surface bracket regardless. But the grid is not unique (depends on pass-1), and
pass-1 ↔ pass-2 cost are coupled (a "conservative" large pass-1 inflates the pass-2 ODE).
- Quantities sensitive to edge/pedestal knot placement (kinetic/NTV, resonant-flux, island) may
carry a residual grid-dependence worth quantifying.
Not in scope here
The ideal Δ′ non-convergence bug (rational knot on the matching stencil) is fixed independently by
bracket_mandatory_nodes in the accompanying PR and does not depend on this redesign.
Auto psi-grid: the accuracy-driven density is grid-dependent — pursue a self-consistent / one-pass construction
Summary
The two-pass auto grid (
grid_type = "auto",src/Equilibrium/GridRefinement.jl) sizes knotdensity from an accuracy requirement: place knots so the cubic-spline derivative error of the
profile/geometry channels meets
psi_accuracy. The premise is that this density is a property ofthe equilibrium. It is not — the measured curvature that drives the density grows with the
grid it is measured on, so the grid the generator produces depends on the pass-1 grid rather than
converging to a unique accuracy-defined grid.
This does not affect the ideal Δ′ convergence (fixed separately by rational-surface bracketing —
see the accompanying PR), but it undermines the auto grid's stated guarantee and couples pass-1
resolution to pass-2 grid size (hence ODE cost).
Evidence
Forming the equilibrium on uniform grids of increasing resolution and evaluating
implied_knot_count(the density integral ∫ρ) at a fixedtauon each (DIII-D-like example):A grid-invariant density would saturate; instead ∫ρ grows ~monotonically with the measurement
grid. The same effect makes
implied/used ≈ 2(and climbing) in two-pass runs — long read as"underpacking," it is actually this non-convergence of the measurement.
Root cause
Near the separatrix the flux geometry is genuinely near-singular (q → ∞ ~ −A·ln(1−ψ_N); the r²,
jacobian and ν channels compress at the X-point). Each finer equilibrium solve resolves sharper
edge curvature, so the divided-difference
|f''''|estimate diverges as resolution increases. Tworegularizations were tried and both fail (documented so they are not re-attempted):
_fourth_derivative_nodes(anchor the 4th-difference to a fixedwidth instead of the 5 adjacent nodes): ∫ρ still grew 418→2643. The dominant edge growth is the
2D geometry channels, whose singularity a wider window cannot bound.
∫ρ still grew (464→3713). ι → 0 but ι′ itself diverges (~1/[(1−ψ)ln²(1−ψ)]), so the
singularity order only drops; and q is not the dominant channel anyway.
The only grid-invariant treatment of a real singularity is an a-priori model, not measurement.
Proposed directions (any one is a big enough change to warrant its own PR)
with the analytic edge model
1/(dlog·(1−ψ))(already present but only used as amaxfloor),as the core region already does. Needs a principled pedestal↔edge threshold so real pedestal
(kinetic) curvature is still measured.
integral stabilizes (
implied ≈ used), with a convergence criterion instead of a hard-codedPASS1_INTERVALS. Removes the pass-1 dependence — but only converges once (1) bounds the edge.(q, p, F, geometry from the geqdsk/first solve) or via an r-adaptive equidistribution monitor
during the solve, so the equilibrium is formed once on the accuracy-defined grid.
Impact / severity
N_capandMIN_KNOT_SPACINGcap the grid; ideal Δ′ converges viathe rational-surface bracket regardless. But the grid is not unique (depends on pass-1), and
pass-1 ↔ pass-2 cost are coupled (a "conservative" large pass-1 inflates the pass-2 ODE).
carry a residual grid-dependence worth quantifying.
Not in scope here
The ideal Δ′ non-convergence bug (rational knot on the matching stencil) is fixed independently by
bracket_mandatory_nodesin the accompanying PR and does not depend on this redesign.