Skip to content

Add cs stress profiles#4160

Open
chris-ashe wants to merge 2 commits into
mainfrom
add_cs_stress_profiles
Open

Add cs stress profiles#4160
chris-ashe wants to merge 2 commits into
mainfrom
add_cs_stress_profiles

Conversation

@chris-ashe
Copy link
Copy Markdown
Collaborator

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

This pull request adds the capability to calculate, store, and visualize the time evolution of the central solenoid (CS) midplane axial stress throughout the machine pulse. The changes include new data structures, calculation logic, output handling, and a plotting function, along with updates to the main plotting routine to display the new stress profile.

Central Solenoid Stress Time Profile Support:

  • Added a new variable stress_z_cs_self_midplane_profile to pfcoil_variables.py to store the CS midplane axial stress at each time point, updated initialization, and included it in the module's variable list.
  • Implemented the calculation of the CS midplane axial stress profile over time in CSCoil.calculate_cs_self_midplane_axial_stress_time_profile, and integrated it into the OH coil calculation workflow.
  • Modified the output logic to write each time point's stress value to the output file for later retrieval and plotting.

Visualization Enhancements:

image
  • Added a static method plot_stress_time_profile to CSCoil for plotting the CS midplane axial stress vs. time, including retrieval of relevant timing and stress data from the output file.
  • Updated the main plotting routine in plot_proc.py to include the new CS stress time profile plot and reorganized subplot positions for clarity.
  • Adjusted placement of annotation text in CS coil structure and turn structure plots for improved readability.

Imports and Dependencies:

  • Added necessary imports for plotting and data access in both plot_proc.py and pfcoil.py.

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 requested a review from a team as a code owner April 1, 2026 10:32
@chris-ashe chris-ashe requested a review from j-a-foster April 1, 2026 10:33
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 1, 2026

Codecov Report

❌ Patch coverage is 55.17241% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.93%. Comparing base (d7449c3) to head (f8b0363).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
process/models/pfcoil.py 50.00% 12 Missing ⚠️
process/core/io/plot/summary.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4160      +/-   ##
==========================================
- Coverage   50.99%   50.93%   -0.06%     
==========================================
  Files         151      151              
  Lines       29772    29778       +6     
==========================================
- Hits        15181    15167      -14     
- Misses      14591    14611      +20     

☔ 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.

@clmould clmould self-assigned this Apr 8, 2026
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

@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.

Could you rebase this please then I'll take a look

Copilot AI review requested due to automatic review settings May 14, 2026 09:41
@chris-ashe chris-ashe force-pushed the add_cs_stress_profiles branch from 26e8acc to f8b0363 Compare May 14, 2026 09:41
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

Adds central solenoid midplane axial stress time-profile support, from calculation and mfile output through to plotting in the summary figures.

Changes:

  • Adds a new PF coil data-structure variable for the six-point CS axial stress profile.
  • Adds stress profile calculation/output logic in the PF/CS coil model.
  • Adds a CS stress profile plot and updates the CS summary figure layout.

Reviewed changes

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

File Description
process/models/pfcoil.py Adds CS stress profile calculation, output, plotting helper, and related imports.
process/data_structure/pfcoil_variables.py Adds and initializes stress_z_cs_self_midplane_profile.
process/core/io/plot/summary.py Adds the new stress plot to the main plotting routine and adjusts CS subplot text/layout.
Comments suppressed due to low confidence (3)

process/models/pfcoil.py:3556

  • This call runs before PFCoil.pfcoil populates pfcoil_variables.c_pf_coil_turn for the six pulse time points (that happens later in pfcoil around the waveform generation loop). As a result, the new stress profile is computed from zero or stale per-turn currents rather than the actual time-profile currents, so the mfile values and plot will be wrong. Move this calculation to after the waveform currents are set, or compute it from data that is already initialized here.
        self.calculate_cs_self_midplane_axial_stress_time_profile()

process/models/pfcoil.py:2549

  • The profile values are stored in pascals (the new data-structure docstring and the existing peak stress output both use Pa), but the mfile description says MPa while writing the unscaled value. This will mislead mfile consumers and makes the plotted conversion ambiguous; either scale the value before writing or label it as Pa.
                f"CS coil midplane axial stress at time point {time} (MPa)",
                f"(stress_z_cs_self_midplane_profile[{time}])",
                pfcoil_variables.stress_z_cs_self_midplane_profile[time],

process/models/pfcoil.py:3784

  • The new time-profile calculation is not covered by unit tests, even though the underlying peak axial stress helper has tests in tests/unit/models/test_pfcoil.py. A test should assert that the profile uses all six CS waveform currents (and would catch the current ordering issue where the profile is computed before c_pf_coil_turn is populated).
    def calculate_cs_self_midplane_axial_stress_time_profile(
        self,
    ) -> None:
        for time in range(6):
            stress_value, _ = self.calculate_cs_self_peak_midplane_axial_stress(

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

Comment thread process/models/pfcoil.py
from scipy.special import ellipe, ellipk

import process.core.io.mfile as mf
import process.models.superconductors as superconductors
Comment thread process/models/pfcoil.py
Comment on lines +2544 to +2549
for time in range(6):
op.ovarre(
self.mfile,
f"CS coil midplane axial stress at time point {time} (MPa)",
f"(stress_z_cs_self_midplane_profile[{time}])",
pfcoil_variables.stress_z_cs_self_midplane_profile[time],
Comment on lines 49 to +50
from process.models.physics.bootstrap_current import BootstrapCurrentFractionModel
from process.models.pfcoil import CSCoil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants