Ensure i_plasma_pedestal=0 profile does not have 0 elements#4038
Ensure i_plasma_pedestal=0 profile does not have 0 elements#4038timothy-nunn merged 1 commit intomainfrom
Conversation
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
46a0131 to
0bcdc2e
Compare
|
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) |
There was a problem hiding this comment.
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.
grmtrkngtn
left a comment
There was a problem hiding this comment.
Please make the adjustment recommended in profiles.py
0bcdc2e to
560284b
Compare
|
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. |
Hi @ym1906 thanks for pointing that out. Should be corrected now. |
grmtrkngtn
left a comment
There was a problem hiding this comment.
Yes, looks good to me now. This fix removes the error when I run the helias_5b example file.

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