Skip to content

Add ion species enum - #4730

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

chris-ashe wants to merge 22 commits into
mainfrom
add_ion_species_enum_refresh

Conversation

@chris-ashe

Copy link
Copy Markdown
Member

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.

…ation for consistency across plotting scripts
…nSpecies enumeration for improved consistency
@chris-ashe chris-ashe added Radiation Plasma radiated power Refactor labels Nov 4, 2026
@chris-ashe chris-ashe changed the title Add ion species enum refresh Add ion species enum Nov 5, 2026
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown

⚠️ improve_quality_job warning!

Files changed by this PR have introduced 2 more linting errors when compared to main

Please fix these

To check what these are, run hatch run lint:fmt_extra on your branch and on main

@chris-ashe
chris-ashe marked this pull request as ready for review November 5, 2026 08:20
@chris-ashe
chris-ashe requested a review from a team as a code owner November 5, 2026 08:20
@codecov-commenter

codecov-commenter commented Nov 5, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 64.51613% with 44 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.37%. Comparing base (5e52d67) to head (c0b3b3d).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
process/core/io/plot/summary/profiles/radiation.py 4.34% 22 Missing ⚠️
process/models/physics/impurity_radiation.py 60.00% 6 Missing ⚠️
process/models/physics/physics.py 80.00% 4 Missing ⚠️
process/core/io/plot/summary/profiles/atomic.py 0.00% 3 Missing ⚠️
...ess/data_structure/impurity_radiation_variables.py 94.00% 3 Missing ⚠️
process/core/io/plot/summary/profiles/misc.py 33.33% 2 Missing ⚠️
process/core/io/plot/summary/profiles/plasma.py 33.33% 2 Missing ⚠️
process/core/io/plot/summary/plasma/physics.py 50.00% 1 Missing ⚠️
process/models/physics/radiation_power.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4730      +/-   ##
==========================================
+ Coverage   50.36%   50.37%   +0.01%     
==========================================
  Files         181      181              
  Lines       30666    30683      +17     
==========================================
+ Hits        15444    15456      +12     
- Misses      15222    15227       +5     

☔ 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 Nov 5, 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.

A few comments on the naming of certain enum fields. I think some stuff could be redefined to simplify the indexing.

Certain things could be added as a method on the enum to reduce duplication.

Comment on lines +192 to +193
for species in (species for species in IonSpecies if species.is_impurity):
ind = species.value - 1

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
for species in (species for species in IonSpecies if species.is_impurity):
ind = species.value - 1
for species in IonSpecies:
if species.is_impurity:
continue
ind = species.value - 1

Reading what is written currently confused me greatly... too many species

for species in (species for species in IonSpecies if species.is_impurity):
ind = species.value - 1
if imp_frac[ind] > 1.0e-30:
lbl = species.label.replace("_", "")

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 this be added as a method on the enum? e.g. species.symbol()

rho,
pden_rad_array[ind] * 1.0e-6,
label=imp_labels[ind].replace("_", ""),
label=species.label.replace("_", ""),

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 could be replaced by the aforementioned method

if not species.is_impurity:
continue

ind = species.value - 1

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 also do this calculation a lot. Could this also be a method to avoid someone making a mistake somewhere and forgetting the -1?

if imp_frac[ind] > 1.0e-30:
for species in IonSpecies:
if species.is_impurity and imp_frac[species.index] > 1.0e-30:
lbl = species.symbol

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.

species.symbol can be used directly below, it doesn't need to be assigned to a variable

# find impurity densities
imp_frac = np.array([
mfile.get(f"f_nd_impurity_electrons({i:02d})", scan=scan) for i in range(1, 15)
mfile.get(f"f_nd_impurity_electrons({i:02d})", scan=scan)

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
mfile.get(f"f_nd_impurity_electrons({i:02d})", scan=scan)
mfile.get(f"f_nd_impurity_electrons({i+1:02d})", scan=scan)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will break the indexing I think


impurity_frac = self.data.impurity_radiation.f_nd_impurity_electron_array[
self.data.reinke.impvardiv - 1
self.data.reinke.impvardiv

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.

Was this changed elsewhere in the code or was it a pre-existing bug?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indexes now start at 0 so all values are down shifted

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 file still has some uses of IonSpecies.value, can these be replaced with .index?

…acy and consistency in radiation calculations
…ion for improved clarity and consistency in radiation profile plotting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Radiation Plasma radiated power Refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants