Skip to content

♻️ Refactor plasma toroidal ripple#3905

Merged
timothy-nunn merged 9 commits intomainfrom
refactor_plasma_toroidal_ripple
Nov 3, 2025
Merged

♻️ Refactor plasma toroidal ripple#3905
timothy-nunn merged 9 commits intomainfrom
refactor_plasma_toroidal_ripple

Conversation

@chris-ashe
Copy link
Copy Markdown
Collaborator

@chris-ashe chris-ashe commented Oct 14, 2025

This pull request makes several improvements and refactors related to the handling and visualization of toroidal field (TF) coil geometry and ripple calculations in the codebase. The changes enhance the modularity and clarity of the TF coil ripple calculation, introduce new variables for more detailed coil geometry modeling, and improve the plotting of coil properties.

❇️ New variables

  • dx_tf_side_case_peak : Maximum side case thickness on the inboard TF coil

TF coil ripple calculation refactor and improvements:

  • Refactored the plasma_outboard_edge_toroidal_ripple method in process/build.py to accept all required parameters explicitly, removing reliance on global variables and improving documentation and clarity of the calculation. This includes a clearer distinction between analytical and numerical models and more robust handling of input ranges.
  • Updated calls to plasma_outboard_edge_toroidal_ripple in calculate_radial_build to pass the new expanded parameter list, ensuring correct data flow and improving maintainability.
  • Added import of superconducting_tf_coil_variables to process/build.py to support the expanded parameterization.

TF coil geometry variable enhancements:

  • Added new variable dx_tf_side_case_peak to tfcoil_variables.py to represent the peak thickness of the TF coil sidewall case, along with initialization and global declaration updates.

Plotting and visualization improvements:

  • Updated plot_superconducting_tf_wp in plot_proc.py to plot the maximum toroidal width including the side case using the new dx_tf_side_case_peak variable, and to display this value in the coil casing information textbox.
  • Added the outboard ripple value to the main plasma information plot for improved diagnostic visibility.

🐛 Bugs

Quite a handful of TF side case geometry was being calculated in-situ. This has now been replaced with the actual variables taken from the TF class.

if tfcoil_variables.tfc_sidewall_is_fraction:
                t_wp_max = 2.0e0 * (
                    (r_wp_max - tfcoil_variables.casths_fraction * r_wp_min)
                    * np.tan(np.pi / n)
                    - tfcoil_variables.dx_tf_wp_insulation
                    - tfcoil_variables.dx_tf_wp_insertion_gap
                )
            else:
                t_wp_max = 2.0e0 * (
                    r_wp_max * np.tan(np.pi / n)
                    - tfcoil_variables.dx_tf_side_case_min
                    - tfcoil_variables.dx_tf_wp_insulation
                    - tfcoil_variables.dx_tf_wp_insertion_gap
                )

dx_tf_wp_conductor_max = dx_tf_wp_primary_toroidal - 2.0 * (
                dx_tf_wp_insulation + dx_tf_wp_insertion_gap
            )

The WP centre was being calculated incorrectly as it was using the inboard edge and then adding half of the total WP thickness which includes the insulation and gap and is not just the conductor region.

# Rectangular WP
            if tfcoil_variables.i_tf_wp_geom == 0:
                r_wp_max = r_wp_min

            # Double rectangle WP
            elif tfcoil_variables.i_tf_wp_geom == 1:
                r_wp_max = r_wp_min + 0.5e0 * tfcoil_variables.dr_tf_wp_with_insulation

            # Trapezoidal WP
            elif tfcoil_variables.i_tf_wp_geom == 2:
                r_wp_max = r_wp_min + tfcoil_variables.dr_tf_wp_with_insulation

# Rectangular WP
            if tfcoil_variables.i_tf_wp_geom == 0:
                r_wp_max = r_wp_min

            # Double rectangle WP
            elif tfcoil_variables.i_tf_wp_geom == 1:
                r_wp_max = r_tf_wp_inboard_centre

            # Trapezoidal WP
            elif tfcoil_variables.i_tf_wp_geom == 2:
                r_wp_max = r_tf_wp_inboard_outer

🎨 Output changes

A new toroidal rupple map has been added to plot_proc

image

Other minor changes:

  • Added import of Build to plot_proc.py for future extensibility.

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 self-assigned this Oct 14, 2025
@chris-ashe chris-ashe added Refactor Physics Relating to the physics models labels Oct 14, 2025
@chris-ashe chris-ashe force-pushed the refactor_plasma_toroidal_ripple branch from a69375f to 5f5ff46 Compare October 14, 2025 10:55
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Oct 14, 2025

Codecov Report

❌ Patch coverage is 11.04294% with 145 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.01%. Comparing base (a88d34b) to head (64b44e1).

Files with missing lines Patch % Lines
process/io/plot_proc.py 1.44% 136 Missing ⚠️
process/build.py 66.66% 5 Missing ⚠️
process/superconducting_tf_coil.py 40.00% 3 Missing ⚠️
process/tf_coil.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3905      +/-   ##
==========================================
- Coverage   46.19%   46.01%   -0.18%     
==========================================
  Files         123      123              
  Lines       28589    28723     +134     
==========================================
+ Hits        13206    13217      +11     
- Misses      15383    15506     +123     

☔ 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 refactor_plasma_toroidal_ripple branch 2 times, most recently from 70fe73a to d3dc8fc Compare October 27, 2025 14:36
@chris-ashe chris-ashe marked this pull request as ready for review October 29, 2025 11:45
@chris-ashe chris-ashe requested a review from j-a-foster October 29, 2025 13:50
Copy link
Copy Markdown
Collaborator

@j-a-foster j-a-foster left a comment

Choose a reason for hiding this comment

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

Happy with changes.

Copy link
Copy Markdown
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.

Happy with code, just one question then good for merge

Comment thread process/build.py
@chris-ashe chris-ashe force-pushed the refactor_plasma_toroidal_ripple branch from d331b34 to 41a826d Compare November 3, 2025 11:05
@chris-ashe chris-ashe force-pushed the refactor_plasma_toroidal_ripple branch from 41a826d to 64b44e1 Compare November 3, 2025 11:06
@timothy-nunn timothy-nunn merged commit 0fdad95 into main Nov 3, 2025
14 of 18 checks passed
@timothy-nunn timothy-nunn deleted the refactor_plasma_toroidal_ripple branch November 3, 2025 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

New Variables Physics Relating to the physics models Refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants