BPM and WPM fixes for odd grids#7
Open
EkaterinaBolotskaya wants to merge 2 commits intooptbrea:mainfrom
Open
Conversation
f5564ef to
48b9c0b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
1. BPM asymmetry - commit 1
BPM simulations are asymmetric on even grids and produce an error on odd grids.
BPM fix - “build frequency list correctly.”
Bug demonstration
Added a PSF profile into the lenses test file: https://diffractio.readthedocs.io/en/latest/source/examples_scalar/lenses.html XZ lens: BPM scheme section
Before the fix:
Asymmetric results on an even grid, error on an odd grid.
Changed the X resolution to (even):

x0 = np.linspace(-diameter / 2, diameter / 2, 2*1024)Changed the X resolution to (odd):

x0 = np.linspace(-diameter / 2, diameter / 2, 2047)After the fix in scalar_fields_XZ
Symmetric and no errors.
Changed the X resolution to (even):

x0 = np.linspace(-diameter / 2, diameter / 2, 2*1024)Changed the X resolution to (odd):

x0 = np.linspace(-diameter / 2, diameter / 2, 2047)I DID NOT TEST THE EQUIVALENT FIX I MADE IN scalar_fields_XYZ
2. WPM asymmetry on odd grids
This one was identified by Lisa Gavronskiy (lisa.gavronskiy@irradiant.tech, https://github.com/lisagavronskiy)
WPM fix - “put spectrum back in the right order before inverse FFT.”
Same example used.
Resolution - odd:
x0 = np.linspace(-diameter / 2, diameter / 2, 2023)Method BPM -> WPM
Before:

After:

I DID NOT TEST THE EQUIVALENT FIX I MADE IN scalar_fields_XY
Testing
pytestoutput is the same before and after fixes: