Repository navigation
Data on half a field period with stellarator symmetry; GetTargetCoord - #10
Merged
Merged
Conversation
…current Xt_ and Xp_ are -dX/dt and -dX/dp, as SurfaceOp::Grad2D() returns them, and J0_ flows in the direction of Xt_, that is of decreasing toroidal index, as vacuum-field.hpp says. The comment on J0_ said only "in the direction of Xt_". On the five-period surface of test/vacuum-field, with Jplasma = 1, the current J returned by ExtVacuumField::ComputeBplasma() has sum J.dX/dt / sum |J||dX/dt| = -0.99, and Bplasma = -Bcoil for a loop carrying the current 1 in the direction of increasing toroidal index, on grids whose index increases counterclockwise and clockwise. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…in place of is_surf - Parity (surface.hpp): Even for surface coordinates, Odd for a stellarator symmetric magnetic field B and for data that changes sign under stellarator symmetry, such as B.n and sigma. - CompleteVecField(X, half_period, NFP, Nt, Np, Y, parity, tor_orient, dtheta = 0): with half_period, the other half of the field period is built from Y with the given parity. is_surf, which made data of 3 components Even (surface coordinates) or Odd (a vector field) and other data always Even, is removed. - parity and tor_orient have no defaults, and tor_orient must be +1 or -1: tor_orient = 0 detected the orientation from Y only for surface coordinates, and was +1 otherwise. - VacuumFieldBase keeps tor_orient_, the orientation of the surface, from Setup_ in place of computing it at each EvalOffSurface, and completes B.n, sigma and J with Parity::Odd. - WriteVTK completes an F of 3 components with Parity::Odd and other F with Parity::Even, as before. - The documentation lists Parity. The results are bitwise those of fff1d47, on a Genoa node with GCC 13.3: the tests surface-op, boundary-integ-op, bie-solvers and vacuum-field; the exterior and interior fields of a current loop and a wire on a five-period surface, on grids whose index increases counterclockwise and clockwise; IntVacuumField for NFP = 1 and 5, with and without a current I0; and doc/examples/field-period. A call with parity and tor_orient swapped, with an integer parity, or with the arguments of fff1d47 does not compile. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
WriteVTK took the parity of F from its number of components, Odd for 3 and Even otherwise, so a scalar that changes sign under stellarator symmetry, such as B.n or sigma, was written with the wrong sign on the mirrored half. It now takes the parity, with no default. For a scalar f that changes sign, given on half a field period (NFP = 3) of a stellarator symmetric surface, the values written on the mirrored half reach 14.7 to 15.3 digits against the exact f, in place of -0.3 digits; a vector field B reaches 15.2 to 15.4 digits, as before; on grids whose index increases counterclockwise and clockwise. The other results are bitwise those of the previous commit, and a call without the parity does not compile. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Eval(), for one surface and for several, takes half_period and the parity of the density (defaults false and Parity::Even). With half_period, the density is given on half a field period; Eval() completes it to the full torus by stellarator symmetry (SurfaceOp::CompleteVecField) and resamples it to the quadrature grid, in scratch memory. test/boundary-integ-op checks that Eval() of a density on half a field period equals Eval() of the same density on one field period, for an even and an odd scalar density with the Laplace double-layer kernel and an even and an odd vector density with the Biot-Savart kernel, on grids whose index increases counterclockwise and clockwise. The 8 checks reach 14.9 to 15.3 digits (tolerance 12 digits); with the parities swapped all 8 fail. The other results are bitwise those of the previous commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- half_period is one constant of VacuumFieldBase in place of a local flag in each of Setup_, ComputeB_, ComputeU_ and EvalOffSurface; it is still false. - torus_Nt_, the toroidal dimension of the field grid on the full torus, is NFP*2*Nt with half_period: the surface resampled to the field grid (XX), its derivatives and normals, J0_ and the densities of EvalOffSurface have this many toroidal points, in place of NFP*Nt, and the SetupSingular() of ComputeB_ and ComputeU_ take torus_Nt_ / Nt_ target grids. - ComputeB_ and ComputeU_ pass half_period and Parity::Odd to FieldPeriodBIOp::Eval() with the densities B.n and sigma. - ComputeU() checks the size of sigma at its start. With a sigma of other than Nt*Np values it aborted in SurfaceOp::CompleteVecField, or, for 3*Nt*Np values, with "Cannot ReInit a fixed-size Vector". With half_period = false the results are bitwise those of the previous commit. With half_period = true, on half a field period of the five-period surface, the exterior and interior fields of a current loop and a wire reach 6.5 and 6.1 digits on the surface and 11.8 and 10.8 digits off it, as with the full period, and sigma, U, B and J agree with those of the full period to 12.3 digits or more; on grids whose index increases counterclockwise and clockwise. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ld grid - GetTargetCoord() returns the coordinates (SoA order) of the Nt x Np field grid of one field period, on which ComputeBdotN() takes B and ComputeBplasma() or ComputeB() returns the field: the surface given to Setup() interpolated to that grid. It is implemented in VacuumFieldBase, like ComputeBdotN(). - test/vacuum-field checks it against the points of the field grid of the test; it reaches 15.2 digits, and 14.9 digits on half a field period with half_period = true. - The documentation and the tutorial list it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Data given on half a field period, with the other half built by stellarator symmetry, in
FieldPeriodBIOp::EvalandVacuumFieldBase; andGetTargetCoord, the points of the field grid ofExtVacuumFieldandIntVacuumField. InVacuumFieldBase,half_periodis a constant that is stillfalse, and the results are bitwise those of master.Changes
biest::Parity(surface.hpp): the parity of data under stellarator symmetry,Evenfor surface coordinates,Oddfor a stellarator symmetric magnetic field B and for B.n, sigma and J (7186bcc).SurfaceOp::CompleteVecFieldtakes the parity and the toroidal orientation in place ofis_surf(7186bcc).WriteVTKwithhalf_periodtakes the parity of F. It took the parity from the number of components, so a scalar that changes sign, such as B.n, was written with the wrong sign on the mirrored half (42d9650).FieldPeriodBIOp::Evaltakeshalf_periodand the parity of the density. Withhalf_period, it completes a density given on half a field period to the full torus by stellarator symmetry, in scratch memory (bd09a6a).VacuumFieldBase(b988adb):half_periodconstant in place of a local flag in each routine; it is stillfalse.half_period, the field grid on the full torus hasNFP*2*Nttoroidal points.ComputeUchecks the size of sigma.ExtVacuumField::GetTargetCoordandIntVacuumField::GetTargetCoordreturn the coordinates of the points of the field grid of one field period, on which B is given and computed (402c20d).Xt_and of the surface current (65b6dc3).Interface changes
SurfaceOp::CompleteVecField(X, half_period, NFP, Nt, Np, Y, parity, tor_orient, dtheta = 0)in place of(X, is_surf, half_period, NFP, Nt, Np, Y, dtheta = 0, tor_orient = 0).parityandtor_orienthave no defaults, andtor_orientmust be +1 or -1.WriteVTK(fname, NFP, half_period, surf_Nt, surf_Np, X, src_Nt, src_Np, F, parity): the parity has no default.FieldPeriodBIOp::Eval(U, F, NFP, src_Nt, src_Np, half_period = false, parity = Parity::Even), for one surface and for several.CompleteVecFieldandWriteVTK, and needs the new arguments.Results
On an AMD EPYC 9474F node, GCC 13.3, 48 threads:
half_period = trueinVacuumFieldBase, on a five-period surface, on grids whose index increases counterclockwise and clockwise:These are the digits of the same fields with the data on a whole field period. sigma, U, B and J agree with those of the whole field period to 12.3 digits or more.
FieldPeriodBIOp::Evalof a density on half a field period against the same density on one field period: 14.9 to 15.3 digits, for an even and an odd scalar density (Laplace double layer) and an even and an odd vector density (Biot-Savart). With the parities swapped, all 8 checks fail.WriteVTK: a scalar that changes sign is written on the mirrored half at 14.7 to 15.3 digits, in place of -0.3 digits.GetTargetCoord: 15.2 digits, and 14.9 digits withhalf_period = true.Tests
boundary-integ-opfrom bd09a6a, and the 4GetTargetCoordchecks ofvacuum-fieldin 402c20d.half_period = false, each commit's results are bitwise those of master for:IntVacuumFieldfor NFP = 1 and 5, with and without a current I0;doc/examples/field-period.half_period = true, b988adb and 402c20d give bitwise the same results.CompleteVecFieldarguments, an integer parity,parityandtor_orientswapped, andWriteVTKwithout the parity.🤖 Generated with Claude Code