From ac0211facb88c2cd136114b32eb35d0944126756 Mon Sep 17 00:00:00 2001 From: momchil Date: Tue, 12 Dec 2023 12:01:01 -0800 Subject: [PATCH] Mode solver eps_complex check at central frequency only --- tidy3d/plugins/mode/mode_solver.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tidy3d/plugins/mode/mode_solver.py b/tidy3d/plugins/mode/mode_solver.py index 019db070c8..b4395d8740 100644 --- a/tidy3d/plugins/mode/mode_solver.py +++ b/tidy3d/plugins/mode/mode_solver.py @@ -4,6 +4,7 @@ from __future__ import annotations from typing import List, Tuple, Dict +from math import isclose import numpy as np import pydantic.v1 as pydantic @@ -642,14 +643,16 @@ def _has_fully_anisotropic_media(self) -> bool: @cached_property def _has_complex_eps(self) -> bool: - """Check if there are media with a complex-valued epsilon in the plane of the mode at the - mode solver freqs. A separate check is done inside the solver, which looks at the actual + """Check if there are media with a complex-valued epsilon in the plane of the mode. + A separate check is done inside the solver, which looks at the actual eps and mu and uses a tolerance to determine whether to use real or complex fields, so the actual behavior may differ from what's predicted by this property.""" + check_freqs = np.unique([np.amin(self.freqs), np.amax(self.freqs), np.mean(self.freqs)]) for int_mat in self._intersecting_media: - max_imag_eps = np.amax(np.abs(np.imag(int_mat.eps_model(np.array(self.freqs))))) - if not np.isclose(max_imag_eps, 0): - return False + for freq in check_freqs: + max_imag_eps = np.amax(np.abs(np.imag(int_mat.eps_model(freq)))) + if not isclose(max_imag_eps, 0): + return False return True def to_source(