Installation
mpifield needs Python 3.10 or newer. Install it from PyPI:
pip install mpifieldor, for development, from a checkout with uv:
git clone https://github.com/max-models/mpifield.gitcd mpifieldmake install # uv sync --extra dev, plus the pre-commit hooksOptional extras
Section titled “Optional extras”| Extra | Installs | For |
|---|---|---|
mpi | mpi4py | runs under mpiexec or srun; serial runs use maybempi’s stand-in and never start MPI |
plot | matplotlib, plasma-plots | Field.plot |
gpu | CuPy | the CUDA kernels, for fields and markers on the GPU |
metal | MLX | the Metal kernels on Apple-silicon Macs |
test | pytest, pytest-mpi, coverage | the tests |
docs | the notebook runner, griffe | this site |
dev | ruff, pyright, pre-commit, plus test and docs | development |
pip install "mpifield[mpi,plot]"The compiled kernels
Section titled “The compiled kernels”The CPU kernels are Python files compiled with Pyccel the first time they run, with OpenMP, and cached on disk:
| Variable | Default | Effect |
|---|---|---|
MPIFIELD_KERNEL_CACHE | ~/.cache/mpifield/kernels | where the compiled kernels are kept |
MPIFIELD_OPENMP | 1 | 0 builds them without OpenMP |
OMP_NUM_THREADS | all cores | threads per process; under MPI, the cores per rank |
Compiling needs a C compiler. Without one, run the NumPy versions:
cunumpy.kernels.set_host_kernel_implementation("numpy").