Skip to content

Detailed plasma 4#4148

Open
chris-ashe wants to merge 35 commits intomainfrom
detailed_plasma_4
Open

Detailed plasma 4#4148
chris-ashe wants to merge 35 commits intomainfrom
detailed_plasma_4

Conversation

@chris-ashe
Copy link
Copy Markdown
Collaborator

This pull request adds several new plasma physics variables to the physics_variables.py data structure, primarily focused on collision times, collision frequencies, mean free paths, and resistivity profiles for various plasma species. These additions enhance the granularity and detail of plasma modeling, especially for electron interactions with deuterons, tritons, and alpha particles.

New plasma variable additions:

  • Added profiles for Spitzer classical resistivity, electron-alpha Spitzer slowing down time, and various collision times, collision frequencies, and mean free paths between electrons and other plasma species (deuterons, tritons, alpha particles) to the data structure (process/data_structure/physics_variables.py).
    Initialization updates:

  • Updated the init_physics_variables function to include initialization and zeroing of the new plasma variable profiles and to ensure these new variables are properly set up as empty lists or default values (process/data_structure/physics_variables.py).

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 Plotting labels Mar 30, 2026
Comment thread process/models/physics/physics.py Outdated
@chris-ashe chris-ashe marked this pull request as ready for review April 10, 2026 15:44
@chris-ashe chris-ashe requested a review from a team as a code owner April 10, 2026 15:44
@chris-ashe chris-ashe requested review from Copilot and je-cook April 10, 2026 15:44
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 10, 2026

Codecov Report

❌ Patch coverage is 51.56250% with 186 lines in your changes missing coverage. Please review.
✅ Project coverage is 49.69%. Comparing base (7b5ea2b) to head (7b3c464).

Files with missing lines Patch % Lines
process/core/io/plot/summary.py 7.81% 118 Missing ⚠️
process/models/physics/physics.py 46.03% 68 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4148      +/-   ##
==========================================
+ Coverage   49.63%   49.69%   +0.06%     
==========================================
  Files         148      148              
  Lines       29746    30098     +352     
==========================================
+ Hits        14764    14957     +193     
- Misses      14982    15141     +159     

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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds additional detailed physics outputs for collisions (times/frequencies/mean free paths), Spitzer slowing-down time, and Spitzer resistivity, and exposes them through unit tests, MFILE output, and summary plotting.

Changes:

  • Compute and output new collision-related profiles plus Spitzer slowing-down time and Spitzer resistivity in DetailedPhysics.run() / output_detailed_physics().
  • Extend the physics variable data structure and initialization to include the new profiles.
  • Add plotting helpers and extra summary pages to visualize the new profiles; extend the detailed-physics unit test to assert the new outputs are finite and correctly shaped.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
tests/unit/test_physics.py Adds assertions for the new detailed-physics profiles.
process/models/physics/physics.py Computes new collision/resistivity/slowing-down profiles; outputs them to MFILE.
process/data_structure/physics_variables.py Adds new profile variables and initializes them.
process/core/io/plot/summary.py Adds plots for new profiles and adjusts summary pagination/layout.
documentation/source/physics-models/detailed_physics.md Documents new formulas for the added detailed-physics quantities.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/unit/test_physics.py Outdated
)

# ============================
# Resistivites
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

Section header comment has a typo ("Resistivites"). Please correct to "Resistivities" for consistency and readability.

Suggested change
# Resistivites
# Resistivities

Copilot uses AI. Check for mistakes.
Comment on lines +5155 to +5159
physics_variables.res_plasma_fuel_spitzer_profile = self.calculate_spitzer_resistivity(
n_charge=1,
electron_ion_coulomb_log=physics_variables.plasma_coulomb_log_electron_deuteron_profile,
temp_plasma_electron_kev=self.plasma_profile.teprofile.profile_y,
)
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

Spitzer resistivity is being stored in res_plasma_fuel_spitzer_profile, but the data structure also introduces rho_plasma_spitzer_classical_profile (which remains unused). Please align naming/usage (e.g., populate the newly-added *_spitzer_classical_profile, or remove/rename it) so there is a single canonical variable for the Spitzer resistivity profile.

Suggested change
physics_variables.res_plasma_fuel_spitzer_profile = self.calculate_spitzer_resistivity(
n_charge=1,
electron_ion_coulomb_log=physics_variables.plasma_coulomb_log_electron_deuteron_profile,
temp_plasma_electron_kev=self.plasma_profile.teprofile.profile_y,
)
physics_variables.rho_plasma_spitzer_classical_profile = self.calculate_spitzer_resistivity(
n_charge=1,
electron_ion_coulomb_log=physics_variables.plasma_coulomb_log_electron_deuteron_profile,
temp_plasma_electron_kev=self.plasma_profile.teprofile.profile_y,
)
physics_variables.res_plasma_fuel_spitzer_profile = (
physics_variables.rho_plasma_spitzer_classical_profile
)

Copilot uses AI. Check for mistakes.
Comment thread process/data_structure/physics_variables.py Outdated
Comment thread documentation/source/physics-models/detailed_physics.md
Comment thread process/core/io/plot/summary.py Outdated
scan :
axis : plt.Axes
Axis object to plot on
mfile_data : mf.MFile
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

Docstring parameter type refers to mf.MFile, but mf is not imported and the function signature uses MFile. Update the docstring type to MFile for accuracy.

Suggested change
mfile_data : mf.MFile
mfile_data : MFile

Copilot uses AI. Check for mistakes.
Comment thread process/core/io/plot/summary.py Outdated
Comment on lines +12934 to +12939
axis : plt.Axes
Axis object to plot on
mfile_data : mf.MFile
MFILE data object
scan : int
Scan number to use
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

Docstring parameter type refers to mf.MFile, but mf is not imported and the function signature uses MFile. Update the docstring type to MFile for accuracy.

Copilot uses AI. Check for mistakes.
Comment thread process/core/io/plot/summary.py Outdated
Comment on lines 13166 to 13167
"""Plot the plasma coloumb logarithms on the given axis.

Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

Function name and docstring use the misspelling "coloumb". Consider renaming to "coulomb" (keeping a backward-compatible alias if needed) and correcting the docstring text to avoid propagating the typo.

Suggested change
"""Plot the plasma coloumb logarithms on the given axis.
"""Backward-compatible alias for plotting plasma Coulomb logarithms."""
return plot_plasma_coulomb_logarithms(axis, mfile_data, scan)
def plot_plasma_coulomb_logarithms(axis: plt.Axes, mfile_data: MFile, scan: int) -> None:
"""Plot the plasma Coulomb logarithms on the given axis.

Copilot uses AI. Check for mistakes.
Comment thread process/models/physics/physics.py
Comment thread documentation/source/physics-models/detailed_physics.md Outdated
@chris-ashe chris-ashe requested a review from j-a-foster April 13, 2026 10:22
Copy link
Copy Markdown
Collaborator

@je-cook je-cook left a comment

Choose a reason for hiding this comment

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

Just the one from me

Comment thread process/core/io/plot/summary.py Outdated
Copy link
Copy Markdown
Collaborator

@je-cook je-cook left a comment

Choose a reason for hiding this comment

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

Mostly minors on top of my docstring one from before. I havent looked into the maths. I assume your tests cover the results of the calculations, if not we need a test for that

Comment thread process/core/io/plot/summary.py Outdated
Comment thread process/core/io/plot/summary.py Outdated
Comment thread process/core/io/plot/summary.py Outdated
…eron, electron-triton, and electron-alpha interactions in plasma
…ron, electron-triton, deuteron-triton, and electron-alpha interactions
…, electron-deuteron, electron-triton, and electron-alpha interactions
…ctron, electron-deuteron, electron-triton, and electron-alpha interactions
…, electron-deuteron, electron-triton, and electron-alpha interactions
chris-ashe and others added 3 commits April 15, 2026 15:06
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@chris-ashe chris-ashe requested a review from je-cook April 15, 2026 14:18
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 Plotting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants