PortSpec

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

Optical or electrical port specification.

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

Parameters:
  • 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) – Target effective index for numerical mode solving.

  • 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 path integral for voltage calculation in this port.

  • current_path (Sequence[Sequence[float] | complex] | Rectangle | Circle | Polygon | Path) – Sequence of vertices that make up the path integral for current calculation in this port. A planar structure can be used to define the integral over its countour.

  • default_radius (float) – Default radius used for bends created with this specification.

Example

>>> port_spec = 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

Methods

combined_with(port_spec[, offset])

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

copy()

Create a copy of this port specification.

from_json(json_str)

Import object data from json.

get_paths(origin[, scale_width])

Return a list of paths generated by this specification.

inverted()

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

path_profile_for(layer[, technology])

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

path_profiles_list()

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

profile_matches(port_spec)

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

symmetric()

Return a flag indicating whether this port specification is symmetric.

to_tidy3d(frequencies[, mesh_refinement, ...])

Create a Tidy3D ModeSolver from this port specification.

to_tidy3d_impedance_calculator([...])

Create a Tidy3D ImpedanceCalculator from this port specification.

Attributes

added_solver_modes

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

as_bytes

Byte representation of the Port specification (read only).

classification

Port spec classification: optical or electrical (read only).

current_path

Current integration path (for electrical port specifications only).

default_radius

Default radius for bends.

description

Port spec description.

json

(DEPRECATED) Json representation of this layer specification.

limits

Out-of-plane limits.

num_modes

Number of modes supported by this port.

path_profiles

Path profiles.

polarization

Mode polarization selection.

properties

Object properties.

target_neff

Target effective index for port modes.

voltage_path

Voltage integration path (for electrical port specifications only).

width

In-plane width.

added_solver_modes

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

Type:

int

as_bytes

Byte representation of the Port specification (read only).

Type:

bytes

classification

Port spec classification: optical or electrical (read only).

Type:

Literal[‘optical’, ‘electrical’]

combined_with(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.

Parameters:
  • port_spec (PortSpec) – Port specification with the path profiles to be added.

  • offset (float) – Added offset to the new path profiles.

Returns:

Combined profile.

Return type:

PortSpec

Note

The combined specification terminals do not have names.

copy()

Create a copy of this port specification.

Returns:

New copy.

Return type:

PortSpec

current_path

Current integration path (for electrical port specifications only).

Type:

ndarray | None

default_radius

Default radius for bends.

Type:

float

description

Port spec description.

Type:

str

static from_json(json_str)

Import object data from json.

Warning

This method is DEPRECATED and will be removed in the next release.

Parameters:

json_str (str) – String containing the json data.

Returns:

PhotonForge object.

Return type:

Any

get_paths(origin, scale_width=True)

Return a list of paths generated by this specification.

Parameters:
  • 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 of layer and paths.

Return type:

list[tuple[tuple[int, int], Path]]

inverted()

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

Returns:

Inverted specification (self, if symmetric).

Return type:

PortSpec

json

(DEPRECATED) Json representation of this layer specification.

Type:

str

limits

Out-of-plane limits.

Type:

ndarray

num_modes

Number of modes supported by this port.

Type:

int

path_profile_for(layer, technology=None)

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

Parameters:
  • layer (str | tuple[int, int]) – Layer for desired the profile.

  • technology (Technology | None) – Technology specification for this specification.

Returns:

Width(s) and offset(s) for the selected layer.

Return type:

tuple[float, float] | tuple[list[float], list[float]]

Note

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

path_profiles

Path profiles.

Type:

Iterable[tuple[float, float, tuple[int, int]]] | dict[str, tuple[float, float, tuple[int, int]]]

path_profiles_list()

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

Returns:

List of width, offset, and layer from this port specification’s path profiles.

Return type:

list[float, float, tuple[int, int]]

polarization

Mode polarization selection.

Type:

Literal[‘TE’, ‘TM’, ‘’]

profile_matches(port_spec)

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

Parameters:

port_spec (PortSpec) – Port specification to test.

Returns:

Match flag.

Return type:

bool

properties

Object properties.

Type:

Properties

symmetric()

Return a flag indicating whether this port specification is symmetric.

Returns:

Symmetry flag.

Return type:

bool

target_neff

Target effective index for port modes.

Type:

float

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

Create a Tidy3D ModeSolver from this port specification.

Parameters:
  • 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:

Tidy3D mode solver.

Return type:

ModeSolver

to_tidy3d_impedance_calculator(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.

Parameters:
  • 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:

Tidy3D impedance calculator.

Return type:

ImpedanceCalculator

voltage_path

Voltage integration path (for electrical port specifications only).

Type:

ndarray | None

width

In-plane width.

Type:

float