Skip to content

Commit b913b70

Browse files
yaugenst-flexmomchil-flex
authored andcommitted
fix: bug in local field projection for far_field_approx=True
1 parent 68a6e5b commit b913b70

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
- Regression in local field projection leading to incorrect results for `far_field_approx=True`.
12+
1013
## [2.7.6] - 2024-10-30
1114

1215
### Added

tidy3d/components/field_projection.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,11 @@ def contract(currents):
482482

483483
order = [idx_u, idx_v, idx_w]
484484
zeros = np.zeros(jm[0].shape)
485-
J = anp.array([*jm[:2], zeros])[order]
486-
M = anp.array([*jm[2:], zeros])[order]
485+
486+
# for each index (0, 1, 2), if it’s in the first two elements of order,
487+
# select the corresponding jm element for J or the offset element (+2) for M
488+
J = anp.array([jm[order.index(i)] if i in order[:2] else zeros for i in range(3)])
489+
M = anp.array([jm[order.index(i) + 2] if i in order[:2] else zeros for i in range(3)])
487490

488491
cos_theta_cos_phi = cos_theta[:, None] * cos_phi[None, :]
489492
cos_theta_sin_phi = cos_theta[:, None] * sin_phi[None, :]

0 commit comments

Comments
 (0)