Skip to content

prevent log(0) in sauter bootstrap calculation - #4717

Merged
timothy-nunn merged 1 commit into
mainfrom
fix-sauter-zero-density
Oct 30, 2026
Merged

timothy-nunn merged 1 commit into
mainfrom
fix-sauter-zero-density

Conversation

@grmtrkngtn

@grmtrkngtn grmtrkngtn commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Add a small lower bound to the electron-density profile before it is used in the Sauter bootstrap-current calculation:

Calculate electron and ion density profiles

ne = np.maximum(ne, 1.0e-6)

context

During normal PROCESS optimisation the density profile remains within the expected physical domain, but UQ sampling deliberately explores a much wider region of parameter space, including trial points that may be far from a feasible solution.

At some of these trial points, one or more values in the calculated electron-density profile can reach zero. Passing these values into the Sauter calculation results in log(0), producing non-finite values and causing the model evaluation to fail.

This is particularly problematic for because an invalid intermediate trial point can terminate or destabilise the optimisation even when a valid equilibrium exists elsewhere in the search space.

solution

The guard is applied only to the local density array used in the bootstrap-current calculation and does not modify the underlying PROCESS density variable or density profile. Itprevents log(0) and subsequent NaN propagation and allows the optimiser to move through otherwise invalid intermediate trial points.

@grmtrkngtn
grmtrkngtn requested a review from a team as a code owner October 28, 2026 14:36
@grmtrkngtn grmtrkngtn added Bootstrap Current Bootstrap current generated by the plasma Bug Something isnt working labels Oct 28, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 50.26%. Comparing base (1fcc5ab) to head (7238d39).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4717   +/-   ##
=======================================
  Coverage   50.26%   50.26%           
=======================================
  Files         181      181           
  Lines       30629    30630    +1     
=======================================
+ Hits        15395    15396    +1     
  Misses      15234    15234           

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

@timothy-nunn
timothy-nunn requested a review from a team October 28, 2026 15:19
@timothy-nunn timothy-nunn self-assigned this Oct 29, 2026
@mkovari

mkovari commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator

I am sure this is fine for the moment.

The profile code has a lot of places where density or temperature could become negative or where the gradients could become negative. In the future it would be nice to sort this out properly.

@timothy-nunn
timothy-nunn merged commit f823c58 into main Oct 30, 2026
10 of 11 checks passed
@timothy-nunn
timothy-nunn deleted the fix-sauter-zero-density branch October 30, 2026 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bootstrap Current Bootstrap current generated by the plasma Bug Something isnt working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants