Skip to content

Fix duplicate switch value making Paz-Soldan scaling unselectable - #4529

Open
dallonby wants to merge 1 commit into
ukaea:mainfrom
dallonby:fix/paz-soldan-switch-value
Open

Fix duplicate switch value making Paz-Soldan scaling unselectable#4529
dallonby wants to merge 1 commit into
ukaea:mainfrom
dallonby:fix/paz-soldan-switch-value

Conversation

@dallonby

Copy link
Copy Markdown

Closes #4528

Overview

ConfinementTimeModel.PAZ_SOLDAN_NT shared switch value 51 with NCST, making it a silent Python enum alias: i_confinement_time = 51 dispatched to the NCST scaling, the Paz-Soldan branch in calculate_confinement_time was unreachable, and the documented value 52 was rejected as invalid input.

Changes

  • process/data_structure/physics_variables.py: assign 52 to PAZ_SOLDAN_NT (matching the existing documentation in plasma_confinement.md) and decorate ConfinementTimeModel with enum.unique so any future duplicate value fails at import instead of silently aliasing.
  • tests/unit/models/physics/test_confinement_time.py: add a uniqueness test over all switch values and an explicit test that 51 → NCST and 52 → PAZ_SOLDAN_NT are distinct members.

Notes for reviewers

  • N_CONFINEMENT_SCALINGS (= len(ConfinementTimeModel)) goes 52 → 53. I checked the three usages: the hfac array grows by one element, input validation now accepts 0–52, and the OUT.DAT confinement-comparison table gains one (OCMMNT text) row — no MFILE variables are added, so regression MFILE comparisons should be unaffected.
  • Full unit suite passes locally (844 passed / 4 skipped, Python 3.12).

Found during an independent audit of v3.4.2.

🤖 Generated with Claude Code

ConfinementTimeModel.PAZ_SOLDAN_NT was assigned 51, the same value as
NCST, making it a silent alias: i_confinement_time=51 dispatched to the
NCST scaling and the Paz-Soldan branch in
PlasmaConfinementTime.calculate_confinement_time was unreachable.

Assign 52, matching the documented switch value in
documentation/source/physics-models/plasma_confinement.md, and add
enum.unique so a duplicate value can never silently alias again.

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:42
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.

Paz-Soldan NT confinement scaling is unselectable: duplicate switch value 51 aliases it to NCST

1 participant