You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The MaterialGrid feature added by @smartalecH in #1242 (which is not documented in the User Interface and is intended mainly for use with the adjoint solver) provides support for importing the material geometry as a NumPy array. One limitation of the current implementation is that it is based on a bilinear interpolation of the user-specified pixel grid onto Meep's Yee grid which is therefore only first-order accurate (rather than second order) with respect to the resolution:
// material grid: interpolate onto user specified material grid to get properties at r
case material_data::MATERIAL_GRID:
meep::realnum u;
int oi;
geom_box_tree tp;
tp = geom_tree_search(p, restricted_tree, &oi);
u = matgrid_val(p, tp, oi, md); // interpolate onto material grid
epsilon_material_grid(md, u); // interpolate material from material grid point
The accuracy of the MaterialGrid feature can be improved by replacing the bilinear interpolation with anisotropic subpixel smoothing using a quadrature scheme similar to what already exists for the material function but without the slow callbacks to Python since it would be implemented entirely in C/C++.
As a demonstration of the convergence properties of the current implementation of the MaterialGrid, we can compute the relative error in the resonant mode of a 2d photonic crystal using a unit cell comprised of a cylinder with n=3.5 in air and non-zero Bloch-periodic boundaries (so that the mode is propagating at an oblique angle to the Cartesian grid). The source polarization is Hz (i.e., in-plane electric field) in order to generate non-parallel fields along the discontinuous dielectric interface. (This type of convergence test was originally demonstrated in Optics Letters, vol. 31, pp. 2972-74 (2006)). For comparison, we can also compute the same result using a Cylinder geometric object which already supports subpixel smoothing.
The following schematic shows the Hz profile for the Cylinder and MaterialGrid geometry representations at three different resolutions. The discrete artifacts of the MaterialGrid are slightly more apparent than the Cylinder representation. (These images were generated using plot2D and the red dots are the source locations.)
The simulation involves using Harminv to compute the frequency of the resonant mode over a range of resolutions (20-200). The "exact' result is computed at a resolution of 300.
A plot of the relative error vs. resolution for the two methods demonstrates that the MaterialGrid is indeed first-order accurate whereas the Cylinder is second order.
To verify that anisotropic subpixel smoothing has been correctly set up for the MaterialGrid, we can use this same convergence test to verify that it is second-order accurate.
The text was updated successfully, but these errors were encountered:
The
MaterialGrid
feature added by @smartalecH in #1242 (which is not documented in the User Interface and is intended mainly for use with the adjoint solver) provides support for importing the material geometry as a NumPy array. One limitation of the current implementation is that it is based on a bilinear interpolation of the user-specified pixel grid onto Meep's Yee grid which is therefore only first-order accurate (rather than second order) with respect to the resolution:meep/src/meepgeom.cpp
Lines 693 to 701 in 7067536
The accuracy of the
MaterialGrid
feature can be improved by replacing the bilinear interpolation with anisotropic subpixel smoothing using a quadrature scheme similar to what already exists for the material function but without the slow callbacks to Python since it would be implemented entirely in C/C++.As a demonstration of the convergence properties of the current implementation of the
MaterialGrid
, we can compute the relative error in the resonant mode of a 2d photonic crystal using a unit cell comprised of a cylinder with n=3.5 in air and non-zero Bloch-periodic boundaries (so that the mode is propagating at an oblique angle to the Cartesian grid). The source polarization is Hz (i.e., in-plane electric field) in order to generate non-parallel fields along the discontinuous dielectric interface. (This type of convergence test was originally demonstrated in Optics Letters, vol. 31, pp. 2972-74 (2006)). For comparison, we can also compute the same result using aCylinder
geometric object which already supports subpixel smoothing.The following schematic shows the Hz profile for the
Cylinder
andMaterialGrid
geometry representations at three different resolutions. The discrete artifacts of theMaterialGrid
are slightly more apparent than theCylinder
representation. (These images were generated usingplot2D
and the red dots are the source locations.)The simulation involves using
Harminv
to compute the frequency of the resonant mode over a range of resolutions (20-200
). The "exact' result is computed at a resolution of300
.A plot of the relative error vs. resolution for the two methods demonstrates that the
MaterialGrid
is indeed first-order accurate whereas theCylinder
is second order.To verify that anisotropic subpixel smoothing has been correctly set up for the
MaterialGrid
, we can use this same convergence test to verify that it is second-order accurate.The text was updated successfully, but these errors were encountered: