Install
rfx needs Python 3.11 or newer. The PyPI package is rfx-fdtd, and the import
name is rfx.
pip install rfx-fdtdThis installs JAX and jaxlib 0.10.2 or newer (CPU), NumPy, SciPy, matplotlib and h5py.
GPU
rfx runs on whatever device JAX finds. For an NVIDIA GPU, install the CUDA build of JAX:
pip install "jax[cuda12]" rfx-fdtdpython -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 | gradient-based optimizers in inverse design |
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. This is harmless for the default
precision="float32".
If you want precision="float64", enable JAX 64-bit mode before you build
the simulation:
import jaxjax.config.update("jax_enable_x64", True)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 Memory Reduction.
- 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.
