Repository navigation
Surface quadrature: duplicate-free SquaredFlux and midpoint half-period grid - #127
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests.
|
…riod convergence test
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.
SquaredFlux(all three definitions) averaged withjnp.meanover the raw grid, so withclose=Truethe duplicated theta = 2 pi column (and phi end row) were counted twice: ~10% error on the test surface. It now uses_surface_mean.range_torus='half period', close=Falsesampled phi in [0, pi/nfp) at the left endpoints: first-order quadrature for area/volume/flux/cross-section. The grid is now shifted by half a step (the simsopt convention), a midpoint rule that is spectrally accurate for stellarator-symmetric integrands._surface_meanis a module function; surfaces withoutclose/range_torus(VMEX'sHighOrderSurfaceSamples, an open one-period grid) get the plain mean. VMEX'stest_high_order_surface_composes_with_essos_objectivepasses against this branch.Measured on a shaped nfp=3 surface (ntheta=64) with a toroidal + poloidal field, relative error vs a 256-point reference for nphi = 2, 4, 8, 16, 32 on the half-period grid:
SIMSOPT 1.11.1 gives the same numbers as this PR (same midpoint rule), so this brings ESSOS in line rather than ahead.
Tests: the
('half period', False)case in the grid-independence test,test_squared_flux_does_not_count_duplicated_end_points, andtest_half_period_integrals_converge_spectrally(analytic volume 2 pi^2 R0 a b of a shifted-ellipse torus at nphi = 3, 5, 9; main fails it).Note: points of a half-period open grid no longer include phi = 0.