---
title: Amplifier lab
heading: Stability across frequency, complex noise and gain circles, and the unilateral figure of merit, in Python
eyebrow: S6 · Lesson 38 · Amplifier lab
xp: 60
---

::: hook
Lessons 32 to 37 analyzed transistors at one frequency with real numbers where possible. A real design starts from a data sheet of complex S-parameters and noise parameters at many frequencies, and the first question is not gain but stability: a transistor that is well behaved at 4 GHz may oscillate at 1 GHz, where it has far more gain. This lab computes K, |Δ| and μ across a band, draws noise-figure and gain circles with complex reflection coefficients and checks points on them, and measures how far the unilateral approximation can be trusted.
:::

::: play
- The curve is Rollett's K for a model transistor whose $|S_{21}| = a/f$ (f in GHz) falls 6 dB per octave while $|S_{12}|$ = 0.04, $|S_{11}|^2$ = 0.5, $|S_{22}|^2$ = 0.4 and $|\Delta|^2$ = 0.2 stay fixed, a common pattern: K rises with frequency.
- Below a crossover frequency K < 1 and the device is only conditionally stable, even if the design band is well above it.
- Stabilizing resistors are chosen to lift K above 1 everywhere the transistor has gain, not just in band.
:::

```sim plot
view: graph
x: f = 0.5..10 GHz log
y: K = 0..4
slider: a = 2..20 = 10
plot: (1 - 0.5 - 0.4 + 0.2)/(2*0.04*a/f) | label: K
plot: 1 + 0*f | dashed | label: K = 1
```

::: predict
## Pozar's GaAs FET at 4 GHz has S₁₁ = 0.72∠−116°, S₂₁ = 2.60∠76°, S₁₂ = 0.03∠57°, S₂₂ = 0.73∠−54°. Its μ is 1.04. The same device at 1 GHz has μ = 0.24. What does that mean for a 4 GHz amplifier built with it?

- [ ] Nothing: only in-band stability matters
- [x] The design must be checked and stabilized at 1 GHz too: there, some passive terminations the matching networks present could make it oscillate
- [ ] The amplifier will certainly oscillate
- [ ] The device can't be used at 4 GHz

::: reveal
μ > 1 means unconditionally stable; μ < 1 means some source or load terminations give $|\Gamma_\text{in}|$ or $|\Gamma_\text{out}| > 1$. Matching networks designed for 4 GHz present quite different impedances at 1 GHz, so the designer checks where they land against the 1 GHz stability circles, or adds loss (a series resistor in the gate, a shunt RC at the drain) that lifts μ above 1 at all frequencies.
:::
:::

::: nameit
## What the lab computes

- **Stability** at each frequency: $\Delta = S_{11}S_{22} - S_{12}S_{21}$, $K = \frac{1 - |S_{11}|^2 - |S_{22}|^2 + |\Delta|^2}{2|S_{12}S_{21}|}$ and $\mu = \frac{1 - |S_{11}|^2}{|S_{22} - \Delta S_{11}^*| + |S_{12}S_{21}|}$, all with complex S.
- **Noise figure and circles**: $F = F_\text{min} + \frac{4R_N}{Z_0}\frac{|\Gamma_S - \Gamma_\text{opt}|^2}{(1 - |\Gamma_S|^2)|1 + \Gamma_\text{opt}|^2}$; the circle for F has center $\Gamma_\text{opt}/(N + 1)$ and radius $\sqrt{N(N + 1 - |\Gamma_\text{opt}|^2)}/(N + 1)$.
- **Unilateral gain circles**: $C_S = \frac{g_SS_{11}^*}{1 - (1 - g_S)|S_{11}|^2}$, $R_S = \frac{\sqrt{1 - g_S}(1 - |S_{11}|^2)}{1 - (1 - g_S)|S_{11}|^2}$.
- **Unilateral figure of merit**: $U = \frac{|S_{11}S_{12}S_{21}S_{22}|}{(1 - |S_{11}|^2)(1 - |S_{22}|^2)}$. The true transducer gain lies within $\frac{1}{(1 + U)^2} < \frac{G_T}{G_{TU}} < \frac{1}{(1 - U)^2}$ of the unilateral estimate.
:::

::: check
kind: python

## Write `stability(S11, S21, S12, S22)` returning (K, |Δ|, μ) for complex S-parameters, and `unstable(table)`: given a dict of frequency → (S11, S21, S12, S22), the sorted list of frequencies where μ ≤ 1.

```python starter
def stability(S11, S21, S12, S22):
    return (2.0, 0.5, 2.0)

def unstable(table):
    return []
```

```python solution
def stability(S11, S21, S12, S22):
    D = S11 * S22 - S12 * S21
    K = (1 - abs(S11) ** 2 - abs(S22) ** 2 + abs(D) ** 2) / (2 * abs(S12 * S21))
    mu = (1 - abs(S11) ** 2) / (abs(S22 - D * S11.conjugate()) + abs(S12 * S21))
    return (K, abs(D), mu)

def unstable(table):
    return sorted(f for f, s in table.items() if stability(*s)[2] <= 1)
```

```python tests
import cmath, math
P = lambda m, d: cmath.rect(m, math.radians(d))
K, D, mu = stability(P(0.72, -116), P(2.6, 76), P(0.03, 57), P(0.73, -54))
assert abs(K - 1.195) < 0.001 and abs(D - 0.488) < 0.001 and mu > 1, "Pozar's 4 GHz FET: K = 1.195, |Δ| = 0.488."
table = {1: (P(0.95, -40), P(5, 140), P(0.04, 60), P(0.85, -25)), 2: (P(0.85, -75), P(3.8, 110), P(0.04, 55), P(0.78, -40)), 4: (P(0.72, -116), P(2.6, 76), P(0.03, 57), P(0.73, -54))}
assert unstable(table) == [1, 2], "Conditionally stable at 1 and 2 GHz, unconditionally at 4."
```

::: right
Right. A device stable in band but not below it is the usual case; the low-frequency gain is what needs taming.
:::
:::

::: check
kind: python

## Write `noise_figure_db(Gs, Fmin_db, Gopt, Rn, Z0=50)` for complex reflection coefficients, and `noise_circle(F_db, Fmin_db, Gopt, Rn, Z0=50)` returning (center, radius).

```python starter
def noise_figure_db(Gs, Fmin_db, Gopt, Rn, Z0=50):
    return Fmin_db

def noise_circle(F_db, Fmin_db, Gopt, Rn, Z0=50):
    return (0j, 0.0)
```

```python solution
import math

def noise_figure_db(Gs, Fmin_db, Gopt, Rn, Z0=50):
    Fm = 10 ** (Fmin_db / 10)
    return 10 * math.log10(Fm + 4 * Rn / Z0 * abs(Gs - Gopt) ** 2 / ((1 - abs(Gs) ** 2) * abs(1 + Gopt) ** 2))

def noise_circle(F_db, Fmin_db, Gopt, Rn, Z0=50):
    N = (10 ** (F_db / 10) - 10 ** (Fmin_db / 10)) / (4 * Rn / Z0) * abs(1 + Gopt) ** 2
    return (Gopt / (N + 1), math.sqrt(N * (N + 1 - abs(Gopt) ** 2)) / (N + 1))
```

```python tests
import cmath, math
Go = cmath.rect(0.62, math.radians(100))
C, R = noise_circle(2.0, 1.6, Go, 20)
assert abs(abs(C) - 0.563) < 0.001 and abs(R - 0.245) < 0.001, "Pozar's 2.0 dB circle: 0.56∠100°, radius 0.24."
assert all(abs(noise_figure_db(C + R * cmath.exp(1j * t), 1.6, Go, 20) - 2.0) < 1e-9 for t in (0, 1, 2, 3, 4, 5)), "Every point on it gives 2.0 dB."
assert abs(noise_figure_db(0, 1.6, Go, 20) - 2.948) < 0.001, "Driven straight from 50 Ω: 2.95 dB."
```

::: right
Right. Checking points on the circle against the defining formula is the surest test of a circle formula.
:::
:::

::: check
kind: python

## Write `gain_circle(S11, g)`: the unilateral source-gain circle (center, radius) for normalized gain g, `source_gain(S11, Gs)`: $G_S(1 - |S_{11}|^2)$ for a source reflection Gs, and `unilateral_U(S11, S21, S12, S22)` returning (U, lower dB, upper dB) for the error bounds.

```python starter
def gain_circle(S11, g):
    return (0j, 0.0)

def source_gain(S11, Gs):
    return 0.0

def unilateral_U(S11, S21, S12, S22):
    return (0.0, 0.0, 0.0)
```

```python solution
import math

def gain_circle(S11, g):
    d = 1 - (1 - g) * abs(S11) ** 2
    return (g * S11.conjugate() / d, math.sqrt(1 - g) * (1 - abs(S11) ** 2) / d)

def source_gain(S11, Gs):
    return (1 - abs(Gs) ** 2) / abs(1 - S11 * Gs) ** 2 * (1 - abs(S11) ** 2)

def unilateral_U(S11, S21, S12, S22):
    U = abs(S11 * S12 * S21 * S22) / ((1 - abs(S11) ** 2) * (1 - abs(S22) ** 2))
    return (U, -20 * math.log10(1 + U), -20 * math.log10(1 - U))
```

```python tests
import cmath, math
S11 = cmath.rect(0.72, math.radians(-116))
C, R = gain_circle(S11, 0.7)
assert all(abs(source_gain(S11, C + R * cmath.exp(1j * t)) - 0.7) < 1e-9 for t in (0, 1, 2, 3)), "Points on the circle give g = 0.7."
U, lo, hi = unilateral_U(S11, cmath.rect(2.6, math.radians(76)), cmath.rect(0.03, math.radians(57)), cmath.rect(0.73, math.radians(-54)))
assert abs(U - 0.182) < 0.001 and abs(lo + 1.45) < 0.01 and abs(hi - 1.75) < 0.01, "Pozar's FET: U = 0.18, so the unilateral estimate may be off by −1.45 to +1.75 dB."
```

::: right
Right. With U = 0.18 the unilateral design could be almost 2 dB off, which is why this FET is designed bilaterally.
:::
:::

::: explain
## Why must an amplifier's stability be checked far outside its operating band?

::: model
A transistor usually has much more gain at low frequencies than in its intended band, and its reverse transmission doesn't fall in proportion, so it is often only conditionally stable there. The matching networks are designed to present particular impedances in band, but at other frequencies they present quite different ones, possibly inside the transistor's unstable region. If that happens anywhere the device has gain, the amplifier can oscillate at a frequency nobody was looking at. Designers therefore compute stability across the device's whole gain range and add loss, usually resistors that matter little in band, to make it unconditionally stable everywhere.
:::
:::
