Skip to content

Fix inverted q95 to qbar transform in Peng TART scalings - #4533

Open
dallonby wants to merge 1 commit into
ukaea:mainfrom
dallonby:fix/peng-tart-qbar-transform
Open

Fix inverted q95 to qbar transform in Peng TART scalings#4533
dallonby wants to merge 1 commit into
ukaea:mainfrom
dallonby:fix/peng-tart-qbar-transform

Conversation

@dallonby

Copy link
Copy Markdown

Closes #4532

Overview

The q95 → qbar transform in the two i_plasma_current=2 (Peng TART/STAR) call sites multiplied by 1.3*(1-eps)^0.6 where inverting the documented relation q95 = 1.3*qbar*(1-eps)^0.6 requires division. Detail and pre-#3320 history in the issue.

Changes

  • process/models/physics/plasma_current.py (calculate_plasma_current_peng) and process/models/physics/plasma_fields.py (calculate_surface_averaged_poloidal_field, TART branch): divide by 1.3e0 * (1 - eps)**0.6e0 and document the inversion in a comment.
  • New tests/unit/models/physics/test_plasma_current.py (first unit tests for this module): hand-derived reference values for the corrected current and bpol at ST parameters, a round-trip test on the transform (including qbar > q95, which the forward relation requires for any eps > 0), and a consistency test that both call sites share the same qbar.
  • tests/unit/models/physics/test_physics.py: the four existing golden values for calculate_plasma_current_peng / calculate_surface_averaged_poloidal_field are updated to the corrected values. Justification per CONTRIBUTING: these goldens pinned the inverted transform; both sit at conventional aspect ratio (A=2.7/3.0) where the correction is only −3.0%/+3.9%, which is why they never exposed the bug. Comments in the diff give the scale factor (1.3*(1-eps)^0.6)^2.

Behavioural impact

Only i_plasma_current=2 runs change. No shipped regression input uses it, so regression MFILEs should be unchanged. External ST studies using the Peng scaling will see plasma current drop ~35–60% at A=1.4–1.8 — that is the fix, not a regression: with it, icurr=2 agrees to ~2% with the independent icurr=9 scaling on the shipped ST geometry (22.5 vs 22.9 MA), where it previously disagreed by ~55%.

Verification

  • Full unit suite passes locally (846 passed / 4 skipped, Python 3.12).
  • If maintainers know of a historical STAR-code benchmark for icurr=2, that would be the ideal additional cross-check.

Found during an independent audit of v3.4.2.

🤖 Generated with Claude Code

calculate_plasma_current_peng (i_plasma_current=2) and the TART branch
of calculate_surface_averaged_poloidal_field derived qbar as
q95 * 1.3 * (1 - eps)^0.6. The documented Peng/STAR relation is
q95 = 1.3 * qbar * (1 - eps)^0.6, so recovering qbar from q95 requires
division; before the pure-Python refactor (ukaea#3320) the input safety
factor was interpreted as qbar directly and q95 was derived from it
with exactly this forward relation, keeping the pair self-consistent.

The multiply/divide inversion under-computed qbar by
(1.3 * (1 - eps)^0.6)^2, overestimating plasma current by ~57% at
A=1.8. With the fix, the Peng scaling at the ST regression geometry
(q95=6, A=1.8, a=2.5 m, B_T=3 T, kappa=2.8) gives 22.5 MA, consistent
with the 22.9 MA the independent i_plasma_current=9 scaling produces
for the same machine; the inverted transform gave 35.2 MA.

Adds the first unit tests for plasma_current.py: hand-derived reference
values for the current and bpol, a round-trip check on the transform,
and a consistency check that both call sites share the same qbar.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@dallonby
dallonby requested a review from a team as a code owner August 15, 2026 13:43
@dallonby

Copy link
Copy Markdown
Author

Correction to the 'Behavioural impact' section above: the regression MFILEs are not fully unchanged — the diagnostic comparison entry c_plasma_peng_double_null (the Peng-scaling current reported alongside every run's chosen scaling) changes by the fix's factor even on inputs that use other i_plasma_current models. Verified on st_regression: every design variable is identical to the last digit; only this one diagnostic row moves (3.291e7 → 2.102e7 A, −36%). So the 0.2%/5% regression jobs will flag exactly that one variable per tokamak input. All actual design outputs are unaffected.

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.

q95 to qbar transform inverted in Peng TART scalings (i_plasma_current=2): plasma current overestimated ~57% at A=1.8

1 participant