
The task: a short Python script, written with an AI coding assistant, that puts a 1 m cable, a 10 dB attenuator and a waveguide-to-coax adapter in series and plots the loss from 26.5 to 40 GHz. The most direct way to write it runs without an error, draws a plausible curve, and contains an adapter that produces 17% more power than goes in. An AI-written RF script is useful only after it passes checks whose answers you know in advance: passivity, a matched-limit sum, a delay, and reciprocity. This page shows the four checks, three mistakes that each still draw a believable plot and the check that catches each one, the verified script in full, and what the model says about the path: with every part at its VSWR limit and the reflections of mating connectors placed to add, the loss runs from 0.04 dB below to 0.31 dB above the three datasheet losses added together.
The task and why it is a fair test
The path is an ordinary Ka-band bench setup: signal generator, a 1 m phase-stable cable with 2.92 mm plugs, a 10 dB attenuator to steady the match, and a WR-28 waveguide-to-coax adapter feeding a horn. The numbers come from the datasheets of parts in our catalog: the cable assembly is specified at 2.8 dB maximum at 40 GHz with VSWR 1.3 and 83% velocity of propagation, the attenuator at VSWR 1.25, and the adapter at 0.25 dB maximum with VSWR 1.25. Connector families for this band are compared in SMA vs 3.5 mm vs 2.92 mm vs 2.4 mm vs 1.85 mm, and the waveguide side in the waveguide size chart.
It is a fair test for an AI assistant because the task is small, the library (scikit-rf) is well documented, and every intermediate result has a closed-form answer. If a script cannot be trusted here, it cannot be trusted on a filter or an antenna, where nobody knows the answer in advance.
Four checks with known answers

1. Passivity: no part may create power
A cable, a pad and an adapter can only lose power. For an S-matrix that means its largest singular value is at most 1 at every frequency. The direct approach writes the datasheet numbers straight into each matrix: S11 = S22 = 0.111 (from VSWR 1.25) and S21 = S12 = 0.972 (from 0.25 dB). Each entry looks right. Together they are impossible: the largest singular value is 0.111 + 0.972 = 1.083, so with both ports driven in phase the adapter would deliver 1.083² = 1.17 W for every watt supplied. In a lossless, symmetric two-port the reflected and transmitted waves are a quarter cycle apart, and a real low-loss part is close to that. The direct approach throws that phase relation away.
The fix is to build each part from pieces that are passive by construction: a small lossless reflecting joint at each connector, and a matched lossy line between them. The reflections then come out of the cascade with the right phase.
2. Matched limit: with reflections off, dB must add
Set every VSWR to 1 and the cascade has one correct answer at 40 GHz: 2.8 + 10 + 0.25 = 13.05 dB. A script that prints 6.53 dB, exactly half, has used 10·log10 on |S21|, which is a voltage ratio and needs 20·log10. The curve has the right shape and a believable value for a pad and a cable, which is why this kind of error survives a glance at the plot.
3. Delay: the phase slope must match the cable length
One metre of cable with 83% velocity of propagation delays the signal by 1 / (0.83 × 299,792,458 m/s) = 4.02 ns, and the script can recover that from the slope of the S21 phase. A result of 4.02 × 10⁻⁹ ns means the frequency axis was passed in GHz to a formula that expects Hz. Loss is unaffected by that mistake, so the first two checks pass; only the ripple is wrong: its period becomes far wider than the band, so the curve shows a smooth offset with no ripple.
4. Reciprocity: S21 must equal S12
Parts without ferrites or amplifiers pass signal equally in both directions. None of the three mistakes above breaks it. Keep it anyway, because a matrix filled in one direction only (S21 written, S12 left at zero) is a common slip and this is the check that sees it.
The verified script
The complete script is below. It needs Python with numpy and scikit-rf, takes under a second, and prints the check results before the answer. Change the datasheet numbers at the top of build() to model another path.
chain.py: the full script (about 70 lines)
"""40 GHz test path built from datasheet limits with scikit-rf, plus four checks with known answers.
Parts (maker's datasheet maxima, Kymopsis RF catalog, 16 Nov 2026):
cable 2.92 mm male-male, 142A series, 1000 mm: loss <= 2.8 dB at 40 GHz, VSWR <= 1.3, velocity 83 %
pad 2.92 mm fixed attenuator 10 dB: VSWR <= 1.25 (accuracy -0.7/+0.8 dB not modelled)
adapter WR-28 to 2.92 mm: loss <= 0.25 dB, VSWR <= 1.25
Model: every part = reflecting joint + matched lossy line + reflecting joint. Not a measurement."""
import numpy as np, skrf as rf
C0 = 299_792_458.0
freq = rf.Frequency(26.5, 40, 2701, "GHz")
f = freq.f # Hz
def gamma(vswr): return (vswr - 1) / (vswr + 1)
def joint(g):
"""Lossless shunt susceptance whose reflection magnitude is g (frequency-independent simplification)."""
b = 2 * g / np.sqrt(1 - g ** 2) # |S11| = b / sqrt(4 + b^2) = g
y = 1j * b
s = np.zeros((len(f), 2, 2), complex)
s[:, 0, 0] = s[:, 1, 1] = -y / (2 + y)
s[:, 0, 1] = s[:, 1, 0] = 2 / (2 + y)
return rf.Network(frequency=freq, s=s, z0=50)
def line(loss_db, length_m, vf):
"""Matched line: loss in dB (array or scalar) and delay length/(vf*c)."""
t = 10 ** (-np.asarray(loss_db, float) / 20) * np.exp(-2j * np.pi * f * length_m / (vf * C0))
s = np.zeros((len(f), 2, 2), complex)
s[:, 0, 1] = s[:, 1, 0] = t
return rf.Network(frequency=freq, s=s, z0=50)
def part(loss_db, vswr, length_m, vf):
"""Joint + line + joint.
Joint size: the two joints add to the VSWR limit in the worst case (the far one is seen through the line twice).
Line loss: datasheet loss minus the mismatch loss of the two joints, because a datasheet insertion loss is
measured in a 50 ohm system and already contains the part's own reflections."""
L = float(np.min(loss_db))
g = gamma(vswr) / (1 + 10 ** (-2 * L / 20)) if vswr > 1 else 0.0
if not g:
return line(loss_db, length_m, vf)
own = 2 * -10 * np.log10(1 - g ** 2)
j = joint(g)
return j ** line(np.asarray(loss_db, float) - own, length_m, vf) ** j
def build(vswr_on=True):
v = (lambda x: x) if vswr_on else (lambda x: 1.0)
cable = part(2.8 * np.sqrt(f / 40e9), v(1.3), 1.000, 0.83) # loss scaled with sqrt(f) from the 40 GHz point
pad = part(10.0, v(1.25), 0.020, 1.0)
adapter = part(0.25, v(1.25), 0.025, 1.0)
return cable, pad, adapter
def checks(parts, total):
out = {}
out["passive"] = all(np.linalg.svd(p.s, compute_uv=False).max() <= 1 + 1e-9 for p in list(parts) + [total])
out["reciprocal"] = bool(np.allclose(total.s[:, 0, 1], total.s[:, 1, 0]))
c0, p0, a0 = build(vswr_on=False); ideal = c0 ** p0 ** a0
out["matched_limit_db_at_40"] = float(-20 * np.log10(abs(ideal.s[-1, 1, 0]))) # must be 2.8 + 10 + 0.25
gd = -np.gradient(np.unwrap(np.angle(line(0, 1.0, 0.83).s[:, 1, 0])), 2 * np.pi * f)
out["delay_1m_ns"] = float(gd.mean() * 1e9) # must be 1/(0.83 c) = 4.02 ns
return out
if __name__ == "__main__":
cable, pad, adapter = build(); total = cable ** pad ** adapter
il = -20 * np.log10(abs(total.s[:, 1, 0])); rl = -20 * np.log10(abs(total.s[:, 0, 0]))
c0, p0, a0 = build(False); nom = -20 * np.log10(abs((c0 ** p0 ** a0).s[:, 1, 0]))
print("checks:", {k: (round(v, 2) if isinstance(v, float) else v) for k, v in checks((cable, pad, adapter), total).items()})
print(f"loss at 26.5 GHz nominal {nom[0]:.2f} dB, at 40 GHz nominal {nom[-1]:.2f} dB")
print(f"cascade minus sum: {(il - nom).min():+.2f} .. {(il - nom).max():+.2f} dB; mean {(il-nom).mean():+.2f} dB")
print(f"worst input return loss {rl.min():.1f} dB")
np.savez("chain.npz", f=f, il=il, nom=nom, rl=rl)
Output:
checks: {'passive': True, 'reciprocal': True, 'matched_limit_db_at_40': 13.05, 'delay_1m_ns': 4.02}
loss at 26.5 GHz nominal 12.53 dB, at 40 GHz nominal 13.05 dB
cascade minus sum: -0.04 .. +0.31 dB; mean +0.12 dB
worst input return loss 14.1 dB
Four modelling choices are assumptions, not datasheet facts, and the script says so in its comments. Cable loss is scaled with the square root of frequency from the single 40 GHz point. That is the conductor-loss law; it is exact at 40 GHz by construction and slightly pessimistic lower in the band, because the part of the 40 GHz figure that is dielectric loss falls faster than √f. Each connector reflection is a frequency-independent joint sized so that the part just meets its VSWR limit, and the line loss is reduced by the joints’ own mismatch loss so that each part alone still shows its datasheet insertion loss to within about ±0.03 dB (its own internal ripple). The joints of two mating connectors sit at the same place and add in phase, which is the worst case. And the attenuator’s accuracy tolerance of −0.7/+0.8 dB is left out, although it is larger than everything the reflections do.
What the model says about the path
Each part alone, between ideal 50 Ω ports, shows its datasheet loss to within ±0.03 dB, and the three add up to 13.05 dB at 40 GHz. Connected to each other they do not: the modelled loss runs from 0.04 dB below the sum to 0.31 dB above it, 0.12 dB above on average, and it ripples with a period of about 0.12 GHz, set by the 1 m cable between two reflecting connectors. Two effects are at work. Where two connectors mate, their reflections combine, and in this model they add: the cable-to-pad and pad-to-adapter interfaces each reflect more than either connector alone. And reflections from different interfaces add in and out of phase as the frequency moves, by the usual 20·log10(1 ± Γ1Γ2) estimate. In hardware the phases are whatever they happen to be, so the interaction is an uncertainty of a few tenths of a dB around the sum, not a fixed penalty. The input return loss of the chain is 14.1 dB at worst, against 17.7 dB for the cable alone at its limit.
For a link budget this is a reminder to keep a few tenths of a dB of margin for a chain like this at 40 GHz. For a measurement it is the reason a pad sits next to the adapter: the 10 dB pad improves the return loss the cable sees from the horn and adapter by 20 dB (10 dB on the way in, 10 dB on the way back), down to the pad’s own match. That effect is explained in RF Attenuators Explained and 50 Ohm, VSWR and Return Loss Explained. Real parts are usually better than their limits, so treat the curve as what the datasheets permit and not as a prediction. The 40 GHz cables are in the RF cable assemblies section, with the loss of each length on the product page.
When measured S-parameters exist, use them. scikit-rf reads Touchstone files with rf.Network('part.s2p') and cascades them with the same ** operator, and the same four checks apply to the files: a measured passive part must also be passive and reciprocal within the measurement noise.
A prompt that gets a checkable script
What you ask for decides whether the result can be checked. A request that produces a checkable script has five parts:
- Give the numbers. Paste the datasheet values with their conditions. An assistant asked to model “a typical 40 GHz cable” will invent one.
- Name the model. Say how each part is to be represented, here a matched lossy line between two reflecting joints, and ask for every assumption to be listed in comments.
- Demand the checks first. Passivity, the matched-limit sum, the delay of a known length and reciprocity, each printed with its expected value next to it.
- Fix the units. State that frequency is in Hz inside the code and GHz only on the axis.
- Ask what is not modelled. The answer (tolerance, dielectric loss, frequency dependence of the joints) belongs next to the plot.
The same pattern scales to full-wave tools. Agent-driven RF design with solvers such as openEMS, CST and ADS is being tried in research and in hobby projects, and the same discipline applies there: validate against a case with a known answer before trusting a new one. For a horn or a waveguide transition the known answers are the cutoff frequency, the gain of a standard horn from its aperture, and power conservation between ports.
The per-metre cable loss used in a chain like this can be read from datasheet length tables, as shown in choosing a 40 to 110 GHz test cable.
The launches at each end of a test board are part of such a chain; what sets their reflection is in end launch connector vs vertical launch connector.
-

2.92 mm Male to 2.92 mm Male RF Cable Assembly, DC to 40 GHz, 142A Series Low Loss Phase Stable Flexible Coax, 2.2 dB/m@40 GHz
From $142.00Reset options600 mm800 mm500 mm1000 mm1500 mm2000 mm3000 mmSelect options This product has multiple variants. The options may be chosen on the product page -

2.92 mm RF Fixed Attenuator, DC to 40 GHz, 2 W
$162.00Reset options1 dB2 dB3 dB4 dB5 dB6 dB7 dB8 dB9 dB10 dB20 dB30 dBSelect options This product has multiple variants. The options may be chosen on the product page -

WR-28 to 2.92 mm Female Straight Waveguide to Coax Adapter with UBR320 Flange, 26.5 to 40 GHz
$487.00 Buy Now
If you would rather have a transition, antenna or interconnect simulated full-wave and delivered as Touchstone files, see EM simulation.
FAQ
Can an AI assistant simulate RF circuits?
It can write the script that does, quickly and often correctly. It cannot tell you whether the result is right. That takes checks with known answers, and for hardware decisions a measurement.
How do I cascade S-parameters in Python?
With scikit-rf: load or build each two-port as an rf.Network on the same frequency grid and join them with the ** operator, for example total = cable ** pad ** adapter. Port 2 of each part connects to port 1 of the next.
How do I check that S-parameters are passive?
Compute the singular values of the S-matrix at each frequency; all must be at most 1. In numpy: np.linalg.svd(network.s, compute_uv=False).max() <= 1.
Why does the cascaded loss differ from the sum of the insertion losses?
Because the reflections of the parts interact once they are connected to each other. With VSWR 1.25 to 1.3 on three parts and the reflections placed to add, the model gives 0.04 dB below to 0.31 dB above the sum at 26.5 to 40 GHz. With other phases it can be closer to the sum or slightly below it.
Is this a measurement?
No. It is a model built from datasheet maxima, and real parts are usually better than their limits. Use measured Touchstone files where you have them.
Sources and method
- Supplier datasheets of the 2.92 mm cable assembly (142A series, 1000 mm), 2.92 mm fixed attenuator and WR-28 to 2.92 mm adapter in the Kymopsis RF catalog, read on 16 November 2026.
- scikit-rf documentation: Network, Frequency and cascading.
- D. M. Pozar, Microwave Engineering, 4th ed., Wiley, 2012: scattering matrix, lossless and reciprocal networks, mismatch.
- Hackaday, “Bruteforcing accidental antenna designs”, 17 February 2026 and “From Prompt to Prototype: Towards a Frontier LLM Driven RF Engineering Workflow”, arXiv:2608.31006: examples of LLM-driven RF design work.
The script was written with an AI coding assistant and passes the four checks shown. The three mistakes were introduced on purpose in a second script (drafts.py) to show each check failing; the values quoted are the ones it printed. All curves are simulations from datasheet maxima under the stated assumptions. Nothing on this page is a measurement.
