Skip to content

♻️ Refactor CS coil 1#3962

Merged
timothy-nunn merged 7 commits intomainfrom
refactor_cs_coil_1
Nov 4, 2025
Merged

♻️ Refactor CS coil 1#3962
timothy-nunn merged 7 commits intomainfrom
refactor_cs_coil_1

Conversation

@chris-ashe
Copy link
Copy Markdown
Collaborator

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

This pull request refactors and improves the calculation and handling of axial stress and axial force at the midplane of the central solenoid (CS) due to its own field. The changes include renaming variables and functions for clarity, updating documentation, refactoring the main calculation routine, and improving unit test coverage for the new function. These updates enhance code readability, maintainability, and scientific accuracy.

🔄 Renames

  • axial_stress() -> calculate_cs_self_peak_midplane_axial_stress()
  • sig_axial -> stress_z_cs_self_peak_midplane
  • axial_force -> forc_z_cs_self_peak_midplane

Central solenoid axial stress and force calculation improvements:

  • Refactored the main calculation routine: replaced axial_stress() with calculate_cs_self_peak_midplane_axial_stress(), which uses elliptic integrals for more accurate computation and has improved documentation and parameterization.
  • Renamed variables and outputs for clarity: sig_axialstress_z_cs_self_peak_midplane and axial_forceforc_z_cs_self_peak_midplane throughout the codebase, including initialization, output, and plotting routines.

Documentation updates:

  • Updated engineering model documentation to reflect the new calculation method, equations, and references for axial stress and force at the CS midplane.

Testing improvements:

  • Replaced and expanded unit tests to directly test calculate_cs_self_peak_midplane_axial_stress() across typical, zero-current, extreme geometry, and invalid input scenarios, improving reliability and coverage.
  • Removed obsolete test for the old axial_stress() function.

Other codebase maintenance:

  • Updated output and plotting routines to use the new variable names and display the updated axial stress and force values in user-facing outputs. )

These changes collectively improve the scientific accuracy, clarity, and maintainability of the central solenoid stress calculations in the codebase.

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.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Oct 30, 2025

Codecov Report

❌ Patch coverage is 93.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 46.04%. Comparing base (ec3fdee) to head (d69ca42).
⚠️ Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
process/pfcoil.py 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3962      +/-   ##
==========================================
+ Coverage   45.98%   46.04%   +0.05%     
==========================================
  Files         123      123              
  Lines       28550    28549       -1     
==========================================
+ Hits        13129    13144      +15     
+ Misses      15421    15405      -16     

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

…al force, and stress in the plot output

🔄 - Refactor test cases for calculate_cs_self_peak_midplane_axial_stress to ensure proper assertions and formatting
@chris-ashe chris-ashe marked this pull request as ready for review October 30, 2025 09:01
@chris-ashe chris-ashe requested a review from j-a-foster October 30, 2025 09:02
@chris-ashe chris-ashe changed the title Refactor cs coil 1 ♻️ Refactor CS coil 1 Oct 30, 2025
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 the code changes, will approve and merge once @j-a-foster has done his bit. One question re test reference values.

Comment thread tests/unit/test_pfcoil.py
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.

@timothy-nunn timothy-nunn merged commit 5eeaeff into main Nov 4, 2025
25 of 36 checks passed
@timothy-nunn timothy-nunn deleted the refactor_cs_coil_1 branch November 4, 2025 15:34
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.

4 participants