From f5ea62e2b51cb238e87605a7b177be03af2ac24d Mon Sep 17 00:00:00 2001 From: Gregory Roberts Date: Tue, 2 Dec 2025 14:47:18 -0500 Subject: [PATCH] fix(adjoint): correct normal for box minimum face when computing shape gradient --- CHANGELOG.md | 1 + tidy3d/components/geometry/base.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f094397115..da7785471a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fix to `outer_dot` when frequencies stored in the data were not in increasing order. Previously, the result would be provided with re-sorted frequencies, which would not match the order of the original data. - Fixed bug where an extra spatial coordinate could appear in `complex_flux` and `ImpedanceCalculator` results. +- Fixed normal for `Box` shape gradient computation to always point outward from boundary which is needed for correct PEC handling. ## [2.10.0rc3] - 2025-11-26 diff --git a/tidy3d/components/geometry/base.py b/tidy3d/components/geometry/base.py index a6eae24230..f83bdce265 100644 --- a/tidy3d/components/geometry/base.py +++ b/tidy3d/components/geometry/base.py @@ -2740,7 +2740,7 @@ def compute_integration_weight(grid_points: NDArray[float]) -> float: perps1 = np.zeros_like(grid_points) perps2 = np.zeros_like(grid_points) - normals[:, axis_normal] = 1 + normals[:, axis_normal] = -1 if (min_max_index == 0) else 1 perps1[:, axis_perp[0]] = 1 perps2[:, axis_perp[1]] = 1