rfx is an open-source 3-D FDTD simulator for RF and microwave engineering, written in JAX. Write a loss on S-parameters, a radiation pattern or a field, and rfx returns its derivative with respect to the permittivity of every cell in a design region, from one forward and one reverse simulation. An optimiser can then shape a design cell by cell.
pip install "rfx-fdtd>=2.0" See the showcase GitHub
A substrate’s permittivity and loss, recovered from |S11|
A probe-fed patch antenna on RT/Duroid 5880 starts from the datasheet permittivity. Gradient descent fits its |S11| over 2.15–2.50 GHz to a reference curve and recovers the substrate’s permittivity and conductivity together, with the gradient taken through the FDTD solve. The reference is rfx’s own curve for the same model with known values, not a measurement: the case shows the gradient finding values a model was built with. Read the case
A printed waveguide filter, designed by gradient
An 81 mm insert in a WR-90 guide may take any permittivity from 1 to 10 in 2.54 mm pixels along the guide. Gradient descent through the FDTD solve and the waveguide S-matrix shapes it from a uniform fill into a bandpass filter that meets a mask on |S11| and |S21|. Read the case
A printable lens, designed by gradient
A dipole above a 30 mm ground plate radiates a broad beam. In front of it sits a 90 × 90 × 30 mm block whose permittivity may take any value PLA printed at variable infill can give, 1 ≤ εr ≤ 2.7, in 3 mm pixels: 2,250 design variables after the feed’s two mirror symmetries. At each step the optimiser takes the gradient of the boresight directivity, averaged over 9.5, 10 and 10.5 GHz, with respect to every pixel, through the FDTD solve and the far-field transform. Starting from a uniform block, the descent grows a graded-index lens, εr 2.6 on the axis falling to about 1 at the corners, and the boresight directivity at 10 GHz rises from 7.5 dBi for the feed alone to 19.0 dBi. Solved again on 1.5, 1.0 and 0.75 mm meshes, the result moves by 0.03–0.05 dB over the last refinement; the gradient was checked against central differences and against a 1.5× longer simulation. The dipole is driven as a soft source, a current impressed on the grid with no feed line, and the lens is lossless, so these are directivities, not realized gains. Read the case
What the code looks like
The objective is an ordinary Python function of the permittivity in a design box. JAX differentiates the whole time-stepping loop.
... # imports, board, corners, freqs, n_steps, checkpoint_segments, eps_bg: see the full script
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[0, 0] return jnp.real(s[0]) ** 2 + jnp.imag(s[0]) ** 2
v, g = jax.jit(jax.value_and_grad(J))(eps_bg)The full script builds the board, runs preflight once on it, and checks the gradient against finite differences before anything is plotted. Full script
Start here
- Install and run a first model: Installation · Quick Start
- Watch fields move before measuring them: The visual manual (the teaching films)
- Design with gradients: Autodiff and adjoint · Inverse design · Gradient behavior
- Look up a call: API reference
Before you trust a number
A result holds for the structure, mesh and observable it was checked on. Read Support before combining features, and check that the run is long enough and the mesh fine enough before reporting an RF result. Validation shows how rfx itself is checked.
Papers
- B. Kim, “rfx: An End-to-End Differentiable 3-D FDTD Simulator for RF and Microwave Engineering,” IEEE Transactions on Microwave Theory and Techniques, 2026, doi:10.1109/TMTT.2026.3729863: the simulator.
- B. Kim, “Delayed Convergence of S-Parameter Sensitivities to Design Parameters in FDTD Simulations,” arXiv:2610.28496, 2026: the simulation time an S-parameter gradient needs (Simulation time for gradients).
To cite rfx in your own work, see Citing rfx.
