YMatrix

class photonforge.YMatrix(frequencies, elements, terminals=None)

Nodal admittance matrix (Y matrix).

Represents a frequency-dependent nodal admittance matrix where terminals correspond to circuit nodes. Can be returned from LumpedModel.start_mna(); when a port_map is specified, LumpedModel will extract port parameters and convert to S-matrix.

Parameters:
  • frequencies (Sequence[float]) – Frequency values for the computed elements.

  • elements (dict[tuple[str, str], Sequence[complex]]) – Mapping from pairs of terminal names to Y matrix elements. The keys must be: ("terminal1", "terminal2").

  • terminals (dict[str, Terminal | None] | None) – Mapping from terminal names to terminals or to None.

Example

>>> import numpy as np
>>> frequencies = [1e9, 2e9, 5e9]
>>> R, C = 100.0, 1e-12
>>> omega = 2 * np.pi * np.array(frequencies)
>>> Y_R = np.full(len(frequencies), 1 / R, dtype=complex)
>>> Y_C = 1j * omega * C
>>> y_matrix = pf.YMatrix(frequencies, {
...     ("in", "in"): Y_R,
...     ("in", "out"): -Y_R,
...     ("out", "in"): -Y_R,
...     ("out", "out"): Y_R + Y_C,
... })

Methods

copy()

Create a copy.

force_symmetric()

Force this Y matrix to be symmetric.

to_z_matrix()

Convert this Y matrix to a Z matrix by inversion.

Attributes

elements

Y matrix elements (read only).

frequencies

Y matrix frequencies (read only).

properties

Object properties.

terminals

Y matrix terminals (read only).

wavelengths

Y matrix wavelengths (read only).

copy()

Create a copy.

Returns:

New copy.

Return type:

YMatrix

elements

Y matrix elements (read only).

Type:

dict[tuple[str, str], ndarray]

force_symmetric()

Force this Y matrix to be symmetric.

Reciprocity is ensured by averaging transposed entries (if both are present) or filling in missing elements.

Returns:

This object.

Return type:

YMatrix

frequencies

Y matrix frequencies (read only).

Type:

ndarray

properties

Object properties.

Type:

Properties

terminals

Y matrix terminals (read only).

Type:

dict[str, Terminal | None]

to_z_matrix()

Convert this Y matrix to a Z matrix by inversion.

Z = Y^(-1)

Returns:

The inverted impedance matrix.

Return type:

ZMatrix

Raises:

RuntimeError – If the Y matrix is singular at any frequency.

wavelengths

Y matrix wavelengths (read only).

Type:

ndarray