Summary
For toroidal geometry (Igeometry=3), the HDF5 grid/Bp dataset is documented as the physical cylindrical toroidal component B^varphi, but write_grid stores the contravariant coordinate component B^zeta. The cylindrical scale factor R is missing.
Source-level cause
At current master (b23a2408fc3f1dfbc14896e16d73a57f7d1d9e88), src/sphdf5.f90 describes the grid outputs as cylindrical (B^R,B^varphi,B^Z) components. In the Igeometry=3 branch, however, the assignment is:
ijimag(jk) = ( one ) * gBzeta / sg(jk,0) ! Bp
Here gBzeta/sqrt(g) is B^zeta. Since zeta is the physical cylindrical angle in stzxyz, the physical unit-vector component is
The neighboring BR and BZ expressions already apply the coordinate-basis derivatives; only Bp omits its scale factor.
Reproduction
- Build current
master and run the shipped toroidal case:
mkdir -p /tmp/spec-bp-repro
cp InputFiles/TestCases/G3V01L0Fi.001.sp /tmp/spec-bp-repro/
build/build/bin/xspec /tmp/spec-bp-repro/G3V01L0Fi.001.sp
- Inspect the first nonsingular radial grid point at
theta=zeta=0 in the resulting HDF5 file. On current master the native values are:
R = 10.15625
grid/Bp = 0.066064035949282...
R * grid/Bp = 0.670962865109...
An independent reconstruction from the stored A_theta/A_zeta Fourier-Zernike coefficients gives the physical cylindrical component B_phi = 0.670962865109..., while it gives the contravariant component B^zeta = 0.066064035949282....
Across every nonsingular point in the shipped 32 x 32 x 8 grid:
max |grid/Bp - independently reconstructed B_phi| = 6.7139900606e-1
max |R*grid/Bp - independently reconstructed B_phi| = 1.67e-15
max |grid/BR - independently reconstructed B_R| = 1.81e-16
max |grid/BZ - independently reconstructed B_Z| = 1.53e-16
The independent reconstruction uses the native phase m*theta-in*zeta, the A_s=0 curl identities, the signed Jacobian, and the Cartesian map (R cos(zeta), R sin(zeta), Z); it does not call SPEC field helpers.
Expected behavior
For Igeometry=3, grid/Bp should store the physical cylindrical component consistently with its documentation and with grid/BR and grid/BZ:
ijimag(jk) = Rij(jk,0,0) * gBzeta / sg(jk,0) ! Bphi
Actual behavior
grid/Bp stores B^zeta, so consumers treating it as a cylindrical field component understate B_phi by a factor of R.
Suggested regression
For G3V01L0Fi.001.sp, independently reconstruct (B_R,B_phi,B_Z) from the vector-potential coefficients and geometry, then compare all three arrays pointwise. Keep a negative assertion that raw B^zeta differs from B_phi whenever R != 1.
This report concerns only the toroidal HDF5 grid component. It does not claim that the internal contravariant field, field-line equations, or BR/BZ outputs are wrong.
Summary
For toroidal geometry (
Igeometry=3), the HDF5grid/Bpdataset is documented as the physical cylindrical toroidal componentB^varphi, butwrite_gridstores the contravariant coordinate componentB^zeta. The cylindrical scale factorRis missing.Source-level cause
At current
master(b23a2408fc3f1dfbc14896e16d73a57f7d1d9e88),src/sphdf5.f90describes the grid outputs as cylindrical(B^R,B^varphi,B^Z)components. In theIgeometry=3branch, however, the assignment is:Here
gBzeta/sqrt(g)isB^zeta. Sincezetais the physical cylindrical angle instzxyz, the physical unit-vector component isThe neighboring
BRandBZexpressions already apply the coordinate-basis derivatives; onlyBpomits its scale factor.Reproduction
masterand run the shipped toroidal case:theta=zeta=0in the resulting HDF5 file. On current master the native values are:An independent reconstruction from the stored
A_theta/A_zetaFourier-Zernike coefficients gives the physical cylindrical componentB_phi = 0.670962865109..., while it gives the contravariant componentB^zeta = 0.066064035949282....Across every nonsingular point in the shipped 32 x 32 x 8 grid:
The independent reconstruction uses the native phase
m*theta-in*zeta, theA_s=0curl identities, the signed Jacobian, and the Cartesian map(R cos(zeta), R sin(zeta), Z); it does not call SPEC field helpers.Expected behavior
For
Igeometry=3,grid/Bpshould store the physical cylindrical component consistently with its documentation and withgrid/BRandgrid/BZ:Actual behavior
grid/BpstoresB^zeta, so consumers treating it as a cylindrical field component understateB_phiby a factor ofR.Suggested regression
For
G3V01L0Fi.001.sp, independently reconstruct(B_R,B_phi,B_Z)from the vector-potential coefficients and geometry, then compare all three arrays pointwise. Keep a negative assertion that rawB^zetadiffers fromB_phiwheneverR != 1.This report concerns only the toroidal HDF5 grid component. It does not claim that the internal contravariant field, field-line equations, or
BR/BZoutputs are wrong.