Skip to content

♻️ Refactor Bruner div heat split - #4511

Open
chris-ashe wants to merge 27 commits into
mainfrom
add_bruner_div_heat_split
Open

♻️ Refactor Bruner div heat split#4511
chris-ashe wants to merge 27 commits into
mainfrom
add_bruner_div_heat_split

Conversation

@chris-ashe

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

Copy link
Copy Markdown
Collaborator

Description

This pull request introduces significant improvements to the plasma exhaust modeling and visualization in PROCESS. The main changes include the addition of new documentation for plasma exhaust physics, refactoring and renaming of variables related to divertor power splits for clarity and consistency, and the implementation of new plotting functions to visualize separatrix power splits and Brunner model power sharing. These updates enhance both the usability and accuracy of the plasma exhaust modeling, while also improving the documentation and user interface.

Plasma Exhaust Modeling and Documentation:

  • Added a comprehensive new documentation page (plasma_exhaust.md) describing separatrix power, divertor protection metrics, and the Brunner model for power splits.
  • Added Plasma Exhaust to the navigation in mkdocs.yml for easier access to the new documentation.

Variable Renaming and Data Structure Updates:

  • Refactored all instances of f_p_div_lower to f_p_div_lower_separatrix and updated related obsolete variable mappings for clarity and consistency in input, scan, and obsolete variable code.
  • Expanded PhysicsData to include explicit variables for separatrix power splits and target powers (e.g., f_p_div_inboard_separatrix, p_div_lower_inboard_separatrix_mw, etc.), replacing ambiguous or legacy variable names.

Visualization and Plotting Enhancements:

  • Added two new plotting functions: one for visualizing Brunner divertor power splits as a stack plot, and another for displaying separatrix power splits as a bar chart, both integrated into the summary plotting workflow.
  • Ensured that these new visualizations are included in the plasma exhaust summary page for improved user analysis.

Large tokamak

image

ST

image

Codebase Maintenance:

  • Updated imports and references to support new models and maintain code clarity, including importing DivertorNumberModels and PlasmaExhaust where required. [1] [2]

These changes collectively improve the clarity, maintainability, and scientific accuracy of the plasma exhaust modeling in PROCESS, while also enhancing the user experience through better documentation and visualization.

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 Physics Relating to the physics models Divertor Scrape off Layer Relating to the scrape off layer outside the plasma separatrix labels Aug 10, 2026
@codecov-commenter

codecov-commenter commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 34.53608% with 127 lines in your changes missing coverage. Please review.
✅ Project coverage is 49.26%. Comparing base (c0ae5b2) to head (7769f8a).

Files with missing lines Patch % Lines
process/core/io/plot/summary.py 4.76% 80 Missing ⚠️
process/models/physics/exhaust.py 55.17% 26 Missing ⚠️
process/models/physics/physics.py 0.00% 16 Missing ⚠️
process/models/physics/scrape_off_layer.py 0.00% 4 Missing ⚠️
process/models/build.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4511      +/-   ##
==========================================
- Coverage   49.32%   49.26%   -0.07%     
==========================================
  Files         150      150              
  Lines       29802    29940     +138     
==========================================
+ Hits        14700    14750      +50     
- Misses      15102    15190      +88     

☔ 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 changed the title Add bruner div heat split ♻️ Refactor Bruner div heat split Aug 14, 2026
@chris-ashe
chris-ashe force-pushed the add_bruner_div_heat_split branch from e5d6816 to 95eb74f Compare August 14, 2026 12:49
…date references in plasma calculations; add Brunner's method for divertor power splits calculation
…rSeparatrixPowerSplits dataclass and update related methods
… and distances for double null configuration
… inner divertor power splits and update references
@chris-ashe
chris-ashe force-pushed the add_bruner_div_heat_split branch from 95eb74f to 6168a31 Compare August 17, 2026 08:58
@chris-ashe
chris-ashe marked this pull request as ready for review August 17, 2026 09:50
@chris-ashe
chris-ashe requested a review from a team as a code owner August 17, 2026 09:50

@staticmethod
def calculate_brunner_divertor_power_splits(
dr_plasma_outboard_midplane_separatrix_separation: float,

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 name is far too long to be used in the function (hence the formatting nightmare), fine if you want it for input but please rename it to something more useable inside the function

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

I think generally looks fine, some stylistic things and a model review required.

I have general comment on long variable names. I understand and mostly agree with the reasoning within the data structure (as that is user facing).
However within functions I think long variable names are less readable and make the code harder to read not easier. I have to scroll either along or down remove all the extraneous information and then see what the calculation is. This is annoying when its everywhere.

My suggestion is when creating variables within a function that they are reasonably short, not necessarily 6char limits or anything silly but just shorter. Anything thats user facing (function I/O, data structure), continue as before.

Happy to have a discussion here (or offline)

f_p_outboard_upper = np.zeros_like(dr_sep_values)

for idx, dr_sep in enumerate(dr_sep_values):
div_power_splits = PlasmaExhaust().calculate_brunner_divertor_power_splits(

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.

As your using it here you dont need to initialise the PlasmaExhaust class (its a staticmethod).

I would suggest moving the method out of the class and just leaving in the the exhaust file and calling that here. If you need it on the class for some reason have a method that passes all logic to the function.

"""Plot Brunner divertor power split fractions as a stack plot over dr_sep."""
# Use the case decay length when available; fall back to 1 mm if absent.

len_plasma_sol_outboard_power_decay = mfile.get(

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.

then you only need one call to mfile (as you've used below). Also we're inside a function you dont need to use the full length of all the names here, this is probably a general point I will flag too

Suggested change
len_plasma_sol_outboard_power_decay = mfile.get(
len_sol_outboard_pd, len_sol_inboard_pd = mfile.get_variables("len...", "len...", scan=scan)

Comment on lines +372 to +437
po.ovarre(
self.outfile,
"Required distance between the first and second plasma separatrixes at "
"the outer midplane (δR_sep) [m]",
"(dr_plasma_outboard_midplane_separatrix_separation)",
self.data.physics.dr_plasma_outboard_midplane_separatrix_separation,
"OP ",
)
po.oblnkl(self.outfile)

po.ovarre(
self.outfile,
"Outboard side heat flux decay length (m)",
"(len_sol_outboard_power_decay)",
self.data.physics.len_sol_outboard_power_decay,
"OP ",
)
po.oblnkl(self.outfile)

po.ovarre(
self.outfile,
"Fraction of separatrix power on the inner target(s)",
"(f_p_div_inboard_separatrix)",
self.data.physics.f_p_div_inboard_separatrix,
"OP ",
)
po.ovarre(
self.outfile,
"Fraction of separatrix power on the outer target(s)",
"(f_p_div_outboard_separatrix)",
self.data.physics.f_p_div_outboard_separatrix,
"OP ",
)

po.oblnkl(self.outfile)

po.ovarre(
self.outfile,
"Fraction of separatrix power on the inner lower target",
"(f_p_div_lower_inboard_separatrix)",
self.data.physics.f_p_div_lower_inboard_separatrix,
"OP ",
)
po.ovarre(
self.outfile,
"Separatrix power on the inner lower target",
"(p_div_lower_inboard_separatrix_mw)",
self.data.physics.p_div_lower_inboard_separatrix_mw,
"OP ",
)
po.oblnkl(self.outfile)

po.ovarre(
self.outfile,
"Fraction of separatrix power on the outer lower target",
"(f_p_div_lower_outboard_separatrix)",
self.data.physics.f_p_div_lower_outboard_separatrix,
"OP ",
)
po.ovarre(
self.outfile,
"Separatrix power on the outer lower target",
"(p_div_lower_outboard_separatrix_mw)",
self.data.physics.p_div_lower_outboard_separatrix_mw,
"OP ",
)

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 kind of style makes big output blocks much easier to read IMO. Less duplication of function calls and thier arguments, below suggestion is not finished just for gist

Suggested change
po.ovarre(
self.outfile,
"Required distance between the first and second plasma separatrixes at "
"the outer midplane (δR_sep) [m]",
"(dr_plasma_outboard_midplane_separatrix_separation)",
self.data.physics.dr_plasma_outboard_midplane_separatrix_separation,
"OP ",
)
po.oblnkl(self.outfile)
po.ovarre(
self.outfile,
"Outboard side heat flux decay length (m)",
"(len_sol_outboard_power_decay)",
self.data.physics.len_sol_outboard_power_decay,
"OP ",
)
po.oblnkl(self.outfile)
po.ovarre(
self.outfile,
"Fraction of separatrix power on the inner target(s)",
"(f_p_div_inboard_separatrix)",
self.data.physics.f_p_div_inboard_separatrix,
"OP ",
)
po.ovarre(
self.outfile,
"Fraction of separatrix power on the outer target(s)",
"(f_p_div_outboard_separatrix)",
self.data.physics.f_p_div_outboard_separatrix,
"OP ",
)
po.oblnkl(self.outfile)
po.ovarre(
self.outfile,
"Fraction of separatrix power on the inner lower target",
"(f_p_div_lower_inboard_separatrix)",
self.data.physics.f_p_div_lower_inboard_separatrix,
"OP ",
)
po.ovarre(
self.outfile,
"Separatrix power on the inner lower target",
"(p_div_lower_inboard_separatrix_mw)",
self.data.physics.p_div_lower_inboard_separatrix_mw,
"OP ",
)
po.oblnkl(self.outfile)
po.ovarre(
self.outfile,
"Fraction of separatrix power on the outer lower target",
"(f_p_div_lower_outboard_separatrix)",
self.data.physics.f_p_div_lower_outboard_separatrix,
"OP ",
)
po.ovarre(
self.outfile,
"Separatrix power on the outer lower target",
"(p_div_lower_outboard_separatrix_mw)",
self.data.physics.p_div_lower_outboard_separatrix_mw,
"OP ",
)
for op in [
(
"Required distance between the first and second plasma separatrixes at "
"the outer midplane (δR_sep) [m]",
"(dr_plasma_outboard_midplane_separatrix_separation)",
self.data.physics.dr_plasma_outboard_midplane_separatrix_separation,
),
None,
(...),
]:
if op is None:
po.oblnkl(self.outfile)
else:
desc, var, val = op
po.ovvare(self.outfile, desc, var, val, "OP ")

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 rather imagined that the new data structure would allow us to write something simple like
Output variables a, b, c, d

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.

soon :)

return p_plasma_rad_mw / p_plasma_heating_mw

@staticmethod
def calculate_brunner_divertor_power_splits(

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 I have @ukaea/process-model-review look at this please

@je-cook
je-cook requested a review from a team August 18, 2026 12:44
@je-cook je-cook self-assigned this Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Divertor Physics Relating to the physics models Refactor Scrape off Layer Relating to the scrape off layer outside the plasma separatrix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants