|
26 | 26 | from ...components.data.monitor_data import ModeSolverData
|
27 | 27 | from ...exceptions import ValidationError, SetupError
|
28 | 28 | from ...constants import C_0
|
29 |
| -from .solver import compute_modes, EigSolver |
| 29 | + |
| 30 | +# Importing the local solver may not work if e.g. scipy is not installed |
| 31 | +IMPORT_ERROR_MSG = """Could not import local solver, 'ModeSolver' objects can still be constructed |
| 32 | +but will have to be run through the server. |
| 33 | +""" |
| 34 | +try: |
| 35 | + from .solver import compute_modes |
| 36 | + |
| 37 | + LOCAL_SOLVER_IMPORTED = True |
| 38 | +except ImportError: |
| 39 | + log.warning(IMPORT_ERROR_MSG) |
| 40 | + LOCAL_SOLVER_IMPORTED = False |
30 | 41 |
|
31 | 42 | FIELD = Tuple[ArrayComplex3D, ArrayComplex3D, ArrayComplex3D]
|
32 | 43 | MODE_MONITOR_NAME = "<<<MODE_SOLVER_MONITOR>>>"
|
@@ -453,6 +464,10 @@ def _solve_single_freq(
|
453 | 464 |
|
454 | 465 | The fields are rotated from propagation coordinates back to global coordinates.
|
455 | 466 | """
|
| 467 | + |
| 468 | + if not LOCAL_SOLVER_IMPORTED: |
| 469 | + raise ImportError(IMPORT_ERROR_MSG) |
| 470 | + |
456 | 471 | solver_fields, n_complex, eps_spec = compute_modes(
|
457 | 472 | eps_cross=self._solver_eps(freq),
|
458 | 473 | coords=coords,
|
@@ -628,9 +643,10 @@ def _has_complex_eps(self) -> bool:
|
628 | 643 | eps and mu and uses a tolerance to determine whether to use real or complex fields, so
|
629 | 644 | the actual behavior may differ from what's predicted by this property."""
|
630 | 645 | for int_mat in self._intersecting_media:
|
631 |
| - if EigSolver.isinstance_complex(int_mat.eps_model(np.array(self.freqs))): |
632 |
| - return True |
633 |
| - return False |
| 646 | + max_imag_eps = np.amax(np.abs(np.imag(int_mat.eps_model(np.array(self.freqs))))) |
| 647 | + if not np.isclose(max_imag_eps, 0): |
| 648 | + return False |
| 649 | + return True |
634 | 650 |
|
635 | 651 | def to_source(
|
636 | 652 | self,
|
|
0 commit comments