Skip to content

Commit

Permalink
Disable subpixel smoothing by default in MaterialGrid class objects (
Browse files Browse the repository at this point in the history
…#2758)

* disable subpixel smoothing by default in MaterialGrid

* enable subpixel smoothing in test_adjoint_cyl.py to retain default behavior
  • Loading branch information
oskooi authored Jan 13, 2024
1 parent 0dc44da commit 4f67cb6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion doc/docs/Python_User_Interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -4691,7 +4691,7 @@ def __init__(self,
medium2: meep.geom.Medium,
weights: numpy.ndarray = None,
grid_type: str = 'U_DEFAULT',
do_averaging: bool = True,
do_averaging: bool = False,
beta: float = 0,
eta: float = 0.5,
damping: float = 0):
Expand Down
2 changes: 1 addition & 1 deletion python/geom.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ def __init__(
medium2: Medium,
weights: np.ndarray = None,
grid_type: str = "U_DEFAULT",
do_averaging: bool = True,
do_averaging: bool = False,
beta: float = 0,
eta: float = 0.5,
damping: float = 0,
Expand Down
10 changes: 8 additions & 2 deletions python/tests/test_adjoint_cyl.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ def get_source(m):

def forward_simulation(design_params, m, far_x):
matgrid = mp.MaterialGrid(
mp.Vector3(Nr, 0, Nz), SiO2, Si, weights=design_params.reshape(Nr, 1, Nz)
mp.Vector3(Nr, 0, Nz),
SiO2,
Si,
weights=design_params.reshape(Nr, 1, Nz),
do_averaging=True,
)

geometry = [
Expand Down Expand Up @@ -113,7 +117,9 @@ def forward_simulation(design_params, m, far_x):

def adjoint_solver(design_params, m, far_x):

design_variables = mp.MaterialGrid(mp.Vector3(Nr, 0, Nz), SiO2, Si)
design_variables = mp.MaterialGrid(
mp.Vector3(Nr, 0, Nz), SiO2, Si, do_averaging=True
)
design_region = mpa.DesignRegion(
design_variables,
volume=mp.Volume(
Expand Down

0 comments on commit 4f67cb6

Please sign in to comment.