# Which cells move a patch antenna's match?

Channel: development; package: 2.0.0rc1; source: 2c32b7cf79b796fae825bfa08fc73d9914e61723

Page: https://remilab.ai/rfx/showcase/sensitivity-map/
Source: https://github.com/bk-squared/rfx/blob/2c32b7cf79b796fae825bfa08fc73d9914e61723/docs/public/showcase/sensitivity-map.mdx

A 39.7 × 49.25 mm patch on 3.175 mm RT/Duroid 5880 (εr 2.2), fed by a 50 Ω
probe, resonates near 2.3 GHz. We ask how |S11| at 2.356 GHz, 1 % above the
return-loss minimum, changes when the permittivity of any one substrate cell
changes. rfx answers for all 20,592 cells under and around the patch with one
forward and one reverse pass.

  ![Video poster](https://remilab.cnu.ac.kr/share/7c02ad43c580/patch-sensitivity/patch_sensitivity_poster.png)

    [source](https://remilab.cnu.ac.kr/share/7c02ad43c580/patch-sensitivity/patch_sensitivity.mp4)

    [Download the loop (MP4)](https://remilab.cnu.ac.kr/share/7c02ad43c580/patch-sensitivity/patch_sensitivity.mp4).
  

  20,592 design cells
  2×10⁻⁵ worst reverse-mode vs finite-difference difference (float64)
  24 s value and gradient on one RTX A6000 (1.4× a forward run)

  [The sensitivity map, |S11| with f_r and f_t marked, and the |E_z|² panel](https://remilab.cnu.ac.kr/share/7c02ad43c580/patch-sensitivity/patch_sensitivity_site.png)

## What the map shows

The derivative is positive wherever it is significant and concentrated in two
bands, under and just outside the two radiating edges; along the centre line
between them it is about 450 times weaker. That is what cavity perturbation
predicts for the TM010 mode: a local permittivity change shifts the resonance in
proportion to the local |E_z|², and E_z of this mode peaks at the radiating
edges and vanishes on the centre line. The map and |E_z(2.356 GHz)|² from the
same run correlate at r = 0.948. The sign is the expected one: raising εr lowers
the resonance, which moves the return-loss minimum further below 2.356 GHz and
raises |S11| there.

## How the gradient was checked

- Finite differences: six blocks of cells chosen before the run (at the
  radiating edges, on the centre line, outside the patch). On the four large
  enough to judge, reverse mode and central differences agree to
  2.4×10⁻⁶–1.9×10⁻⁵ relative, in float64.
- Record length: repeating the gradient with a 1.5× longer time record changes
  those block sums by at most 5.4×10⁻⁴.
- The same board's forward model agrees with openEMS (see
  [forward checks](https://remilab.ai/rfx/showcase/forward-checks/)).

This map is for this board on a mesh of 4 cells through the substrate, whose resonance is 0.91 % below the finest mesh's; it is not a manufacturing tolerance or a statement about other boards.

## What the code looks like

```python
def J(eps_box):
    res = board.sim.forward(
        design_box=corners, design_eps_override=eps_box,
        design_box_holds_ports=True, n_steps=n_steps, checkpoint=False,
        checkpoint_segments=checkpoint_segments,
        port_s11_freqs=freqs, skip_preflight=True)
    s = res.s_params
    s = s if s.ndim == 1 else s[0]
    return jnp.real(s[0]) ** 2 + jnp.imag(s[0]) ** 2

v, g = jax.jit(jax.value_and_grad(J))(eps_bg)
```

[Full script →](https://github.com/bk-squared/rfx/blob/2c32b7cf79b796fae825bfa08fc73d9914e61723/scripts/showcase/patch_sensitivity.py)

## Downloads

  [gradient_full.npz](https://remilab.cnu.ac.kr/share/7c02ad43c580/patch-sensitivity/gradient_full.npz)
  [ez2_mid.npz](https://remilab.cnu.ac.kr/share/7c02ad43c580/patch-sensitivity/ez2_mid.npz)
  [baseline_h4.s1p](https://remilab.cnu.ac.kr/share/7c02ad43c580/patch-sensitivity/baseline_h4.s1p)
  [result.json](https://remilab.cnu.ac.kr/share/7c02ad43c580/patch-sensitivity/result.json)
  [patch_sensitivity_social.mp4 (4:5)](https://remilab.cnu.ac.kr/share/7c02ad43c580/patch-sensitivity/patch_sensitivity_social.mp4)
  [patch_sensitivity_social.png](https://remilab.cnu.ac.kr/share/7c02ad43c580/patch-sensitivity/patch_sensitivity_social.png)

  Evidence
  
    rfx commit [655b1fc6](https://github.com/bk-squared/rfx/commit/655b1fc6c1989fed88fe80ffbeb19ffa0bcf1277) (checks) and [b46a8220](https://github.com/bk-squared/rfx/commit/b46a8220775b67f8720fb13c3e256c01cf7d6883) (board builder)
    the pre-declaration note [docs/design_notes/20260927_showcase_predeclaration.md](https://github.com/bk-squared/rfx/blob/2c32b7cf79b796fae825bfa08fc73d9914e61723/docs/design_notes/20260927_showcase_predeclaration.md)
    f_t = 1.01 × the |S11| minimum (2.333099 GHz → 2.356430 GHz, |S11(f_t)| = −12.57 dB on the rising flank)
    FD step Δεr = 0.1 on blocks of 3 × 3 cells through the 4-cell substrate (36 cells, 2.4 × 2.4 mm); judged blocks are those with |FD| ≥ 10 % of the largest
    418 of 20,592 cells have a negative derivative, the largest 0.30 % of the maximum
    issue [#1332](https://github.com/bk-squared/rfx/issues/1332), PR [#1337](https://github.com/bk-squared/rfx/pull/1337)
