# Installation

Channel: development; package: 2.0.0rc1; source: 2c32b7cf79b796fae825bfa08fc73d9914e61723

Page: https://remilab.ai/rfx/start/install/
Source: https://github.com/bk-squared/rfx/blob/2c32b7cf79b796fae825bfa08fc73d9914e61723/docs/public/start/install.mdx

## Install

rfx needs Python 3.11 or newer. The PyPI package is `rfx-fdtd`, and the import
name is `rfx`.

```bash
pip install rfx-fdtd
```

This 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:

```bash
pip install "jax[cuda12]" rfx-fdtd
python -c "import jax; print(jax.devices())"   # should list a CUDA device
```

See the [JAX installation guide](https://docs.jax.dev/en/latest/installation.html)
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

```bash
rfx-diagnose
```

This 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:

```python
import jax
jax.config.update("jax_enable_x64", True)
```

## Development install

```bash
git clone https://github.com/bk-squared/rfx.git
cd rfx
pip install -e ".[dev]"
python examples/quickstart/hello_world.py
```

`hello_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](https://remilab.ai/rfx/project/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](https://remilab.ai/rfx/run/memory-and-speed/).
- 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](https://remilab.ai/rfx/start/first-simulation/).
