Skip to content

Commit aa1d50c

Browse files
committed
fix: Exact field projection J/M indexing
1 parent ef715d5 commit aa1d50c

File tree

2 files changed

+9
-17
lines changed

2 files changed

+9
-17
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2222
- `Structure.background_permittivity : float` for specifying background medium for shape differentiation deprecated in favor of `Structure.background_medium : Medium` for more generality.
2323

2424
### Fixed
25-
- Regression in local field projection leading to incorrect results for `far_field_approx=True`.
25+
- Regression in local field projection leading to incorrect projection results.
2626
- Bug when differentiating with respect to `Cylinder.center`.
2727
- `xarray` 2024.10.0 compatibility for autograd.
2828
- Some failing examples in the expressions plugin documentation.

tidy3d/components/field_projection.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -878,22 +878,14 @@ def _fields_for_surface_exact(
878878
cmp_1, cmp_2 = source_names
879879

880880
# set the surface current density Cartesian components
881-
order = [idx_u, idx_v, idx_w]
882-
zeros = anp.zeros(currents[f"E{cmp_1}"].shape)
883-
J = anp.array(
884-
[
885-
currents[f"E{cmp_1}"].data,
886-
currents[f"E{cmp_2}"].data,
887-
zeros,
888-
]
889-
)[order]
890-
M = anp.array(
891-
[
892-
currents[f"H{cmp_1}"].data,
893-
currents[f"H{cmp_2}"].data,
894-
zeros,
895-
]
896-
)[order]
881+
J = [None] * 3
882+
M = [None] * 3
883+
J[idx_u] = currents[f"E{cmp_1}"].data
884+
J[idx_v] = currents[f"E{cmp_2}"].data
885+
J[idx_w] = anp.zeros(J[idx_u].shape)
886+
M[idx_u] = currents[f"H{cmp_1}"].data
887+
M[idx_v] = currents[f"H{cmp_2}"].data
888+
M[idx_w] = anp.zeros(M[idx_u].shape)
897889

898890
# observation point in the new spherical system
899891
r, theta_obs, phi_obs = surface.monitor.car_2_sph(

0 commit comments

Comments
 (0)