piel.tools.sax.utils#
This file provides a set of utilities that allow much easier integration between sax and the relevant tools that we use.
Attributes#
Functions#
|
This function returns the connection index of the sax dense S-parameter matrix. |
A |
Module Contents#
- get_sdense_ports_index(input_ports_order: tuple, all_ports_index: dict) dict[source]#
This function returns the connection index of the sax dense S-parameter matrix.
Given that the order of the iteration is provided by the user, the dictionary keys will also be ordered accordingly when iterating over them. This requires the user to provide a set of ordered.
TODO verify reasonable iteration order.
# The input_ports_order can be a tuple of tuples that contain the index and port name. Eg. input_ports_order = ((0, "in_o_0"), (5, "in_o_1"), (6, "in_o_2"), (7, "in_o_3")) # The all_ports_index is a dictionary of the connection index. Eg. all_ports_index = { "in_o_0": 0, "out_o_0": 1, "out_o_1": 2, "out_o_2": 3, "out_o_3": 4, "in_o_1": 5, "in_o_2": 6, "in_o_3": 7, } # Output {"in_o_0": 0, "in_o_1": 5, "in_o_2": 6, "in_o_3": 7}
- Parameters:
input_ports_order (tuple) – The connection order tuple. Can be a tuple of tuples that contain the index and port name.
all_ports_index (dict) – The connection index dictionary.
- Returns:
The ordered input connection index tuple.
- Return type:
tuple
- sax_to_s_parameters_standard_matrix(sax_input: Any, input_ports_order: tuple[str] | None = None, round_int: bool | None = None, *args, **kwargs) piel.types.SParameterMatrixTuple[source]#
A
saxS-parameter SDict is provided as a dictionary of tuples with (port0, port1) as the key. This determines the direction of the scattering relationship. It means that the number of terms in an S-parameter matrix is the number of connection squared.In order to generalise, this function returns both the S-parameter matrices and the indexing connection based on the amount provided. In terms of computational speed, we definitely would like this function to be algorithmically very fast. For now, I will write a simple python implementation and optimise in the future.
It is possible to see the sax SDense notation equivalence here: https://flaport.github.io/sax/nbs/08_backends.html
import jax.numpy as jnp from sax.core import SDense # Directional coupler SDense representation dc_sdense: SDense = ( jnp.array([[0, 0, τ, κ], [0, 0, κ, τ], [τ, κ, 0, 0], [κ, τ, 0, 0]]), {"in0": 0, "in1": 1, "out0": 2, "out1": 3}, ) # Directional coupler SDict representation # Taken from https://flaport.github.io/sax/nbs/05_models.html def coupler(*, coupling: float = 0.5) -> SDict: kappa = coupling**0.5 tau = (1 - coupling) ** 0.5 sdict = reciprocal( { ("in0", "out0"): tau, ("in0", "out1"): 1j * kappa, ("in1", "out0"): 1j * kappa, ("in1", "out1"): tau, } ) return sdict
If we were to relate the mapping accordingly based on the connection indexes, a S-Parameter matrix in the form of \(S_{(output,i),(input,i)}\) would be:
\[\begin{split}S = \begin{bmatrix} S_{00} & S_{10} \\ S_{01} & S_{11} \\ \end{bmatrix} = \begin{bmatrix} \tau & j \kappa \\ j \kappa & \tau \\ \end{bmatrix}\end{split}\]Note that the standard S-parameter and hence unitary representation is in the form of:
\[\begin{split}S = \begin{bmatrix} S_{00} & S_{01} \\ S_{10} & S_{11} \\ \end{bmatrix}\end{split}\]\[\begin{split}\begin{bmatrix} b_{1} \\ \vdots \\ b_{n} \end{bmatrix} = \begin{bmatrix} S_{11} & \dots & S_{1n} \\ \vdots & \ddots & \vdots \\ S_{n1} & \dots & S_{nn} \end{bmatrix} \begin{bmatrix} a_{1} \\ \vdots \\ a_{n} \end{bmatrix}\end{split}\]TODO check with Floris, does this mean we need to transpose the matrix? TODO document round_int
- Parameters:
sax_input (sax.SType) – The sax S-parameter dictionary.
input_ports_order (tuple) – The connection order tuple containing the names and order of the input connection.
round_int (bool) – Whether to round the complex numbers to integers.
- Returns:
The S-parameter matrix and the input connection index tuple in the standard S-parameter notation.
- Return type:
tuple
- snet#