Fallout from the gpec.h5 schema overhaul (#226, PR #364). While giving the Equilibrium/ scalars literature names I audited every field of Equilibrium.EquilibriumParameters against its assignment site, and two related problems turned up. Neither is a regression — both predate the schema work — but the rename made them visible, so they are worth fixing deliberately rather than carrying forward.
1. Several flux-bookkeeping fields are hardcoded constants, not computed
src/Equilibrium/Equilibrium.jl:370-381 is the sole assignment site for the whole flux-bookkeeping family, and most of it is literals:
pe.params.psi0 = psio
pe.params.psi_axis = pe.psio
pe.params.psi_boundary = 1.0
pe.params.psi_boundary_norm = 1.0
pe.params.psi_axis_norm = 0.0
pe.params.psi_norm = 0.0
pe.params.psi_axis_offset = 0.0
pe.params.psi_boundary_offset = 0.0
pe.params.psi_axis_sign = 1
pe.params.psi_boundary_sign = -1
pe.params.psi_boundary_zero = false
Everything from psi_boundary down is a constant independent of the equilibrium being loaded. In normalized-flux terms psi_axis_norm = 0 and psi_boundary_norm = 1 are true by definition of psi_N, so those two are honest tautologies — but psi_boundary = 1.0 is written with units Wb/rad in the schema and is not the boundary poloidal flux of any real equilibrium, and the offsets/signs/psi_boundary_zero look like they were meant to record what the ingest actually did (Fortran GPEC derived the equivalent quantities from the g-file simag/sibry pair and the COCOS handling). The likely story is that the Julia port stubbed them and nothing downstream noticed.
Separately, four fields of the struct are never assigned anywhere in src/ — ro, zo, psio, b_norm. The HDF5 writer works around the first three by pulling them off PlasmaEquilibrium directly (equil.ro, equil.zo, equil.psio) and b_norm is silently skipped because it stays nothing.
Ask: compute these from the ingest rather than hardcoding them — real psi_axis/psi_boundary in Wb/rad, real offsets/signs reflecting the COCOS/normalization actually applied, a decision on b_norm (compute it or delete the field), and either populate params.ro/zo/psio or delete them in favour of the PlasmaEquilibrium fields so there is one source of truth.
2. Three variables are the same number for psi on axis
psi0, psi_axis, and psio all end up holding the total poloidal flux difference. psi_axis in particular is misnamed: it is assigned pe.psio, i.e. the total flux, not the flux at the axis. psi_axis_norm is likewise an exact duplicate of psi_norm (both 0.0).
For the schema overhaul I took the conservative route: Equilibrium/psi_total is written once (from equil.psio) and the duplicates psi0, psi_axis, psi_axis_norm are dropped from the HDF5 output via EQUIL_H5_SKIP in src/HDF5Schema.jl. That fixes the file, not the struct.
Ask: collapse the redundancy in EquilibriumParameters itself — either delete the duplicate fields, or, if each was intended to mean something distinct (axis flux vs. total flux vs. normalization constant), define those meanings and make the assignments match the names. Whatever survives should have a docstring entry stating which of the three it is; today a reader of the struct cannot tell them apart.
Notes
- Fixing (1) will move numbers only if a downstream consumer reads the stubbed values; a regression-harness run (
regress --cases diiid_n1,solovev_n1 --refs develop,local) should confirm the blast radius before merging.
- Any change to which fields exist must be mirrored in
EQUIL_H5_NAMES / EQUIL_H5_SKIP (src/HDF5Schema.jl) and the naming rules in docs/development/hdf5-conventions.md.
Fallout from the
gpec.h5schema overhaul (#226, PR #364). While giving theEquilibrium/scalars literature names I audited every field ofEquilibrium.EquilibriumParametersagainst its assignment site, and two related problems turned up. Neither is a regression — both predate the schema work — but the rename made them visible, so they are worth fixing deliberately rather than carrying forward.1. Several flux-bookkeeping fields are hardcoded constants, not computed
src/Equilibrium/Equilibrium.jl:370-381is the sole assignment site for the whole flux-bookkeeping family, and most of it is literals:Everything from
psi_boundarydown is a constant independent of the equilibrium being loaded. In normalized-flux termspsi_axis_norm = 0andpsi_boundary_norm = 1are true by definition of psi_N, so those two are honest tautologies — butpsi_boundary = 1.0is written with unitsWb/radin the schema and is not the boundary poloidal flux of any real equilibrium, and the offsets/signs/psi_boundary_zerolook like they were meant to record what the ingest actually did (Fortran GPEC derived the equivalent quantities from the g-filesimag/sibrypair and the COCOS handling). The likely story is that the Julia port stubbed them and nothing downstream noticed.Separately, four fields of the struct are never assigned anywhere in
src/—ro,zo,psio,b_norm. The HDF5 writer works around the first three by pulling them offPlasmaEquilibriumdirectly (equil.ro,equil.zo,equil.psio) andb_normis silently skipped because it staysnothing.Ask: compute these from the ingest rather than hardcoding them — real
psi_axis/psi_boundaryinWb/rad, real offsets/signs reflecting the COCOS/normalization actually applied, a decision onb_norm(compute it or delete the field), and either populateparams.ro/zo/psioor delete them in favour of thePlasmaEquilibriumfields so there is one source of truth.2. Three variables are the same number for psi on axis
psi0,psi_axis, andpsioall end up holding the total poloidal flux difference.psi_axisin particular is misnamed: it is assignedpe.psio, i.e. the total flux, not the flux at the axis.psi_axis_normis likewise an exact duplicate ofpsi_norm(both0.0).For the schema overhaul I took the conservative route:
Equilibrium/psi_totalis written once (fromequil.psio) and the duplicatespsi0,psi_axis,psi_axis_normare dropped from the HDF5 output viaEQUIL_H5_SKIPinsrc/HDF5Schema.jl. That fixes the file, not the struct.Ask: collapse the redundancy in
EquilibriumParametersitself — either delete the duplicate fields, or, if each was intended to mean something distinct (axis flux vs. total flux vs. normalization constant), define those meanings and make the assignments match the names. Whatever survives should have a docstring entry stating which of the three it is; today a reader of the struct cannot tell them apart.Notes
regress --cases diiid_n1,solovev_n1 --refs develop,local) should confirm the blast radius before merging.EQUIL_H5_NAMES/EQUIL_H5_SKIP(src/HDF5Schema.jl) and the naming rules indocs/development/hdf5-conventions.md.