Fix inverted q95 to qbar transform in Peng TART scalings - #4533
Open
dallonby wants to merge 1 commit into
Open
Conversation
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>
Author
|
Correction to the 'Behavioural impact' section above: the regression MFILEs are not fully unchanged — the diagnostic comparison entry |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4532
Overview
The q95 → qbar transform in the two
i_plasma_current=2(Peng TART/STAR) call sites multiplied by1.3*(1-eps)^0.6where inverting the documented relationq95 = 1.3*qbar*(1-eps)^0.6requires division. Detail and pre-#3320 history in the issue.Changes
process/models/physics/plasma_current.py(calculate_plasma_current_peng) andprocess/models/physics/plasma_fields.py(calculate_surface_averaged_poloidal_field, TART branch): divide by1.3e0 * (1 - eps)**0.6e0and document the inversion in a comment.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 forcalculate_plasma_current_peng/calculate_surface_averaged_poloidal_fieldare 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=2runs 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
Found during an independent audit of v3.4.2.
🤖 Generated with Claude Code