-
Notifications
You must be signed in to change notification settings - Fork 633
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
Eigenmode overlaps from get_eigenmode_coefficients()
vary with k-direction
#1773
Comments
Is what I am seeing in the results above expected or does it appear to be a bug? If it is not a bug, which mode overlap values are considered to be correct? |
I looked into what could be causing the discrepancy in the mode coefficients in the forward- and backward-propagating in the example above for a single frequency (
(a)
(b)
The problem therefore in (b) is that MPB is computing the wrong mode. The group velocity should be negative rather than positive.
Lines 945 to 946 in fa23466
(a)
(b)
We need to first figure out why MPB is not computing the correct backward-propagating mode. |
Realize that MPB is computing the group velocity relative to the direction of k, so if k is in the backward direction, and the mode is backward propagating, then it will return a group velocity that is positive. |
I think I have tracked down what could be the cause of the unexpected results reported here (i.e., why the mode coefficients of the backward mode are not identical to those of the forward mode with the order just swapped). It has to do with the phase of the eigenmodes returned by MPB via Lines 912 to 916 in d12e544
For the 2d example posted above, I plotted the eigenmode profile for the Hy and Ez fields computed by MPB at the DFT line monitor and discovered that while the Hy field is identical for the forward ( The fix therefore involves ensuring that an identical eigenmode profile is used to compute the mode coefficients for the forward and backward modes. |
That's correct — for the backward mode, you have to flip the relative phase of Hy and Ez, in order to flip the sign of the Poynting vector. (Note that the transverse fields Hy and Ez can be chosen to be purely real. MPB might be multiplying both by an arbitrary phase, but if one is real then at first glance it seems that the other should be real too.) |
For some reason, when plotting the mode profile of the actual eigenmode from MPB interpolated into the Meep grid and used to compute the overlap integral from this line: Line 945 in 434f3fb
The Ez field is complex but Hy is purely real as shown in the following figures for the real and imaginary parts of each field component separately. This should not affect the results but it is unexpected. Note: the Ez fields of the "forward" ( |
It seems there is a bug when computing the mode coefficients which involve adding two different cross products Lines 945 to 946 in 849bf3d
The problem is that |
Even if there is a bug there (and you would need to check if things are being interpolated elsewhere), that would only be a first-order error and would go away with increasing resolution, which is not the problem you're seeing here. |
Whether or not this happens is determined by |
It looks like this issue is related to #1470 and only when the DFT mode monitors used to compute the mode coefficients are defined on the centered grid, the error converges to zero with increasing resolution (see right plot of first figure below). This is not the case when the mode coefficients are computed using a DFT mode monitor on the Yee grid which is the case for the To demonstrate this, I set up a test case based on a 2d waveguide from the user manual and computed |S11|2 and |S21|2 using four different cases which are a combination of: (1) The following two figures show these results comparing the centered vs. Yee grid. It therefore seems that there is nothing fundamentally wrong with the computation of the mode overlap integrals as long as the mode monitor is defined on the centered grid. The fix therefore involves simply changing the |
I am confused as to how what we're observing here relates to #1470 and reciprocity, since the location of the sources and monitors are not being changed in this setup. It's the same monitor and the same simulation but the result of the overlap calculation is changing. This seems surprising to me, even at a finite simulation resolution. |
The connection to #1470 relates to the discretization error introduced by the interpolation of the eigenmode from MPB onto the Meep grid when computing the overlap integral for the mode coefficients. #1470 and the results shown above demonstrate that this error converges to zero in the limit of infinite resolution. Note from the results in the right plot of the first figure above that when using the centered grid, |S11|2 is nearly identical (and converging to zero with increasing resolution) when using a |
The value is nearly identical but, from my calculation, the relative difference between the S11 for the +/-k cases is actually consistent with the difference between S21 for the +/-k cases. It looks like the value varies by more than 10% for a resolution of 20. Here we're considering a straight waveguide so what we're calling S11 will be much smaller than S21, but this won't be the case in general. I would have thought that changing the sign of the k-point just flips the coordinate system of MPB. It's surprising that you can get significantly different values depending on how you choose to specify your direction. I understand that the difference goes away at infinite resolution, but at a finite resolution it's unclear what the preferred approach / value is from a user POV. |
For accurate computations of the S-parameters, note that you can always do a separate normalization run to compute the incident DFT fields from just the sources and then subtract these from the DFT fields of the "real" run. This approach is described in Section 4.3 "Separating Incident and Scattered Fields" of our book chapter: https://arxiv.org/pdf/1301.5366.pdf. |
The relative difference in |S21|2 and |S11|2 for +k and -k is actually very similar which is reassuring. This is shown in the following figures. In the figure above, the seemingly large difference in |S21|2 relative to |S11|2 is actually just an artifact of the different magnitudes: in the limit of infinite resolution, |S21|2 is ~1100 whereas |S11|2 is 0 (1e-4); a difference of about 7 orders. The choice of the loglog axes obscures the difference in magnitude. For this geometry, the relative difference in +k vs. -k (second figure below) is less than 1% at the smallest resolutions. Nevertheless, the relative difference seems to be geometry dependent and just happens to be small in this case. |
Closing this issue as it is not a bug but rather a feature of computing mode coefficients on the Yee grid vs. centered grid for |
When using
get_eigenmode_coefficients()
withdirection=mp.NO_DIRECTION
and manually specifying the direction viakpoint_func
, the returned mode overlap values change when flipping the sign of the k-point. I believe this relates to what was observed in #1593, because the solution there was to change the k-point sign based on the direction of the requested mode overlap.Consider the following simulation setup:
This produces the following DFT fields:
The output of (automatic direction):
is:
The output of (no direction with positive k-point):
is:
The output of (no direction with negative k-point):
is:
So, the automatic direction and the positive k-point coefficient values are consistent but the negative k-point coefficient values are slightly different. I would have thought that the negative k-point coefficient values are the same, but with the fwd / bkwd array indexes swapped.
The text was updated successfully, but these errors were encountered: