Install
rfx needs Python 3.11 or newer. The PyPI package is rfx-fdtd, and the import
name is rfx.
pip install "rfx-fdtd>=2.0"These pages describe rfx 2.0. rfx 1.x (1.7.0 on PyPI) stays installable as
pip install "rfx-fdtd<2"; these pages do not describe it.
This installs JAX and jaxlib (CPU), NumPy, SciPy, matplotlib and h5py. rfx asks for JAX from 0.10.2 up to, not including, 0.11.2: pip picks 0.11.1 on Python 3.12 or newer and 0.10.2 on Python 3.11. jaxlib 0.11.2 and 0.12.0 run the CPU time step 2.3–3× slower; a newer JAX installed by hand still imports.
GPU
rfx runs on whatever device JAX finds. For an NVIDIA GPU, install the CUDA build of JAX:
pip install "jax[cuda12]" "rfx-fdtd>=2.0"python -c "import jax; print(jax.devices())" # should list a CUDA deviceSee the JAX installation guide for CUDA and driver requirements.
Optional extras
| Extra | Adds | Needed for |
|---|---|---|
rfx-fdtd[optimization] | optax | examples that use optax directly; topology_optimize uses built-in Adam and needs no extra |
rfx-fdtd[visualization] | matplotlib, pillow | plots and field animations |
rfx-fdtd[cad] | trimesh, rtree, cascadio | importing STL/STEP geometry with MeshShape |
rfx-fdtd[dashboard] | streamlit, pandas | the rfx-dashboard browser UI |
rfx-fdtd[all] | everything above plus the dev tools | development |
Check the install
rfx-diagnoseThis prints a PASS / WARN / FAIL line for Python, rfx, the JAX backend and devices, the core dependencies and the optional extras. It then runs a tiny FDTD simulation. It exits with code 0 when every critical check passes.
Two warnings are normal:
- CPU-only backend. Everything works, but large 3-D runs are slow.
- x64 disabled. Expected with the default
precision="float32": fields are float32 and the frequency-domain sums are complex64, which the line calls reduced precision.
If you want precision="float64", build and run the simulation inside a
scoped JAX 64-bit block:
import jaxfrom rfx import Simulation
with jax.enable_x64(): sim = Simulation(..., precision="float64") result = sim.run(...)Do not switch 64-bit mode on for the whole process, as the tool’s hint
suggests; rfx refuses precision="float64" outside 64-bit mode and asks for
the scoped block.
Development install
git clone https://github.com/bk-squared/rfx.gitcd rfxpip install -e ".[dev]"python examples/quickstart/hello_world.pyhello_world.py runs a 20 mm PEC box with one source and one probe. It
finishes in seconds. The scripts in examples/ come only with a source
checkout; the PyPI wheel does not include them.
To contribute, see Contributing.
Hardware
- Memory: 4 GB is enough for the examples. Use 16 GB or more for large 3-D models. On a GPU, device memory is usually the limit, and gradients need much more of it than a plain forward run; see Reduce Memory Use.
- GPU: an NVIDIA card with CUDA 12 or newer. Absorbing boundaries cost more per cell than PEC, so budget for them in open-boundary work.
Next
Continue with the Quick Start.
