Commit 04bb5e5
Fix NaN handling in electrostatic_sphere_eb MR analysis (#6807)
## Summary
In IEEE floats, `np.nan != np.nan` is _always_ `True`, so the old code
was buggy:
NaN is never equal to anything, _including itself_.
## Original Description - Spotted by @zippylab
The find_first_non_zero_from_bottom_left/upper_right helper functions
used ``matrix[i][j] != np.nan`` to skip NaN values. Per IEEE 754, NaN !=
NaN is always True, so this check never filtered out NaN cells.
On GPU platforms where openpmd outputs NaN for cells outside the refined
patch (rather than zero), the analysis selected NaN regions as valid
data, producing ``nan`` errors for level 1 and failing the assertion.
Fix: replace ``!= np.nan`` with ``not np.isnan()``.
With the fix, level 1 errors on A100 GPU are 0.029% (phi) and 0.083%
(Er), well within the 0.4% tolerance.
## X-ref
Isolated from #6801
Co-authored-by: Tim Williams <tjwilliams@anl.gov>1 parent bc30e14 commit 04bb5e5
1 file changed
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
0 commit comments