Reject a profile that its evaluator cannot evaluate - #816
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
The opt failure is Threed1ShafranovIntegralsTest/cma at 5.462e-11 against its 5.0e-11 bound, in a test this PR cannot reach: cma uses power_series, whose minimum knot count is zero, so the new check never fires. It passes locally at opt on this branch. #764, now unstacked and standalone, raises that bound to 5.0e-10 from the measured 4.08e-11. |
…unordered or short knots
|
Extended to the other ways a profile reaches the solver as zero. The closed-form parameterizations have the same gap as the splines: below their coefficient count |
CheckProfilerequires a spline profile to carry knots and requires the two arrays to have the same length, but not to be long enough to evaluate. Below their knot count the evaluators return0.0for everysafter one line on stderr:evalAkimaandevalCubicneed four knots,evalLineSegmenttwo.That is the failure the validation added in #719 exists to prevent, in its own words: an unusable parameterization "reaches the solver as a zero profile, which converges to a silently wrong equilibrium."
Fortran VMEC halts instead.
profile_functions.fcounts the knots and stops before the evaluator:IF (i < 4) STOP 'pcurr: check s-grid for curr-grid values!', and the same guard on the pressure and iota branches.Running
cth_like_fixed_bdy.jsonunchanged and then withpmass_type = "cubic_spline"over three knots:two_power(as shipped)cubic_spline, 3 knotscubic_spline, 4 knotspresf(0)betatotalThe run writes a
woutreporting a converged zero-pressure equilibrium while the input asked for 432 Pa. Withncurr = 1the same holds for the prescribed current, as in #798.The parameterization table now records how many knots each evaluator needs, 4 for the Akima and cubic families and 2 for the line segments, and
CheckProfilerejects an input that carries fewer.NeedsSplineData()becomes that count being positive, so its one caller is unchanged.The new test drives the three families through
IsConsistentone knot short and one knot at the minimum, for the pressure, current and iota profiles; all six rejections fail without the check.bazel test --config=opt //vmecpp/... //vmecpp_large_cpp_tests/...andpytestpass.