Fix bug in collapse_array for point objects of DFT fields in 1D cell and add unit test#3010
Conversation
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #3010 +/- ##
==========================================
- Coverage 73.81% 73.79% -0.03%
==========================================
Files 18 18
Lines 5423 5445 +22
==========================================
+ Hits 4003 4018 +15
- Misses 1420 1427 +7 🚀 New features to boost your workflow:
|
|
Looks like this was introduced in #1333 by @smartalecH, any comments? Seems like this should affect all cases where you have a DFT monitor that is a single point, not just 1d. |
|
It would be good to double-check a 2d case with a single-point DFT monitor: presumably that was also wrong before this PR, and is now fixed. |
I have verified that this bug was also present in 2D. The test is a 2D version of the 1D test in this PR. This bug fix produces the correct results in 2D as well. The test script and results are available in this gist. |
Fixes #3009.
This PR fixes a bug in the
collapse_arrayroutine used byfields::get_dft_arrayshown below whereby specifying a point object in a 1D cell (via either a 1D or 3D simulation) resulted in the fields of only a single restricted point to be returned rather than the sum of all the restricted points (including their weights).A unit test is also included which verifies two properties of the DFT fields of a planewave in vacuum of a 1D cell obtained using a 1D and 3D simulation: (1) the relative phase of two different points in the 1D cell agree with the expected analytic result and (2) the DFT fields at the two points are the same whether they are obtained from either a single point or an array slice of the DFT fields.
meep/src/dft.cpp
Lines 1268 to 1276 in bc5ac50