Skip to content

Data on half a field period with stellarator symmetry; GetTargetCoord - #10

Merged
dmalhotra merged 6 commits into
masterfrom
vacuum-field-half-period-v2
Nov 10, 2026
Merged

dmalhotra merged 6 commits into
masterfrom
vacuum-field-half-period-v2

Conversation

@dmalhotra

Copy link
Copy Markdown
Owner

Data given on half a field period, with the other half built by stellarator symmetry, in FieldPeriodBIOp::Eval and VacuumFieldBase; and GetTargetCoord, the points of the field grid of ExtVacuumField and IntVacuumField. In VacuumFieldBase, half_period is a constant that is still false, and the results are bitwise those of master.

Changes

  • biest::Parity (surface.hpp): the parity of data under stellarator symmetry, Even for surface coordinates, Odd for a stellarator symmetric magnetic field B and for B.n, sigma and J (7186bcc).
  • SurfaceOp::CompleteVecField takes the parity and the toroidal orientation in place of is_surf (7186bcc).
  • WriteVTK with half_period takes 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::Eval takes half_period and the parity of the density. With half_period, it completes a density given on half a field period to the full torus by stellarator symmetry, in scratch memory (bd09a6a).
  • VacuumFieldBase (b988adb):
    • One half_period constant in place of a local flag in each routine; it is still false.
    • With half_period, the field grid on the full torus has NFP*2*Nt toroidal points.
    • ComputeU checks the size of sigma.
  • ExtVacuumField::GetTargetCoord and IntVacuumField::GetTargetCoord return the coordinates of the points of the field grid of one field period, on which B is given and computed (402c20d).
  • Comments on the direction of 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). parity and tor_orient have no defaults, and tor_orient must 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.
  • virtual-casing calls CompleteVecField and WriteVTK, and needs the new arguments.

Results

On an AMD EPYC 9474F node, GCC 13.3, 48 threads:

  • half_period = true in VacuumFieldBase, on a five-period surface, on grids whose index increases counterclockwise and clockwise:

    field on the surface off the surface
    exterior: a current loop inside the torus 6.5 digits 11.8 digits
    interior: a loop outside the torus and a wire on the z-axis 6.1 digits 10.8 digits

    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::Eval of 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 with half_period = true.

Tests

  • Each commit builds without warnings and passes the four BIEST tests. The output is identical to master's except for the new checks: the 8 half-period checks of boundary-integ-op from bd09a6a, and the 4 GetTargetCoord checks of vacuum-field in 402c20d.
  • With half_period = false, each commit's results are bitwise those of master for:
    • the exterior and interior fields above (18 output files of a test program not in this PR);
    • IntVacuumField for NFP = 1 and 5, with and without a current I0;
    • doc/examples/field-period.
  • With half_period = true, b988adb and 402c20d give bitwise the same results.
  • These calls do not compile: master's CompleteVecField arguments, an integer parity, parity and tor_orient swapped, and WriteVTK without the parity.

🤖 Generated with Claude Code

dmalhotra and others added 6 commits November 10, 2026 15:22
…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>
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 BIEST | 🛠️ Build #35795910 | 📁 Comparing 402c20d against latest (fff1d47)

  🔍 Preview build  

7 files changed · ± 7 modified

± Modified

@dmalhotra
dmalhotra merged commit 95dafcf into master Nov 10, 2026
7 checks passed
@dmalhotra
dmalhotra deleted the vacuum-field-half-period-v2 branch November 10, 2026 20:42
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