Skip to content

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

Merged
timothy-nunn merged 7 commits intomainfrom
create_transition_class
Mar 19, 2026
Merged

Refactor L-H transition calculations and integrate into Physics model#4123
timothy-nunn merged 7 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.

@codecov-commenter
Copy link

codecov-commenter commented Mar 6, 2026

Codecov Report

❌ Patch coverage is 57.00000% with 86 lines in your changes missing coverage. Please review.
✅ Project coverage is 47.84%. Comparing base (e8f83ff) to head (e69a91d).

Files with missing lines Patch % Lines
process/models/physics/l_h_transition.py 57.67% 80 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.74%   47.84%   +0.09%     
==========================================
  Files         141      141              
  Lines       29682    29754      +72     
==========================================
+ Hits        14172    14236      +64     
- Misses      15510    15518       +8     

☔ 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.

@timothy-nunn timothy-nunn self-assigned this Mar 16, 2026
@timothy-nunn timothy-nunn self-requested a review March 19, 2026 10:44
- 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.
@chris-ashe chris-ashe force-pushed the create_transition_class branch from 2627efd to e69a91d Compare March 19, 2026 11:00
@timothy-nunn timothy-nunn merged commit c9a2074 into main Mar 19, 2026
16 of 20 checks passed
@timothy-nunn timothy-nunn deleted the create_transition_class branch March 19, 2026 14:09
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