This repo provides functionality to read and manipulate S-parameter files, including cascading operations on 2 port models.
The input files must follow the standardized Touchstone file format (.snp
, where n
is the number of ports), and contain sets of data representing scattering parameters of linear networks.
Process Summary:
- Read S-parameter files, validate format
- Verify all S-parameter sets are defined over the same frequency points. If not, interpolate.
- Conversion to T parameters (for 3-port networks): NOT IMPLEMENTED
- Cascading: Perform cascading matrix operation
- Back Conversion (for 3-port networks): NOT IMPLEMENTED
The script will read both files, extracting sets of parameters (each representing a two port network component) and calculates a resulting parameter set as if these two networks were connected in series. The cascading algorithm directly embeds the combined network response into a single whole network. This approach utilizes a generalized two port chain scattering model and system of network embedding equations. Read more this model from LibreTexts here, and the embedding equations from RFCafe here.
The two port networks from the above figure can be described in the following matrix form:
Where:
- S11 and S22 are the input and output reflection coefficients , respectively.
- S21 and S12 are the forward and reverse transmission coefficients, respectively.
The resulting S-parameter matrix can be calculated using the following formulas for each element of the cascaded S-parameter matrix:
- Note that the input and output of each network affects the other.
- The division by
$1 - S^2_{11} \cdot S^1_{22}$ or$1 - S^1_{22} \cdot S^2_{11}$ in these formulas accounds for this interaction between the two networks.
Here is the corresponding implementation inside cascade_s2p
:
s11 = s1[i][0,0] + (s1[i][0,1] * s1[i][1,0] * s2[i][0,0]) / (1 - s2[i][0,0] * s1[i][1,1])
s12 = (s1[i][0,1] * s2[i][0,1]) / (1 - s2[i][0,0] * s1[i][1,1])
s21 = (s2[i][1,0] * s1[i][1,0]) / (1 - s1[i][1,1] * s2[i][0,0])
s22 = s2[i][1,1] + (s2[i][1,0] * s2[i][0,1] * s1[i][1,1]) / (1 - s1[i][1,1] * s2[i][0,0])