Skip to content

fix[adjoint]: update polyslab in simulation bounds check to allow for… #2681

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed
- Updated the autograd check for if a `PolySlab` is inside the simulation bounds to work when the slab thickness is zero.

## [2.9.0rc2] - 2025-07-17

### Added
Expand Down
6 changes: 4 additions & 2 deletions tidy3d/components/geometry/polyslab.py
Original file line number Diff line number Diff line change
Expand Up @@ -1449,11 +1449,13 @@ def _compute_derivatives(self, derivative_info: DerivativeInfo) -> AutogradField

sim_min, sim_max = map(np.asarray, derivative_info.bounds_intersect)
extents = sim_max - sim_min
is_2d = np.isclose(extents[self.axis], 0.0)
polyslab_2d = np.isclose(np.diff(self.slab_bounds), 0.0)
sim_2d = np.isclose(extents[self.axis], 0.0)
is_2d = polyslab_2d and sim_2d
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is failing a unit test - actually I think maybe we don't want to add the polyslab_2d check in here for cases like the unit test that's failing where the simulation is 2d but the polyslab isn't. in that case, the polyslab should still be integrated as if it was 2d.


# early return if polyslab is not in simulation domain
slab_min, slab_max = self.slab_bounds
if (slab_max <= sim_min[self.axis]) or (slab_min >= sim_max[self.axis]):
if (slab_max < sim_min[self.axis]) or (slab_min > sim_max[self.axis]):
log.warning(
"'PolySlab' lies completely outside the simulation domain.",
log_once=True,
Expand Down