|
norm_factor = 1.0 / np.sqrt(self_dot) |
EigSolver's _normalize_modes normalizes each mode's self-dot to +1. For backward modes (direction="-") this is negative, so it multiplies the entire mode by ±i via the sqrt. The effective index is unaffected, but the fields no longer follow the usual phase convention (real transverse components for lossless modes).
Potential fix: normalize the self-dot to −1 for backward modes, keeping the norm factor real.
# Normalize self-dot to +1 for forward modes, -1 for backward modes
target = -1.0 if self_dot.real < 0 else 1.0
norm_factor = 1.0 / np.sqrt(self_dot / target)
Is there a reason for strictly normalizing to +1, or are you happy with me creating a PR?
tidy3d/tidy3d/components/mode/solver.py
Line 1334 in 5a41d86
EigSolver's
_normalize_modesnormalizes each mode's self-dot to +1. For backward modes (direction="-") this is negative, so it multiplies the entire mode by ±i via the sqrt. The effective index is unaffected, but the fields no longer follow the usual phase convention (real transverse components for lossless modes).Potential fix: normalize the self-dot to −1 for backward modes, keeping the norm factor real.
Is there a reason for strictly normalizing to +1, or are you happy with me creating a PR?