Skip to content

Mode normalization in mode/solver.py introduces phase shift #3379

Description

@l-berg

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions