Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

include interpolation weights in DFT slice output #787

Merged
merged 3 commits into from
Mar 28, 2019
Merged

Conversation

stevengj
Copy link
Collaborator

@stevengj stevengj commented Mar 27, 2019

This ensures that empty dimensions are collapsed correctly. I think this should fix #784 — what was happening is that at "unlucky" resolutions where the DFT slice fell between two pixels, the collapse_empty_dims was summing over two pixels in the empty direction, but without the interpolation weights this effectively doubled the field value, resulting in the factor-of-two oscillation observed in #784.

One downside of this PR is that, at the edges of the output volume, the edge pixels might be multiplied by an integration weight factor (between 0 and 1). It might be nice to only include the interpolation weights for empty dimensions, but not for edge pixels, but that would require some additional work (e.g. a different IVEC_LOOP_WEIGHT function or a modified loop_in_chunks). Update: Now the PR only includes the empty-dimension interpolation weights, and not the edge integration weights.

@oskooi
Copy link
Collaborator

oskooi commented Mar 27, 2019

Running this on the test in #784 for a resolution of 40 (which was producing incorrect results), the "interior" points returned by get_dft_array are now correct. It would be nice to also correct the endpoints.

n2f_dft_res40_nd20

@oskooi
Copy link
Collaborator

oskooi commented Mar 27, 2019

For some reason, the latest commit seems to not have fixed the endpoints and the interior points are just as they were in #784 (i.e. off by an overall scale factor).

n2f_dft_res40_nd20

@stevengj
Copy link
Collaborator Author

stevengj commented Mar 27, 2019

@oskooi, should be fixed now.
image

@oskooi
Copy link
Collaborator

oskooi commented Mar 27, 2019

Indeed everything is working correctly now (i.e. get_dft_array is no longer resolution-dependent and the endpoints are fixed). The norm of the relative difference in the two fields is decreasing (mostly monotonically). Shown below are results for resolutions of 40, 50, 60, and 70 with norms of 3.31022, 2.47782, 1.49521, and 1.63235.

n2f_dft_res40_nd20

n2f_dft_res50_nd20

n2f_dft_res60_nd20

n2f_dft_res70_nd20

@stevengj stevengj merged commit a5308c1 into master Mar 28, 2019
@stevengj stevengj deleted the dftsliceinterp branch March 28, 2019 15:14
bencbartlett pushed a commit to bencbartlett/meep that referenced this pull request Sep 9, 2021
* include interpolation weights in DFT slice output, so that empty dimensions are collapsed correctly

* don't include integration weights, only interpolation weights

* whoops
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.

discretization artifacts in get_dft_array
2 participants