Curved edges when using MaterialGrid #2760
-
Hello Meep community, I'm attempting to generate a square grid with two materials using import meep as mp
import numpy as np
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
resolution = 70
cell_size = mp.Vector3(2,2,0)
weights = np.ones((11,11))
weights[0,0]=0
Nx = len(weights)
Ny = len(weights)
mat_interp = mp.MaterialGrid(mp.Vector3(Nx,Ny,0),
mp.Medium(index=3.5),
mp.Medium(index=1.5),
weights=weights,
beta=mp.inf,)
geometry = [mp.Block(material=mat_interp,
center=mp.Vector3(),
size=mp.Vector3(2,2,0))]
sim = mp.Simulation(cell_size=cell_size,
resolution=resolution,
geometry=geometry)
fig, ax = plt.subplots()
sim.plot2D(ax=ax)
fig.suptitle('resolution = {}, (Nx,Ny) = ({},{})'.format(resolution,Nx,Ny))
fig.savefig('matgrid_graded_res{}_{}_{}.png'.format(resolution,Nx,Ny),
bbox_inches='tight',
dpi=300) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
This might happen because of subpixel smoothing. You can try |
Beta Was this translation helpful? Give feedback.
-
Why is your MaterialGrid so course? Typically you should match or exceed the resolution as your simulation. When you specify a beta, meep runs a linear interpolation routine to map the MaterialGrid to the yee lattice. This acts like a spatial low pass filter. Try a much finer MaterialGrid. |
Beta Was this translation helpful? Give feedback.
Why is your MaterialGrid so course? Typically you should match or exceed the resolution as your simulation.
When you specify a beta, meep runs a linear interpolation routine to map the MaterialGrid to the yee lattice. This acts like a spatial low pass filter.
Try a much finer MaterialGrid.