Skip to content

Commit d518f1c

Browse files
Gregory Robertsyaugenst-flex
authored andcommitted
fix[adjoint]: fix diffraction data adjoint source creation
1 parent 572cad6 commit d518f1c

File tree

5 files changed

+443
-4
lines changed

5 files changed

+443
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Changed
1111
- Validate mode solver object for large number of grid points on the modal plane.
1212

13+
### Fixed
14+
- Fixed missing amplitude factor and handling of negative normal direction case when making adjoint sources from `DiffractionMonitor`.
15+
1316
## [2.9.0] - 2025-08-04
1417

1518
### Added

tests/test_components/test_autograd_mode_polyslab_numerical.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ def eval_fn(sim_data):
457457
fd_mag = np.linalg.norm(fd_grad)
458458
adj_mag = np.linalg.norm(pattern_dot_adj_gradient)
459459
percentage_error = 100.0 * np.mean(
460-
(fd_grad - pattern_dot_adj_gradient) / (fd_grad + np.finfo(np.float64).eps)
460+
np.abs(fd_grad - pattern_dot_adj_gradient) / (np.abs(fd_grad) + np.finfo(np.float64).eps)
461461
)
462462

463463
print("\n" * 3)

tests/test_components/test_autograd_numerical.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ def test_finite_difference_field_data(field_data_test_parameters, rng, tmp_path,
333333
fd_mag = np.linalg.norm(fd_grad)
334334
adj_mag = np.linalg.norm(pattern_dot_adj_gradient)
335335
percentage_error = 100.0 * np.mean(
336-
(fd_grad - pattern_dot_adj_gradient) / (fd_grad + np.finfo(np.float64).eps)
336+
np.abs(fd_grad - pattern_dot_adj_gradient) / (np.abs(fd_grad) + np.finfo(np.float64).eps)
337337
)
338338

339339
print("\n" * 3)

0 commit comments

Comments
 (0)