S648 of 55
0 XP
  1. Hook
  2. Predict
  3. Name it
  4. Check
  5. Explain

S6 · Lesson 48 · Network toolkit lab

Converting between S and ABCD parameters, building and cascading networks, and designing single-stub matches in Python

Every calculation in this course's first half reduces to a few operations: convert a two-port between representations, multiply chains of ABCD matrices, and solve for the lines and stubs that make a load look like 50 Ω. Circuit simulators do these things internally. In this lab you'll write them yourself, in about forty lines of NumPy, and the tests will hold your code to the lessons' own results: the attenuator from lesson 1, the Butterworth filter from lesson 21, the Kuroda filter from lesson 22 and Pozar's single-stub example from lesson 9.

Predict

A filter built from stubs and unit elements by Kuroda's identities is compared with its Richards prototype, at many frequencies. How closely should their |S₂₁| agree?

Name it

Converting between S and ABCD

In a Z0 system, with Δ=A+B/Z0+CZ0+D:

S11=A+B/Z0−CZ0−DΔ,S12=2(AD−BC)Δ,S21=2Δ,S22=−A+B/Z0−CZ0+DΔ

and in the other direction

A=(1+S11)(1−S22)+S12S212S21,B=Z0(1+S11)(1+S22)−S12S212S21
C=(1−S11)(1−S22)−S12S212S21Z0,D=(1−S11)(1+S22)+S12S212S21

Building blocks

Series impedance [[1, z], [0, 1]], shunt admittance [[1, 0], [y, 1]], and a lossless line [[cos θ, jz sin θ], [j sin θ/z, cos θ]]. In NumPy, A @ B multiplies matrices and dtype=complex keeps them complex.

Single-stub tuning

Lesson 9's closed form: t=tan⁡βd=XL±RL[(Z0−RL)2+XL2]/Z0RL−Z0, the susceptance B there, and a short stub of 12πarctan⁡Y0B, with λ/2 added to any negative length or distance.

Worked example

Check the first step by hand: what S-parameters does a series 25 Ω resistor have in 50 Ω, and in 75 Ω?

Show the solution
  1. ABCD matrix. [12501]
  2. In 50 Ω. Δ=1+0.5+0+1=2.5S11=0.5/2.5=0.2S21=2/2.5=0.8 as R/(R+2Z0) and 2Z0/(R+2Z0) say.
  3. In 75 Ω. Δ=2.333S11=25/175=0.143S21=0.857

Answer in 50 Ω, S11 = 0.2 and S21 = 0.8; in 75 Ω, S11 = 0.143 and S21 = 0.857.

Worked example

Why does the second step's test of the Kuroda filter also check tline?

Show the solution
  1. What differs between the two. The distributed filter contains two 217.4 Ω unit elements, and the prototype contains none.
  2. What a bug would do. If tline had a wrong sign or a misplaced z, the two responses would differ.
  3. What agreement proves. They agree only if the line's matrix is exactly [[cos θ, jz sin θ], [j sin θ/z, cos θ]] and the stubs' susceptances use the same tan θ.

Answer the distributed filter's two unit elements go through tline and the prototype has none, so the two responses agree only if tline is exactly right.

Check

Step 1. Write abcd_to_s(M, z0) and s_to_abcd(S, z0): conversions between ABCD and S-parameters for any two-port.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

Step 2. Write the building blocks series, shunt and tline, and cascade, which multiplies ABCD matrices in order.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

Step 3. Write single_stub(zl, z0): both shunt short-stub solutions for any load, as (d, ℓ) pairs in wavelengths.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Explain why

Why are ABCD matrices the right tool for cascading, while S-parameters are the right tool for measuring?

Practice

Keep practicing

3 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.