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?
Exactly. Kuroda's identities are matrix identities between two-ports that share the same Richards variable, so they hold at every frequency, not just near the design point. Your cascade function will show the two networks agreeing to about 10⁻¹² dB, a good test that each building block is right.
Name it
Converting between S and ABCD
In a system, with :
and in the other direction
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: , the susceptance B there, and a short stub of , 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
- ABCD matrix.
- In 50 Ω. as and say.
- In 75 Ω.
Answer in 50 Ω, = 0.2 and = 0.8; in 75 Ω, = 0.143 and = 0.857.
Worked example
Why does the second step's test of the Kuroda filter also check tline?
Show the solution
- What differs between the two. The distributed filter contains two 217.4 Ω unit elements, and the prototype contains none.
- What a bug would do. If
tlinehad a wrong sign or a misplaced z, the two responses would differ. - 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?
ABCD matrices relate the voltage and current at one port to those at the other, so connecting networks in a chain just means multiplying their matrices, which is why the toolkit cascades in ABCD form. But voltages and currents can't be measured directly at microwave frequencies, and the open and short circuits that Z and Y parameters need are hard to make and can make active devices oscillate. S-parameters are defined with matched terminations and traveling waves, which is what a network analyzer's couplers measure. So measurements arrive as S-parameters, get converted to ABCD to be combined, and are converted back to S to describe the result.
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.