-
Notifications
You must be signed in to change notification settings - Fork 631
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
tutorial and unit test for mode sources using DiffractedPlanewave
object
#2226
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2226 +/- ##
==========================================
+ Coverage 73.20% 73.23% +0.02%
==========================================
Files 17 17
Lines 4904 4916 +12
==========================================
+ Hits 3590 3600 +10
- Misses 1314 1316 +2
|
The This test passes on my local machine which builds Meep using MPI. Since |
Looks like there was an issue with Python's garbage collection which can be resolved simply by putting |
The segmentation fault may go away if
instead of the opposite. In my experience, this sequence issue alone does not cause error, but may cause error in the presence of
|
(Note that for any direction with zero thickness, the Cartesian and reciprocal bases are the same in that direction.) |
If you are worried about the initial guess as commented in #333, you could always change the initial guess manually. It shouldn't make any different in the mode that it converges to, it should only affect the number of Newton iterations. |
This statement is only partially true in this example, unfortunately. No matter what I manually set as the initial guess for Here are two examples of different initial Example 1 initial k[0] = 2.68742 * R[0][0]; k[1] = 1.33333 * R[1][1]; k[2] = 0 * R[2][2];
update_maxwell_data_k(mdata, k, G[0], G[1], G[2]); output of Newton solver and MPB's eigensolver:
Example 2 initial k[0] = 1.65873 * R[0][0]; k[1] = -0.89742 * R[1][1]; k[2] = 0 * R[2][2];
update_maxwell_data_k(mdata, k, G[0], G[1], G[2]); output of Newton solver and MPB's eigensolver:
|
(Note that R[0] should be (1,0,0), R[1] should be [0,Λ,0], and R[2] should be (0,0,1).) You might try a few different ky values and see what kx values you get. It should be some function of the form |
There seems to be an inconsistency in the output from MPB related to the mode's wavevector compared to the actual mode that is found. (This inconsistency makes it difficult to debug this PR since we are relying on the output from MPB to determine whether it has found the correct mode or not.) As a demonstration, this inconsistency can be seen in the output of The correct mode is launched in both cases as verified by the field snapshot (shown below). However, in the case of (1), the output from MPB is: Given the non-orthogonal lattice and reciprocal lattice basis vectors, perhaps the wavevector is simply not being converted to Cartesian coordinates correctly in the output? Lines 573 to 576 in 82734d1
sources = [
mp.EigenModeSource(
src=mp.ContinuousSource(fsrc),
center=mp.Vector3(),
size=mp.Vector3(y=10),
direction=mp.NO_DIRECTION,
eig_kpoint=k_point,
eig_parity=mp.ODD_Z,
)
]
For reference, the lattice
sources = [
mp.EigenModeSource(
src=mp.ContinuousSource(fsrc),
center=mp.Vector3(),
size=mp.Vector3(y=10),
eig_band=mp.DiffractedPlanewave((0, 0, 0), mp.Vector3(0, 1, 0), 1, 0),
)
]
|
Some additional information. It seems that while #2114 fixed one bug in The problematic issue in the unit test of this PR as well as the example in #2054 (comment) involves launching an input planewave source with a given |
Closes #2107.
Unfortunately, I was not able to (again) fix the merge conflicts in #2107 and so just created another new PR.
I think the discussion in #2107 is now resolved by #2107 (comment).
This PR also includes some minor fixes (i.e., proper formatting) and additional comments to
run_binary_grating_diffraction
which is part oftest_diffracted_planewave
inpython/tests/test_diffracted_planewave.py
.