Skip to content

Detailed plasma 4#4148

Merged
je-cook merged 35 commits intomainfrom
detailed_plasma_4
Apr 17, 2026
Merged

Detailed plasma 4#4148
je-cook merged 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
Comment thread process/core/io/plot/summary.py Outdated
Comment thread process/core/io/plot/summary.py Outdated
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
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.

Approving from the code side. Modelling should be reviewed too

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 enabled auto-merge (squash) April 17, 2026 11:00
@je-cook je-cook disabled auto-merge April 17, 2026 11:19
@je-cook je-cook merged commit 7fd03c5 into main Apr 17, 2026
8 of 11 checks passed
@je-cook je-cook deleted the detailed_plasma_4 branch April 17, 2026 11:19
grmtrkngtn pushed a commit that referenced this pull request Apr 17, 2026
* Add methods to calculate electron-electron and electron-ion collision times

* Refactor plotting functions into DetailedPhysics class for better organization and maintainability

* Add profile for electron-electron collision time in plasma

* Add collision time calculations and plotting to DetailedPhysics class

* Add profiles for electron-deuteron and electron-triton collision times in plasma

* Add electron-deuteron and electron-triton collision time calculations and profiles to DetailedPhysics class

* Add profile for electron-alpha collision time in plasma

* Add electron-alpha thermal collision time calculations and profile to DetailedPhysics class

* Add collision frequency profiles for electron-electron, electron-deuteron, electron-triton, and electron-alpha interactions in plasma

* Add collision frequency calculations and plotting for electron interactions in DetailedPhysics class

* Add mean free path profiles for electron interactions in physics_variables module

* Add mean free path calculations and plotting for electron interactions in DetailedPhysics class

* Add Spitzer ion slowing down time calculation to DetailedPhysics class

* Add electron-alpha Spitzer slowing down time profile to physics_variables module

* Add Spitzer ion slowing down time calculation and plotting to DetailedPhysics class

* Add Spitzer resistivity calculations and plotting to DetailedPhysics class

* Adjust subplot spacing in main_plot function for improved layout

* Post rebase commits

* Update docs and tidy functions

* Add fuel-specific Spitzer resistivity calculations and update related tests

* Add volume averaged thermal velocities for electrons, deuterons, tritons, and alpha particles

* Add volume averaged Coulomb logarithm calculations for electron-deuteron, electron-triton, deuteron-triton, and electron-alpha interactions

* Update Spitzer label formatting in ion slowing down time and resistivity profile plots

* Add volume averaged collision time calculations for electron-electron, electron-deuteron, electron-triton, and electron-alpha interactions

* Add volume averaged collision frequency calculations for electron-electron, electron-deuteron, electron-triton, and electron-alpha interactions

* Add volume averaged mean free path calculations for electron-electron, electron-deuteron, electron-triton, and electron-alpha interactions

* Add volume averaged Spitzer resistivity calculations for plasma fuel ions

* Add volume averaged plasma frequency and Larmor frequency calculations for electrons, deuterons, and tritons

* Add volume averaged toroidal Larmor radius calculations for deuterons and tritons

* Add volume averaged electron-alpha Spitzer slowing down time calculations

* Add function to plot detailed plasma parameters from physics data

* Add test for detailed physics profile computations with monkeypatching

* Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Refactor Debye length and velocity profile plotting functions to simplify docstrings and improve readability

* Refactor plot_detailed_plasma_parameters to use variables for bounding box styles for improved readability

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.

5 participants