Skip to content

Refactor L-H transition calculations and integrate into Physics model#4123

Open
chris-ashe wants to merge 6 commits intomainfrom
create_transition_class
Open

Refactor L-H transition calculations and integrate into Physics model#4123
chris-ashe wants to merge 6 commits intomainfrom
create_transition_class

Conversation

@chris-ashe
Copy link
Collaborator

@chris-ashe chris-ashe commented Mar 6, 2026

This pull request improves the clarity and maintainability of the L-H transition (plasma confinement transition) model in both the documentation and the codebase. The main updates include refactoring the code to use the PlasmaConfinementTransition class, updating documentation to reference specific calculation methods, improving plotting output, and updating tests to use the new class-based interface.

Documentation Improvements:

  • Updated plasma_h_mode.md to reference the PlasmaConfinementTransition class and specific calculation methods for each L-H threshold scaling, making the documentation clearer and directly linked to the code implementation.

  • Improved equation formatting by replacing \mathtt{} with \texttt{} for code-style math, enhancing consistency.

Code Refactoring and Integration:

  • Refactored code to use the PlasmaConfinementTransition class (and its model enum) throughout the codebase, improving encapsulation and maintainability. This includes updates in main.py and plot_proc.py to use the new class for L-H threshold calculations and display.

  • Enhanced the plasma information plot to display the full L-H threshold model name, with line wrapping for long names, making the output more user-friendly.

  • Minor formatting improvements in plot labels for better readability.

Testing Updates:

  • Updated unit tests to use the PlasmaConfinementTransition class methods instead of standalone functions, ensuring tests are aligned with the new code structure and improving test clarity.

Description

Checklist

I confirm that I have completed the following checks:

  • My changes follow the PROCESS style guide
  • I have justified any large differences in the regression tests caused by this pull request in the comments.
  • I have added new tests where appropriate for the changes I have made.
  • If I have had to change any existing unit or integration tests, I have justified this change in the pull request comments.
  • If I have made documentation changes, I have checked they render correctly.
  • I have added documentation for my change, if appropriate.

- Removed direct function calls for L-H transition calculations and encapsulated them within the PlasmaConfinementTransition class.
- Updated the Physics class to utilize the new PlasmaConfinementTransition instance for L-H power threshold calculations.
- Modified unit tests to instantiate PlasmaConfinementTransition and validate its methods.
- Cleaned up unused L-H transition functions from the physics module.
@codecov-commenter
Copy link

codecov-commenter commented Mar 6, 2026

Codecov Report

❌ Patch coverage is 57.36041% with 84 lines in your changes missing coverage. Please review.
✅ Project coverage is 47.61%. Comparing base (67340b1) to head (5798705).

Files with missing lines Patch % Lines
process/models/physics/l_h_transition.py 58.06% 78 Missing ⚠️
process/core/io/plot_proc.py 20.00% 4 Missing ⚠️
process/models/physics/physics.py 50.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4123      +/-   ##
==========================================
+ Coverage   47.51%   47.61%   +0.10%     
==========================================
  Files         141      141              
  Lines       29487    29557      +70     
==========================================
+ Hits        14010    14073      +63     
- Misses      15477    15484       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@chris-ashe chris-ashe marked this pull request as ready for review March 6, 2026 12:20
@chris-ashe chris-ashe requested a review from a team as a code owner March 6, 2026 12:20
Copy link
Collaborator

@timothy-nunn timothy-nunn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before I give this a review can you fix the integration tests that are failing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants