Skip to content

Commit

Permalink
re-instate get_array_slice_dimensions in Python interface (NanoComp#1464
Browse files Browse the repository at this point in the history
)
  • Loading branch information
oskooi authored Jan 8, 2021
1 parent a078ffa commit 8094604
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions python/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3299,6 +3299,28 @@ def get_array_metadata(self, vol=None, center=None, size=None, dft_cell=None,
return points,weights
return tuple(tics) + (weights,)

def get_array_slice_dimensions(self, component, vol=None, center=None, size=None):
"""
Computes the dimensions of an array slice for a particular `component` (`mp.Ez`, `mp.Ey`, etc.).
Accepts either a volume object (`vol`), or a `center` and `size` `Vector3` pair.
Returns a tuple containing the dimensions (`dim_sizes`), a `Vector3` object
corresponding to the minimum corner of the volume (`min_corner`),
and a `Vector3` object corresponding to the maximum corner (`max_corner`).
"""
if vol is None and center is None and size is None:
v = self.fields.total_volume()
else:
v = self._volume_from_kwargs(vol, center, size)
dim_sizes = np.zeros(3, dtype=np.uintp)
corners = []
_,_ = mp._get_array_slice_dimensions(self.fields, v, dim_sizes, False, False, component, corners)
dim_sizes[dim_sizes==0] = 1
min_corner = corners[0]
max_corner = corners[1]
return dim_sizes, min_corner, max_corner

def get_eigenmode_coefficients(self, flux, bands, eig_parity=mp.NO_PARITY, eig_vol=None,
eig_resolution=0, eig_tolerance=1e-12, kpoint_func=None, direction=mp.AUTOMATIC):
"""
Expand Down

0 comments on commit 8094604

Please sign in to comment.