# A 3-D-printable lens, designed by gradient

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

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

A dipole above a 30 mm ground plate has a broad beam: 7.5 dBi toward boresight at
10 GHz. A flat lens in front of it narrows the beam when its refractive index is
highest on the axis and falls toward the rim, so that the central rays are delayed
more than the edge rays and the phase front leaving the lens is flat. Here the lens
is 90 × 90 × 30 mm, 45 mm above the dipole, and its permittivity is limited to what
PLA at variable infill can print, 1 ≤ εr ≤ 2.7, in 3 mm pixels: 9,000 cells, 2,250 free
variables after the feed's two mirror symmetries. Adam raises the boresight directivity
averaged over 9.5, 10 and 10.5 GHz, with the gradient taken through the FDTD solve
and the near-to-far-field transform. The case shows that this gradient is enough to
shape a printable lens from a uniform block, pixel by pixel.

  ![Video poster](https://remilab.cnu.ac.kr/share/f1abd0bff18d/grin-lens/grin_lens_film_poster.png)

    [source](https://remilab.cnu.ac.kr/share/f1abd0bff18d/grin-lens/grin_lens_film.mp4)

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

  19.0 dBi boresight directivity at 10 GHz (feed alone 7.5 dBi)
  +11 dB over the bare feed, 9.5–10.5 GHz

## What happened

At the start, every pixel has εr = 1.85; this uniform block gives 12.2 dBi at
10 GHz on the 1.0 mm mesh the optimiser runs on. The gradient already says where to
change: raising the permittivity near the axis raises boresight directivity, and
raising it near the rim lowers it. The descent grows that profile into a
graded-index lens, εr 2.6 on the axis falling to about 1 at the corners, with a
ring structure in the layer nearest the feed.

  [The uniform block cut open above the dipole at the start, 12.2 dBi: cells coloured by the gradient, red where more permittivity would raise boresight directivity (near the axis) and blue where it would lower it (toward the rim)](https://remilab.cnu.ac.kr/share/f1abd0bff18d/grin-lens/grin_lens_start.png)

Solved again without the optimiser on 1.5, 1.0 and 0.75 mm meshes, the lens gives
18.5 / 19.0 / 18.8 dBi at 9.5 / 10 / 10.5 GHz on the finest mesh. The feed alone
gives 7.5 / 7.5 / 7.4 dBi. The uniform-aperture bound 4πA/λ² for the lens's
90 × 90 mm face is 20.1 / 20.5 / 21.0 dBi.

## How it was checked

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

- **Gradient against central differences** at the start: 6.5×10⁻⁴ and 4.9×10⁻³ on
  the two judged pixels.
- **Gradient against a 1.5× longer simulation time**: 3.3×10⁻⁵ at the start and
  1.5×10⁻⁴ at the final design.
- **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),
  on every mesh. rfx calls this check settling; CST's time-domain solver instead
  stops on the decay of the total field energy.
- **Three meshes**: the designed lens moves 0.07–0.13 dB from 1.5 to 1.0 mm and
  0.03–0.05 dB from 1.0 to 0.75 mm, falling monotonically. Part of that trend is the
  ground plate's solved size converging to its drawn 30 mm.

  [Boresight directivity of each design on the 1.5, 1.0 and 0.75 mm meshes](https://remilab.cnu.ac.kr/share/f1abd0bff18d/grin-lens/lens_mesh.png)

## A second goal: a fan beam

The same block, feed and permittivity range can serve another pattern. The second
design asks for a fan beam, wide in the plane across the dipole and narrow in the
other, the kind of coverage an automotive radar uses for its detection region. The
objective is the ripple of directivity over a ±30° strip along the wide plane (within
5° of it) minus its lowest value there, averaged over the three frequencies; 300 iterations start from the same
uniform block.

  [The block after the fan-beam design, with its radiation lobe wide in one plane: the lowest directivity over the ±30° strip along that plane is 10.6 dBi at 10 GHz](https://remilab.cnu.ac.kr/share/f1abd0bff18d/grin-lens/grin_lens_fan.png)

Solved again on the 1.5, 1.0 and 0.75 mm meshes, the directivity over that strip
varies by 0.98 / 0.66 / 0.64 dB at 9.5 / 10 / 10.5 GHz on the finest mesh, and
less as the mesh is refined (1.14, 1.02 and 0.98 dB at 9.5 GHz). On the finest mesh its
lowest value is 10.0 / 10.6 / 10.7 dBi, and the half-power beamwidth in the narrow
plane is 26.9° / 26.1° / 24.8°. The targets declared before the run were 2 dB ripple, 11.0 dBi
and 23°: the ripple target is met, the level is 0.3–0.95 dB short and the narrow
plane 1.8–3.9° wider than asked. The same gradient, simulation-time and mesh checks
as for the lens passed.

Computed with rfx main 4705f69e (2026-10-04); the numbers will be recomputed after rfx 2.0. The feed is a soft source, so these are directivities, not realized gains; the lens is a lossless dielectric. The fan-beam design was computed with rfx
main 9ed83eb8 (2026-10-05). The film is rendered with Blender
(Cycles) from the stored iterates; every number in it comes from the records below.

## Downloads

  [grin_lens_film.mp4](https://remilab.cnu.ac.kr/share/f1abd0bff18d/grin-lens/grin_lens_film.mp4)
  [result.json](https://remilab.cnu.ac.kr/share/f1abd0bff18d/grin-lens/result.json)
  [iterations.npz](https://remilab.cnu.ac.kr/share/f1abd0bff18d/grin-lens/iterations.npz)
  [mesh_trend.json](https://remilab.cnu.ac.kr/share/f1abd0bff18d/grin-lens/mesh_trend.json)
  [fan beam: result.json](https://remilab.cnu.ac.kr/share/f1abd0bff18d/grin-lens-fan/result.json)
  [fan beam: mesh_trend.json](https://remilab.cnu.ac.kr/share/f1abd0bff18d/grin-lens-fan/mesh_trend.json)
  [fan beam: iterations.npz](https://remilab.cnu.ac.kr/share/f1abd0bff18d/grin-lens-fan/iterations.npz)

## Run it

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

The design itself needs a GPU and runs in three stages, each reading the previous
stage's output folder and writing a new one:

```bash
python scripts/showcase/design_lens.py --stage trial --out out/lens-trial
python scripts/showcase/design_lens.py --stage main --record out/lens-trial --out out/lens-main
python scripts/showcase/design_lens.py --stage resolve --record out/lens-main --out out/lens-resolve
```

`main` refuses to start unless the trial met its continuation rule; `resolve`
solves the final design again on the three meshes. Add `--objective fan` for the
fan beam. `scripts/vessl_showcase_lens.yaml` is the lab's cluster job file, with
the pinned JAX, CUDA and package versions the numbers above were computed with.
