Skip to content

Refactor fusion reactions for dataclass - #4592

Open
chris-ashe wants to merge 22 commits into
mainfrom
refactor_fus_reactions_dataclass
Open

chris-ashe wants to merge 22 commits into
mainfrom
refactor_fus_reactions_dataclass

Conversation

@chris-ashe

@chris-ashe chris-ashe commented Sep 10, 2026

Copy link
Copy Markdown
Member

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.

…aged' terminology for consistency across the codebase
…aged' terminology for consistency across the codebase
…ed' terminology for consistency across the codebase
…minology for consistency across the codebase
…ons classes for improved modularity and clarity in calculations
…lasmaReactions class for improved organization and clarity
@chris-ashe chris-ashe added Physics Relating to the physics models Refactor Variable rename labels Sep 10, 2026
…terminology for consistency across the codebase
@codecov-commenter

codecov-commenter commented Sep 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 37.34940% with 156 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.09%. Comparing base (4618fd4) to head (366cbcb).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
process/models/physics/fusion_reactions.py 32.07% 108 Missing ⚠️
process/core/io/plot/summary.py 0.00% 28 Missing ⚠️
process/models/physics/physics.py 23.52% 13 Missing ⚠️
process/models/stellarator/stellarator.py 0.00% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4592      +/-   ##
==========================================
+ Coverage   49.91%   50.09%   +0.18%     
==========================================
  Files         151      151              
  Lines       29860    29958      +98     
==========================================
+ Hits        14904    15008     +104     
+ Misses      14956    14950       -6     

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

…wer density variables and update related calculations for consistency
…minology for consistency across plasma reactions and related calculations
@chris-ashe
chris-ashe marked this pull request as ready for review September 11, 2026 09:27
@chris-ashe
chris-ashe requested a review from a team as a code owner September 11, 2026 09:27

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

Will need a modeller to check some of the model changes (even if results have not changed) and new tests

Regression test failing:

FAILED tests/regression/test_process_input_files.py::test_input_file[stellarator_helias] - AttributeError: module 'process.models.physics.fusion_reactions' has no attribute 'FusionReactionRate'

Some unit tests are also failing

Comment on lines +262 to +263
def _make_beam_fusion_reactions():
return reactions.BeamReactions(data=DataStructure())

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.

This should be a fixture rather than a helper function

fusden_plasma_alpha_vol_avg: float = 0.0
fusden_plasma_protons_vol_avg: float = 0.0

def __iadd__(self, other: "FusionYieldDensities") -> Self:

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 would add some validation to this method which raises an error if other is not an instance of type(self)

fusden_plasma_alpha_vol_avg: float = 0.0
fusden_plasma_protons_vol_avg: float = 0.0

def __iadd__(self, other: "FusionYieldDensities") -> Self:

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.

Can we also add a specific unit test just dedicated to testing the addition of two FusionYieldDensities works correctly

fusden_plasma_alpha_vol_avg: float = 0.0
fusden_plasma_protons_vol_avg: float = 0.0

def __iadd__(self, other: "FusionYieldDensities") -> Self:

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.

Suggested change
def __iadd__(self, other: "FusionYieldDensities") -> Self:
def __iadd__(self, other: FusionYieldDensities) -> Self:

Add this line to the top of the file also

from __future__ import annotations

return self


class PlasmaReactions:

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.

If this is a model in main.py it should inherit from process.core.model.Model like other models.

Take a look at another model but this means it should not explicitly be passed the data structure.

po.oblnkl(self.outfile)


class BeamReactions:

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.

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.

We need to create an issue to remove the state in these models. Any self.xyz data should be in the data structure!

@timothy-nunn
timothy-nunn requested a review from a team September 18, 2026 08:42
@mkovari

mkovari commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator

Will need a modeller to check some of the model changes (even if results have not changed) and new tests

If this is purely a refactor there shouldn't be any model changes. Can you clarify?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Physics Relating to the physics models Refactor Variable rename

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants