Skip to content

Enforce tresca mises methods in tf stresscl()#4433

Merged
timothy-nunn merged 5 commits into
mainfrom
enforce_tresca_mises_methods_in_tf_stresscl
Jul 16, 2026
Merged

Enforce tresca mises methods in tf stresscl()#4433
timothy-nunn merged 5 commits into
mainfrom
enforce_tresca_mises_methods_in_tf_stresscl

Conversation

@chris-ashe

Copy link
Copy Markdown
Collaborator

This pull request refactors the calculation of Tresca and Von Mises stresses in the codebase to improve performance and maintainability. The main changes involve replacing legacy, hand-coded stress calculation logic with optimized, reusable functions, and updating all usages to rely on these new implementations. Additionally, related tests and unused code are cleaned up.

  • Updated process/models/tfcoil/base.py to use the new calculate_tresca_stress and calculate_von_mises_stress functions throughout, replacing manual calculations for both array and scalar cases.

Code cleanup:

  • Removed the old sigvm function from process/models/tfcoil/base.py as it is now superseded by the new stress calculation functions.
  • Deleted the obsolete test_sigvm test from tests/unit/models/tfcoil/test_tfcoil.py that directly tested the removed sigvm function.

These changes make the stress calculations more efficient, easier to maintain, and consistent across the codebase.## Description

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 Jul 13, 2026
@chris-ashe
chris-ashe requested a review from a team as a code owner July 13, 2026 11:29
@codecov-commenter

codecov-commenter commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 44.44444% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 48.63%. Comparing base (616f749) to head (18e8c43).
⚠️ Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
process/models/tfcoil/base.py 20.00% 4 Missing ⚠️
process/models/engineering/materials.py 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4433      +/-   ##
==========================================
- Coverage   48.63%   48.63%   -0.01%     
==========================================
  Files         151      151              
  Lines       29673    29674       +1     
==========================================
  Hits        14432    14432              
- Misses      15241    15242       +1     

☔ View full report in Codecov by Harness.
📢 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.

@timothy-nunn timothy-nunn self-assigned this Jul 15, 2026

@timothy-nunn timothy-nunn left a comment

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.

Happy with code changes. I have a few requests about tests to ensure these functions work with (combinations of) the types stated.

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.

Could you write a couple of quick tests for calculate_tresca_stress that check it returns the expected value when running with floats, numpy arrays, and mixtures of the two (if this makes sense).

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.

Is there an existing test for calculate_von_mises_stress? if not could this test be copied into the appropriate location for that function

@chris-ashe
chris-ashe requested a review from timothy-nunn July 16, 2026 10:29
@timothy-nunn
timothy-nunn merged commit c4a5893 into main Jul 16, 2026
9 of 11 checks passed
@timothy-nunn
timothy-nunn deleted the enforce_tresca_mises_methods_in_tf_stresscl branch July 16, 2026 12:32
mkovari pushed a commit that referenced this pull request Jul 17, 2026
* Change tresca stress calculation to be numba compliant for pytest

* Update von mises function to use numba

* 🔥 Remove `sigvm` method from TF base class and use the calculate_von_mises_stress function from materials file instead

* Add tests for Tresca stress calculation with various input types

* Add tests for von Mises stress calculation with various input types
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Refactor TF Coil Toroidal field coil

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants