Skip to content

PortSpec

PortSpec(
description,
width,
limits,
num_modes=1,
polarization=None,
target_neff=None,
path_profiles=(),
added_solver_modes=0,
voltage_path=None,
current_path=None,
default_radius=0,
impedance=None,
)

Optical or electrical port specification.

This class is mainly used to create optical or electrical waveguide templates for a Technology.

Args

  • description (str): Description of the port specification.
  • width (float): In-plane dimension of the port.
  • limits (Sequence[float]): Out-of-plane bounds of the port.
  • num_modes (int): Number of modes supported by this port.
  • polarization (Literal[“TE”, “TM”, ""] | None): Mode polarization selection.
  • target_neff (float | None): Target effective index for numerical mode solving. If None, the square root of the largest real permittivity among the technology media within limits at the mode solving frequencies is used.
  • path_profiles (Iterable[tuple[float, float, str | tuple[int, int]]] | dict[str, tuple[float, float, str | tuple[int, int]]]): Tuples with (width, offset, layer) describing the path profiles that make up this port’s geometry. Each path profile tuple can be named by using a dictionary.
  • added_solver_modes (int): Additional modes to solve for in mode solver runs (useful when filtering modes by polarization). These are not included in S parameters computed for ports of this type.
  • voltage_path (Sequence[Sequence[float] | complex] | None): Sequence of vertices that make up the integral path for voltage calculation in this port. If an empty sequence is used, the path will be set automatically, if possible.
  • current_path (Sequence[Sequence[float] | complex] | Rectangle | Circle | Polygon | Path): Sequence of vertices that make up the integral path for current calculation in this port. A planar structure can be used to define the integral over its contour. If an empty sequence is used, the path will be set automatically, if possible.
  • default_radius (float): Default radius used for bends created with this specification.
  • impedance (complex | Interpolator | None): Complex impedance as a single or frequency-dependent interpolated value (in ohms). If set to None, calculation is performed by mode-solving when needed.

Note

If all of voltage_path, current_path, and impedance are None, the resulting specification will be classified as optical. Otherwise, it will be an electrical port specification.

Important

Ports whose specifications differ only in target_neff connect directly, so circuit simulations that mix them might give an incorrect result. In such cases, it is advisable that the specifications also differ in some other way to avoid connecting them directly.

Example

>>> port_spec = pf.PortSpec(
... "Single mode strip",
... 1.5,
... (-0.5, 0.75),
... path_profiles=[(0.45, 0, (1, 0)), (3, 0, (1, 2))],
... )

See Also

Ports guide

MethodDescription
combined_withCreate a port specification combining this with with a second one.
copyCreate a copy of this port specification.
get_pathsReturn a list of paths generated by this specification.
invertedReturn an inverted version of this port if it is asymmetric.
path_profile_forReturn the path profile in this port specification for a specific layer.
path_profiles_listReturn the path profiles in this port specification as a list.
profile_matchesTest if the path profiles in this specification match another’s.
symmetricReturn a flag indicating whether this port specification is symmetric.
to_tidy3dCreate a Tidy3D ModeSolver from this port specification.
to_tidy3d_impedance_calculatorCreate a Tidy3D ImpedanceCalculator from this port specification.

combined_with(self, port_spec, offset=0)

Create a port specification combining this with with a second one.

The combined port specification is a copy of this one with additional path profiles from port_spec.

Args

  • port_spec (PortSpec): Port specification with the path profiles to be added.
  • offset (float): Added offset to the new path profiles.

Returns

PortSpec: Combined profile.

Note

The combined specification terminals do not have names.

copy(self)

Create a copy of this port specification.

Returns

PortSpec: New copy.

get_paths(self, origin, scale_width=True)

Return a list of paths generated by this specification.

Args

  • origin (Sequence[float] | complex): Origin of the generated paths.
  • scale_width (bool): Flag passed to Path to indicate whether the width of the created paths should scale when the paths are scaled.

Returns

list[tuple[tuple[int, int], Path]]: List of layer and paths.

inverted(self)

Return an inverted version of this port if it is asymmetric.

Returns

PortSpec: Inverted specification (self, if symmetric).

path_profile_for(self, layer, technology=None)

Return the path profile in this port specification for a specific layer.

Args

  • layer (str | tuple[int, int]): Layer for desired the profile.
  • technology (Technology | None): Technology specification for this specification.

Returns

tuple[float, float] | tuple[list[float], list[float]]: Width(s) and offset(s) for the selected layer.

Note

If the port specification includes several path profiles for the selected layer, width and offset are returned as lists.

path_profiles_list(self)

Return the path profiles in this port specification as a list.

Returns

list[float, float, tuple[int, int]]: List of width, offset, and layer from this port specification’s path profiles.

profile_matches(self, port_spec)

Test if the path profiles in this specification match another’s.

Args

  • port_spec (PortSpec): Port specification to test.

Returns

bool: Match flag.

symmetric(self)

Return a flag indicating whether this port specification is symmetric.

Returns

bool: Symmetry flag.

to_tidy3d(
self,
frequencies,
mesh_refinement=None,
group_index=False,
technology=None,
)

Create a Tidy3D ModeSolver from this port specification.

Args

  • frequencies (Sequence[float]): Sequence of frequency values for the mode solver.
  • mesh_refinement (float | None): Minimal number of mesh elements per wavelength used for mode solving.
  • group_index (bool): Boolean indicating whether the mode solver should include group index computation.
  • technology (Technology | None): Technology specification for this specification.

Returns

ModeSolver: Tidy3D mode solver.

to_tidy3d_impedance_calculator(
self, extrapolate_to_endpoints=True, snap_to_grid=True
)

Create a Tidy3D ImpedanceCalculator from this port specification.

The impedance calculator can be used with mode solver data from this port specificatin to calculate its impedance. Only electrical port specifications support this method.

Args

  • extrapolate_to_endpoints (bool): Set to ignore fields outside the voltage integration path bounds.
  • snap_to_grid (bool): Snap integral paths to the data grid.

Returns

ImpedanceCalculator: Tidy3D impedance calculator.

AttributeDescription
added_solver_modesint: Additional modes to include in mode solver runs for this port.
classificationLiteral[‘optical’, ‘electrical’]: Port spec classification: optical or electrical (read only).
current_pathndarray | None: Current integration path (for electrical port specifications only).
default_radiusfloat: Default radius for bends.
descriptionstr: Port spec description.
impedanceInterpolator | None: Impedance interpolator (for electrical port specifications only).
limitsndarray: Out-of-plane limits.
num_modesint: Number of modes supported by this port.
path_profilesIterable[tuple[float, float, tuple[int, int]]] | dict[str, tuple[float, float, tuple[int, int]]]: Path profiles.
polarizationLiteral[‘TE’, ‘TM’, ”]: Mode polarization selection.
propertiesProperties: Object properties.
target_nefffloat | None: Target effective index for port modes (None for the default).
voltage_pathndarray | None: Voltage integration path (for electrical port specifications only).
widthfloat: In-plane width.

int: Additional modes to include in mode solver runs for this port.

Literal[‘optical’, ‘electrical’]: Port spec classification: optical or electrical (read only).

ndarray | None: Current integration path (for electrical port specifications only).

float: Default radius for bends.

str: Port spec description.

Interpolator | None: Impedance interpolator (for electrical port specifications only).

ndarray: Out-of-plane limits.

int: Number of modes supported by this port.

Iterable[tuple[float, float, tuple[int, int]]] | dict[str, tuple[float, float, tuple[int, int]]]: Path profiles.

Literal[‘TE’, ‘TM’, ”]: Mode polarization selection.

Properties: Object properties.

float | None: Target effective index for port modes (None for the default).

ndarray | None: Voltage integration path (for electrical port specifications only).

float: In-plane width.