Skip to content

Conversation

@timothy-nunn
Copy link
Collaborator

Adds in a check of the profile_y when i_plasma_pedestal=0 to set any 0 elements to be slightly above 0, hence avoiding divide by 0's.

@timothy-nunn timothy-nunn linked an issue Jan 8, 2026 that may be closed by this pull request
@timothy-nunn timothy-nunn requested a review from ym1906 January 8, 2026 15:26
@timothy-nunn
Copy link
Collaborator Author

Just to clarify this is what the profile looks like
image

Obviously, that was the case before except the final point is now at 1e-8 not 0.0

@codecov-commenter
Copy link

codecov-commenter commented Jan 8, 2026

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.30%. Comparing base (8a4d67c) to head (560284b).

Files with missing lines Patch % Lines
process/profiles.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4038      +/-   ##
==========================================
- Coverage   46.30%   46.30%   -0.01%     
==========================================
  Files         123      123              
  Lines       28961    28962       +1     
==========================================
  Hits        13411    13411              
- Misses      15550    15551       +1     

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

@timothy-nunn timothy-nunn force-pushed the 2964-stellarator-divide-by-0-warning branch from 46a0131 to 0bcdc2e Compare January 8, 2026 16:55
@timothy-nunn timothy-nunn requested a review from ym1906 January 8, 2026 16:55
@ym1906
Copy link
Collaborator

ym1906 commented Jan 9, 2026

Did this remove the error for you @timothy-nunn ?

self.profile_y = n0 * (1 - rho**2) ** alphan
# profile values of 0 cause divide by 0 errors so ensure the profile value is at least 1e-8
# which is small enough that it won't make a difference to any calculations
self.profile_y = np.maximum(n0 * (1 - rho**2) ** alphan, 1e-8)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is actually being overwritten by the following code, so the fix isn't applied and the error persists. We should add a return statement after this, then an else or "if physics.variables.i_plasma_pedestal == 1" to ensure the code runs correctly.

Copy link
Collaborator

@ym1906 ym1906 left a comment

Choose a reason for hiding this comment

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

Please make the adjustment recommended in profiles.py

@timothy-nunn timothy-nunn force-pushed the 2964-stellarator-divide-by-0-warning branch from 0bcdc2e to 560284b Compare January 9, 2026 13:17
@ym1906
Copy link
Collaborator

ym1906 commented Jan 9, 2026

One more thing @timothy-nunn the change is only applied to the ne profile but actually the bug occurs with the te profile, we should apply the same solution there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stellarator divide by 0 warning

4 participants