TwoPortModel

class photonforge.TwoPortModel(t=1, r0=0, r1=0, ports=None)

Analytic model for a 2-port component.

\[\begin{split}S = \begin{bmatrix} r_0 & t \\ t & r_1 \\ \end{bmatrix}\end{split}\]
Parameters:
  • t (complex | Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) – Transmission coefficient. For multimode ports, a sequence of coefficients must be provided.

  • r0 (complex | Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) – Reflection coefficient for the first port. For multimode ports, a sequence of coefficients must be provided.

  • r1 (complex | Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) – Reflection coefficient for the second port. For multimode ports, a sequence of coefficients must be provided.

  • ports (Sequence[str] | None) – List of port names. If not set, the sorted list of port names from the component is used.

Notes

For multimode ports, mixed-mode coefficients are zero (not included in the result). Dispersion can be included in the model by setting the coefficients to a 2D array with shape (M, N), in which M is the number of modes, and N the length of the frequency sequence used in the S matrix computation.

Methods

from_bytes(byte_repr)

De-serialize this model.

s_matrix(component, frequencies[, ...])

Compute the S matrix for a component using this model.

start(component, frequencies, **kwargs)

Start computing the S matrix response from a component.

update(*args, **kwargs)

Update this model.

Attributes

as_bytes

Serialize this model.

parametric_function

Function used to update a parametric component.

parametric_kwargs

Keyword arguments used to update a parametric component.

random_variables

List of monte_carlo.RandomVariable associated to this component's parameters.

property as_bytes: bytes

Serialize this model.

classmethod from_bytes(byte_repr)

De-serialize this model.

Parameters:

byte_repr (bytes)

Return type:

TwoPortModel

start(component, frequencies, **kwargs)

Start computing the S matrix response from a component.

Parameters:
  • component (Component) – Component from which to compute the S matrix.

  • frequencies (Sequence[float]) – Sequence of frequencies at which to perform the computation.

  • **kwargs – Unused.

Returns:

Model result with attributes status and s_matrix.

Return type:

ModelResult