-
Notifications
You must be signed in to change notification settings - Fork 772
tutorial and unit test for mode sources using DiffractedPlanewave object
#2107
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
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be able to delete these lines as I commented in #2072. (It's possible you were having problems before that are now fixed by #2114.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's not working, make sure the MPB/Meep verbosity is > 1 and look at the
NEW KPOINTandMPB solved for frequencyverbose outputs — you should see that it is setting the parallel component ofkby the boundary conditions, and varying the perpendicular component ofk.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there is a potential bug because printing out
NEW KPOINTshows that its value is clearly incorrect:The y component (i.e., the periodic direction of the monitor monitor) should be 1.333... (i.e., 4/3) to match the
k_pointof theSimulationobject. The reason it is not this value is due to these lines:meep/src/mpb.cpp
Lines 426 to 433 in 405b7e6
In this example,
R = (1,1.5,1)andkcart = (0,1.33333,0)which results ink = (0, 2.0, 0).The fix seems to be to just replace
k[i] = dot_product(R[i], kcart)withk[i] = kcart[i]?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, that code is correct — MPB expects the k point in the reciprocal-lattice basis, so it has to convert from the Cartesian basis of Meep. (It does the same thing with the
DiffractedPlanewaveobject.)Instead, something weird is going on. You said the output is:
which means that it is taking the nonzero ky into account, but somehow it is getting the wrong kx — somehow, it is acting as though it is passing
ky==0to MPB, even though we are clearly printing that it is passing a nonzerok[1].There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I have finally gotten to the bottom of this issue. TLDR: the current behavior is a feature and not a bug.
Currently, to launch oblique planewaves using an$\left|k_\perp\right| = (n\omega)^2 - \left|k_\parallel\right|$ is only computed automatically for the case when
EigenModeSourcewitheig_bandset to an integer (rather than anDiffractedPlanewaveobject), the user must provide its wavevectork(ameep.Vector3object) viadirection=mp.NO_DIRECTIONandeig_kpoint=k. This is because even though internally Meep sets the component ofkparallel to the line source (in the directions with periodic boundaries) to the components of thek_pointof theSimulationobject, the correct perpendicular componenteig_bandis aDiffractedPlanewaveobject.It would be nice to extend this feature to when
eig_bandis an integer but that can be a separate PR since it is not directly related to this PR.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. A
DiffractedPlanewaveobject only enables the analytical calculation of k. Otherwise, it uses a Newton solver to find the k where ω(k) = specified frequency. This of course should be the same thing (but slower, and with more ambiguity about polarization and more difficulty in choosing a specific diffraction order).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The wavevector of the oblique planewave in Cartesian coordinates should be:
k = (2.68742, 1.33333, 0.00000). However, the Newton solver shows:Note that the$y$ component (parallel direction) of the MPB mode ($x$ component (perpendicular direction) (
1.33333) is correct but the3) is not2.68742.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out that there was a bug in the output of MPB's mode wavevector which is fixed by #2253. (The mode itself was correct.)
With the bug fix, the output from
run_mode_sourceoftest_diffracted_planewave.pyin this PR is:This means
k = (2.68742,1.33333,0)which is equivalent to thek_pointof theSimulationclass object as expected.