Source code for tidy3d.plugins.smatrix.ports.modal

"""Class and custom data array for representing a scattering matrix port based on waveguide modes."""

import pydantic.v1 as pd

from ....components.data.data_array import DataArray
from ....components.geometry.base import Box
from ....components.mode import ModeSpec
from ....components.types import Direction


[docs] class ModalPortDataArray(DataArray): """Port parameter matrix elements for modal ports. Example ------- >>> import numpy as np >>> ports_in = ['port1', 'port2'] >>> ports_out = ['port1', 'port2'] >>> mode_index_in = [0, 1] >>> mode_index_out = [0, 1] >>> f = [2e14] >>> coords = dict( ... port_in=ports_in, ... port_out=ports_out, ... mode_index_in=mode_index_in, ... mode_index_out=mode_index_out, ... f=f ... ) >>> fd = ModalPortDataArray((1 + 1j) * np.random.random((2, 2, 2, 2, 1)), coords=coords) """ __slots__ = () _dims = ("port_out", "mode_index_out", "port_in", "mode_index_in", "f") _data_attrs = {"long_name": "modal port matrix element"}
[docs] class Port(Box): """Specifies a port in the scattering matrix.""" direction: Direction = pd.Field( ..., title="Direction", description="'+' or '-', defining which direction is considered 'input'.", ) mode_spec: ModeSpec = pd.Field( ModeSpec(), title="Mode Specification", description="Specifies how the mode solver will solve for the modes of the port.", ) name: str = pd.Field( ..., title="Name", description="Unique name for the port.", min_length=1, )