Skip to content

Commit 523df25

Browse files
committed
Mode solver eps_complex check at central frequency only
1 parent ca20525 commit 523df25

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

tidy3d/plugins/mode/mode_solver.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from __future__ import annotations
66
from typing import List, Tuple, Dict
7+
from math import isclose
78

89
import numpy as np
910
import pydantic.v1 as pydantic
@@ -642,14 +643,16 @@ def _has_fully_anisotropic_media(self) -> bool:
642643

643644
@cached_property
644645
def _has_complex_eps(self) -> bool:
645-
"""Check if there are media with a complex-valued epsilon in the plane of the mode at the
646-
mode solver freqs. A separate check is done inside the solver, which looks at the actual
646+
"""Check if there are media with a complex-valued epsilon in the plane of the mode.
647+
A separate check is done inside the solver, which looks at the actual
647648
eps and mu and uses a tolerance to determine whether to use real or complex fields, so
648649
the actual behavior may differ from what's predicted by this property."""
650+
check_freqs = np.unique([np.amin(self.freqs), np.amax(self.freqs), np.mean(self.freqs)])
649651
for int_mat in self._intersecting_media:
650-
max_imag_eps = np.amax(np.abs(np.imag(int_mat.eps_model(np.array(self.freqs)))))
651-
if not np.isclose(max_imag_eps, 0):
652-
return False
652+
for freq in check_freqs:
653+
max_imag_eps = np.amax(np.abs(np.imag(int_mat.eps_model(freq))))
654+
if not isclose(max_imag_eps, 0):
655+
return False
653656
return True
654657

655658
def to_source(

0 commit comments

Comments
 (0)