Skip to content

Commit

Permalink
fix off-by-one bug in dimensions of fixed-resolution MaterialGrid for…
Browse files Browse the repository at this point in the history
… adjoint-solver functions (#1769)

* fix off by one bug in MaterialGrid dimensions of adjoint solver functions

* adjust tols

* formatting fixes

* add 1 after dividing by 2

* change design_shape to design_region_size
  • Loading branch information
oskooi authored Sep 29, 2021
1 parent 21e9c35 commit d41b0a4
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 121 deletions.
12 changes: 6 additions & 6 deletions python/adjoint/basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def set_rho_vector(self, rho_vector):


class BilinearInterpolationBasis(Basis):
'''
'''
Simple bilinear interpolation basis set.
'''
def __init__(self, resolution, symmetry=None, **kwargs):
Expand All @@ -65,26 +65,26 @@ def __init__(self, resolution, symmetry=None, **kwargs):
self.symmetry = symmetry

if mp.X in set(self.symmetry):
self.Nx = int(resolution * self.volume.size.x / 2)
self.Nx = int(resolution * self.volume.size.x / 2) + 1
self.rho_x = np.linspace(
self.volume.center.x,
self.volume.center.x + self.volume.size.x / 2, self.Nx)
self.mirror_X = True
else:
self.Nx = int(resolution * self.volume.size.x)
self.Nx = int(resolution * self.volume.size.x) + 1
self.rho_x = np.linspace(
self.volume.center.x - self.volume.size.x / 2,
self.volume.center.x + self.volume.size.x / 2, self.Nx)
self.mirror_X = False

if mp.Y in set(self.symmetry):
self.Ny = int(resolution * self.volume.size.y / 2)
self.Ny = int(resolution * self.volume.size.y / 2) + 1
self.rho_y = np.linspace(
self.volume.center.y,
self.volume.center.y + self.volume.size.y / 2, self.Ny)
self.mirror_Y = True
else:
self.Ny = int(resolution * self.volume.size.y)
self.Ny = int(resolution * self.volume.size.y) + 1
self.rho_y = np.linspace(
self.volume.center.y - self.volume.size.y / 2,
self.volume.center.y + self.volume.size.y / 2, self.Ny)
Expand Down Expand Up @@ -204,7 +204,7 @@ def gen_interpolation_matrix(
):
'''
Generates a bilinear interpolation matrix.
Arguments:
rho_x ................ [N,] numpy array - original x array mapping to povided data
rho_y ................ [N,] numpy array - original y array mapping to povided data
Expand Down
Loading

0 comments on commit d41b0a4

Please sign in to comment.