PoleResidueMatrix

class photonforge.PoleResidueMatrix(poles, residues, frequency_scaling=6.283185, ports=None, delays=None)

Pole-residue representation of an S matrix.

Each element v is represented by a rational function of the form:

Sv=ei2πfdn=0N1rvnspn+rvN

in which pn are the poles (shared by all elements) and rvn are the residues for matrix element v, d is the delay, h is a frequency scaling factor, and s=ihf.

Parameters:
  • poles – Sequence of complex poles shared by all matrix elements.

  • residues – Dictionary of residues, one per matrix element. Each item is a sequence of complex residues used for that element.

  • frequency_scaling – Scaling applied to the frequencies in evaluation.

  • ports – Mapping from port names to ports or to None.

  • delays – Dictionary of explicit time delays (in seconds), one per matrix element. Missing elements have no time delay applied. If a single number is given, this is used as a global delay for all matrix elements.

Note

The number of residues for each element is 1 more that the number of poles because of the last term in the representation.

Including explicit delays in the model can reduce the number of poles required to obtain a good fit. However, if the delays are too large, it can be difficult to obtain a good stable fit.

Example

An SMatrix instance can be obtained by calling an instance of PoleResidueMatrix with the desired frequencies:

>>> pole_res = PoleResidueMatrix(
...     poles=[-C_0 / 1.0],
...     residues={("P0", "P0"): [2.0 * C_0, 0.0]},
... )
>>> s_matrix = pole_res(C_0 / 1.55)
>>> s_matrix.elements
{('P0', 'P0'): array([0.11473006+0.46507755j])}

Methods

copy()

Create a copy of this pole_residue_matrix.

enforce_passivity(frequencies[, ...])

Attempt to make the pole-residue matrix passive, while minimizing the perturbation at the specified frequencies.

get_rms_error(s_matrix)

Compute the error between this pole-residue matrix and another S matrix.

is_passive()

Check whether the pole-residue matrix is passive.

Attributes

delays

Dictionary of delays for each element, in seconds (read only).

frequency_scaling

Frequency scaling factor

poles

Poles for all elements (read only).

ports

Associated ports (read only).

residues

Dictionary of residues for each element (read only).

copy()

Create a copy of this pole_residue_matrix.

Returns:

New copy.

delays

Dictionary of delays for each element, in seconds (read only).

enforce_passivity(frequencies, max_iterations=20, real=False, feedthrough=False)

Attempt to make the pole-residue matrix passive, while minimizing the perturbation at the specified frequencies.

Parameters:
  • frequencies – List of frequencies at which the perturbation should be minimized. This is usually the frequencies of the S matrix data being fit.

  • max_iterations – Maximal number of passivity enforcement iterations.

  • real – Whether the poles come in conjugate pairs, representing a real-valued (non-baseband) system.

  • feedthrough – Whether to include a feedthrough (constant) term in the pole-residue model.

Returns:

Bool representing whether passivity enforcement succeeded.

frequency_scaling

Frequency scaling factor

get_rms_error(s_matrix)

Compute the error between this pole-residue matrix and another S matrix.

Parameters:

s_matrix – S matrix to compare and calculate the RMS error.

Returns:

The RMS error between matrices.

is_passive()

Check whether the pole-residue matrix is passive.

Returns:

Bool representing whether the pole-residue matrix is passive.

poles

Poles for all elements (read only).

ports

Associated ports (read only).

residues

Dictionary of residues for each element (read only).