MNAMatrix

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

Modified Nodal Analysis (MNA) matrix.

Represents a frequency-dependent MNA stamp where terminals correspond to circuit nodes or auxiliary branch-current variables. Entries may be admittance-valued, impedance-valued, or dimensionless (+/-1) depending on the terminal type.

Returned by LumpedModel.start_mna(); used internally to extract S-parameters via port-augmented MNA solve.

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

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

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

Example

>>> R, n, freqs = 50.0, 3, [1e9, 5e9, 10e9]
>>> G = 1 / R
>>> mna_elements = {
...     ("t1", "t1"): np.full(n, G, dtype=complex),
...     ("t1", "t2"): np.full(n, -G, dtype=complex),
...     ("t2", "t1"): np.full(n, -G, dtype=complex),
...     ("t2", "t2"): np.full(n, G, dtype=complex),
... }
>>> mna_matrix = pf.MNAMatrix(freqs, mna_elements)

Methods

copy()

Create a copy.

force_symmetric()

Force this MNA matrix to be symmetric.

Attributes

elements

MNA matrix elements (read only).

frequencies

MNA matrix frequencies (read only).

properties

Object properties.

terminals

MNA matrix terminals (read only).

wavelengths

MNA matrix wavelengths (read only).

copy()

Create a copy.

Returns:

New copy.

Return type:

MNAMatrix

elements

MNA matrix elements (read only).

Type:

dict[tuple[str, str], ndarray]

force_symmetric()

Force this MNA 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:

MNAMatrix

frequencies

MNA matrix frequencies (read only).

Type:

ndarray

properties

Object properties.

Type:

Properties

terminals

MNA matrix terminals (read only).

Type:

dict[str, Terminal | None]

wavelengths

MNA matrix wavelengths (read only).

Type:

ndarray