Open
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #4086 +/- ##
==========================================
+ Coverage 47.84% 47.97% +0.12%
==========================================
Files 141 142 +1
Lines 29754 29885 +131
==========================================
+ Hits 14236 14337 +101
- Misses 15518 15548 +30 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
935e8f0 to
660cc7c
Compare
248115d to
632de11
Compare
- Updated test_physics.py to instantiate PlasmaCurrent for calculating plasma current and related methods. - Replaced direct calls to calculate_plasma_current_peng and calculate_current_coefficient_hastie with PlasmaCurrent class methods. - Modified test_stellarator.py to include PlasmaCurrent in the stellarator setup.
…r improved readability and maintainability
…ed clarity and maintainability
…ated tests for consistency
…calculations in PlasmaCurrent class
…PlasmaCurrent class
…lot_proc and update data structure in PlasmaCurrent class
539add7 to
92b344d
Compare
timothy-nunn
requested changes
Mar 19, 2026
Collaborator
timothy-nunn
left a comment
There was a problem hiding this comment.
There are an awful many changes in the conventional aspect ratio cases, I suspect there is a big somewhere
2026-03-19T15:48:41.5813756Z FAILED tests/regression/test_process_input_files.py::test_input_file[large_tokamak_nof] - AssertionError: �[0;32m 8593 differences: the reference MFile contains different values for some of the variables. See the warnings for a breakdown of the differences.�[0m
2026-03-19T15:48:41.5813858Z assert 8593 == 0
2026-03-19T15:48:41.5815860Z + where 8593 = len([MFileVariableDifference(name='pfc1t4', ref=287728.4430610426, new=-2272946.4289503414, percentage_change=-889.962370341026), MFileVariableDifference(name='i_plasma_current', ref=4.0, new=9.0, percentage_change=125.0), MFileVariableDifference(name='f_c_plasma_hcd_primary', ref=0.027082630195024323, new=0.0, percentage_change=-100.0), MFileVariableDifference(name='f_c_plasma_auxiliary', ref=0.027082630195024326, new=0.0, percentage_change=-100.0), MFileVariableDifference(name='c_hcd_primary_driven', ref=453313.9488936291, new=0.0, percentage_change=-100.0), MFileVariableDifference(name='p_hcd_injected_current_total_mw', ref=9.81398334505902, new=0.0, percentage_change=-100.0), ...])
2026-03-19T15:48:41.5816768Z FAILED tests/regression/test_process_input_files.py::test_input_file[large_tokamak_eval] - AssertionError: �[0;32m 8614 differences: the reference MFile contains different values for some of the variables. See the warnings for a breakdown of the differences.�[0m
2026-03-19T15:48:41.5816850Z assert 8614 == 0
2026-03-19T15:48:41.5818785Z + where 8614 = len([MFileVariableDifference(name='pfc0t4', ref=-543745.9921847769, new=-2804442.4944127165, percentage_change=-415.7633407364417), MFileVariableDifference(name='i_plasma_current', ref=4.0, new=9.0, percentage_change=125.0), MFileVariableDifference(name='f_c_plasma_hcd_primary', ref=0.010312341172393658, new=0.0, percentage_change=-100.0), MFileVariableDifference(name='f_c_plasma_auxiliary', ref=0.010312341172393658, new=0.0, percentage_change=-100.0), MFileVariableDifference(name='c_hcd_primary_driven', ref=165936.8656852688, new=0.0, percentage_change=-100.0), MFileVariableDifference(name='p_hcd_injected_current_total_mw', ref=3.413518735361287, new=0.0, percentage_change=-100.0), ...])
2026-03-19T15:48:41.5819795Z FAILED tests/regression/test_process_input_files.py::test_input_file[low_aspect_ratio_DEMO] - AssertionError: �[0;32m 7988 differences: the reference MFile contains different values for some of the variables. See the warnings for a breakdown of the differences.�[0m
2026-03-19T15:48:41.5819868Z assert 7988 == 0
2026-03-19T15:48:41.5822069Z + where 7988 = len([MFileVariableDifference(name='pfc1t4', ref=-66468.16490802169, new=-2160158.9627523157, percentage_change=-3149.915152225931), MFileVariableDifference(name='cs_t3', ref=8023669.20057866, new=37198927.57899087, percentage_change=363.6149204195521), MFileVariableDifference(name='cs_t2', ref=8023669.20057866, new=37198927.57899087, percentage_change=363.6149204195521), MFileVariableDifference(name='f_j_cs_start_end_flat_top', ref=-0.04323663015144943, new=-0.20045146846873732, percentage_change=-363.6149204195497), MFileVariableDifference(name='big_q_plasma', ref=33.05921861558781, new=95.42180776169131, percentage_change=188.63902946786166), MFileVariableDifference(name='i_plasma_current', ref=4.0, new=9.0, percentage_change=125.0), ...])
Comment on lines
+301
to
+327
| physics_variables.c_plasma_peng_analytic = plasma_currents.get( | ||
| PlasmaCurrentModel.PENG_ANALYTIC_FIT | ||
| ) | ||
| physics_variables.c_plasma_peng_double_null = plasma_currents.get( | ||
| PlasmaCurrentModel.PENG_DIVERTOR_SCALING | ||
| ) | ||
| physics_variables.c_plasma_cyclindrical = plasma_currents.get( | ||
| PlasmaCurrentModel.ITER_SCALING | ||
| ) | ||
| physics_variables.c_plasma_ipdg89 = plasma_currents.get( | ||
| PlasmaCurrentModel.IPDG89_SCALING | ||
| ) | ||
| physics_variables.c_plasma_todd_empirical_i = plasma_currents.get( | ||
| PlasmaCurrentModel.TODD_EMPIRICAL_SCALING_I | ||
| ) | ||
| physics_variables.c_plasma_todd_empirical_ii = plasma_currents.get( | ||
| PlasmaCurrentModel.TODD_EMPIRICAL_SCALING_II | ||
| ) | ||
| physics_variables.c_plasma_connor_hastie = plasma_currents.get( | ||
| PlasmaCurrentModel.CONNOR_HASTIE_MODEL | ||
| ) | ||
| physics_variables.c_plasma_sauter = plasma_currents.get( | ||
| PlasmaCurrentModel.SAUTER_SCALING | ||
| ) | ||
| physics_variables.c_plasma_fiesta_st = plasma_currents.get( | ||
| PlasmaCurrentModel.FIESTA_ST_SCALING | ||
| ) |
Collaborator
There was a problem hiding this comment.
If these are only being calculated in output_plasma_current_models is it required to create new variables to hold their values? Surely these new variables won't be used anywhere else in the code
…ction and improve clarity in calculations
Co-authored-by: Timothy <75321887+timothy-nunn@users.noreply.github.com>
j-a-foster
approved these changes
Mar 23, 2026
Collaborator
j-a-foster
left a comment
There was a problem hiding this comment.
Happy with formula changes.
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.
This pull request introduces significant improvements to how plasma current is modeled, calculated, and visualized throughout the codebase and documentation. It refactors the plasma current logic into a dedicated
PlasmaCurrentclass, updates the documentation for clarity and accuracy, expands the set of tracked plasma current variables, and adapts plotting and testing to use the new structure.Key changes include:
Refactoring and Integration of Plasma Current Calculations:
PlasmaCurrentclass, centralizing all plasma current calculations, and integrated it throughout the codebase, including in the main application logic (process/main.py), plotting (process/core/io/plot_proc.py), and unit tests (tests/unit/test_physics.py).Enhancements to Data Structure:
physics_variablesto include a comprehensive set of plasma current calculation results from different empirical and analytic models, with initialization and documentation for each new variable.Documentation Improvements:
Plotting Updates:
PlasmaCurrent, adjusted subplot indexing to accommodate new plots, and increased the number of figure pages accordingly.Testing Adaptation:
PlasmaCurrentclass and removed outdated test parameters and checks, ensuring alignment with the updated calculation interface.Checklist
I confirm that I have completed the following checks: