jaxrens.backends.jaxmd

jax-md energy backend.

Wraps jax-md’s analytic many-body potentials (Tersoff for covalent solids, EAM for metals) behind the EnergyBackend interface. All-pairs variants only — no neighbor-list state, no allocate/update/overflow pattern (which jaxrens deliberately replaces with bucketed kernel compilation; see CLAUDE.md “Conventions & gotchas”).

jax-md is an optional dependency. All imports are guarded.

Dynamic cell handling

NPT changes the unit cell every iteration. The backend constructs the displacement function once via space.periodic_general(..., fractional_coordinates=False) with a dummy box at init; the real cell is threaded in per call as energy_fn(positions, new_box=cell). jax-md’s smap layer forwards the kwarg into periodic_general’s displacement transform, so the JIT cache hits on subsequent calls (verified: single trace, no recompilation across box changes).

Multi-species support

  • Tersoff: jax-md does not yet support multi-element Tersoff (tersoff(..., species=Optional[Array]) raises NotImplementedError when species is not None). This backend exposes single-element Tersoff only and ignores the species argument from the protocol.

  • EAM: eam_from_lammps_parameters reads single-element DYNAMO setfl files; the backend mirrors that limitation.

The species argument is therefore ignored in __call__; atomic_numbers is set at construction from the element the model was parameterised for.

MIC limitation

jax-md’s energy.tersoff / energy.eam use the minimum image convention internally and have no way to enumerate periodic images or exclude self-image triplets. As a consequence:

  • They are silently incorrect when any cell side falls below 2 * r_cutoff (neighbours wrap to the wrong image and are undercounted).

  • The all-pairs Tersoff path does not respect extensivity for periodic supercells (a 2x2x2 hand-built supercell of the same crystal does not return 8 * e_unit_cell), which prevents the position-replication trick that the other periodic backends (LJ / MACE / Nequix / NeuralIL) use to work around small cells.

This backend therefore intentionally exposes no supercell_trafo knob — use it only when the unit cell is large enough that cell_perp_distance > 2 * r_cutoff for every walker (under NPT, size the cell.min_volume_per_atom prior accordingly).

Functions

create_jaxmd

Create a jax-md backend.

is_available

Classes

JaxMDBackend

jax-md energy backend (all-pairs variants).