Open oskooi opened 4 years ago
You need direction=mp.X
, but I'm not sure why it's giving the "invalid dielectric function" error.
Even with direction=mp.X
in the EigenModeSource
definition, the same error occurs:
File "/usr/local/lib/python3.5/site-packages/meep/__init__.py", line 3868, in add_eigenmode_source
return _meep.fields_add_eigenmode_source(self, *args)
RuntimeError: meep: invalid dielectric function for MPB
I don't think it likes the source extending all the way to the edge. Try size=mp.Vector3(1,sy-2*dpml)
No, same error again unfortunately.
If I remove the Cylinder
objects from the geometry
then it seems to work.
It seems to be a bad interaction with subpixel averaging. Subpixel averaging gives an anisotropic ε on the Yee grid, but we have to interpolate these ε tensor components to get the corresponding MPB values, and that interpolation seems to be destroying positive-definiteness.
Note that in the case where this does not abort, then there is no need to worry — at worst, some isolated pixels will be messed up, but it will still converge with resolution.
To quantify the mode mismatch between MPB and Meep, you could compute the backward-propagating flux from an eigenmode source (at the center frequency), which should go to zero with resolution.
As shown in the results below for the mode at the pulse center frequency of 0.15 in a single mode waveguide, the backward-propagating flux does not seem to be converging to zero with increasing resolution. Rather, it seems to be converging to a constant value. (The results are converged with PML thickness and runtime as well as eig_resolution
and eig_tolerance
for the EigenModeSource
.) Turning off subpixel smoothing reduces the oscillations in the data.
Is there some other kind of discretization effect involved when calling MPB from Meep that we are overlooking?
You might need to increase the runtime and the cutoffs for the gaussians to avoid spectral leakage, since you are trying to resolve pretty small backward fluxes here.
The difference between Meep and MPB should converge with resolution here, although you'll eventually hit a noise floor due to the eigensolver tolerance, the eigensolver source size, spectral leakage, PML reflections, floating-point roundoff, and other errors.
(It's not clear that you've hit a noise floor here since it's still going down, albeit slowly.)
There does not seem to be any change in the results to either the RuntimeError: meep: invalid dielectric function for MPB
reported for the holey waveguide (with subpixel smoothing) or the backward-propagating flux for the single-mode ridge waveguide when changing src/monitor.cpp:261
with if (1)
.
It takes all of the tensor components from the same idx despite the fact that they are different points in the Yee grid
I agree this is a problem... I totally forgot about this issue at the time.
It seems odd to me that we are sampling an already sampled yee grid to generate the MPB grid. This not only makes it incredibly difficult to handle the staggering, but it means that "upsampling" the MPB resolution (e.g. in get_eigenmode_coeffcients()
) requires extensive linear interpolation on a lower resolution grid.
Why not sample directly from the geometry tree like we do in meep-geom? This would dramatically simplify the code (no more ugly interpolation across grid points by looping through chunks) and it lets us more accurately upsample the mpb grid if desired.
It would be easy to parallelize the grid initialization, as we discussed before. Doing things this way may even solve the weird issue with sub-pixel averaging.
Why not sample directly from the geometry tree like we do in meep-geom?
mpb.cpp
can't assume that the Meep geometry came from a geometry tree; it might have been set directly with the C++ interface, for example.
I suppose we could have optional support for meepgeom
in mpb.cpp
in cases where this could work.
The following example tries to launch an eigenmode source in a holey waveguide in a 2d simulation but aborts with an error due to MPB. The same error occurs when trying to use mode decomposition for a 2d eigenmode. Neither
EigenModeSource
orget_eigenmode_coefficients
has previously been tested for this type of use case. All the examples in Tutorial/Mode Decomposition and Tutorial/Eigenmode Source are in 1d.The schematic below (obtained using
plot2D
) shows the 2d source (red hatches) and mode monitor (blue hatches).additional info: removing the
symmetries
from theSimulation
constructor does not solve the problem. However, changing thesize
of the source/monitor from a 2d rectangle to a line in y (i.e.size=mp.Vector3(0,sy)
) works fine.output