Skip to content

Carry B_s to the wout file on the full radial mesh - #25

Open
CharlesCNorton wants to merge 2 commits into
jonathanschilling:masterfrom
CharlesCNorton:fix/bsubs-full-mesh
Open

Carry B_s to the wout file on the full radial mesh#25
CharlesCNorton wants to merge 2 commits into
jonathanschilling:masterfrom
CharlesCNorton:fix/bsubs-full-mesh

Conversation

@CharlesCNorton

@CharlesCNorton CharlesCNorton commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Fixes #22.

jxbforce builds B_s on the full radial mesh in a local array and drops it at RETURN, so wrout receives the half-grid array that bss produced, applies a full-mesh endpoint rule to it and writes it as !Full mesh. bsubsh becomes INTENT(inout) and carries the full-mesh values back, which is what PARVMEC jxbforce.f:33 does. The note at wrout.f90:603 that recorded the mismatch goes with it.

Compute_Currents then has to read bsubsmn on the full mesh rather than averaging two half-grid surfaces into t1. ORNL-Fusion/LIBSTELL read_wout_mod.f90, the copy PARVMEC links against, makes the same four substitutions.

Checked against the PARVMEC wout files for input.solovev, input.cma and input.cth_like_fixed_bdy, as the largest difference over the array relative to its maximum:

bsubsmns currumnc currvmnc
solovev 8.0e-3 -> 9.4e-6 1.5e-10 -> 1.5e-10 4.2e-4 -> 2.5e-11
cma 2.5e-1 -> 5.1e-3 1.0e+0 -> 1.5e-2 9.8e-1 -> 2.6e-2
cth_like_fixed_bdy 2.5e-1 -> 2.2e-4 8.9e-1 -> 2.1e-6 5.1e-1 -> 2.5e-6

The boundary value is the second commit. PARVMEC reads bsubs(ns,:) on the right-hand side of its own edge rule, which is the half-grid value still sitting in the array it shares with the caller; here that value is bsubsh(ns,:), so the outermost half point can be used directly instead of extrapolating from two full-mesh points. The largest disagreement with PARVMEC on the boundary surface goes from 9.4e-6 to 7.2e-13 for solovev and from 1.5e-3 to 7.0e-7 for cth_like_fixed_bdy, level with every interior surface. Compute_Currents runs from 2 to ns-1 and extrapolates the ends, so it never reads that row and the currents are unchanged. The cma residuals are larger because that pair of runs converged to slightly different states: niter differs by 7 percent and bmnc by 3e-4 independently of this change.

lbsubs = T now reaches the wout, since the correction is applied to the array the caller keeps.

VMEC++ writes the half-grid values under the name bsubsmns, to match this code, and publishes the full-grid transform separately as bsubsmns_full; the note at output_quantities.cc:5159 records the mismatch with the wout file's own declaration and leaves it open. After this change educational_VMEC and PARVMEC agree on that variable.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The full-mesh B_s built in jxbforce is discarded, so the wout carries the half-grid one

1 participant