Skip to content

Commit

Permalink
Fixed mode rotation for non-colocated field components
Browse files Browse the repository at this point in the history
  • Loading branch information
QimingFlex committed Nov 13, 2024
1 parent bbc09f0 commit b1c38bc
Show file tree
Hide file tree
Showing 2 changed files with 227 additions and 156 deletions.
23 changes: 6 additions & 17 deletions tidy3d/components/mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,12 @@ class ModeSpec(Tidy3dBaseModel):
False,
title="Use fields rotation when both bend and angle are defined",
description="Defines how modes are computed when both a bend and an angle are defined. "
" If `False`, the two coordinate transformations are directly composed. If `True`, the "
"structures in the simulation are first rotated, to compute a mode solution at a reference"
"plane normal to the bend's azimuthal direction. Then, the fields are rotated to align with"
"the mode plane, using the `n_eff` calculated at the reference plane. The second option can"
"produce more accurate results, but more care must be taken for example in ensuring that the"
"original mode plane intersects the right geometries in the simulation with rotated structures.",
"If `False`, the two coordinate transformations are directly composed. "
"If `True`, the structures in the simulation are first rotated to compute a mode solution at "
"a reference plane normal to the bend's azimuthal direction. Then, the fields are rotated to align with "
"the mode plane, using the `n_eff` calculated at the reference plane. The second option can "
"produce more accurate results, but more care must be taken, for example, in ensuring that the "
"original mode plane intersects the correct geometries in the simulation with rotated structures.",
)

track_freq: Union[TrackFreq, None] = pd.Field(
Expand Down Expand Up @@ -172,17 +172,6 @@ def bend_radius_not_zero(cls, val, values):
raise SetupError("The magnitude of 'bend_radius' must be larger than 0.")
return val

@pd.validator("bend_angle_rotation", always=True)
@skip_if_fields_missing(["bend_radius", "bend_axis"])
def validate_bend_correction_requirements(cls, val, values):
"""Ensure that both ``bend_axis`` and ``bend_radius`` are provided if ``bend_correction`` is enabled."""
if val is True:
if values.get("bend_axis") is None or values.get("bend_radius") is None:
raise SetupError(
"'bend_correction' can only be enabled when both 'bend_axis' and 'bend_radius' are provided."
)
return val

@pd.validator("angle_theta", allow_reuse=True, always=True)
def glancing_incidence(cls, val):
"""Warn if close to glancing incidence."""
Expand Down
Loading

0 comments on commit b1c38bc

Please sign in to comment.