Skip to content

Commit

Permalink
Fix to simultaneous bend and angle mode solve
Browse files Browse the repository at this point in the history
  • Loading branch information
momchil-flex committed Jun 16, 2024
1 parent bad1c4e commit 559a61b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [2.7.0] - 2024-06-13
## [2.7.0] - 2024-06-17

### Added
- EME solver through `EMESimulation` class.
Expand Down Expand Up @@ -57,6 +57,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Default variant for silicon dioxide in material library switched from `Horiba` to `Palik_Lossless`.
- Sources and monitors which are exactly at the simulation domain boundaries will now error. They can still be placed very close to the boundaries, but need to be on the inside of the region.
- Relaxed `dt` stability criterion for 1D and 2D simulations.
- Switched order of angle and bend transformations in mode solver when both are present.

### Fixed
- Bug in PolySlab intersection if slab bounds are `inf` on one side.
Expand Down
8 changes: 4 additions & 4 deletions tidy3d/plugins/mode/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ def compute_modes(
jac_e = np.real(np.copy(identity_tensor))
jac_h = np.real(np.copy(identity_tensor))

if bend_radius is not None:
new_coords, jac_e, jac_h = radial_transform(new_coords, bend_radius, bend_axis)

if np.abs(angle_theta) > 0:
new_coords, jac_e_tmp, jac_h_tmp = angled_transform(new_coords, angle_theta, angle_phi)
new_coords, jac_e, jac_h = angled_transform(new_coords, angle_theta, angle_phi)

if bend_radius is not None:
new_coords, jac_e_tmp, jac_h_tmp = radial_transform(new_coords, bend_radius, bend_axis)
jac_e = np.einsum("ij...,jp...->ip...", jac_e_tmp, jac_e)
jac_h = np.einsum("ij...,jp...->ip...", jac_h_tmp, jac_h)

Expand Down
9 changes: 3 additions & 6 deletions tidy3d/plugins/mode/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ def radial_transform(coords, radius, bend_axis):
offsetting the plane such that its center is a distance of ``radius`` away from the center of
curvature, we have, e.g. for ``bend_axis=='y'``:
u = (x**2 + z**2)
u = sqrt(x**2 + z**2)
v = y
w = R acos(x / u)
w = R asin(z / u)
These are all evaluated at z = 0 below.
Expand All @@ -39,9 +39,6 @@ def radial_transform(coords, radius, bend_axis):
Jacobian of the transformation at the E-field positions, shape ``(3, 3, Nx * Ny)``.
jac_h: np.ndarrray
Jacobian of the transformation at the H-field positions, shape ``(3, 3, Nx * Ny)``.
k_to_kp: np.ndarray
A matrix of shape (3, 3) that transforms the k-vector from the original coordinates to the
transformed ones.
"""

Nx, Ny = coords[0].size - 1, coords[1].size - 1
Expand Down Expand Up @@ -101,7 +98,7 @@ def angled_transform(coords, angle_theta, angle_phi):
Nx, Ny = coords[0].size - 1, coords[1].size - 1

# The new coordinates are exactly the same at z = 0
new_coords = (np.copy(c) for c in coords)
new_coords = [np.copy(c) for c in coords]

# The only nontrivial derivatives are dudz, dvdz and they are constant everywhere
jac = np.zeros((3, 3, Nx * Ny))
Expand Down

0 comments on commit 559a61b

Please sign in to comment.