Skip to content

Commit

Permalink
fix: Exact field projection J/M indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
yaugenst-flex committed Nov 14, 2024
1 parent ef715d5 commit aa1d50c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `Structure.background_permittivity : float` for specifying background medium for shape differentiation deprecated in favor of `Structure.background_medium : Medium` for more generality.

### Fixed
- Regression in local field projection leading to incorrect results for `far_field_approx=True`.
- Regression in local field projection leading to incorrect projection results.
- Bug when differentiating with respect to `Cylinder.center`.
- `xarray` 2024.10.0 compatibility for autograd.
- Some failing examples in the expressions plugin documentation.
Expand Down
24 changes: 8 additions & 16 deletions tidy3d/components/field_projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -878,22 +878,14 @@ def _fields_for_surface_exact(
cmp_1, cmp_2 = source_names

# set the surface current density Cartesian components
order = [idx_u, idx_v, idx_w]
zeros = anp.zeros(currents[f"E{cmp_1}"].shape)
J = anp.array(
[
currents[f"E{cmp_1}"].data,
currents[f"E{cmp_2}"].data,
zeros,
]
)[order]
M = anp.array(
[
currents[f"H{cmp_1}"].data,
currents[f"H{cmp_2}"].data,
zeros,
]
)[order]
J = [None] * 3
M = [None] * 3
J[idx_u] = currents[f"E{cmp_1}"].data
J[idx_v] = currents[f"E{cmp_2}"].data
J[idx_w] = anp.zeros(J[idx_u].shape)
M[idx_u] = currents[f"H{cmp_1}"].data
M[idx_v] = currents[f"H{cmp_2}"].data
M[idx_w] = anp.zeros(M[idx_u].shape)

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

0 comments on commit aa1d50c

Please sign in to comment.