Skip to content

🎨 Pressure profile plot_proc#3870

Merged
jonmaddock merged 11 commits intomainfrom
pressure_profile_plot_proc
Oct 10, 2025
Merged

🎨 Pressure profile plot_proc#3870
jonmaddock merged 11 commits intomainfrom
pressure_profile_plot_proc

Conversation

@chris-ashe
Copy link
Copy Markdown
Collaborator

@chris-ashe chris-ashe commented Sep 25, 2025

This pull request introduces enhancements to the handling and reporting of plasma pressure profiles in the codebase. The main focus is on adding support for electron, ion, and fuel pressure profiles, ensuring these are properly calculated, initialized, and outputted. Additionally, the number of elements in plasma profiles is now tracked and reported.


❇️ New variables

pres_plasma_electron_profile
pres_plasma_ion_total_profile
pres_plasma_total_profile
pres_plasma_fuel_profile
n_plasma_profile_elements

Plasma pressure profile support:

  • Added new variables to physics_variables.py for storing electron, ion total, and fuel pressure profiles (pres_plasma_electron_profile, pres_plasma_ion_total_profile, pres_plasma_fuel_profile) and the number of profile elements (n_plasma_profile_elements). These are initialized in both the variable declarations and the init_physics_variables function.
  • In plasma_profiles.py, set n_plasma_profile_elements to profile_size during initialization, and calculated the electron, ion, and fuel pressure profiles in calculate_profile_factors.

Output improvements:

  • Updated physics.py to output the number of plasma profile elements and to iterate over and report each value in the electron, ion total, and fuel pressure profiles.

The plasma contour plot only works currently for the plasma shape selected with i_plasma_shape=1 as it is a continuous closed boundry`

image

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 self-assigned this Sep 25, 2025
@chris-ashe chris-ashe added the Input/Output Files Issues related to the input and output data files label Sep 25, 2025
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Sep 25, 2025

Codecov Report

❌ Patch coverage is 10.75697% with 224 lines in your changes missing coverage. Please review.
✅ Project coverage is 45.46%. Comparing base (50cfc49) to head (cc23e47).
⚠️ Report is 41 commits behind head on main.

Files with missing lines Patch % Lines
process/io/plot_proc.py 3.08% 220 Missing ⚠️
process/physics.py 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3870      +/-   ##
==========================================
- Coverage   46.45%   45.46%   -0.99%     
==========================================
  Files         123      123              
  Lines       28050    28875     +825     
==========================================
+ Hits        13030    13129      +99     
- Misses      15020    15746     +726     

☔ View full report in Codecov by Sentry.
📢 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 September 25, 2025 10:51
@chris-ashe chris-ashe force-pushed the pressure_profile_plot_proc branch from 24ee174 to 1d29150 Compare September 30, 2025 10:36
@jonmaddock jonmaddock requested review from jonmaddock and removed request for jonmaddock September 30, 2025 12:48
Copy link
Copy Markdown
Collaborator

@j-a-foster j-a-foster left a comment

Choose a reason for hiding this comment

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

Happy with changes.

@chris-ashe chris-ashe force-pushed the pressure_profile_plot_proc branch from 78acd11 to b129e9f Compare September 30, 2025 14:30
@chris-ashe chris-ashe requested a review from jonmaddock October 1, 2025 08:12
@chris-ashe chris-ashe force-pushed the pressure_profile_plot_proc branch from b129e9f to 408148a Compare October 2, 2025 10:00
@jonmaddock
Copy link
Copy Markdown
Contributor

jonmaddock commented Oct 7, 2025

@chris-ashe can you fix the integration test failures please?

@chris-ashe chris-ashe force-pushed the pressure_profile_plot_proc branch from dbcd067 to 3f6b0aa Compare October 7, 2025 13:47
Comment thread process/data_structure/physics_variables.py
Comment thread process/io/plot_proc.py


def plot_plasma_pressure_profiles(axis, mfile_data, scan):
# Plot the plasma pressure profiles on the given axis
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Docstring with types please.

Comment thread process/io/plot_proc.py Outdated
# Plot the plasma pressure profiles on the given axis
pres_plasma_profile = [
mfile_data.data[f"pres_plasma_electron_profile{i}"].get_scan(scan)
for i in range(500)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remove hardcoded list length please.

Comment thread process/io/plot_proc.py Outdated
plot_33 = fig18.add_subplot(111, aspect="equal")
plot_main_power_flow(plot_33, m_file_data, scan, fig18)

plot_34 = fig19.add_subplot(122)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I really don't like this hardcoding of pages, plots and figures: changing anything results in a huge amount of churn. Can you make an issue to turn this into a list and tag me in it?

Comment thread process/physics.py Outdated
"OP ",
)

for i in range(len(physics_variables.pres_plasma_electron_profile)):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you document somewhere that each element of the profile is actually a separate variable at this stage, rather than an array?

"""
# Default profile_size = 501, but it's possible to experiment with this value.
self.profile_size = 501
physics_variables.n_plasma_profile_elements = self.profile_size
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What is the point of this being stored on the class instance as well as an output variable? Does it need to be an output var?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It was originally just a class variable so that it could do its own array calc withing the class. I added it as an output to standardise our profile size and so we aren't hardcoding array sizes in the plotting scripts

Comment thread process/io/plot_proc.py
pres_plasma_profile_total = [
mfile_data.data[f"pres_plasma_total_profile{i}"].get_scan(scan)
for i in range(n_plasma_profile_elements)
]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seems like a fair bit of duplication for the 4 profiles now. Could you put all of this into a single function or loop?

physics_variables.pres_plasma_ion_total_profile = (
physics_variables.nd_ions_total
* (self.neprofile.profile_y / physics_variables.dene)
* (self.neprofile.profile_y / physics_variables.nd_plasma_electrons_vol_avg)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please fixup this commit: rebase conflicts not resolve correctly.

pres_plasma_fuel_profile = []
j_plasma_on_axis = 0.0
n_plasma_profile_elements = 0
n_plasma_profile_elements = 500
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this is duplicated in the profile class.

R._Stambaugh_normalised_beta_upper_limit_________________________________ (beta_norm_max_stambaugh)______ 2.06087953258754553e+00 OP
Plasma_thermal_energy_derived_from_thermal_beta_(J)______________________ (e_plasma_beta_thermal)________ 9.66355464245535374e+08 OP
Plasma_thermal_energy_derived_from_the_total_beta_(J)____________________ (e_plasma_beta)________________ 1.10779607068200541e+09 OP
Number_of_radial_points_in_plasma_profiles_______________________________ (n_plasma_profile_elements)____ 501
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think these numbers should disagree.

@chris-ashe chris-ashe force-pushed the pressure_profile_plot_proc branch 3 times, most recently from f76ce88 to 24d344f Compare October 8, 2025 10:36
…mproved performance and update related output handling
@chris-ashe chris-ashe force-pushed the pressure_profile_plot_proc branch from 24d344f to cc23e47 Compare October 9, 2025 12:05
@chris-ashe
Copy link
Copy Markdown
Collaborator Author

@jonmaddock Have added docstring and explanation to the 1D interpolation

@jonmaddock jonmaddock self-requested a review October 10, 2025 09:39
@chris-ashe chris-ashe removed the request for review from timothy-nunn October 10, 2025 09:40
@jonmaddock jonmaddock merged commit c9a56cd into main Oct 10, 2025
14 of 18 checks passed
@jonmaddock jonmaddock deleted the pressure_profile_plot_proc branch October 10, 2025 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Input/Output Files Issues related to the input and output data files New Variables

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants