Skip to content

Commit 8e70dfe

Browse files
tylerflexmomchil-flex
authored andcommitted
size=0 adjoint montiors for single pixel dims in custom mediums
1 parent e76d6cc commit 8e70dfe

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
- Autograd support for local field projections using `FieldProjectionKSpaceMonitor`.
1212
- Function `components.geometry.utils.flatten_groups` now also flattens transformed groups when requested.
1313

14+
### Changed
15+
- `CustomMedium` design regions require far less data when performing inverse design by reducing adjoint field monitor size for dims with one pixel.
16+
1417
### Fixed
1518
- Regression in local field projection leading to incorrect results for `far_field_approx=True`.
1619
- Bug when differentiating with respect to `Cylinder.center`.

tidy3d/components/structure.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,20 @@ def make_adjoint_monitors(
222222
if isinstance(self.geometry, PolySlab):
223223
size[self.geometry.axis] = 0
224224

225+
# custom medium only needs fields at center locations of unit cells.
226+
if isinstance(self.medium, CustomMedium):
227+
for axis, dim in enumerate("xyz"):
228+
if self.medium.permittivity is not None:
229+
if len(self.medium.permittivity.coords[dim]) == 1:
230+
size[axis] = 0
231+
if self.medium.eps_dataset is not None:
232+
zero_size = True
233+
for _, fld in self.medium.eps_dataset.field_components.items():
234+
if len(fld.coords[dim]) != 1:
235+
zero_size = False
236+
if zero_size:
237+
size[axis] = 0
238+
225239
mnt_fld = FieldMonitor(
226240
size=size,
227241
center=center,

0 commit comments

Comments
 (0)