♻️ Refactor CS coil#4262
Conversation
11241c9 to
4c3139c
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4262 +/- ##
==========================================
+ Coverage 50.14% 50.18% +0.04%
==========================================
Files 151 151
Lines 29355 29451 +96
==========================================
+ Hits 14719 14780 +61
- Misses 14636 14671 +35 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
29f4622 to
035b649
Compare
There was a problem hiding this comment.
Pull request overview
This PR refactors the Central Solenoid (CS) engineering model by introducing clearer CS geometry/turn-geometry data structures, expanding CS-related variables (geometry, stress, temperature), and updating outputs, plotting, and cost calculations to use the new fields.
Changes:
- Refactors CS geometry and EU-DEMO turn geometry routines to return dataclasses and propagates new CS geometry variables through the PF/CS model.
- Replaces legacy CS conductor+void area variable (
awpoh) witha_cs_cable_spaceacross models, costs, and tests; adds CS operating temperature input/variable. - Extends CS plotting and documentation to cover new geometry and stress quantities (including radial/hoop stress profiles and toroidal area).
Reviewed changes
Copilot reviewed 9 out of 11 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/models/test_pfcoil.py | Updates CS-related unit tests for new dataclass returns and updated CS stress/area APIs. |
| tests/unit/models/test_costs_1990.py | Updates cost-model tests to use a_cs_cable_space instead of awpoh. |
| process/models/pfcoil.py | Implements CS dataclasses, new CS stress/geometry fields, updated outputs, and adds CS stress plotting helpers. |
| process/models/costs/costs.py | Switches PF/CS cost calculations from awpoh to a_cs_cable_space. |
| process/data_structure/pfcoil_variables.py | Adds/renames CS data fields (geometry, areas, stress profiles, operating temperature). |
| process/data_structure/build_variables.py | Clarifies CS build-variable docstrings (radial thickness naming). |
| process/core/io/plot/summary.py | Updates summary plotting to include new CS stress subplots and CS toroidal area annotation. |
| process/core/input.py | Adds new input variable temp_cs_superconductor_operating. |
| documentation/source/eng-models/central-solenoid.md | Expands CS documentation with new geometry/stress sections and equations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -10,6 +12,7 @@ | |||
| from process.core import constants | |||
| from process.core import process_output as op | |||
| from process.core.exceptions import ProcessValueError | |||
| from process.core.io.mfile import MFile | |||
| from process.core.model import DataStructure, Model | |||
| Parameters | ||
| ---------- | ||
| r_stress_point : float/np.ndarray | ||
| Radial location at which to calculate the hoop stress (m) | ||
| r_cs_inner : float | ||
| Inner radius of the central solenoid (m) | ||
| r_cs_outer : float | ||
| Outer radius of the central solenoid (m) | ||
| j_cs : float | ||
| Current density in the central solenoid (A/m^2) | ||
| b_cs_inner : float | ||
| Magnetic field at the inner radius of the central solenoid (T) | ||
| f_poisson_cs_structure : float | ||
| Poisson's ratio of the central solenoid structure (dimensionless) | ||
|
|
||
| Returns | ||
| ------- | ||
| float | ||
| radial stress at the specified radial location (MPa) | ||
|
|
| def calculate_cs_radial_stress( | ||
| self, | ||
| r_stress_point: float | np.ndarray, | ||
| r_cs_inner: float, | ||
| r_cs_outer: float, | ||
| j_cs: float, | ||
| b_cs_inner: float, | ||
| f_poisson_cs_structure: float, | ||
| ) -> float: |
geograham
left a comment
There was a problem hiding this comment.
A few minor things and worth looking through the copilot suggestions.
There was a problem hiding this comment.
- The time labels on the currents profile over time plot are currently overlapping.
- The red dot on the CS poloidal x-section plot is unlabelled.
| - If the calculated conduit thickness is negative or too small, it is set to a minimum value of 1 mm. | ||
| - The calculation assumes a stadium-shaped cross-section for the CS turn. | ||
| - If the calculated conduit thickness is negative or too small, it is set | ||
| to a minimum value of 1 mm. |
There was a problem hiding this comment.
This was here when I got to the issue, I'm assuming this is to force it to a minimum viable value to prevent divide by zero errors.
| Switch `iohcl` controls whether a central solenoid is present. A value of 1 denotes that this coil | ||
| is present, and should be assigned a non-zero thickness `dr_cs`. A value of `iohcl` = 0 denotes | ||
| that no central solenoid is present, in which case the thickness `dr_cs` should be zero. No PF | ||
| coils should be located at positions defined by `i_pf_location(j)` = 1 if no central solenoid is present. |
There was a problem hiding this comment.
Could explain what i_pf_location(j) = 1 means.
There was a problem hiding this comment.
This is outside the PR. I will actually write an enum for that asap
|
|
||
| The turn geometry is calculated as follows: | ||
|
|
||
| 1. The vertical height of the turn is given by: |
There was a problem hiding this comment.
I am getting some errors for the equations below, are they displaying ok for you?
There was a problem hiding this comment.
You normally need to just refresh the page and they load
…ate documentation
…for improved accuracy
…oop stress calculation
…d update references
…related variables
…e modules and update related references
…pdate plotting functions
…ent divide by zero errors
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…pport multiple return types
This pull request makes significant improvements to the documentation and data structures for the central solenoid (CS) in the engineering models, as well as updates the plotting and cost calculation code to support new geometry and stress parameters. The main focus is on clarifying and expanding the CS geometry and stress calculations, adding new physical variables, and ensuring these are reflected throughout the codebase and documentation.
Documentation and Model Improvements:
Plotting and Visualization Enhancements:
Cost Model Adjustments:
a_cs_cable_spacevariable instead of the oldawpoh, ensuring consistency with the revised data structure.Documentation and Model Updates
PFCoilDatafor inner/outer radius, upper/lower/middle z locations, toroidal area, steel area, cable space area, bore field, outer midplane field, and detailed stress profiles.BuildDatafor better consistency (e.g., specifying "radial" thickness).temp_cs_superconductor_operatingas a new input and data variable for CS operating temperature.Plotting and Visualization
CSCoilandCsFatiguemodels.Cost Model
a_cs_cable_spacevariable, replacing the deprecatedawpoh.Checklist
I confirm that I have completed the following checks: