Skip to content

Expand fitted temperature range of impurities - #4521

Merged
clmould merged 9 commits into
mainfrom
expand_impurity_data_range
Aug 21, 2026
Merged

Expand fitted temperature range of impurities#4521
clmould merged 9 commits into
mainfrom
expand_impurity_data_range

Conversation

@chris-ashe

@chris-ashe chris-ashe commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Description

Updates the loss function data for impurities to comprise of 600 elements from 0.25 eV up to 500 keV

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 Impurities Plasma impurities label Aug 13, 2026
@chris-ashe chris-ashe changed the title Increase array dimensions for impurity radiation data structures from… Expand fitted temperature range of impurities Aug 13, 2026
@chris-ashe
chris-ashe force-pushed the expand_impurity_data_range branch from f233594 to 24adec2 Compare August 13, 2026 14:13
@codecov-commenter

codecov-commenter commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 49.46%. Comparing base (6b82c17) to head (0322c73).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4521      +/-   ##
==========================================
+ Coverage   49.43%   49.46%   +0.03%     
==========================================
  Files         150      150              
  Lines       29880    29912      +32     
==========================================
+ Hits        14771    14797      +26     
- Misses      15109    15115       +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.

@chris-ashe
chris-ashe marked this pull request as ready for review August 13, 2026 14:45
@chris-ashe
chris-ashe requested a review from a team as a code owner August 13, 2026 14:45
@chris-ashe
chris-ashe force-pushed the expand_impurity_data_range branch from 5ffc809 to a91ba5e Compare August 13, 2026 14:50
@@ -54,7 +54,7 @@ class ImpurityRadiationData:
)

n_charge_impurity_profile: list[float] = field(
default_factory=lambda: np.zeros((N_IMPURITIES, 200))
default_factory=lambda: np.zeros((N_IMPURITIES, 600))

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 we make 600 a constant at the top of this file?

Comment thread process/models/physics/impurity_radiation.py
@timothy-nunn timothy-nunn self-assigned this Aug 14, 2026
@timothy-nunn
timothy-nunn requested a review from a team August 14, 2026 07:32
@timothy-nunn

Copy link
Copy Markdown
Collaborator

Requesting modeller review to confirm changes to unit tests and regression tests are acceptable

@mkovari

mkovari commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Requesting modeller review to confirm changes to unit tests and regression tests are acceptable

As long as you can confirm you have checked that Lz and are the close to the old values for the old temperature range I don't there will be a problem.

I find the high value of Lz for Fe below 1 eV surprising, but since we never use temperatures below 1 eV, and we never use Fe, this is hardly an issue.

@timothy-nunn

Copy link
Copy Markdown
Collaborator

@mkovari here is a plot of the old data and new data (only the new data on the old time range). There is very little difference.
adas_radiation

Comment thread process/models/physics/impurity_radiation.py Outdated
@chris-ashe
chris-ashe requested a review from clmould August 17, 2026 08:14
@clmould clmould self-assigned this Aug 20, 2026
@@ -31,7 +34,8 @@ def initialise_imprad(data: DataStructure):
"""
errorflag = 0

table_length = 200 # Number of temperature and Lz values in data file
# Number of temperature and Lz values in data file
table_length = N_IMPURITIY_LOSS_FUNCTION_POINTS

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 agree with Tim's comment here - instead of having table_length = N_IMPURITIY_LOSS_FUNCTION_POINTS and then setting len_tab=table_length in all the calls to init_imp_element(), you can use len_tab=N_IMPURITIY_LOSS_FUNCTION_POINTS instead

if Path(data_folder).is_dir():
fig, ax = plt.subplots(figsize=(8, 6))
plot_line_brem_loss_function_profile(ax, impp=data_folder)
else:

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 don't think this else will ever be hit. Ik this if/else comes from summary.py so I think this was just super outdated and doesn't work as intended any more:

resources.path() returns a pathlib.Path object, so imp_path is always a path to Ar_lz_tau.dat, and then data_folder is always pointing to the lz_non_corona_14_elements folder, so Path(data_folder).is_dir() is always True, so it will never hit this else

I tried to hit the else - by deleting the lz_non_corona_14_elements folder, deleting all the entries in this folder, deleting some of the entries in this folder - but always end up with a FileNotFoundError or ModuleNotFoundError.

I think that removing the if/else and instead just calling the plotting function here and in summary.py will work the same, and if any .dat files are missing then that will be covered by the FileNotFoundErrors

Comment thread documentation/source/physics-models/plasma_radiation.md Outdated
chris-ashe and others added 7 commits August 20, 2026 13:24
… 200 to 600 to accommodate larger datasets. Updated relevant initialisation parameters in `impurity_radiation_variables.py` and `impurity_radiation.py`.
…date documentation

- Introduced `impurity_loss_functions.py` to plot Line and Bremsstrahlung loss function profiles.
- Updated the electron density in plasma radiation documentation from \(10^{19} \text{m}^{-3}\) to \(10^{20} \text{m}^{-3}\).
- Increased the source data points from 200 to 600 and adjusted the fitted temperature range.
…s function points and update related calculations
Co-authored-by: clmould <86794332+clmould@users.noreply.github.com>
@chris-ashe
chris-ashe force-pushed the expand_impurity_data_range branch from ecd167c to d48efdd Compare August 20, 2026 12:24
Comment thread process/core/io/plot/summary.py Outdated
Comment thread process/models/physics/impurity_radiation.py
@chris-ashe
chris-ashe requested a review from clmould August 21, 2026 09:54
@clmould
clmould merged commit d9cffbf into main Aug 21, 2026
8 of 11 checks passed
@clmould
clmould deleted the expand_impurity_data_range branch August 21, 2026 10:39
clmould added a commit to clmould/PROCESS-clair that referenced this pull request Aug 21, 2026
* Increase array dimensions for impurity radiation data structures from 200 to 600 to accommodate larger datasets. Updated relevant initialisation parameters in `impurity_radiation_variables.py` and `impurity_radiation.py`.

* Add plotting script for total impurity radiation loss function and update documentation

- Introduced `impurity_loss_functions.py` to plot Line and Bremsstrahlung loss function profiles.
- Updated the electron density in plasma radiation documentation from .
- Increased the source data points from 200 to 600 and adjusted the fitted temperature range.

* Update expected values in unit tests for impurity radiation calculations

* Enhance impurity loss function plotting with varied line styles for better visualization

* Refactor impurity radiation data structures to use a constant for loss function points and update related calculations

* Update documentation/source/physics-models/plasma_radiation.md

Co-authored-by: clmould <86794332+clmould@users.noreply.github.com>

* Fix impurity path error catching

* use N_IMPURITIY_LOSS_FUNCTION_POINTS directly instead of `table_length` alias

* Remove redundant assignment to impurity path

---------

Co-authored-by: clmould <86794332+clmould@users.noreply.github.com>
je-cook pushed a commit that referenced this pull request Aug 21, 2026
* Increase array dimensions for impurity radiation data structures from 200 to 600 to accommodate larger datasets. Updated relevant initialisation parameters in `impurity_radiation_variables.py` and `impurity_radiation.py`.

* Add plotting script for total impurity radiation loss function and update documentation

- Introduced `impurity_loss_functions.py` to plot Line and Bremsstrahlung loss function profiles.
- Updated the electron density in plasma radiation documentation from 10^19 10^20.
- Increased the source data points from 200 to 600 and adjusted the fitted temperature range.

* Update expected values in unit tests for impurity radiation calculations

* Enhance impurity loss function plotting with varied line styles for better visualization

* Refactor impurity radiation data structures to use a constant for loss function points and update related calculations

* Update documentation/source/physics-models/plasma_radiation.md



* Fix impurity path error catching

* use N_IMPURITIY_LOSS_FUNCTION_POINTS directly instead of `table_length` alias

* Remove redundant assignment to impurity path

---------

Co-authored-by: Christopher Ashe <91618944+chris-ashe@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Impurities Plasma impurities

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants