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
9 changes: 9 additions & 0 deletions tests/test_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,15 @@ def test_medium_dispersion():
m_DR = Drude(eps_inf=1.0, coeffs=[(1, 3), (2, 4)])
m_DB = Debye(eps_inf=1.0, coeffs=[(1, 3), (2, 4)])

with pytest.raises(pydantic.ValidationError) as e_info:
mf_SM = Sellmeier(coeffs=[(2, 0), (2, 4)])

with pytest.raises(pydantic.ValidationError) as e_info:
mf_DR = Drude(eps_inf=1.0, coeffs=[(1, 0), (2, 4)])

with pytest.raises(pydantic.ValidationError) as e_info:
mf_DB = Debye(eps_inf=1.0, coeffs=[(1, 0), (2, 4)])

freqs = np.linspace(0.01, 1, 1001)
for medium in [m_PR, m_SM, m_LZ, m_LZ2, m_DR, m_DB]:
eps_c = medium.eps_model(freqs)
Expand Down
7 changes: 4 additions & 3 deletions tidy3d/components/medium.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from typing import List, Tuple, Union, Callable
import pydantic
import numpy as np
from pydantic import PositiveFloat

from .base import Tidy3dBaseModel
from .types import PoleAndResidue, Ax, FreqBound
Expand Down Expand Up @@ -473,7 +474,7 @@ class Sellmeier(DispersiveMedium):
>>> eps = sellmeier_medium.eps_model(200e12)
"""

coeffs: List[Tuple[float, float]] = pydantic.Field(
coeffs: List[Tuple[float, PositiveFloat]] = pydantic.Field(
title="Coefficients", description="List of Sellmeier (:math:`B_i, C_i`) coefficients."
)

Expand Down Expand Up @@ -615,7 +616,7 @@ class Drude(DispersiveMedium):
description="Relative permittivity at infinite frequency (:math:`\\epsilon_\\infty`).",
)

coeffs: List[Tuple[float, float]] = pydantic.Field(
coeffs: List[Tuple[float, PositiveFloat]] = pydantic.Field(
..., title="Coefficients", description="List of (:math:`f_i, \\delta_i`) values for model."
)

Expand Down Expand Up @@ -682,7 +683,7 @@ class Debye(DispersiveMedium):
description="Relative permittivity at infinite frequency (:math:`\\epsilon_\\infty`).",
)

coeffs: List[Tuple[float, float]] = pydantic.Field(
coeffs: List[Tuple[float, PositiveFloat]] = pydantic.Field(
...,
title="Coefficients",
description="List of (:math:`\\Delta\\epsilon_i, \\tau_i`) values for model.",
Expand Down
1 change: 1 addition & 0 deletions tidy3d/components/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ def __modify_schema__(cls, field_schema):
"""Sets the schema of NumpyArray."""
field_schema.update(NumpyArray.schema())


class ArrayMeta(type):
"""metclass for Array, enables Array[type] -> TypedArray"""

Expand Down
5 changes: 1 addition & 4 deletions tidy3d/material_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,10 +642,7 @@ def export_matlib_to_file(fname: str = "matlib.json") -> None:

cSi_Li1993_293K = PoleResidue(
eps_inf=1.0,
poles=[
((0.0 + 1j * 4010819041318578.0), (0.0 + 1j * 1.2156273362672036e16)),
((0.0 + 1j * 5022626939326166.0), (-0.0 - 1j * 4.1977794227247144e16)),
],
poles=[((0.0 + 1j * 6241549589084091.0), (0.0 - 1j * 3.3254308736142404e16))],
frequency_range=(21413747041496.2, 249827048817455.7),
)

Expand Down