Skip to content

Restore axisymmetric (Nz=1) virtual-casing mirroring lost in #1 - #3

Merged
krystophny merged 1 commit into
masterfrom
lhd/g3v08-regression-20261025
Oct 26, 2026
Merged

krystophny merged 1 commit into
masterfrom
lhd/g3v08-regression-20261025

Conversation

@krystophny

Copy link
Copy Markdown
Member

Fork PR #1 (d390088) replaced the stellarator-symmetry completion in bnorml by mirror_normal_field. For axisymmetric grids (Nz=1), bnorml evaluates only theta indices 0..(Nt+1)/2 and the old if (Nz.eq.1) branch filled the rest of the row. The new routine has no such branch (its toroidal loop is empty for Nz=1), so the upper half of the row kept stale values. That is why the free-boundary references G3V08L3Fr and G3V08L3FrGrid (Ntor=0) fail on master, while upstream passes.

Trace (-std=legacy, gfortran 16.2.1): building upstream b23a240 plus only the casing.f90 hunk of #1 passes G3V08L3Fr. Building it plus only the bnorml.f90 hunk fails exactly like master, with BR 2.98e-3, Rij 0.40 and Bns 2.2e-2 average differences.

Oracle independent of the references: a build that evaluates every grid point directly (Nzwithsym=Nz, no Nz=1 skip, no mirroring) reproduces both existing references within 1e-10. The references therefore describe the correct solution and are left unchanged. Master converges self-consistently (8 free-boundary iterations, bnserr 3.0e-7) to a different equilibrium, because the stale half-row enters every iteration, so its own residuals cannot detect the error.

The change restores the Nz=1 completion with periodic indices. Unlike the original upstream loop, it does not negate the already computed theta=pi sample. The symmetry unit test now poisons exactly the samples that bnorml does not evaluate, and it fails on master and passes with this change.

Verified locally: both CTests pass, and all 8 CI reference cases of build.yml pass at their tolerances with -std=legacy. The upstream draft PrincetonUniversity#234 carries the same bnorml hunk and needs the same fix.

Chris&AI

…ield

For Nz=1, bnorml evaluates only theta indices 0..(Nt+1)/2 and relies on the
stellarator-symmetry mirror to fill the rest of the row. Fork PR #1
(d390088) replaced the mirror by mirror_normal_field, whose toroidal loop
is empty for Nz=1, so the upper half of the row kept stale values. This
changed the free-boundary regression cases G3V08L3Fr and G3V08L3FrGrid
(Ntor=0), e.g. Rij average difference 0.40 at tol 1e-10.

mirror_normal_field now fills theta index jj > (Nt+1)/2 with -field(Nt-jj)
for Nz=1. Unlike the upstream branch, it does not negate the computed
theta=pi sample. The symmetry unit test now poisons exactly the samples
bnorml does not evaluate, which fails without this change.

Oracle independent of the references: a build that evaluates every grid
point by brute force (Nzwithsym=Nz, no Nz=1 skip, no mirroring) reproduces
the existing G3V08L3Fr and G3V08L3FrGrid references within 1e-10, as does
this fix, so the references stay unchanged. All 8 CI reference cases pass
with -std=legacy.
@krystophny
krystophny marked this pull request as ready for review October 26, 2026 11:55
@krystophny
krystophny merged commit 6c1823f into master Oct 26, 2026
8 of 10 checks passed
@krystophny
krystophny deleted the lhd/g3v08-regression-20261025 branch November 6, 2026 20:33
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.

1 participant