Skip to content

Commit 40bd0b2

Browse files
committed
Set angle_phi to multiple of np.pi / 2 if angle_rotation is used
1 parent 098908e commit 40bd0b2

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
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

2525
### Changed
2626
- `num_freqs` in Gaussian beam type sources limited to 20, which should besufficient for all cases.
27+
- The `angle_phi` parameter of `ModeSpec` is only limited to multiples of `np.pi / 2` if `angle_rotation` is set to `True`, as other values would currently not work correctly.
2728

2829
## [2.8.1] - 2025-03-20
2930

tests/test_components/test_mode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def test_angle_rotation_with_phi():
7272

7373
# Case where angle_phi is not a multiple of np.pi and angle_rotation is True
7474
with pytest.raises(pydantic.ValidationError):
75-
td.ModeSpec(angle_phi=np.pi / 2, angle_rotation=True)
75+
td.ModeSpec(angle_phi=np.pi / 3, angle_rotation=True)
7676

7777

7878
def get_mode_sim():

tidy3d/components/mode_spec.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,10 @@ def check_precision(cls, values):
225225

226226
@pd.validator("angle_rotation")
227227
def angle_rotation_with_phi(cls, val, values):
228-
"""Currently ``angle_rotation`` is only supported with ``angle_phi % np.pi == 0``."""
229-
if val and not isclose(values["angle_phi"] % np.pi, 0):
228+
"""Currently ``angle_rotation`` is only supported with ``angle_phi % (np.pi / 2) == 0``."""
229+
if val and not isclose(values["angle_phi"] % (np.pi / 2), 0):
230230
raise ValidationError(
231-
"Parameter 'angle_phi' must be a multiple of 'np.pi' when 'angle_rotation' is "
231+
"Parameter 'angle_phi' must be a multiple of 'np.pi / 2' when 'angle_rotation' is "
232232
"enabled."
233233
)
234234
return val

0 commit comments

Comments
 (0)