Add a geometry tolerance that holds a run until the flux surfaces stop moving - #843
Open
CharlesCNorton wants to merge 2 commits into
Open
Add a geometry tolerance that holds a run until the flux surfaces stop moving#843CharlesCNorton wants to merge 2 commits into
CharlesCNorton wants to merge 2 commits into
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
…ng on the first one
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.
Change -
VmecInputgainsgeometry_tolerance, a distance in metres, default 0 which leaves everything as it is. When positive, a multigrid step converges only once the force residuals meetftol_arrayAND the flux surfaces have stopped moving:fc_.geometry_change, the Euclidean norm of the change in the R and Z spectral coefficients over the lastnstepiterations.Vmec::AccumulateGeometryChangefolds each thread's contribution over the surfaces it owns, so the measure does not depend on the thread count, and it resets at every multigrid stage because the radial grid changes between stages.Cause - the convergence test reads the force residual, which is small in exactly the directions the equilibrium is still moving along, so a run that meets its tolerance can stop with the quantities it is used for still in motion. On
examples/data/w7x.jsonat ns = 99, a run stopped at ftol 1e-8 leaves the magnetic axis 14.7 mm from where it settles and the mid-radius rotational transform off by 3.1e-3.Evidence -
examples/data/w7x.jsonat ns = 99, single grid, deviation measured against the same case run to ftol 1e-16, which takes 5884 iterations:and
cth_like_fixed_bdyat ns = 51, against its own ftol 1e-16 run at 1963 iterations:Ten microns of surface motion is a stricter statement about the equilibrium than ftol 1e-12 is: on W7-X it reaches iota to 3.0e-7 where ftol 1e-12 alone reaches 4.5e-5.
Tests -
tests/test_geometry_tolerance.py: that the default leaves the iteration count and the wout bit-identical, that a run held to 1e-5 lands on the axis and iota of the fully converged case where the residual alone does not, that a tighter tolerance lands closer, that a negative value is rejected, and that the field survives a JSON round trip.bazel test --config=opt //vmecpp/...is 24 of 24 andpytest tests/is 234 passed, 4 skipped. Pre-commit clean.Scope - unset, the convergence test is the one that was there and every existing test reproduces its iteration count. The measure is computed at the printout interval only, from a copy of the R and Z coefficients, so it costs one comparison per
nstepiterations. The criterion can only extend a run, never shorten one. The HDF5 read is guarded on the dataset being present, so inputs written before this still load.