Skip to content

bsubsmns holds half-grid B_s under the full-mesh label #7

Description

@CharlesCNorton

fileout.f90:79 passes crmn_o to wrout as bsubs. eqfor.f90:102 passes the same array to jxbforce as bsubsh, INTENT(in), and jxbforce builds its full-grid bsubs as a local (jxbforce.f90:46, 168-173). So the array wrout transforms is the half-grid B_s from bss, and it is written with the full-mesh label:

! wrout.f90:605-609
  ! NOTE: This assumes that bsubs (from which bsubsmns is computed) is on the full grid.
  ! However, since crmn_o is passed as bsubs in fileout(),
  ! HERE, bsubs is ACTUALLY on the HALF-grid !!! WTF ???
  ! (The full-grid bsubs array is a LOCAL variable in jxbforce().)
  bsubsmns(:,1) = 2*bsubsmns(:,2) - bsubsmns(:,3) ! extrapolation on full grid
! wrout.f90:700
  CALL cdf_write(nwout, vn_bsubsmns, bsubsmns)      !Full mesh

The netCDF attribute reads sinmn covariant s-component of B, full mesh.

Measured on input.cth_like_fixed_bdy against PARVMEC (Stellarator-Tools, serial, version_ = 10.0), which converts the jxbforce dummy in place and writes the result:

comparison, modes within (mpol, ntor), js = 2..ns-1 max abs / max abs PARVMEC
bsubsmns(js) vs PARVMEC bsubsmns(js) 2.0e-1
0.5*(bsubsmns(js) + bsubsmns(js+1)) vs PARVMEC bsubsmns(js) 2.7e-6

The rest of the wout agrees with PARVMEC to 1e-8 on that case.

The 2017 STELLOPT copy of VMEC2000 8.52 in this repository's history already has the local-copy structure (VMEC2000/Sources/Input_Output/jxbforce.f, bsubsh INTENT(in) and a local bsubs), so the data has been half-grid under this label since 8.52. LIBSTELL's Compute_Currents of that generation averages adjacent surfaces of bsubsmns (the copy at read_wout_mod.f:730 documents the half grid), and the current LIBSTELL drops the average with the note that jxbforce placed bsubs on the full grid. Either the label and the axis extrapolation at wrout.f90:609 should say half mesh, or the array should be converted the way PARVMEC does before wrout.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions