Skip to content

Commit 0b68e6d

Browse files
Fix arrow curvature in bent sources/monitors
Signed-off-by: Lucas Heitzmann Gabrielli <[email protected]>
1 parent cf98f4e commit 0b68e6d

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2424
- Fixed scaling for adjoint sources when differentiating with respect to `FieldData` to account for the mesh size of the monitor and thus the created source. This aligns adjoint gradient magnitudes with numerical finite difference gradients for field data.
2525
- Warn when mode solver pml covers a significant portion of the mode plane.
2626
- TFSF server errors related to the auxiliary plane wave source that would previously happen on the server are now caught upon simulation creation.
27+
- Opposite arrow curvature for mode sources and monitors with non-zero bendind radius when plotted in the figure's Y axis.
2728

2829
### Changed
2930
- `num_freqs` in Gaussian beam type sources limited to 20, which should besufficient for all cases.

tidy3d/components/monitor.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,14 +364,19 @@ def plot(
364364
kwargs_alpha = patch_kwargs.get("alpha")
365365
arrow_alpha = ARROW_ALPHA if kwargs_alpha is None else kwargs_alpha
366366

367+
bend_radius = self.mode_spec.bend_radius
368+
# Curvature has to be reversed because of ploting coordinates
369+
if (self.normal_axis, self._bend_axis) in [(1, 2), (2, 0), (2, 1)]:
370+
bend_radius = -bend_radius
371+
367372
# and then add an arrow using the direction comuputed from `_dir_arrow`.
368373
ax = self._plot_arrow(
369374
x=x,
370375
y=y,
371376
z=z,
372377
ax=ax,
373378
direction=self._dir_arrow,
374-
bend_radius=self.mode_spec.bend_radius,
379+
bend_radius=bend_radius,
375380
bend_axis=self._bend_axis,
376381
color=ARROW_COLOR_MONITOR,
377382
alpha=arrow_alpha,

tidy3d/components/source/base.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,15 @@ def plot(
8686
if self._dir_vector is not None:
8787
bend_radius = None
8888
bend_axis = None
89-
if hasattr(self, "mode_spec"):
89+
if hasattr(self, "mode_spec") and self.mode_spec.bend_radius is not None:
9090
bend_radius = self.mode_spec.bend_radius
9191
bend_axis = self._bend_axis
92+
sign = 1 if self.direction == "+" else -1
93+
# Curvature has to be reversed because of ploting coordinates
94+
if (self.size.index(0), bend_axis) in [(1, 2), (2, 0), (2, 1)]:
95+
bend_radius *= -sign
96+
else:
97+
bend_radius *= sign
9298

9399
ax = self._plot_arrow(
94100
x=x,

0 commit comments

Comments
 (0)