Skip to content

CS plot proc#3693

Merged
jonmaddock merged 8 commits intomainfrom
cs_plot_proc
Jun 24, 2025
Merged

CS plot proc#3693
jonmaddock merged 8 commits intomainfrom
cs_plot_proc

Conversation

@chris-ashe
Copy link
Copy Markdown
Collaborator

@chris-ashe chris-ashe commented Jun 17, 2025

This pull request introduces several updates to improve the handling and visualization of central solenoid (CS) coil and turn structures in the codebase. Key changes include updates to data files to rename parameters for clarity, and enhancements to the plotting functionality to visualize CS coil and turn structures. This includes a temporary output plotting method output_cs_structure()

🔄 Renames

d_cond_cst -> dz_cs_turn
l_cond_cst -> dr_cs_turn
r_in_cst -> radius_cs_turn_cable_space


Visualization Enhancements:

  • Added plot_cs_coil_structure and plot_cs_turn_structure functions to process/io/plot_proc.py for visualizing CS coil cross-sections and turn conductor structures. These functions plot detailed geometries and annotate parameters such as turn dimensions, cable space, and structural thickness.
  • Integrated the new plotting functions into the main_plot function, adding new subplots (fig10) for CS coil and turn structure visualizations.

Updates to Main Plotting Workflow:

  • Extended the main(args=None) function to include the new figure (page10) for CS structure visualizations, ensuring it is saved to the PDF output and properly closed after execution.

✍️ plot_proc update

The new image is now made in plot_proc its a first step so its not very pretty at the moment

image

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 Jun 17, 2025
@chris-ashe chris-ashe added Input/Output Files Issues related to the input and output data files CS Coil labels Jun 17, 2025
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jun 17, 2025

Codecov Report

❌ Patch coverage is 6.45161% with 87 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.03%. Comparing base (9201e19) to head (628da58).
⚠️ Report is 382 commits behind head on main.

Files with missing lines Patch % Lines
process/io/plot_proc.py 2.98% 65 Missing ⚠️
process/pfcoil.py 19.04% 17 Missing ⚠️
process/tf_coil.py 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3693      +/-   ##
==========================================
- Coverage   38.13%   38.03%   -0.11%     
==========================================
  Files          88       88              
  Lines       22470    22558      +88     
==========================================
+ Hits         8570     8579       +9     
- Misses      13900    13979      +79     

☔ 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 requested a review from Copilot June 17, 2025 15:01
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 renames several CS turn parameters for clarity, updates their usage in calculations and I/O routines, and adds new plotting functions to visualize the CS coil and turn structures.

  • Renamed l_cond_cst, d_cond_cst, r_in_cst to dr_cs_turn, dz_cs_turn, radius_cs_turn_cable_space across data files, Fortran, and Python code.
  • Updated CS turn geometry calculations, output routines (output_cs_structure), and removed deprecated CF writes.
  • Added plot_cs_coil_structure and plot_cs_turn_structure in process/io/plot_proc.py and integrated them into main_plot.

Reviewed Changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/unit/data/large_tokamak_MFILE.DAT Updated CS turn parameter names in unit test data
tests/integration/data/*MFILE.DAT Updated CS turn parameter names in integration data
examples/data/*MFILE.DAT Updated example data to reflect renamed parameters
source/fortran/pfcoil_variables.f90 Renamed CS turn variables in module definition
process/tf_coil.py Refactored CS turn geometry calculation to use new names
process/pfcoil.py Replaced old CS turn vars, added output_cs_structure
process/io/plot_proc.py Added plotting functions for CS coil and turn, integrated into workflow
documentation/proc-pages/eng-models/central-solenoid.md Updated docs to use new parameter names
Comments suppressed due to low confidence (3)

process/io/plot_proc.py:4347

  • The function docstring mentions a demo_ranges parameter which isn't in the signature. Update or remove that reference to keep docs accurate.
def plot_cs_coil_structure(axis, fig, mfile_data, scan, colour_scheme=1):

process/io/plot_proc.py:4445

  • The data key 'n_pf_coil_turns[n_cs_pf_coils-1]' is unlikely to exist. You should fetch 'n_pf_coil_turns' and then index it with n_cs_pf_coils-1 rather than including brackets in the key.
        f"CS height vs TF internal height: {mfile_data.data['f_z_cs_tf_internal'].get_scan(scan):.2f}\n"

source/fortran/pfcoil_variables.f90:399

  • The comment for dr_cs_turn still refers to "Length of CS of CS coil turn conduit". Update it to clearly describe the new meaning (e.g., "radial length of a CS turn conduit").
  real(dp) :: dr_cs_turn

…ations for CS turn cable space and add output variables for conduit dimensions.
@chris-ashe chris-ashe requested a review from clmould June 17, 2025 15:25
Copy link
Copy Markdown
Collaborator

@clmould clmould left a comment

Choose a reason for hiding this comment

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

Looks good, just a couple minor comments.

Also, the old variables d_cond_cst, l_cond_cst and r_in_cst need to be updated in vardes.md.

csfv.t_structural_vertical = csfv.t_structural_radial
# add a check for negative conduit thickness
if csfv.t_structural_radial < 1.0e-3:
csfv.t_structural_radial = 1.0e-3
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Was this needed? Or can it safely be removed? (I am unsure either way)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Its a fudge in my eyes that creates discontinuities in the calculations

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I agree that it creates discontinuities, but I think that removing it may cause issues where t_structural_radial becomes negative. A continuous kludge has been implemented for pdivt in #3579 (more info in #3578), so perhaps this idea could be used here so it ensures that t_structural_radial does not go negative whilst keeping things continuous

csfv.t_structural_vertical = csfv.t_structural_radial
# add a check for negative conduit thickness
if csfv.t_structural_radial < 1.0e-3:
csfv.t_structural_radial = 1.0e-3
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I agree that it creates discontinuities, but I think that removing it may cause issues where t_structural_radial becomes negative. A continuous kludge has been implemented for pdivt in #3579 (more info in #3578), so perhaps this idea could be used here so it ensures that t_structural_radial does not go negative whilst keeping things continuous

@clmould clmould self-requested a review June 23, 2025 17:05
@jonmaddock jonmaddock merged commit 3e6ec15 into main Jun 24, 2025
21 of 27 checks passed
@jonmaddock jonmaddock deleted the cs_plot_proc branch June 24, 2025 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CS Coil Input/Output Files Issues related to the input and output data files Variable rename

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants