Skip to content

Create confinement time class#4121

Open
chris-ashe wants to merge 12 commits intomainfrom
create_confinement_class
Open

Create confinement time class#4121
chris-ashe wants to merge 12 commits intomainfrom
create_confinement_class

Conversation

@chris-ashe
Copy link
Collaborator

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

This pull request refactors how confinement time models are accessed and labeled throughout the codebase. The main improvement is the centralization of confinement time calculations and model labels into the PlasmaConfinementTime and ConfinementTimeModel classes, which increases code maintainability and clarity. Additionally, hardcoded label lists have been removed, and references to confinement time models are now made through well-defined class properties.

Key changes:

Refactoring confinement time model access:

  • All calls to confinement time scaling functions in plot_proc.py are now accessed via the PlasmaConfinementTime class, replacing the previous use of the confine module. This change standardizes how these models are instantiated and used.

Centralizing and improving model labeling:

  • The hardcoded LABELS_CONFINEMENT_SCALINGS list has been removed from physics_variables.py, and references to confinement time model labels in plot_proc.py are now made through the ConfinementTimeModel class's full_name property. This ensures label consistency and reduces duplication.

Initialization and dependency injection improvements:

  • The PlasmaConfinementTime class is now instantiated and injected as a dependency into the Physics class in main.py, making it easier to manage and test.

API updates for downstream usage:

  • The calculate_confinement_time method in the stellarator model is now accessed via self.physics.confinement, reflecting the new structure for confinement time calculations.

Documentation and cleanup:

  • The docstring for i_confinement_time in physics_variables.py has been updated to remove references to the deleted label list, reflecting the new approach to model labeling.## 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.

@chris-ashe chris-ashe added Confinement time Plasma energy or particle confinement times Refactor labels Mar 5, 2026
@codecov-commenter
Copy link

codecov-commenter commented Mar 5, 2026

Codecov Report

❌ Patch coverage is 30.00000% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 47.73%. Comparing base (67340b1) to head (07e7a7b).

Files with missing lines Patch % Lines
process/core/io/plot_proc.py 9.52% 19 Missing ⚠️
process/models/physics/physics.py 66.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4121      +/-   ##
==========================================
+ Coverage   47.51%   47.73%   +0.21%     
==========================================
  Files         141      141              
  Lines       29487    29628     +141     
==========================================
+ Hits        14010    14142     +132     
- Misses      15477    15486       +9     

☔ 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 force-pushed the create_confinement_class branch from 50b103f to c5b7ace Compare March 5, 2026 11:52
- Updated test_confinement_time.py to replace direct function calls from the confinement_time module with method calls from the PlasmaConfinementTime class.
- Adjusted the parameterized tests to reflect the new method structure.
- Modified test_physics.py to call the confinement time calculation method from the confinement attribute of the physics object.
@chris-ashe chris-ashe force-pushed the create_confinement_class branch from d7153bb to a90a9c5 Compare March 5, 2026 14:56
…rison and find_other_h_factors methods to PlasmaConfinementTime class
…onfinement_time_info method in PlasmaConfinementTime class
@chris-ashe chris-ashe marked this pull request as ready for review March 5, 2026 15:45
@chris-ashe chris-ashe requested a review from a team as a code owner March 5, 2026 15:45
@chris-ashe chris-ashe changed the title Create confinement class :clock: Create confinement time class Mar 5, 2026
@chris-ashe chris-ashe changed the title :clock: Create confinement time class Create confinement time class Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Confinement time Plasma energy or particle confinement times Refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants