From 597e4db280ff2d4204807d4ead6ed92330ebf999 Mon Sep 17 00:00:00 2001 From: Ardavan Oskooi Date: Fri, 12 Jan 2024 14:38:38 -0800 Subject: [PATCH 1/2] disable subpixel smoothing by default in MaterialGrid --- doc/docs/Python_User_Interface.md | 2 +- python/geom.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/docs/Python_User_Interface.md b/doc/docs/Python_User_Interface.md index 3adafe6a5..5ebe657ac 100644 --- a/doc/docs/Python_User_Interface.md +++ b/doc/docs/Python_User_Interface.md @@ -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): diff --git a/python/geom.py b/python/geom.py index 6642bf31b..26f7b5270 100755 --- a/python/geom.py +++ b/python/geom.py @@ -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, From 4dfb1ef458712cf524abaa2b6d61736e492c4264 Mon Sep 17 00:00:00 2001 From: Ardavan Oskooi Date: Fri, 12 Jan 2024 16:54:54 -0800 Subject: [PATCH 2/2] enable subpixel smoothing in test_adjoint_cyl.py to retain default behavior --- python/tests/test_adjoint_cyl.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/python/tests/test_adjoint_cyl.py b/python/tests/test_adjoint_cyl.py index 08a328bb6..44653de6e 100644 --- a/python/tests/test_adjoint_cyl.py +++ b/python/tests/test_adjoint_cyl.py @@ -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 = [ @@ -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(