NeuralILBackend

class jaxrens.backends.neuralil.NeuralILBackend(model_params, r_cutoff, sorted_elements, supercell_trafo, n_max, embed_d, core_widths, is_ensemble, has_morse, n_ensemble=1, energy_shift_per_atom=0.0, morse_type='RepulsiveMorse', softcore=False, softcore_kwargs=None)[source]

Bases: object

NeuralIL energy backend for jaxrens.

The dynamics model is built once at construction time. max_neighbors is a runtime call-time argument (static at trace time) that shapes the neighbor-buffer slice inside the descriptor generator.

Single-model and ensemble checkpoints are both supported; the layout is selected via is_ensemble and the energy is reduced accordingly (.mean() over the ensemble axis, identity for a single model).

Parameters:
property atomic_numbers: tuple[int, ...]

Atomic numbers (Z) of the elements the model was trained on, in the same order as sorted_elements. Used by the resolver to map user-supplied Z numbers in start_species to the model’s contiguous 0-based type indices.

energy_and_forces(positions, species, cell, max_neighbors=50, ensemble_params=None)[source]

Native energy + forces via NeuralIL’s calc_potential_energy_and_forces.

Every dynamics-model variant (single / Morse / soft-core / ensemble) exposes calc_potential_energy_and_forces, returning (energy, forces) with forces = -dE/dx. The soft-core and Morse terms are included because the differentiated calc_potential_energy runs through the same (overridden) calc_atomic_energies as __call__.

For an ensemble the model returns per-member energies (n_ensemble,) and forces (n_ensemble, N, 3); both are reduced by mean to match the committee prediction used in __call__. The per-atom energy shift is a constant and is added to the energy only — it does not affect forces.

Parameters:
  • positions (Array)

  • species (Array)

  • cell (Array)

  • max_neighbors (int)

  • ensemble_params (dict[str, Any] | None)

Return type:

BackendResult

members(positions, species, cell, max_neighbors=50, ensemble_params=None)[source]

Per-committee-member energies and forces (for uncertainty).

Like energy_and_forces() but keeps the per-ensemble-member axis: populates the reserved energy_members (M,) and forces_members (M, N, 3) slots, in addition to the reduced energy / forces committee means and the control fields.

For a single (non-ensemble) model M = 1 (a leading axis is added) so the (M, …) shape contract holds uniformly and the committee spread is exactly zero. The per-atom energy shift is added to every member, preserving the invariant energy == energy_members.mean() (the shift is constant across members, so it does not affect the std).

Parameters:
  • positions (Array)

  • species (Array)

  • cell (Array)

  • max_neighbors (int)

  • ensemble_params (dict[str, Any] | None)

Return type:

BackendResult

energy_members(positions, species, cell, max_neighbors=50, ensemble_params=None)[source]

Per-committee-member total energies, shape (M,) — no forces.

The cheap path for energy-only uncertainty: skips the force jacobian that members() computes. Single (non-ensemble) model → (1,). The per-atom shift is added to every member (constant; irrelevant to the committee std, kept for absolute-scale consistency).

Parameters:
  • positions (Array)

  • species (Array)

  • cell (Array)

  • max_neighbors (int)

  • ensemble_params (dict[str, Any] | None)

Return type:

Array

max_neighbors_for(positions, cell)[source]

Geometry-only per-walker max neighbor count.

Mirrors MACE’s same-named method (mace.py:224-237) so the resolver’s _finalise_initial_energies_and_counts can take the bucket-aware branch instead of falling through to the max_neighbors=0 path. No NeuralIL forward pass is triggered — the result is a static-shape buffer sizing hint derived purely from coordinates + the model’s r_cutoff + supercell_trafo.

Pass dummy zero species since neighbor counting depends only on positions and the cutoff (species enter only through a padded-atom mask which _get_max_number_of_neighbors ignores for length-N inputs).

Parameters:
  • positions (Array)

  • cell (Array)

Return type:

Array