Skip to content

Commit

Permalink
Mode solver eps_complex check at central frequency only
Browse files Browse the repository at this point in the history
  • Loading branch information
momchil-flex committed Dec 12, 2023
1 parent e176ec5 commit ac0211f
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions tidy3d/plugins/mode/mode_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit ac0211f

Please sign in to comment.