diff --git a/CHANGELOG.md b/CHANGELOG.md index 2fca4ca471..312b71e26a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/tidy3d/components/geometry/polyslab.py b/tidy3d/components/geometry/polyslab.py index 41a7a2ebf3..8478cb70ec 100644 --- a/tidy3d/components/geometry/polyslab.py +++ b/tidy3d/components/geometry/polyslab.py @@ -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 # 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,