Skip to content

🐛 Add full tf midplane thickness#4201

Merged
je-cook merged 7 commits intomainfrom
add_full_tf_midplane_thickness
Apr 20, 2026
Merged

🐛 Add full tf midplane thickness#4201
je-cook merged 7 commits intomainfrom
add_full_tf_midplane_thickness

Conversation

@chris-ashe
Copy link
Copy Markdown
Collaborator

@chris-ashe chris-ashe commented Apr 17, 2026

This pull request introduces two new parameters describing the toroidal field (TF) coil's geometry at the midplane—dr_tf_full_midplane and dr_tf_internal_midplane—and refactors the code to use a dataclass (TFGlobalGeometry) for returning TF coil geometry. It updates the calculation, storage, output, and plotting of these new parameters, and adapts related tests accordingly.

TF coil geometry calculation and data structure refactor:

  • Introduced a TFGlobalGeometry dataclass in process/models/tfcoil/base.py to encapsulate all global TF coil geometry parameters, replacing the previous tuple return value from tf_global_geometry. The dataclass now includes the new dr_tf_full_midplane and dr_tf_internal_midplane fields.
  • Updated run_base_tf to use the new dataclass and assign its fields to the appropriate variables.

New TF coil midplane width parameters:

  • Added dr_tf_full_midplane and dr_tf_internal_midplane to process/data_structure/tfcoil_variables.py, with initialization and docstrings, and ensured they are initialized in init_tfcoil_variables.
  • Calculated these parameters in tf_global_geometry as the full external and internal coil widths at the midplane.

Output and plotting updates:

  • Updated the output routine (outtf) to write the new parameters to output files.
  • Modified plotting in process/core/io/plot/summary.py to use the new parameters for midplane width annotations.

Test updates:

  • Updated tests in tests/unit/models/tfcoil/test_tfcoil.py to check the new parameters, use the dataclass, and compare results using astuple.

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 the TF Coil Toroidal field coil label Apr 17, 2026
@chris-ashe chris-ashe changed the title Add full tf midplane thickness 🐛 Add full tf midplane thickness Apr 17, 2026
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 17, 2026

Codecov Report

❌ Patch coverage is 70.83333% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 52.10%. Comparing base (4c99916) to head (9a056d7).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
process/models/tfcoil/base.py 66.66% 14 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4201      +/-   ##
==========================================
+ Coverage   52.07%   52.10%   +0.02%     
==========================================
  Files         148      148              
  Lines       30321    30365      +44     
==========================================
+ Hits        15791    15822      +31     
- Misses      14530    14543      +13     

☔ 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 April 17, 2026 16:05
@chris-ashe chris-ashe requested a review from a team as a code owner April 17, 2026 16:05
Copilot AI review requested due to automatic review settings April 17, 2026 16:05
@chris-ashe chris-ashe added the Bug Something isnt working label Apr 17, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds explicit TF coil midplane radial thickness outputs (full/external and internal) to the TF coil model, surfaces them in output/MFILE, and updates plotting and unit tests to use the new values.

Changes:

  • Refactor tf_global_geometry to return a TFGlobalGeometry dataclass and add dr_tf_full_midplane / dr_tf_internal_midplane calculations.
  • Persist the new midplane thickness values into tfcoil_variables and output them via outtf.
  • Update summary plotting and unit tests to consume the new midplane thickness values.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
process/models/tfcoil/base.py Introduces TFGlobalGeometry dataclass, computes/stores new midplane thickness variables, and outputs them.
process/data_structure/tfcoil_variables.py Adds new TF coil variable slots and initializes them.
process/core/io/plot/summary.py Updates TF coil structure plot labels to use dr_tf_*_midplane from MFILE.
tests/unit/models/tfcoil/test_tfcoil.py Updates unit tests for the new return type and verifies the new thickness values.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 10072 to 10076
axis.text(
(r_tf_inboard_out + r_tf_outboard_in) / 1.5,
-z_tf_inside_half / 12,
f"{r_tf_outboard_in - r_tf_inboard_in:.3f} m",
f"{mfile.get('dr_tf_internal_midplane', scan=scan):.3f} m",
fontsize=7,
Comment on lines 10096 to 10100
axis.text(
(r_tf_inboard_out + r_tf_outboard_in) / 1.5,
0.0,
f"{(r_tf_outboard_in + dr_tf_outboard) - r_tf_inboard_in:.3f} m",
f"{mfile.get('dr_tf_full_midplane', scan=scan):.3f} m",
fontsize=7,
Comment thread process/models/tfcoil/base.py Outdated
Comment thread process/models/tfcoil/base.py Outdated
Comment thread process/models/tfcoil/base.py Outdated
@je-cook je-cook self-assigned this Apr 20, 2026
@chris-ashe chris-ashe requested a review from je-cook April 20, 2026 08:29
@chris-ashe chris-ashe force-pushed the add_full_tf_midplane_thickness branch from 959bf16 to 9b1d1b3 Compare April 20, 2026 08:51
@je-cook je-cook enabled auto-merge (squash) April 20, 2026 09:38
@je-cook je-cook disabled auto-merge April 20, 2026 10:19
@je-cook je-cook merged commit 244f360 into main Apr 20, 2026
8 of 11 checks passed
@je-cook je-cook deleted the add_full_tf_midplane_thickness branch April 20, 2026 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isnt working TF Coil Toroidal field coil

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants