Repository navigation
Restore axisymmetric (Nz=1) virtual-casing mirroring lost in #1 - #3
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fork PR #1 (d390088) replaced the stellarator-symmetry completion in
bnormlbymirror_normal_field. For axisymmetric grids (Nz=1),bnormlevaluates only theta indices 0..(Nt+1)/2 and the oldif (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.f90hunk of #1 passes G3V08L3Fr. Building it plus only thebnorml.f90hunk 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
bnormldoes 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
bnormlhunk and needs the same fix.Chris&AI