Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tidy3d/components/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ class PolySlab(Planar):
"""

slab_bounds: Tuple[float, float]
vertices: Vertices #Union[Vertices, Array[float]]
vertices: Union[Vertices, Array[float]]
type: Literal["PolySlab"] = "PolySlab"

@pydantic.validator("slab_bounds", always=True)
Expand Down
14 changes: 13 additions & 1 deletion tidy3d/components/medium.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import numpy as np

from .base import Tidy3dBaseModel
from .types import PoleAndResidue, Literal, Ax, FreqBound
from .types import PoleAndResidue, Literal, Ax, FreqBound, ComplexNumber
from .viz import add_ax_if_none
from .validators import validate_name_str

Expand Down Expand Up @@ -422,6 +422,18 @@ class PoleResidue(DispersiveMedium):
poles: List[PoleAndResidue] = []
type: Literal["PoleResidue"] = "PoleResidue"

@pydantic.validator("poles", always=True)
def convert_complex(cls, val):
"""convert list of poles to complex"""
poles_complex = []
for (a, c) in val:
if isinstance(a, ComplexNumber):
a = a.real + 1j * a.imag
if isinstance(c, ComplexNumber):
c = c.real + 1j * c.imag
poles_complex.append((a, c))
return poles_complex

@ensure_freq_in_range
def eps_model(self, frequency: float) -> complex:
"""Complex-valued permittivity as a function of frequency.
Expand Down
4 changes: 3 additions & 1 deletion tidy3d/components/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,9 @@ def discretize(self, box: Box) -> Grid:
sub_boundaries = Coords(**sub_cell_boundary_dict)
return Grid(boundaries=sub_boundaries)

def epsilon(self, box: Box, coord_key: str = 'centers', freq: float = None) -> Dict[str, xr.DataArray]:
def epsilon(
self, box: Box, coord_key: str = "centers", freq: float = None
) -> Dict[str, xr.DataArray]:
"""Get array of permittivity at volume specified by box and freq

Parameters
Expand Down
3 changes: 2 additions & 1 deletion tidy3d/components/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ class ComplexNumber(pydantic.BaseModel):
imag: float


PoleAndResidue = Tuple[complex, complex]
Complex = Union[complex, ComplexNumber]
PoleAndResidue = Tuple[Complex, Complex]
FreqBound = Union[float, Inf, Literal[-inf]]

""" symmetries """
Expand Down
1 change: 0 additions & 1 deletion tidy3d/components/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from ..log import ValidationError, SetupError
from .geometry import Box


""" Explanation of pydantic validators:

Validators are class methods that are added to the models to validate their fields (kwargs).
Expand Down
2 changes: 1 addition & 1 deletion tidy3d/plugins/near2far/near2far.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def __init__(self, sim_data: SimulationData, mon_name: str, frequency: float):
self.Mx = np.squeeze(Ey.values)
self.My = -np.squeeze(Ex.values)

def _radiation_vectors(self, theta : float, phi : float):
def _radiation_vectors(self, theta: float, phi: float):
"""Compute radiation vectors at an angle in spherical coordinates

Parameters
Expand Down
10 changes: 9 additions & 1 deletion tidy3d/web/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,15 @@ def monitor(self) -> None: # pylint:disable=too-many-locals
def pbar_description(task_name: str, status: str) -> str:
return f"{task_name}: status = {status}"

run_statuses = ["queued", "preprocess", "queued_solver", "running", "postprocess", "visualize", "success"]
run_statuses = [
"queued",
"preprocess",
"queued_solver",
"running",
"postprocess",
"visualize",
"success",
]
end_statuses = ("success", "error", "diverged", "deleted", "draft")

pbar_tasks = {}
Expand Down