# A printed waveguide filter, designed by gradient

Channel: release; package: 2.2.0; source: 084b5032b7d014f12b65b4b947cf61a840970bf4

Page: https://remilab.ai/rfx/showcase/waveguide-filter/
Source: https://github.com/bk-squared/rfx/blob/084b5032b7d014f12b65b4b947cf61a840970bf4/docs/public/showcase/waveguide-filter.mdx

Dielectric blocks in a waveguide reflect part of the wave; spaced right, the
reflections add up to resonances that pass one band and reject the rest. Here an
81 mm insert in WR-90 (22.86 × 10.16 mm) is the design: its permittivity, limited to
what ceramic-filled filament can print, 1 ≤ εr ≤ 10, in 2.54 mm pixels along the guide,
each uniform across the guide height and width, so that the insert cannot convert
the TE10 wave into any other mode. The specification is a mask: |S11| ≤ −15 dB over 10.0–10.6 GHz, and
|S21| ≤ −25 dB over 8.2–9.0 GHz and 11.6–12.4 GHz. Adam lowers how far |S11| and
|S21| stand outside the mask, with the gradient taken through the FDTD solve and the
waveguide S-matrix.

  [A printed insert in a cut-open WR-90 guide at iteration 39 of 400: each cell is more opaque where its permittivity is higher and coloured by how the mask violation would change with more permittivity (red helps, blue hurts); beside it the worst stopband |S21| of −23.6 dB on the design mesh (a/36), |S11| and |S21| against the mask with the start and the final design, and the worst stopband |S21| over the iterations](https://remilab.cnu.ac.kr/share/f1abd0bff18d/waveguide-filter/waveguide_filter_site.png)

  3 of 3 meshes with the response inside the mask
  −16.6 dB worst |S11| over 10.0–10.6 GHz on the finest mesh (mask −15 dB)
  −25.5 dB worst |S21| in the stopbands on the finest mesh (mask −25 dB)

  ![Video poster](https://remilab.cnu.ac.kr/share/f1abd0bff18d/waveguide-filter/waveguide_filter_film_poster.png)

    [source](https://remilab.cnu.ac.kr/share/f1abd0bff18d/waveguide-filter/waveguide_filter_film.mp4)

    [Download the film (MP4, 1920×1080, 73 s)](https://remilab.cnu.ac.kr/share/f1abd0bff18d/waveguide-filter/waveguide_filter_film.mp4).
  
  The design in 73 seconds, with narration.

## What happened

The descent starts from the insert filled uniformly with εr = 1.5, which passes the whole
band. Over 400 iterations it grows two high-permittivity slabs and lower steps near the
ends and between them, a stepped-impedance filter along the guide. The descent runs on
a mesh of a/36 (0.635 mm), where the final design's worst stopband |S21| is −25.2 dB,
as the picture and the loop show. Solved again without
the optimiser on meshes of a/36, a/54 and a/72 (0.635, 0.423 and 0.318 mm), the response
stays inside the mask on all three. On the finest mesh the worst passband |S11| is
−16.6 dB and the worst stopband |S21| is −25.5 dB, 0.5 dB inside the mask.

  [|S11| and |S21| of the designed insert on the three meshes, with the mask](https://remilab.cnu.ac.kr/share/f1abd0bff18d/waveguide-filter/filter_mesh.png)

## How it was checked

The checks below and their thresholds were fixed before any run, in §2.5 of the
[pre-declaration](https://github.com/bk-squared/rfx/blob/084b5032b7d014f12b65b4b947cf61a840970bf4/docs/design_notes/20261004_showcase_lens_filter_predeclaration.md).

- **Gradient against central differences** at the start: 4.8×10⁻³, 2.3×10⁻³ and
  9×10⁻⁵ on the three judged pixels.
- **Gradient against a 1.5× longer simulation time**: 1.6×10⁻⁶ at the start,
  9.3×10⁻⁴ at the final design, and below 2×10⁻³ at every iterate the loop shows.
- **End of the simulation**: the response still arriving after the simulation ends
  would change every frequency value read by less than 1 % in amplitude (−40 dB),
  for both drives, on every mesh. rfx calls this check settling; CST's time-domain
  solver instead stops on the decay of the total field energy.
- **Power**: the insert is lossless; |S11|² + |S21|² stays within 4×10⁻⁵ of 1 on every
  mesh (the check allowed 0.98–1.01).
- **Three meshes**: from a/36 to a/54 to a/72 the worst passband |S11| moves 0.15 then
  0.06 dB and the worst stopband |S21| 0.25 then 0.09 dB.

Computed with rfx main 9ed83eb8 (2026-10-05); the numbers will be recomputed after rfx 2.0. The walls are perfect conductors and the insert is lossless, so the filter has no insertion loss here.

## Downloads

  [result.json](https://remilab.cnu.ac.kr/share/f1abd0bff18d/waveguide-filter/result.json)
  [iterations.npz](https://remilab.cnu.ac.kr/share/f1abd0bff18d/waveguide-filter/iterations.npz)
  [mesh_trend.json](https://remilab.cnu.ac.kr/share/f1abd0bff18d/waveguide-filter/mesh_trend.json)
  [waveguide_filter_social.mp4](https://remilab.cnu.ac.kr/share/f1abd0bff18d/waveguide-filter/waveguide_filter_social.mp4)
  [waveguide_filter_social.png](https://remilab.cnu.ac.kr/share/f1abd0bff18d/waveguide-filter/waveguide_filter_social.png)

## Run it

```bash
python scripts/showcase/design_filter.py --stage describe --out out/filter   # builds the three meshes, no solve
```

The full stages need a GPU. A `--stage trial` run comes first; the descent is
`--stage main --record  --out  --start S1 --iterations 400 --y-uniform`,
and `--stage resolve --record  --out ` solves its final
design again on the three meshes. `scripts/vessl_showcase_filter.yaml` is the lab's
cluster job file, with the pinned package versions.
